Skip to content

Commit 1da81ae

Browse files
committed
Make market orders possible by removing price requirement
1 parent 8880956 commit 1da81ae

File tree

12 files changed

+638
-638
lines changed

12 files changed

+638
-638
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ 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+
data["price_int"] = converterToFive.FromDecimal(order.Price.Value);
256256
break;
257257
case OrderType.Market:
258-
data["amount_funds_int"] = converterToFive.FromDecimal(roundedAmount * order.Price);
258+
data["amount_funds_int"] = converterToFive.FromDecimal(roundedAmount * order.Price.Value);
259259
break;
260260
default:
261261
throw new NotSupportedException($"{order.OrderType} is not supported");

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

Lines changed: 2 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);
@@ -559,7 +559,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
559559

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ 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+
payload["price"] = (await ClampOrderPrice(marketSymbol, order.Price.Value)).ToStringInvariant();
485485
}
486486
else
487487
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ protected override async Task<IEnumerable<ExchangeOrderResult>> OnGetCompletedOr
442442
List<ExchangeOrderResult> orders2 = new List<ExchangeOrderResult>();
443443
foreach (var group in groupings)
444444
{
445-
decimal spentQuoteCurrency = group.Sum(o => o.AveragePrice * o.AmountFilled);
445+
decimal spentQuoteCurrency = group.Sum(o => o.AveragePrice.Value * o.AmountFilled);
446446
ExchangeOrderResult order = group.First();
447447
order.AmountFilled = group.Sum(o => o.AmountFilled);
448448
order.AveragePrice = spentQuoteCurrency / order.AmountFilled;

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

Lines changed: 3 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,7 @@ 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+
decimal orderPrice = await ClampOrderPrice(order.MarketSymbol, order.Price.Value);
382382
string url = "/orders";
383383
Dictionary<string, object> orderParams = await GetNoncePayloadAsync();
384384
orderParams.Add("marketSymbol", order.MarketSymbol);
@@ -507,7 +507,7 @@ protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(Exchan
507507
{
508508
/*
509509
"currencySymbol": "string",
510-
"quantity": "number (double)",
510+
"quantity": "number (double)",
511511
"cryptoAddress": "string",
512512
"cryptoAddressTag": "string",
513513
"clientWithdrawalId": "string (uuid)"

0 commit comments

Comments
 (0)