Skip to content

Commit

Permalink
Add fallback price value (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
v36u authored Jan 11, 2024
1 parent 603647a commit ea0dc3b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,11 @@ private ExchangeOrderResult ParseOpenOrder(JToken token)
.DateTime
};

if (order.AveragePrice == 0)
{
order.AveragePrice = token["dealFunds"].ConvertInvariant<decimal>() / token["dealSize"].ConvertInvariant<decimal>();
}

// Amount and Filled are returned as Sold and Pending, so we'll adjust
order.AmountFilled = token["dealSize"].ConvertInvariant<decimal>();
order.Amount = token["size"].ConvertInvariant<decimal>() + order.AmountFilled.Value;
Expand Down Expand Up @@ -895,6 +900,12 @@ private ExchangeOrderResult ParseCompletedOrder(JToken token)
.FromUnixTimeMilliseconds(token["createdAt"].ConvertInvariant<long>())
.DateTime
};

if (order.AveragePrice == 0)
{
order.AveragePrice = token["dealFunds"].ConvertInvariant<decimal>() / token["dealSize"].ConvertInvariant<decimal>();
}

if (token["cancelExist"].ToStringInvariant().ToUpper() == "TRUE")
{
order.Result = ExchangeAPIOrderResult.Canceled;
Expand All @@ -903,6 +914,7 @@ private ExchangeOrderResult ParseCompletedOrder(JToken token)
{
order.Result = ExchangeAPIOrderResult.Filled;
}

return order;
}

Expand Down

0 comments on commit ea0dc3b

Please sign in to comment.