Fix Wallet balances

This commit is contained in:
2025-07-17 22:29:13 +07:00
parent 0ea05bca50
commit 03a4e179f7
2 changed files with 3 additions and 2 deletions

View File

@@ -296,7 +296,8 @@ namespace Managing.Application.Backtesting
var optimizedMoneyManagement = var optimizedMoneyManagement =
TradingBox.GetBestMoneyManagement(candles, bot.Positions, config.MoneyManagement); TradingBox.GetBestMoneyManagement(candles, bot.Positions, config.MoneyManagement);
var stats = TradingHelpers.GetStatistics(bot.WalletBalances); var stats = TradingHelpers.GetStatistics(bot.WalletBalances);
var growthPercentage = TradingHelpers.GetGrowthFromInitalBalance(config.BotTradingBalance, finalPnl); var growthPercentage =
TradingHelpers.GetGrowthFromInitalBalance(bot.WalletBalances.FirstOrDefault().Value, finalPnl);
var hodlPercentage = TradingHelpers.GetHodlPercentage(candles[0], candles.Last()); var hodlPercentage = TradingHelpers.GetHodlPercentage(candles[0], candles.Last());
var fees = bot.GetTotalFees(); var fees = bot.GetTotalFees();

View File

@@ -1313,7 +1313,7 @@ public class TradingBot : Bot, ITradingBot
public decimal GetProfitAndLoss() public decimal GetProfitAndLoss()
{ {
var pnl = Positions.Where(p => p.ProfitAndLoss != null).Sum(p => p.ProfitAndLoss.Realized); var pnl = Positions.Where(p => p.ProfitAndLoss != null && p.IsFinished()).Sum(p => p.ProfitAndLoss.Realized);
return pnl - GetTotalFees(); return pnl - GetTotalFees();
} }