Add position count property map

This commit is contained in:
2025-11-19 14:16:30 +07:00
parent 9b25201def
commit 096fb500e4
5 changed files with 8 additions and 9 deletions

View File

@@ -320,7 +320,8 @@ public static class PostgreSqlMappers
RequestId = entity.RequestId,
Metadata = entity.Metadata,
InitialBalance = entity.InitialBalance,
NetPnl = entity.NetPnl
NetPnl = entity.NetPnl,
PositionCount = entity.PositionCount
};
return backtest;
@@ -362,7 +363,8 @@ public static class PostgreSqlMappers
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow,
InitialBalance = backtest.InitialBalance,
NetPnl = backtest.NetPnl
NetPnl = backtest.NetPnl,
PositionCount = backtest.Positions.Count
};
}
@@ -618,7 +620,7 @@ public static class PostgreSqlMappers
// Set ProfitAndLoss with proper type
position.ProfitAndLoss = new ProfitAndLoss { Realized = entity.ProfitAndLoss, Net = entity.NetPnL };
// Set fee properties
position.UiFees = entity.UiFees;
position.GasFees = entity.GasFees;
@@ -658,7 +660,8 @@ public static class PostgreSqlMappers
MoneyManagementJson = position.MoneyManagement != null
? JsonConvert.SerializeObject(position.MoneyManagement)
: null,
NetPnL = position.ProfitAndLoss?.Net ?? (position.ProfitAndLoss?.Realized - position.UiFees - position.GasFees ?? 0)
NetPnL = position.ProfitAndLoss?.Net ??
(position.ProfitAndLoss?.Realized - position.UiFees - position.GasFees ?? 0)
};
}