Fix roi with fees
This commit is contained in:
@@ -81,7 +81,8 @@ public class AgentGrain : Grain, IAgentGrain
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
ActiveStrategiesCount = 0,
|
||||
TotalVolume = 0,
|
||||
TotalBalance = 0
|
||||
TotalBalance = 0,
|
||||
TotalFees = 0
|
||||
};
|
||||
|
||||
await _agentService.SaveOrUpdateAgentSummary(emptySummary);
|
||||
|
||||
@@ -722,10 +722,10 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
|
||||
var fees = _tradingBot.GetTotalFees();
|
||||
var volume = TradingBox.GetTotalVolumeTraded(_tradingBot.Positions);
|
||||
|
||||
// Calculate ROI based on total investment
|
||||
// Calculate ROI based on total investment (PnL minus fees)
|
||||
var totalInvestment = _tradingBot.Positions.Values
|
||||
.Sum(p => p.Open.Quantity * p.Open.Price);
|
||||
var roi = totalInvestment > 0 ? (pnl / totalInvestment) * 100 : 0;
|
||||
var roi = totalInvestment > 0 ? ((pnl - fees) / totalInvestment) * 100 : 0;
|
||||
|
||||
// Calculate long and short position counts
|
||||
var longPositionCount = _tradingBot.Positions.Values
|
||||
|
||||
Reference in New Issue
Block a user