public static IFeedHistory Create(IFeedHistory item) { return(new FeedHistory { AssetPair = item.AssetPair, PriceType = item.PriceType, DateTime = item.DateTime, Candles = item.Candles }); }
public static CandleWithPairId ToCandleWithPairId(this IFeedHistory feedHistory) { return(new CandleWithPairId { AssetPairId = feedHistory.AssetPair, Candle = new FeedCandle { DateTime = feedHistory.FeedTime, Close = feedHistory.TradeCandles.Last().Close, High = feedHistory.TradeCandles.Last().High, IsBuy = feedHistory.PriceType == TradePriceType.Bid, Low = feedHistory.TradeCandles.Last().Low, Open = feedHistory.TradeCandles.Last().Open } }); }
public IReadOnlyList <ICandle> FillGapUpTo(AssetPair assetPair, IFeedHistory feedHistory) { var key = GetKey(feedHistory.AssetPair, feedHistory.PriceType); var candles = feedHistory.Candles .Where(item => item.Low > 0 && item.High > 0 && item.Open > 0 && item.Close > 0) .Select(item => item.ToCandle(feedHistory.AssetPair, feedHistory.PriceType, feedHistory.DateTime)) .ToList(); _lastCandles.TryGetValue(key, out var lastCandle); bool removeFirstCandle; // Use the last candle as the first candle, if any if (lastCandle != null) { removeFirstCandle = true; candles.Insert(0, lastCandle); } else { removeFirstCandle = false; } var result = GenerateMissedCandles(assetPair, candles); // Remember the last candle, if any if (result.Any()) { _lastCandles[key] = Candle.Copy(result.Last()); } if (removeFirstCandle) { result.RemoveAt(0); } return(new ReadOnlyCollection <ICandle>(result)); }
public IReadOnlyList <ICandle> FillGapUpTo(AssetPair assetPair, IFeedHistory feedHistory) { return(feedHistory.Candles .Select(item => item.ToCandle(feedHistory.AssetPair, feedHistory.PriceType, feedHistory.DateTime)) .ToList()); }