Exemple #1
0
        public Task AddAsync(ICandle candle)
        {
            return(_storage.InsertOrModifyAsync(
                       CandleEntity.GetPartitionKey(candle.AssetPairId, candle.CandleTimestamp),
                       CandleEntity.GetRowKey(candle.CandleTimestamp),
                       () => new CandleEntity(candle),
                       c =>
            {
                if (c.Low > candle.Low)
                {
                    c.Low = candle.Low;
                }

                if (c.High < candle.High)
                {
                    c.High = candle.High;
                }

                if (c.CloseTimestamp < candle.CloseTimestamp)
                {
                    c.Close = candle.Close;
                    c.CloseTimestamp = candle.CloseTimestamp;
                }

                if (c.OpenTimestamp > candle.OpenTimestamp)
                {
                    c.Open = candle.Open;
                    c.OpenTimestamp = candle.OpenTimestamp;
                }

                return true;
            }));
        }
Exemple #2
0
 public async Task <IEnumerable <ICandle> > GetAsync(string assetPairId, DateTime candleTimestamp)
 {
     return(await _storage.GetDataAsync(CandleEntity.GetPartitionKey(assetPairId, candleTimestamp)));
 }