Skip to content

Make market orders possible by removing price requirement #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ExchangeSharp/API/Exchanges/BL3P/ExchangeBL3PAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
switch (order.OrderType)
{
case OrderType.Limit:
data["price_int"] = converterToFive.FromDecimal(order.Price);
data["price_int"] = converterToFive.FromDecimal(order.Price.Value);
break;
case OrderType.Market:
data["amount_funds_int"] = converterToFive.FromDecimal(roundedAmount * order.Price);
data["amount_funds_int"] = converterToFive.FromDecimal(roundedAmount * order.Price.Value);
break;
default:
throw new NotSupportedException($"{order.OrderType} is not supported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public async Task OnGetHistoricalTradesAsync(Func<IEnumerable<ExchangeTrade>, bo
// TODO : Refactor into a common layer once more Exchanges implement this pattern
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#compressedaggregate-trades-list
if(limit > 1000) limit = 1000; //Binance max = 1000
var maxRequestLimit = 1000;
var maxRequestLimit = 1000;
var trades = new List<ExchangeTrade>();
var processedIds = new HashSet<long>();
marketSymbol = NormalizeMarketSymbol(marketSymbol);
Expand Down Expand Up @@ -559,7 +559,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd

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

// Binance does not accept quantities with more than 20 decimal places.
payload["quantity"] = Math.Round(outputQuantity, 20);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd

if (order.OrderType != OrderType.Market)
{
payload["price"] = (await ClampOrderPrice(marketSymbol, order.Price)).ToStringInvariant();
payload["price"] = (await ClampOrderPrice(marketSymbol, order.Price.Value)).ToStringInvariant();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ protected override async Task<IEnumerable<ExchangeOrderResult>> OnGetCompletedOr
List<ExchangeOrderResult> orders2 = new List<ExchangeOrderResult>();
foreach (var group in groupings)
{
decimal spentQuoteCurrency = group.Sum(o => o.AveragePrice * o.AmountFilled);
decimal spentQuoteCurrency = group.Sum(o => o.AveragePrice.Value * o.AmountFilled);
ExchangeOrderResult order = group.First();
order.AmountFilled = group.Sum(o => o.AmountFilled);
order.AveragePrice = spentQuoteCurrency / order.AmountFilled;
Expand Down
6 changes: 3 additions & 3 deletions src/ExchangeSharp/API/Exchanges/Bittrex/ExchangeBittrexAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private ExchangeOrderResult ParseOrder(JToken token)
decimal amountFilled = token["fillQuantity"].ConvertInvariant<decimal>();
order.Amount = amount;
order.AmountFilled = amountFilled;
order.Price = token["limit"].ConvertInvariant<decimal>(order.AveragePrice);
order.Price = token["limit"].ConvertInvariant<decimal>(order.AveragePrice.Value);
order.Message = string.Empty;
order.OrderId = token["id"].ToStringInvariant();

Expand Down Expand Up @@ -378,7 +378,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
{

decimal orderAmount = await ClampOrderQuantity(order.MarketSymbol, order.Amount);
decimal orderPrice = await ClampOrderPrice(order.MarketSymbol, order.Price);
decimal orderPrice = await ClampOrderPrice(order.MarketSymbol, order.Price.Value);
string url = "/orders";
Dictionary<string, object> orderParams = await GetNoncePayloadAsync();
orderParams.Add("marketSymbol", order.MarketSymbol);
Expand Down Expand Up @@ -507,7 +507,7 @@ protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(Exchan
{
/*
"currencySymbol": "string",
"quantity": "number (double)",
"quantity": "number (double)",
"cryptoAddress": "string",
"cryptoAddressTag": "string",
"clientWithdrawalId": "string (uuid)"
Expand Down
Loading