diff --git a/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs b/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs index 8a5cd5e0..45ab4a61 100644 --- a/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs @@ -210,7 +210,7 @@ protected internal override async Task> OnGetMarketS protected override async Task> OnGetMarketSymbolsAsync() { - return (await GetMarketSymbolsMetadataAsync()).Where(market => market.IsActive).Select(market => market.MarketSymbol); + return (await GetMarketSymbolsMetadataAsync()).Where(market => market.IsActive ?? true).Select(market => market.MarketSymbol); } protected override async Task> OnGetCurrenciesAsync() diff --git a/src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs b/src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs index 57c1c7ac..ba3b3f3a 100644 --- a/src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs @@ -245,7 +245,9 @@ protected virtual Task OnUserDataWebSocketAsync(Action callb protected async Task ClampOrderPrice(string marketSymbol, decimal outputPrice) { ExchangeMarket? market = await GetExchangeMarketFromCacheAsync(marketSymbol); - return market == null ? outputPrice : CryptoUtility.ClampDecimal(market.MinPrice, market.MaxPrice, market.PriceStepSize, outputPrice); + if (market.MinPrice == null || market.MaxPrice == null || market.PriceStepSize == null) + throw new NotImplementedException($"Exchange must return {nameof(market.MinPrice)} and {nameof(market.MaxPrice)} in order for {nameof(ClampOrderPrice)}() to work"); + else return market == null ? outputPrice : CryptoUtility.ClampDecimal(market.MinPrice.Value, market.MaxPrice.Value, market.PriceStepSize, outputPrice); } /// @@ -257,7 +259,9 @@ protected async Task ClampOrderPrice(string marketSymbol, decimal outpu protected async Task ClampOrderQuantity(string marketSymbol, decimal outputQuantity) { ExchangeMarket? market = await GetExchangeMarketFromCacheAsync(marketSymbol); - return market == null ? outputQuantity : CryptoUtility.ClampDecimal(market.MinTradeSize, market.MaxTradeSize, market.QuantityStepSize, outputQuantity); + if (market.MinPrice == null || market.MaxPrice == null || market.PriceStepSize == null) + throw new NotImplementedException($"Exchange must return {nameof(market.MinPrice)} and {nameof(market.MaxPrice)} in order for {nameof(ClampOrderQuantity)}() to work"); + else return market == null ? outputQuantity : CryptoUtility.ClampDecimal(market.MinTradeSize.Value, market.MaxTradeSize.Value, market.QuantityStepSize, outputQuantity); } /// diff --git a/src/ExchangeSharp/Model/ExchangeMarket.cs b/src/ExchangeSharp/Model/ExchangeMarket.cs index f702b161..b00614c1 100644 --- a/src/ExchangeSharp/Model/ExchangeMarket.cs +++ b/src/ExchangeSharp/Model/ExchangeMarket.cs @@ -28,7 +28,7 @@ public class ExchangeMarket public string AltMarketSymbol2 { get; set; } /// A value indicating whether the market is active. - public bool IsActive { get; set; } + public bool? IsActive { get; set; } /// In a pair like ZRX/BTC, BTC is the quote currency. public string QuoteCurrency { get; set; } @@ -38,10 +38,10 @@ public class ExchangeMarket /// The minimum size of the trade in the unit of "BaseCurrency". For example, in /// DOGE/BTC the MinTradeSize is currently 423.72881356 DOGE - public decimal MinTradeSize { get; set; } + public decimal? MinTradeSize { get; set; } /// The maximum size of the trade in the unit of "BaseCurrency". - public decimal MaxTradeSize { get; set; } = decimal.MaxValue; + public decimal? MaxTradeSize { get; set; } /// The minimum size of the trade in the unit of "QuoteCurrency". To determine an order's /// trade size in terms of the Quote Currency, you need to calculate: price * quantity @@ -54,10 +54,10 @@ public class ExchangeMarket public decimal? MaxTradeSizeInQuoteCurrency { get; set; } /// The minimum price of the pair. - public decimal MinPrice { get; set; } + public decimal? MinPrice { get; set; } /// The maximum price of the pair. - public decimal MaxPrice { get; set; } = decimal.MaxValue; + public decimal? MaxPrice { get; set; } /// Defines the intervals that a price can be increased/decreased by. The following /// must be true for price: Price % PriceStepSize == 0 Null if unknown or not applicable. @@ -71,7 +71,7 @@ public class ExchangeMarket /// /// Margin trading enabled for this market /// - public bool MarginEnabled { get; set; } + public bool? MarginEnabled { get; set; } public override string ToString() {