diff --git a/src/Managing.Application/Grains/PlatformSummaryGrain.cs b/src/Managing.Application/Grains/PlatformSummaryGrain.cs
index e574cc05..e71f2da9 100644
--- a/src/Managing.Application/Grains/PlatformSummaryGrain.cs
+++ b/src/Managing.Application/Grains/PlatformSummaryGrain.cs
@@ -3,7 +3,7 @@ using Managing.Application.Abstractions.Grains;
using Managing.Application.Abstractions.Services;
using Managing.Application.Orleans;
using Managing.Domain.Candles;
-using Managing.Domain.Trades;
+using Managing.Domain.Shared.Helpers;
using Microsoft.Extensions.Logging;
using static Managing.Common.Enums;
@@ -117,7 +117,7 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
foreach (var position in positions)
{
// Calculate volume using the dedicated method
- var positionVolume = GetVolumeForPosition(position);
+ var positionVolume = TradingHelpers.GetVolumeForPosition(position);
totalVolume += positionVolume;
// Add to open interest for active positions only
@@ -184,41 +184,6 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
}
}
- ///
- /// Calculates the total volume for a position based on its status and filled trades
- ///
- /// The position to calculate volume for
- /// The total volume for the position
- private decimal GetVolumeForPosition(Position position)
- {
- // 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.IsFinished())
- {
- // Add Stop Loss volume if filled
- if (position.StopLoss?.Status == TradeStatus.Filled)
- {
- 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 2 volume if filled
- if (position.TakeProfit2?.Status == TradeStatus.Filled)
- {
- totalVolume += position.TakeProfit2.Price * position.TakeProfit2.Quantity * position.TakeProfit2.Leverage;
- }
- }
-
- return totalVolume;
- }
-
// Event handlers for immediate updates
public async Task UpdateActiveStrategyCountAsync(int newActiveCount)
{
diff --git a/src/Managing.Domain/Shared/Helpers/TradingHelpers.cs b/src/Managing.Domain/Shared/Helpers/TradingHelpers.cs
index 7accdfd5..35fbd897 100644
--- a/src/Managing.Domain/Shared/Helpers/TradingHelpers.cs
+++ b/src/Managing.Domain/Shared/Helpers/TradingHelpers.cs
@@ -189,4 +189,39 @@ public static class TradingHelpers
{
return Constants.GMX.Config.GasFeePerTransaction;
}
+
+ ///
+ /// Calculates the total volume for a position based on its status and filled trades
+ ///
+ /// The position to calculate volume for
+ /// The total volume for the position
+ public static decimal GetVolumeForPosition(Position position)
+ {
+ // 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.IsFinished())
+ {
+ // Add Stop Loss volume if filled
+ if (position.StopLoss?.Status == TradeStatus.Filled)
+ {
+ 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 2 volume if filled
+ if (position.TakeProfit2?.Status == TradeStatus.Filled)
+ {
+ totalVolume += position.TakeProfit2.Price * position.TakeProfit2.Quantity * position.TakeProfit2.Leverage;
+ }
+ }
+
+ return totalVolume;
+ }
}
\ No newline at end of file