Created
April 15, 2012 21:55
-
-
Save DexterHaslem/2395012 to your computer and use it in GitHub Desktop.
Parse test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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