Skip to content

Binance - add support for FilledPartiallyAndCancelled order status #564

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

Merged
merged 1 commit into from
Dec 8, 2020
Merged
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
33 changes: 14 additions & 19 deletions src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -939,35 +939,30 @@ private ExchangeOrderResult ParseOrder(JToken token)
ClientOrderId = token["clientOrderId"].ToStringInvariant()
};

switch (token["status"].ToStringInvariant())
result.Result = ParseExchangeAPIOrderResult(token["status"].ToStringInvariant(), result.AmountFilled);

return result;
}

private ExchangeAPIOrderResult ParseExchangeAPIOrderResult(string status, decimal amountFilled)
{
switch (status)
{
case "NEW":
result.Result = ExchangeAPIOrderResult.Pending;
break;

return ExchangeAPIOrderResult.Pending;
case "PARTIALLY_FILLED":
result.Result = ExchangeAPIOrderResult.FilledPartially;
break;

return ExchangeAPIOrderResult.FilledPartially;
case "FILLED":
result.Result = ExchangeAPIOrderResult.Filled;
break;

return ExchangeAPIOrderResult.Filled;
case "CANCELED":
return amountFilled > 0 ? ExchangeAPIOrderResult.FilledPartiallyAndCancelled : ExchangeAPIOrderResult.Canceled;
case "PENDING_CANCEL":
case "EXPIRED":
case "REJECTED":
result.Result = ExchangeAPIOrderResult.Canceled;
break;

return ExchangeAPIOrderResult.Canceled;
default:
result.Result = ExchangeAPIOrderResult.Error;
break;
return ExchangeAPIOrderResult.Error;
}

ParseAveragePriceAndFeesFromFills(result, token["fills"]);

return result;
}

private ExchangeOrderResult ParseTrade(JToken token, string symbol)
Expand Down