Improve tests logic
This commit is contained in:
@@ -919,31 +919,30 @@ public static class TradingBox
|
||||
/// <returns>The total volume for the position</returns>
|
||||
public static decimal GetVolumeForPosition(Position position)
|
||||
{
|
||||
if (!position.IsValidForMetrics())
|
||||
return 0;
|
||||
|
||||
// Always include the opening trade volume
|
||||
var totalVolume = position.Open.Price * position.Open.Quantity * position.Open.Leverage;
|
||||
|
||||
// For closed positions, add volume from filled closing trades
|
||||
if (position.IsValidForMetrics())
|
||||
// Add Stop Loss volume if filled
|
||||
if (position.StopLoss?.Status == TradeStatus.Filled)
|
||||
{
|
||||
// Add Stop Loss volume if filled
|
||||
if (position.StopLoss?.Status == TradeStatus.Filled)
|
||||
{
|
||||
totalVolume += position.StopLoss.Price * position.StopLoss.Quantity * position.StopLoss.Leverage;
|
||||
}
|
||||
totalVolume += position.StopLoss.Price * position.StopLoss.Quantity * position.StopLoss.Leverage;
|
||||
}
|
||||
|
||||
// Add Take Profit 1 volume if filled
|
||||
if (position.TakeProfit1?.Status == TradeStatus.Filled)
|
||||
{
|
||||
totalVolume += position.TakeProfit1.Price * position.TakeProfit1.Quantity *
|
||||
position.TakeProfit1.Leverage;
|
||||
}
|
||||
// Add Take Profit 1 volume if filled
|
||||
if (position.TakeProfit1?.Status == TradeStatus.Filled)
|
||||
{
|
||||
totalVolume += position.TakeProfit1.Price * position.TakeProfit1.Quantity *
|
||||
position.TakeProfit1.Leverage;
|
||||
}
|
||||
|
||||
// Add Take Profit 2 volume if filled
|
||||
if (position.TakeProfit2?.Status == TradeStatus.Filled)
|
||||
{
|
||||
totalVolume += position.TakeProfit2.Price * position.TakeProfit2.Quantity *
|
||||
position.TakeProfit2.Leverage;
|
||||
}
|
||||
// Add Take Profit 2 volume if filled
|
||||
if (position.TakeProfit2?.Status == TradeStatus.Filled)
|
||||
{
|
||||
totalVolume += position.TakeProfit2.Price * position.TakeProfit2.Quantity *
|
||||
position.TakeProfit2.Leverage;
|
||||
}
|
||||
|
||||
return totalVolume;
|
||||
|
||||
Reference in New Issue
Block a user