/// <summary> /// Verify a value is within range and a multiple of the increment. /// </summary> /// <param name="range"></param> /// <param name="value"></param> /// <returns></returns> public static bool IsValid(this InclusiveRange range, decimal value) { Throw.IfNull(range, nameof(range)); return(value >= range.Minimum && value <= range.Maximum && (value - range.Minimum) % range.Increment == 0); }
/// <summary> /// Constructor. /// </summary> /// <param name="symbol">The symbol.</param> /// <param name="interval">The interval.</param> /// <param name="openTime">The open time.</param> /// <param name="open">The open price.</param> /// <param name="high">The high price.</param> /// <param name="low">The low price.</param> /// <param name="close">The close price.</param> /// <param name="volume">The volume in base asset units.</param> /// <param name="closeTime">The close time.</param> /// <param name="quoteAssetVolume">The volume in quote assset units.</param> /// <param name="numberOfTrades">The number of trades.</param> /// <param name="takerBuyBaseAssetVolume">The taker buy base asset volume.</param> /// <param name="takerBuyQuoteAssetVolume">The taker buy quote asset volume.</param> public Candlestick( string symbol, CandlestickInterval interval, DateTime openTime, decimal open, decimal high, decimal low, decimal close, decimal volume, DateTime closeTime, decimal quoteAssetVolume, long numberOfTrades, decimal takerBuyBaseAssetVolume, decimal takerBuyQuoteAssetVolume) { Throw.IfNull(symbol, nameof(symbol)); if (open < 0) { throw new ArgumentException($"{nameof(Candlestick)}: price must not be less than 0.", nameof(open)); } if (high < 0) { throw new ArgumentException($"{nameof(Candlestick)}: price must not be less than 0.", nameof(high)); } if (low < 0) { throw new ArgumentException($"{nameof(Candlestick)}: price must not be less than 0.", nameof(low)); } if (close < 0) { throw new ArgumentException($"{nameof(Candlestick)}: price must not be less than 0.", nameof(close)); } if (numberOfTrades < 0) { throw new ArgumentException($"{nameof(Candlestick)}: number of trades must not be less than 0.", nameof(numberOfTrades)); } // HACK: https://api.binance.com/api/v1/klines?symbol=TRXBTC&interval=1M returns negative volume. //if (volume < 0) // throw new ArgumentException($"{nameof(Candlestick)}: volume must not be less than 0.", nameof(volume)); if (quoteAssetVolume < 0) { throw new ArgumentException($"{nameof(Candlestick)}: volume must not be less than 0.", nameof(quoteAssetVolume)); } if (takerBuyBaseAssetVolume < 0) { throw new ArgumentException($"{nameof(Candlestick)}: volume must not be less than 0.", nameof(takerBuyBaseAssetVolume)); } if (takerBuyQuoteAssetVolume < 0) { throw new ArgumentException($"{nameof(Candlestick)}: volume must not be less than 0.", nameof(takerBuyQuoteAssetVolume)); } Symbol = symbol.FormatSymbol(); Interval = interval; OpenTime = openTime; Open = open; High = high; Low = low; Close = close; Volume = volume; CloseTime = closeTime; QuoteAssetVolume = quoteAssetVolume; NumberOfTrades = numberOfTrades; TakerBuyBaseAssetVolume = takerBuyBaseAssetVolume; TakerBuyQuoteAssetVolume = takerBuyQuoteAssetVolume; }
/// <summary> /// Constructor. /// </summary> /// <param name="exception">The exception (required).</param> public ErrorEventArgs(Exception exception) { Throw.IfNull(exception, nameof(exception)); Exception = exception; }