Skip to content

Commit f92619b

Browse files
authored
Binance - add support for FilledPartiallyAndCancelled order status (#564)
1 parent 86537b2 commit f92619b

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

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

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -939,35 +939,30 @@ private ExchangeOrderResult ParseOrder(JToken token)
939939
ClientOrderId = token["clientOrderId"].ToStringInvariant()
940940
};
941941

942-
switch (token["status"].ToStringInvariant())
942+
result.Result = ParseExchangeAPIOrderResult(token["status"].ToStringInvariant(), result.AmountFilled);
943+
944+
return result;
945+
}
946+
947+
private ExchangeAPIOrderResult ParseExchangeAPIOrderResult(string status, decimal amountFilled)
948+
{
949+
switch (status)
943950
{
944951
case "NEW":
945-
result.Result = ExchangeAPIOrderResult.Pending;
946-
break;
947-
952+
return ExchangeAPIOrderResult.Pending;
948953
case "PARTIALLY_FILLED":
949-
result.Result = ExchangeAPIOrderResult.FilledPartially;
950-
break;
951-
954+
return ExchangeAPIOrderResult.FilledPartially;
952955
case "FILLED":
953-
result.Result = ExchangeAPIOrderResult.Filled;
954-
break;
955-
956+
return ExchangeAPIOrderResult.Filled;
956957
case "CANCELED":
958+
return amountFilled > 0 ? ExchangeAPIOrderResult.FilledPartiallyAndCancelled : ExchangeAPIOrderResult.Canceled;
957959
case "PENDING_CANCEL":
958960
case "EXPIRED":
959961
case "REJECTED":
960-
result.Result = ExchangeAPIOrderResult.Canceled;
961-
break;
962-
962+
return ExchangeAPIOrderResult.Canceled;
963963
default:
964-
result.Result = ExchangeAPIOrderResult.Error;
965-
break;
964+
return ExchangeAPIOrderResult.Error;
966965
}
967-
968-
ParseAveragePriceAndFeesFromFills(result, token["fills"]);
969-
970-
return result;
971966
}
972967

973968
private ExchangeOrderResult ParseTrade(JToken token, string symbol)

0 commit comments

Comments
 (0)