Fix agent volume

This commit is contained in:
2025-10-08 19:57:19 +07:00
parent 1a99224d18
commit b2a4e1ca5d
3 changed files with 16 additions and 6 deletions

View File

@@ -461,22 +461,24 @@ public static class TradingBox
foreach (var position in positions)
{
// Add entry volume
totalVolume += position.Open.Quantity * position.Open.Price;
totalVolume += position.Open.Quantity * position.Open.Price * position.Open.Leverage;
// Add exit volumes from stop loss or take profits if they were executed
if (position.StopLoss.Status == TradeStatus.Filled)
{
totalVolume += position.StopLoss.Quantity * position.StopLoss.Price;
totalVolume += position.StopLoss.Quantity * position.StopLoss.Price * position.StopLoss.Leverage;
}
if (position.TakeProfit1.Status == TradeStatus.Filled)
{
totalVolume += position.TakeProfit1.Quantity * position.TakeProfit1.Price;
totalVolume += position.TakeProfit1.Quantity * position.TakeProfit1.Price *
position.TakeProfit1.Leverage;
}
if (position.TakeProfit2 != null && position.TakeProfit2.Status == TradeStatus.Filled)
{
totalVolume += position.TakeProfit2.Quantity * position.TakeProfit2.Price;
totalVolume += position.TakeProfit2.Quantity * position.TakeProfit2.Price *
position.TakeProfit2.Leverage;
}
}