Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 2.21 KB | None | 0 0
  1. module StockGlobal
  2.  
  3. type stockTick = {
  4.     pOpen: float; // цена открытия
  5.     pClose: float; // цена закрытия
  6.     bid: float;
  7.     ask: float;
  8.     price: float
  9.     volume: int; // объем торгов
  10.     time: System.DateTime; // дата + время
  11.     fDayOpen: bool; // первая запись дня (открытие дня)
  12.     fDayClose: bool // последняя запись дня (закрытие дня)
  13.     }
  14.  
  15.  
  16.  
  17. module StockLoad
  18.  
  19. open System.IO
  20. open StockGlobal
  21.  
  22. let fromF1a (pathToFile: string) =
  23.      seq {
  24.         use fileStream = new System.IO.StreamReader(pathToFile)
  25.         while not fileStream.EndOfStream do
  26.             let currentLineSplitted = fileStream.ReadLine().Split(',')
  27.             yield {
  28.                 pOpen = 0.0;
  29.                 pClose = 0.0;
  30.                 bid = float currentLineSplitted.[3]
  31.                 ask = float currentLineSplitted.[4]
  32.                 price = float currentLineSplitted.[2]
  33.                 volume = int currentLineSplitted.[5];
  34.                 time = new System.DateTime(int64 232);
  35.                 fDayOpen = false; fDayClose = false
  36.                 }
  37.           }
  38.  
  39.  
  40.  
  41.  
  42.  
  43. module init
  44. open MathNet.Numerics.Statistics
  45. open System.Windows.Forms
  46. open System.Windows.Forms.DataVisualization.Charting
  47.  
  48.  
  49.  
  50.  
  51. [<EntryPoint>]
  52. let main argv =
  53.  
  54.     let ticksSeq = StockLoad.fromF1a(argv.[0])
  55.     let firstItems = Seq.take 100000 ticksSeq |> Seq.toList
  56. //    printfn "%A" firstItems
  57.  
  58.     let myChart = new Chart(Dock = DockStyle.Fill)
  59.     let myChartArea = new ChartArea()
  60.     myChart.ChartAreas.Add(myChartArea)
  61.     let mainLine = myChart.Series.Add("main line")
  62.     List.iter (fun (e: StockGlobal.stockTick) -> mainLine.Points.Add(new DataPoint(0.0, e.price))) firstItems
  63.     let justPrices = firstItems |> List.map  (fun (e: StockGlobal.stockTick)-> e.price)
  64.     myChartArea.AxisY.Minimum <- List.min justPrices
  65.     myChartArea.AxisY.Maximum <- List.max justPrices
  66.  //   mainLine.Points.Add(3.0)
  67.     let myForm = new Form()
  68.     myForm.Controls.Add(myChart)
  69. //    myChart.BeginInit()
  70.  
  71.     Application.Run(myForm)
  72.          
  73.     System.Console.ReadKey() |> ignore
  74.     0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement