예제 #1
0
 public Candle(ExchangeSharp.MarketCandle candle)
 {
     this.OpenPrice  = (float)candle.OpenPrice;
     this.HighPrice  = (float)candle.HighPrice;
     this.LowPrice   = (float)candle.LowPrice;
     this.ClosePrice = (float)candle.ClosePrice;
 }
예제 #2
0
        public void ShouldConvertCandle_WhenTimestampIsUnixEpoch()
        {
            ExchangeSharp.MarketCandle candle = new ExchangeSharp.MarketCandle();
            candle.OpenPrice  = 32m;
            candle.HighPrice  = 50m;
            candle.LowPrice   = 1m;
            candle.ClosePrice = 1m;
            candle.Timestamp  = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            ExchangeSharpPoloniex poloniexApi = new ExchangeSharpPoloniex();
            CandleEvent           myEvent     = poloniexApi.Convert(candle);
            Candle ourCandle = new Candle(32f, 50f, 1f, 1f);

            Assert.Equal(ourCandle, myEvent.Value);
            Assert.Equal(0, myEvent.Date);
        }
예제 #3
0
        public void ShouldConvertCandle_WhenTimestampIsLaterThanUnixEpoch()
        {
            ExchangeSharp.MarketCandle candle = new ExchangeSharp.MarketCandle();
            candle.OpenPrice  = 32m;
            candle.HighPrice  = 50m;
            candle.LowPrice   = 1m;
            candle.ClosePrice = 1m;
            candle.Timestamp  = new DateTime(2019, 2, 19, 15, 22, 32, DateTimeKind.Utc);

            ExchangeSharpPoloniex poloniexApi = new ExchangeSharpPoloniex();
            CandleEvent           myEvent     = poloniexApi.Convert(candle);
            Candle ourCandle = new Candle(32f, 50f, 1f, 1f);

            Assert.Equal(ourCandle, myEvent.Value);
            Assert.Equal(candle.Timestamp.ToNodaTime().ToUnixTimeTicks(), myEvent.Date);
        }