From ea0dc3b978222aa8733c3aed8a44735628df7fbf Mon Sep 17 00:00:00 2001 From: Vlad Dumitru <61616221+v36u@users.noreply.github.com> Date: Thu, 11 Jan 2024 02:23:45 +0200 Subject: [PATCH] Add fallback price value (#823) --- .../API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs b/src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs index 6851adf7..9616d20d 100644 --- a/src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs @@ -863,6 +863,11 @@ private ExchangeOrderResult ParseOpenOrder(JToken token) .DateTime }; + if (order.AveragePrice == 0) + { + order.AveragePrice = token["dealFunds"].ConvertInvariant() / token["dealSize"].ConvertInvariant(); + } + // Amount and Filled are returned as Sold and Pending, so we'll adjust order.AmountFilled = token["dealSize"].ConvertInvariant(); order.Amount = token["size"].ConvertInvariant() + order.AmountFilled.Value; @@ -895,6 +900,12 @@ private ExchangeOrderResult ParseCompletedOrder(JToken token) .FromUnixTimeMilliseconds(token["createdAt"].ConvertInvariant()) .DateTime }; + + if (order.AveragePrice == 0) + { + order.AveragePrice = token["dealFunds"].ConvertInvariant() / token["dealSize"].ConvertInvariant(); + } + if (token["cancelExist"].ToStringInvariant().ToUpper() == "TRUE") { order.Result = ExchangeAPIOrderResult.Canceled; @@ -903,6 +914,7 @@ private ExchangeOrderResult ParseCompletedOrder(JToken token) { order.Result = ExchangeAPIOrderResult.Filled; } + return order; }