public void UpdateHistory(Currency ccyChek, FXMarketHistory fxmh) { if (!TxLoaded) { throw new Exception("Load Transactions First!"); } if (ccyChek != CcyRefLoaded) { throw new Exception("Load Transactions First with correct Fiat!"); } if (fxmh.Freq != FreqLoaded) { FreqLoaded = fxmh.Freq; this.PublishInfo($"Recalculating Chart Data {CcyRefLoaded} - {FreqLoaded} ..."); foreach (DateTime date in fxmh.GetAllDates()) { if (date >= StartDate) { FXMarket fx = fxmh.GetArtificialFXMarket(date); if (!History.Keys.Contains(date)) { AddAllocationToHistory(GetClosestAllocation(date), fx); } History[date].CalculateTotal(fx, CcyRefLoaded); } } } }
public void WriteFXHistory(CurrencyPairTimeSeries cpts) { string pathLib = GetFXLibraryPath(cpts); this.PublishInfo($"Saving FX: {cpts.CurPair.ToString()}"); StringBuilder sb = new StringBuilder(); sb.AppendLine("Time,Close"); IEnumerable <DateTime> DateList = Data.GetAllDates(); //DateList = cpts.Freq.GetSchedule(DateList.First(), DateList.Last(), true); foreach (DateTime date in DateList) { double close = Data.GetQuote(date, cpts.CurPair).Item2.Rate; Int64 dateUnix = StaticLibrary.DateTimeToUnixTimeStamp(date); //if (StaticLibrary.UnixTimeStampToDateTime(dateUnix + FXMinimunFrequency.GetFrequency(true)) < DateTime.UtcNow) if (StaticLibrary.UnixTimeStampToDateTime(dateUnix) < DateTime.UtcNow) { sb.AppendLine($"{dateUnix},{close}"); } else { this.PublishInfo($"Stopped at line: {StaticLibrary.UnixTimeStampToDateTime(dateUnix)}"); } } File.WriteAllText(pathLib, sb.ToString()); }
public void FXMktHist_GetAllDates() { FXMarketHistory fxmh = MarketTestTools.CreateMktHistory(); FXMarket artMkt = fxmh.GetArtificialFXMarket(MarketTestTools.dateArt); TestTools <DateTime> .ListComparisonTest(fxmh.GetAllDates().ToList(), new List <DateTime> { MarketTestTools.date1, MarketTestTools.dateArt, MarketTestTools.date2 }); }