Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module StockGlobal
- type stockTick = {
- pOpen: float; // цена открытия
- pClose: float; // цена закрытия
- bid: float;
- ask: float;
- price: float
- volume: int; // объем торгов
- time: System.DateTime; // дата + время
- fDayOpen: bool; // первая запись дня (открытие дня)
- fDayClose: bool // последняя запись дня (закрытие дня)
- }
- module StockLoad
- open System.IO
- open StockGlobal
- let fromF1a (pathToFile: string) =
- seq {
- use fileStream = new System.IO.StreamReader(pathToFile)
- while not fileStream.EndOfStream do
- let currentLineSplitted = fileStream.ReadLine().Split(',')
- yield {
- pOpen = 0.0;
- pClose = 0.0;
- bid = float currentLineSplitted.[3]
- ask = float currentLineSplitted.[4]
- price = float currentLineSplitted.[2]
- volume = int currentLineSplitted.[5];
- time = new System.DateTime(int64 232);
- fDayOpen = false; fDayClose = false
- }
- }
- module init
- open MathNet.Numerics.Statistics
- open System.Windows.Forms
- open System.Windows.Forms.DataVisualization.Charting
- [<EntryPoint>]
- let main argv =
- let ticksSeq = StockLoad.fromF1a(argv.[0])
- let firstItems = Seq.take 100000 ticksSeq |> Seq.toList
- // printfn "%A" firstItems
- let myChart = new Chart(Dock = DockStyle.Fill)
- let myChartArea = new ChartArea()
- myChart.ChartAreas.Add(myChartArea)
- let mainLine = myChart.Series.Add("main line")
- List.iter (fun (e: StockGlobal.stockTick) -> mainLine.Points.Add(new DataPoint(0.0, e.price))) firstItems
- let justPrices = firstItems |> List.map (fun (e: StockGlobal.stockTick)-> e.price)
- myChartArea.AxisY.Minimum <- List.min justPrices
- myChartArea.AxisY.Maximum <- List.max justPrices
- // mainLine.Points.Add(3.0)
- let myForm = new Form()
- myForm.Controls.Add(myChart)
- // myChart.BeginInit()
- Application.Run(myForm)
- System.Console.ReadKey() |> ignore
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement