Skip to content

Commit ea0dc3b

Browse files
authored
Add fallback price value (#823)
1 parent 603647a commit ea0dc3b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,11 @@ private ExchangeOrderResult ParseOpenOrder(JToken token)
863863
.DateTime
864864
};
865865

866+
if (order.AveragePrice == 0)
867+
{
868+
order.AveragePrice = token["dealFunds"].ConvertInvariant<decimal>() / token["dealSize"].ConvertInvariant<decimal>();
869+
}
870+
866871
// Amount and Filled are returned as Sold and Pending, so we'll adjust
867872
order.AmountFilled = token["dealSize"].ConvertInvariant<decimal>();
868873
order.Amount = token["size"].ConvertInvariant<decimal>() + order.AmountFilled.Value;
@@ -895,6 +900,12 @@ private ExchangeOrderResult ParseCompletedOrder(JToken token)
895900
.FromUnixTimeMilliseconds(token["createdAt"].ConvertInvariant<long>())
896901
.DateTime
897902
};
903+
904+
if (order.AveragePrice == 0)
905+
{
906+
order.AveragePrice = token["dealFunds"].ConvertInvariant<decimal>() / token["dealSize"].ConvertInvariant<decimal>();
907+
}
908+
898909
if (token["cancelExist"].ToStringInvariant().ToUpper() == "TRUE")
899910
{
900911
order.Result = ExchangeAPIOrderResult.Canceled;
@@ -903,6 +914,7 @@ private ExchangeOrderResult ParseCompletedOrder(JToken token)
903914
{
904915
order.Result = ExchangeAPIOrderResult.Filled;
905916
}
917+
906918
return order;
907919
}
908920

0 commit comments

Comments
 (0)