Update position value calculations in AgentGrain and BotService

- Changed the calculation of USDC value in AgentGrain to use net profit and loss instead of realized profit.
- Added similar position value calculations in BotService, including error handling for position retrieval failures.
This commit is contained in:
2025-11-20 20:34:12 +07:00
parent a6adf5e458
commit 4d4e5b6d25
2 changed files with 22 additions and 2 deletions

View File

@@ -214,8 +214,8 @@ public class AgentGrain : Grain, IAgentGrain
foreach (var position in positions.Where(p => p.IsOpen()))
{
var positionUsd = position.Open.Price * position.Open.Quantity;
var realized = position.ProfitAndLoss?.Realized ?? 0;
usdcInPositionsValue += positionUsd + realized;
var net = position.ProfitAndLoss?.Net ?? 0;
usdcInPositionsValue += positionUsd + net;
}
totalBalance = usdcWalletValue + usdcInPositionsValue;