Skip to content

Commit 39786cd

Browse files
authored
Merge pull request #620 from vslee/master
2 parents 2411365 + 9717725 commit 39786cd

File tree

12 files changed

+652
-640
lines changed

12 files changed

+652
-640
lines changed

src/ExchangeSharp/API/Exchanges/BL3P/ExchangeBL3PAPI.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,12 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
252252
switch (order.OrderType)
253253
{
254254
case OrderType.Limit:
255-
data["price_int"] = converterToFive.FromDecimal(order.Price);
255+
if (order.Price == null) throw new ArgumentNullException(nameof(order.Price));
256+
data["price_int"] = converterToFive.FromDecimal(order.Price.Value);
256257
break;
257258
case OrderType.Market:
258-
data["amount_funds_int"] = converterToFive.FromDecimal(roundedAmount * order.Price);
259+
if (order.Price == null) throw new ArgumentNullException(nameof(order.Price));
260+
data["amount_funds_int"] = converterToFive.FromDecimal(roundedAmount * order.Price.Value);
259261
break;
260262
default:
261263
throw new NotSupportedException($"{order.OrderType} is not supported");

src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public async Task OnGetHistoricalTradesAsync(Func<IEnumerable<ExchangeTrade>, bo
443443
// TODO : Refactor into a common layer once more Exchanges implement this pattern
444444
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#compressedaggregate-trades-list
445445
if(limit > 1000) limit = 1000; //Binance max = 1000
446-
var maxRequestLimit = 1000;
446+
var maxRequestLimit = 1000;
447447
var trades = new List<ExchangeTrade>();
448448
var processedIds = new HashSet<long>();
449449
marketSymbol = NormalizeMarketSymbol(marketSymbol);
@@ -548,6 +548,7 @@ protected override async Task<Dictionary<string, decimal>> OnGetAmountsAvailable
548548

549549
protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrderRequest order)
550550
{
551+
if (order.Price == null) throw new ArgumentNullException(nameof(order.Price));
551552
Dictionary<string, object> payload = await GetNoncePayloadAsync();
552553
payload["symbol"] = order.MarketSymbol;
553554
payload["newClientOrderId"] = order.ClientOrderId;
@@ -559,7 +560,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
559560

560561
// Binance has strict rules on which prices and quantities are allowed. They have to match the rules defined in the market definition.
561562
decimal outputQuantity = await ClampOrderQuantity(order.MarketSymbol, order.Amount);
562-
decimal outputPrice = await ClampOrderPrice(order.MarketSymbol, order.Price);
563+
decimal outputPrice = await ClampOrderPrice(order.MarketSymbol, order.Price.Value);
563564

564565
// Binance does not accept quantities with more than 20 decimal places.
565566
payload["quantity"] = Math.Round(outputQuantity, 20);

src/ExchangeSharp/API/Exchanges/Bitfinex/ExchangeBitfinexAPI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
481481

482482
if (order.OrderType != OrderType.Market)
483483
{
484-
payload["price"] = (await ClampOrderPrice(marketSymbol, order.Price)).ToStringInvariant();
484+
if (order.Price == null) throw new ArgumentNullException(nameof(order.Price));
485+
payload["price"] = (await ClampOrderPrice(marketSymbol, order.Price.Value)).ToStringInvariant();
485486
}
486487
else
487488
{

src/ExchangeSharp/API/Exchanges/Bitstamp/ExchangeBitstampAPI.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
202202

203203
if (order.OrderType != OrderType.Market)
204204
{
205-
payload["price"] = order.Price.ToStringInvariant();
205+
if (order.Price == null) throw new ArgumentNullException(nameof(order.Price));
206+
payload["price"] = order.Price.ToStringInvariant();
206207
}
207208

208209
payload["amount"] = order.RoundAmount().ToStringInvariant();
@@ -442,7 +443,7 @@ protected override async Task<IEnumerable<ExchangeOrderResult>> OnGetCompletedOr
442443
List<ExchangeOrderResult> orders2 = new List<ExchangeOrderResult>();
443444
foreach (var group in groupings)
444445
{
445-
decimal spentQuoteCurrency = group.Sum(o => o.AveragePrice * o.AmountFilled);
446+
decimal spentQuoteCurrency = group.Sum(o => o.AveragePrice.Value * o.AmountFilled);
446447
ExchangeOrderResult order = group.First();
447448
order.AmountFilled = group.Sum(o => o.AmountFilled);
448449
order.AveragePrice = spentQuoteCurrency / order.AmountFilled;

src/ExchangeSharp/API/Exchanges/Bittrex/ExchangeBittrexAPI.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private ExchangeOrderResult ParseOrder(JToken token)
8484
decimal amountFilled = token["fillQuantity"].ConvertInvariant<decimal>();
8585
order.Amount = amount;
8686
order.AmountFilled = amountFilled;
87-
order.Price = token["limit"].ConvertInvariant<decimal>(order.AveragePrice);
87+
order.Price = token["limit"].ConvertInvariant<decimal>(order.AveragePrice.Value);
8888
order.Message = string.Empty;
8989
order.OrderId = token["id"].ToStringInvariant();
9090

@@ -378,7 +378,8 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
378378
{
379379

380380
decimal orderAmount = await ClampOrderQuantity(order.MarketSymbol, order.Amount);
381-
decimal orderPrice = await ClampOrderPrice(order.MarketSymbol, order.Price);
381+
if (order.Price == null) throw new ArgumentNullException(nameof(order.Price));
382+
decimal orderPrice = await ClampOrderPrice(order.MarketSymbol, order.Price.Value);
382383
string url = "/orders";
383384
Dictionary<string, object> orderParams = await GetNoncePayloadAsync();
384385
orderParams.Add("marketSymbol", order.MarketSymbol);
@@ -507,7 +508,7 @@ protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(Exchan
507508
{
508509
/*
509510
"currencySymbol": "string",
510-
"quantity": "number (double)",
511+
"quantity": "number (double)",
511512
"cryptoAddress": "string",
512513
"cryptoAddressTag": "string",
513514
"clientWithdrawalId": "string (uuid)"

0 commit comments

Comments
 (0)