Exemplo n.º 1
0
        private static void CrawlNewCandles(Timeframe timeFrame, string ticker, int amountOfCandles, IExchangeApi apiManager, ApplicationContext dbContext)
        {
            // Get new candles
            var      firstTimeStamp = GetFirstTimestamp(dbContext.Candles, timeFrame, ticker);
            DateTime endDate        = firstTimeStamp.Value != DateTime.MinValue ? firstTimeStamp.Value : DateTime.Now.ToUniversalTime();
            var      newCandles     = apiManager.GetData(ticker, timeFrame, amountOfCandles, endDate.AddDays(-100000), endDate).Take(amountOfCandles - 1); // TODO убрать хардкод

            // Save new data to store
            foreach (var candle in newCandles)
            {
                dbContext.Candles.Add(candle);
            }
        }
Exemplo n.º 2
0
        private static void CrawlForTimeFrame(Timeframe timeFrame, string ticker, int amountOfCandles, IExchangeApi apiManager)
        {
            DateTime?lastTimestamp;

            using (var dbContext = new ApplicationContext())
            {
                lastTimestamp = GetLastTimestamp(dbContext.Candles, timeFrame, ticker);
                var newCandles = apiManager.GetData(ticker, timeFrame, amountOfCandles);
                foreach (var candle in newCandles)
                {
                    CreateOrUpdate(candle, dbContext);
                }
                dbContext.SaveChanges();
                CrawlNewCandles(timeFrame, ticker, amountOfCandles, apiManager, dbContext);
                dbContext.SaveChanges();
            }
        }
Exemplo n.º 3
0
 public IList <Candle> GetAllData(string ticker, Timeframe timeframe)
 {
     return(_exchangeApi.GetData(ticker, timeframe, 1000)); //Убрать хардкод
 }