Fix roi with fees

This commit is contained in:
2025-09-28 21:42:08 +07:00
parent 37da5a80b2
commit 6267dad8fa
3 changed files with 28 additions and 29 deletions

View File

@@ -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