Update closing trade date on SL or TP

This commit is contained in:
2025-10-04 19:36:27 +07:00
parent 343b85dada
commit 5468b1e7f7
5 changed files with 54 additions and 66 deletions

View File

@@ -438,13 +438,13 @@ public class PostgreSqlTradingRepository : ITradingRepository
/// <summary>
/// Updates a trade entity with data from a domain trade object
/// Only updates the date if the trade status is changing from Requested to Filled
/// Always updates the date when it changes to ensure accurate execution dates
/// </summary>
private void UpdateTradeEntity(TradeEntity entity, Trade trade)
{
// Only update the date if the trade status is changing from Requested to Filled
// This prevents overwriting dates for trades that are already filled
if (entity.Status != TradeStatus.Filled && trade.Status == TradeStatus.Filled)
if (entity.Status != trade.Status)
{
entity.Date = trade.Date;
}