Skip to content

Instantly share code, notes, and snippets.

@DexterHaslem
Created April 15, 2012 21:55
Show Gist options
  • Save DexterHaslem/2395012 to your computer and use it in GitHub Desktop.
Save DexterHaslem/2395012 to your computer and use it in GitHub Desktop.
Parse test
open System
type bar =
{ Symbol : string; Timestamp : DateTime;
Open : string; High : string; Low : string; Close : string;
Volume: int;
}
// F.US.DGH12 20111201 0107 110020 110020 110020 110020 1
let parse_bar (line : string, delim : char) =
match line.Split(delim) with
| l when l.Length <> 8 -> None
| l ->
let timestamp = DateTime.ParseExact((l.[1] + l.[2]), "yyyyMMddHHmm", Globalization.CultureInfo.InvariantCulture)
Some ({Symbol = l.[0].Trim(); Timestamp = timestamp;
Open = l.[3]; High = l.[4]; Low = l.[5]; Close = l.[6]; Volume = int l.[7];})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment