//TODO: To replace by Set up already defined Ccy Pairs public List <CurrencyPair> GetCurrencyPairs(SortedList <DateTime, Transaction> txList) { FXMarketHistory fxmh = new FXMarketHistory(); foreach (var item in txList) { fxmh.AddQuote(item.Value.Date, item.Value.XRate); } return(fxmh.CpList); }
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); }
/// <summary> /// Auxiliary function in order to fill in the FX Market History (including the increasing Frequency feature) /// </summary> /// <param name="fxmh"></param> /// <param name="cpts"></param> /// <param name="startDate"></param> private void FillFXMarketHistory(FXMarketHistory fxmh, CurrencyPairTimeSeries cpts, DateTime startDate) { List <Tuple <DateTime, double> > ts = GetTimeSeries(cpts, isIndex: false, startDate: startDate); if (ts.Count > 0) { foreach (Tuple <DateTime, double> item in ts) { fxmh.AddQuote(item.Item1, new XChangeRate(item.Item2, cpts.CurPair)); } } DateTime firstDate = fxmh.GetFirstDate(cpts.CurPair); if (firstDate > startDate) { CurrencyPairTimeSeries newCpts = (CurrencyPairTimeSeries)cpts.Clone(); newCpts.IncreaseFreq(); if (newCpts.Freq != Frequency.None) { FillFXMarketHistory(fxmh, newCpts, startDate); } } }