public void AddCandles(ChartEntryEntity entry, DateTime from, DateTime to, Candle[] candles) { FetchHistories.RemoveRange(FetchHistories .Where( history => history.ChartEntry.Id == entry.Id && history.From >= from && history.To <= to)); FetchHistories.Add(new CandleFetchHistory() { ChartEntry = entry, From = from, To = to, FetchCount = candles.Length }); Candles.RemoveRange(Candles .Where( candle => candle.ChartEntry.Id == entry.Id && candle.Time >= from && candle.Time <= to)); Candles.AddRangeAsync( candles.Select(candle => new CandleEntity() { ChartEntry = entry, Time = candle.Time, Open = candle.Open, High = candle.High, Low = candle.Low, Close = candle.Close, Volume = candle.Volume })); SaveChangesAsync(); }
public bool IsCacheAvailable(ChartEntryEntity entry, DateTime to, int takeCount) { return(FetchHistories.Where(fh => fh.ChartEntry.Id == entry.Id && fh.From <= to && fh.To >= to).Sum(fh => fh.FetchCount) >= takeCount); }
public bool IsCacheAvailable(ChartEntryEntity entry, DateTime from, DateTime to) { return(FetchHistories.Where(fh => fh.ChartEntry.Id == entry.Id && fh.From <= from && fh.To >= to).Any()); }