Adding support for downloading the data

The market data will be pulled from Yahoo! Finance on a daily basis; we'll use closing prices and from them calculate the data needed. The data will be downloaded once the Download data button in the GUI is clicked on. The following is the code to illustrate how downloading can be handled by a background thread:

let fetchOne(url:string) =
  let uri = new System.Uri(url)
let client = new WebClient()
let html = client.DownloadString(uri)
html

let downloadNewData(url1:string, url2:string) =
  let worker = new BackgroundWorker()
  worker.DoWork.Add(fun args ->
  printfn("starting background thread")
  let data = fetchOne(url)
  printfn "%A" data)
  worker.RunWorkerAsync()

The trading system will follow these steps from the ...

Get F# for Quantitative Finance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.