/// <summary> /// Read locally downloaded Ledger /// </summary> /// <returns></returns> private GetLedgerResult ReadLedger() { string pathLib = GetLedgerLibraryPath(); GetLedgerResult res = new GetLedgerResult { Ledger = new Dictionary <string, LedgerInfo>() }; if (File.Exists(pathLib)) { List <string[]> csv = StaticLibrary.LoadCsvFile(pathLib); bool isHeaders = true; string[] headers = null; foreach (string[] array in csv) { if (isHeaders) { headers = array; isHeaders = false; } else { Tuple <string, LedgerInfo> li = DataLibraryStaticLibrary.ReadLedgerItems(array, headers); res.Ledger.Add(li.Item1, li.Item2); } } } return(res); }
/// <summary> /// Read already downloaded OHLC data /// </summary> /// <param name="curPair"></param> /// <param name="freq"></param> /// <param name="item"></param> /// <returns></returns> private GetOHLCResult ReadOHLC(CurrencyPair curPair, Frequency freq, string item = "Close") { string pathLib = GetOHLCLibraryPath(curPair, freq); GetOHLCResult res = new GetOHLCResult { Pairs = new Dictionary <string, List <OHLC> > { { curPair.GetRequestID(), new List <OHLC> { } } } }; List <string[]> csv = StaticLibrary.LoadCsvFile(pathLib); bool isHeaders = true; string[] headers = null; foreach (string[] array in csv) { if (isHeaders) { headers = array; isHeaders = false; } else { OHLC ohlc = DataLibraryStaticLibrary.ReadOHLCItems(array, headers); res.Pairs[curPair.GetRequestID()].Add(ohlc); } } return(res); }
private bool ReadFXHistory(CurrencyPairTimeSeries cpts) { string pathLib = GetFXLibraryPath(cpts); if (!File.Exists(pathLib)) { cpts = cpts.GetCloneWithInverseCcyPair(); pathLib = GetFXLibraryPath(cpts); } if (!File.Exists(pathLib)) { return(false); } if (ReadFiles.Contains(cpts.GetFullName())) { return(true); } ReadFiles.Add(cpts.GetFullName()); List <string[]> csv = StaticLibrary.LoadCsvFile(pathLib); bool isHeaders = true; string[] headers = null; foreach (string[] array in csv) { if (isHeaders) { headers = array; isHeaders = false; } else { OHLC ohlc = DataLibraryStaticLibrary.ReadOHLCItems(array, headers); Data.AddQuote(StaticLibrary.UnixTimeStampToDateTime(ohlc.Time), new XChangeRate((double)ohlc.Close, cpts.CurPair)); } } return(false); }