Fix agent volume
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user