Add net Pnl in db
This commit is contained in:
@@ -720,12 +720,13 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
|
||||
var (tradeWins, tradeLosses) = TradingBox.GetWinLossCount(_tradingBot.Positions);
|
||||
var pnl = _tradingBot.GetProfitAndLoss();
|
||||
var fees = _tradingBot.GetTotalFees();
|
||||
var netPnl = pnl - fees; // Net PnL after fees
|
||||
var volume = TradingBox.GetTotalVolumeTraded(_tradingBot.Positions);
|
||||
|
||||
// Calculate ROI based on total investment (PnL minus fees)
|
||||
// Calculate ROI based on total investment (Net PnL)
|
||||
var totalInvestment = _tradingBot.Positions.Values
|
||||
.Sum(p => p.Open.Quantity * p.Open.Price);
|
||||
var roi = totalInvestment > 0 ? ((pnl - fees) / totalInvestment) * 100 : 0;
|
||||
var roi = totalInvestment > 0 ? (netPnl / totalInvestment) * 100 : 0;
|
||||
|
||||
// Calculate long and short position counts
|
||||
var longPositionCount = _tradingBot.Positions.Values
|
||||
@@ -745,7 +746,8 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
|
||||
CreateDate = _state.State.CreateDate,
|
||||
TradeWins = tradeWins,
|
||||
TradeLosses = tradeLosses,
|
||||
Pnl = pnl,
|
||||
Pnl = pnl, // Gross PnL before fees
|
||||
NetPnL = netPnl, // Net PnL after fees
|
||||
Roi = roi,
|
||||
Volume = volume,
|
||||
Fees = fees,
|
||||
|
||||
Reference in New Issue
Block a user