From 096fb500e428f2130b23d48a18b1aa521d0850d4 Mon Sep 17 00:00:00 2001 From: cryptooda Date: Wed, 19 Nov 2025 14:16:30 +0700 Subject: [PATCH] Add position count property map --- src/Managing.Api/appsettings.Production.json | 2 +- .../Backtests/BacktestExecutor.cs | 1 - .../Bots/Grains/BacktestTradingBotGrain.cs | 1 - src/Managing.Domain/Backtests/Backtest.cs | 2 -- .../PostgreSql/PostgreSqlMappers.cs | 11 +++++++---- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Managing.Api/appsettings.Production.json b/src/Managing.Api/appsettings.Production.json index 1d16a1a5..503c898e 100644 --- a/src/Managing.Api/appsettings.Production.json +++ b/src/Managing.Api/appsettings.Production.json @@ -24,7 +24,7 @@ } }, "Kaigen": { - "BaseUrl": "https://srv-captain--kaigen-back:3000" + "BaseUrl": "http://srv-captain--kaigen-back:3000" }, "N8n": { "WebhookUrl": "https://n8n.kai.managing.live/webhook/fa9308b6-983b-42ec-b085-71599d655951", diff --git a/src/Managing.Application/Backtests/BacktestExecutor.cs b/src/Managing.Application/Backtests/BacktestExecutor.cs index b83ce94e..34e92a24 100644 --- a/src/Managing.Application/Backtests/BacktestExecutor.cs +++ b/src/Managing.Application/Backtests/BacktestExecutor.cs @@ -399,7 +399,6 @@ public class BacktestExecutor GrowthPercentage = growthPercentage, HodlPercentage = hodlPercentage, Fees = fees, - WalletBalances = tradingBot.WalletBalances.ToList(), Statistics = stats, Score = scoringResult.Score, ScoreMessage = scoringResult.GenerateSummaryMessage(), diff --git a/src/Managing.Application/Bots/Grains/BacktestTradingBotGrain.cs b/src/Managing.Application/Bots/Grains/BacktestTradingBotGrain.cs index 4efacf74..1de74ca4 100644 --- a/src/Managing.Application/Bots/Grains/BacktestTradingBotGrain.cs +++ b/src/Managing.Application/Bots/Grains/BacktestTradingBotGrain.cs @@ -171,7 +171,6 @@ public class BacktestTradingBotGrain : Grain, IBacktestTradingBotGrain GrowthPercentage = growthPercentage, HodlPercentage = hodlPercentage, Fees = fees, - WalletBalances = tradingBot.WalletBalances.ToList(), Statistics = stats, Score = scoringResult.Score, ScoreMessage = scoringResult.GenerateSummaryMessage(), diff --git a/src/Managing.Domain/Backtests/Backtest.cs b/src/Managing.Domain/Backtests/Backtest.cs index 80fdc53c..1a04d1a1 100644 --- a/src/Managing.Domain/Backtests/Backtest.cs +++ b/src/Managing.Domain/Backtests/Backtest.cs @@ -18,7 +18,6 @@ public class Backtest Config = config; Positions = positions; Signals = signals; - WalletBalances = new List>(); } [Required] public string Id { get; set; } @@ -33,7 +32,6 @@ public class Backtest [Required] public DateTime EndDate { get; set; } [Required] public PerformanceMetrics Statistics { get; set; } [Required] public decimal Fees { get; set; } - [Required] public List> WalletBalances { get; set; } [Required] public User User { get; set; } [Required] public double Score { get; set; } public Guid RequestId { get; set; } diff --git a/src/Managing.Infrastructure.Database/PostgreSql/PostgreSqlMappers.cs b/src/Managing.Infrastructure.Database/PostgreSql/PostgreSqlMappers.cs index 7d519223..5e765f6c 100644 --- a/src/Managing.Infrastructure.Database/PostgreSql/PostgreSqlMappers.cs +++ b/src/Managing.Infrastructure.Database/PostgreSql/PostgreSqlMappers.cs @@ -320,7 +320,8 @@ public static class PostgreSqlMappers RequestId = entity.RequestId, Metadata = entity.Metadata, InitialBalance = entity.InitialBalance, - NetPnl = entity.NetPnl + NetPnl = entity.NetPnl, + PositionCount = entity.PositionCount }; return backtest; @@ -362,7 +363,8 @@ public static class PostgreSqlMappers CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow, InitialBalance = backtest.InitialBalance, - NetPnl = backtest.NetPnl + NetPnl = backtest.NetPnl, + PositionCount = backtest.Positions.Count }; } @@ -618,7 +620,7 @@ public static class PostgreSqlMappers // Set ProfitAndLoss with proper type position.ProfitAndLoss = new ProfitAndLoss { Realized = entity.ProfitAndLoss, Net = entity.NetPnL }; - + // Set fee properties position.UiFees = entity.UiFees; position.GasFees = entity.GasFees; @@ -658,7 +660,8 @@ public static class PostgreSqlMappers MoneyManagementJson = position.MoneyManagement != null ? JsonConvert.SerializeObject(position.MoneyManagement) : null, - NetPnL = position.ProfitAndLoss?.Net ?? (position.ProfitAndLoss?.Realized - position.UiFees - position.GasFees ?? 0) + NetPnL = position.ProfitAndLoss?.Net ?? + (position.ProfitAndLoss?.Realized - position.UiFees - position.GasFees ?? 0) }; }