Fix agent volume

This commit is contained in:
2025-10-08 19:57:19 +07:00
parent 1a99224d18
commit b2a4e1ca5d
3 changed files with 16 additions and 6 deletions

View File

@@ -99,10 +99,17 @@ function AgentSearch({ index }: { index: number }) {
? agentData.strategies.reduce((sum, strategy) => sum + (strategy.winRate || 0), 0) / agentData.strategies.length
: 0
// Calculate total collateral from all positions (quantity * price)
const totalCollateral = agentData.positions.reduce((sum, position) => {
const collateral = (position.Open?.quantity || 0) * (position.Open?.price || 0)
return sum + collateral
}, 0)
return {
totalPnL,
totalNetPnL,
totalVolume,
totalCollateral,
totalWins,
totalLosses,
avgWinRate,
@@ -460,7 +467,7 @@ function AgentSearch({ index }: { index: number }) {
<div className="stat-title text-xs">ROI</div>
<div className="stat-value text-lg">
<span className={summary.totalNetPnL >= 0 ? 'text-green-500' : 'text-red-500'}>
{((summary.totalNetPnL / (summary.totalVolume || 1)) * 100).toFixed(2)}%
{((summary.totalNetPnL / (summary.totalCollateral || 1)) * 100).toFixed(2)}%
</span>
</div>
<div className="stat-desc text-xs">Return on Investment</div>