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 downloading process until the data is parsed:
Download the data from Yahoo! Finance.
Parse the data and perform the calculations.
Store the data in the model.