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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user