1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2026-02-16 14:13:46 +00:00

Fixed bug in UserDataTracker orders logic incorrectly setting order to canceled status

This commit is contained in:
Jkorf 2026-02-09 09:07:17 +01:00
parent 8e18482781
commit 759c8b9a58
2 changed files with 22 additions and 6 deletions

View File

@ -129,6 +129,14 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers
// status changed from open to not open // status changed from open to not open
return true; return true;
if (existingItem.Status != SharedOrderStatus.Open
&& updateItem.Status != SharedOrderStatus.Open
&& existingItem.Status != updateItem.Status)
{
_logger.LogWarning("Invalid order update detected for order {OrderId}; current status: {OldStatus}, new status: {NewStatus}", existingItem.OrderId, existingItem.Status, updateItem.Status);
return false;
}
if (existingItem.Status != SharedOrderStatus.Open && updateItem.Status == SharedOrderStatus.Open) if (existingItem.Status != SharedOrderStatus.Open && updateItem.Status == SharedOrderStatus.Open)
// status changed from not open to open; stale // status changed from not open to open; stale
return false; return false;
@ -264,9 +272,9 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers
// Filter orders to only include where close time is after the start time // Filter orders to only include where close time is after the start time
var relevantOrders = closedOrdersResult.Data.Where(x => var relevantOrders = closedOrdersResult.Data.Where(x =>
x.UpdateTime != null && x.UpdateTime >= _startTime // Updated after the tracker start time (x.UpdateTime != null && x.UpdateTime >= _startTime) // Updated after the tracker start time
|| x.CreateTime != null && x.CreateTime >= _startTime // Created after the tracker start time || (x.CreateTime != null && x.CreateTime >= _startTime) // Created after the tracker start time
|| x.CreateTime == null && x.UpdateTime == null // Unknown time || (x.CreateTime == null && x.UpdateTime == null) // Unknown time
).ToArray(); ).ToArray();
// Check for orders which are no longer returned in either open/closed and assume they're canceled without fill // Check for orders which are no longer returned in either open/closed and assume they're canceled without fill

View File

@ -140,6 +140,14 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers
// status changed from open to not open // status changed from open to not open
return true; return true;
if (existingItem.Status != SharedOrderStatus.Open
&& updateItem.Status != SharedOrderStatus.Open
&& existingItem.Status != updateItem.Status)
{
_logger.LogWarning("Invalid order update detected for order {OrderId}; current status: {OldStatus}, new status: {NewStatus}", existingItem.OrderId, existingItem.Status, updateItem.Status);
return false;
}
if (existingItem.Status != SharedOrderStatus.Open && updateItem.Status == SharedOrderStatus.Open) if (existingItem.Status != SharedOrderStatus.Open && updateItem.Status == SharedOrderStatus.Open)
// status changed from not open to open; stale // status changed from not open to open; stale
return false; return false;
@ -278,9 +286,9 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers
// Filter orders to only include where close time is after the start time // Filter orders to only include where close time is after the start time
var relevantOrders = closedOrdersResult.Data.Where(x => var relevantOrders = closedOrdersResult.Data.Where(x =>
x.UpdateTime != null && x.UpdateTime >= _startTime // Updated after the tracker start time (x.UpdateTime != null && x.UpdateTime >= _startTime) // Updated after the tracker start time
|| x.CreateTime != null && x.CreateTime >= _startTime // Created after the tracker start time || (x.CreateTime != null && x.CreateTime >= _startTime) // Created after the tracker start time
|| x.CreateTime == null && x.UpdateTime == null // Unknown time || (x.CreateTime == null && x.UpdateTime == null) // Unknown time
).ToArray(); ).ToArray();
// Check for orders which are no longer returned in either open/closed and assume they're canceled without fill // Check for orders which are no longer returned in either open/closed and assume they're canceled without fill