Skip to content
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
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