private void SaveOandaCandle(CandlestickDao dao, OandaCandle oandaCandle) { var entity = dao.CreateNewEntity(); entity.Instrument = this.Instrument; entity.Granularity = this.Granularity; entity.DateTime = oandaCandle.DateTime; entity.Open = oandaCandle.openMid; entity.High = oandaCandle.highMid; entity.Low = oandaCandle.lowMid; entity.Close = oandaCandle.closeMid; entity.Volume = oandaCandle.volume; try { entity.Save(); } catch (NpgsqlException e) { if (e.Code == "23505") { Console.WriteLine(e.Message); throw new RetryException(); } else { throw e; } } }
private void SaveOandaCandle(CandlestickDao dao, OandaCandle oandaCandle) { var entity = dao.CreateNewEntity(); entity.Instrument = this.Instrument; entity.Granularity = this.Granularity; entity.DateTime = oandaCandle.DateTime; entity.Open = oandaCandle.openMid; entity.High = oandaCandle.openMid; entity.Low = oandaCandle.openMid; entity.Close = oandaCandle.openMid; entity.Volume = oandaCandle.volume; entity.Save(); }
private DateTime SaveAndAdd(List <Candlestick> result, TimeSpan granularitySpan, CandlestickDao dao, DateTime t, OandaCandle oandaCandle) { while (t < oandaCandle.DateTime) { SaveNullCandle(dao, t); result.Add(new Candlestick() { DateTime = t, Open = 0 }); t = t.Add(granularitySpan); } SaveOandaCandle(dao, oandaCandle); result.Add(oandaCandle.Candlestick); t = t.Add(granularitySpan); return(t); }