Article

Other parts:

An unnamed friend told me that I should stop posting small snippets of code and instead post entire solutions on CodeGallery. I did it for this one; download the stock-price solution.

Here is what’s in the zip file:

  • BackTestF - main library to download stock prices
  • Common.fs - common things used in the rest of the project (i.e. data modeling and common funcs)
  • html.fs - functions to scrap html tables, rows and cells
  • loader.fs - this is where the main async downloading algorithms are implemented
  • persistence.fs - async saving and loading of stock prices to files
  • algorithms.fs - async calculations of compound yearly returns given tickers and dates
  • dotNetWrapper.fs - gives a .NET friendly interface to the whole library so that you can use it from C#/VB.NET

  • Tests - too few testcases running on xUnit (you need to download xUnit separately to run them

  • ReturnCalculator - simple console application to show usage of the library
  • Bob - rough winforms UI application that uses the library. An unnamed friend (Jonathan) promised me that he was going to create a UI for my little library. My requirements were very simple: I want the best UI app of this century, one that fully takes advantage of the async nature of my code. Bob doesn’t fully satisfy my requirements yet 🙂

The code in persistence.fs, algorithms.fs and especially dotnetwrapper.fs is pretty rough and uninteresting. This is why I don’t blog about it. I reserve the right to do it if I get around to clean it up.