Performance Metrics
The Trading System evaluates strategy effectiveness using a suite of quantitative performance metrics. These indicators are calculated during backtesting and are accessible via the Dashboard API or the visual interface to help users assess risk-adjusted returns and strategy robustness.
Core Performance Indicators
The system tracks the following key metrics for every backtest and live trading session:
1. Total Return (%)
The absolute percentage change in portfolio value from the start of the session to the end.
- Formula:
((Final Value - Initial Capital) / Initial Capital) * 100
2. Sharpe Ratio
Measures the risk-adjusted return of the strategy. It indicates how much excess return you receive for the extra volatility of holding a risky asset.
- Interpretation: A higher Sharpe ratio (typically > 1.0) suggests better risk-adjusted performance.
3. Max Drawdown (%)
The largest peak-to-trough decline in the portfolio's equity curve. This represents the "worst-case scenario" loss a user would have experienced during the period.
- Interpretation: Lower percentages indicate better capital preservation.
4. Win Rate
The percentage of closed trades that resulted in a positive return.
- Formula:
(Profitable Trades / Total Trades) * 100
5. Profit Factor
The ratio of gross profits to gross losses.
- Formula:
Sum of Gains / Abs(Sum of Losses) - Interpretation: A value above 1.0 indicates a profitable strategy.
6. Alpha vs. Hold
The excess return generated by the strategy compared to a simple "Buy and Hold" strategy of the underlying asset (e.g., BTC).
- Interpretation: Positive Alpha indicates the Multi-Agent system is outperforming a passive investment.
Data Interface
Metrics are served via the FastAPI backend and consumed by the React dashboard. If you are extending the system or querying the API directly, use the following schema.
Metrics Schema (MetricsResponse)
The MetricsResponse object provides a snapshot of the current or historical performance.
{
"total_return_pct": 15.5,
"sharpe_ratio": 1.85,
"max_drawdown_pct": -4.2,
"win_rate": 65.0,
"total_trades": 12,
"profit_factor": 2.1,
"alpha_vs_hold": 5.3
}
Backtest Detail Object
When retrieving a specific backtest via /api/backtests/{id}, the system returns comprehensive performance data integrated with the equity curve:
class BacktestDetail(BaseModel):
id: int
initial_capital: float
final_value: float
total_return_pct: float
sharpe_ratio: Optional[float]
max_drawdown_pct: Optional[float]
win_rate: Optional[float]
profit_factor: Optional[float]
buy_hold_return_pct: Optional[float]
alpha_vs_hold: Optional[float]
equity_curve: List[EquityPoint]
trades: List[TradeResponse]
Viewing Metrics
Via Dashboard
The Metrics Panel at the top of the dashboard provides a high-level summary. Cards are color-coded based on performance (e.g., green for positive Alpha, red for negative returns).
- Open the Dashboard (default:
http://localhost:5173). - Select a Backtest from the dropdown menu.
- The Metrics Panel will automatically update to reflect that specific run.
Via CLI
To quickly view trade-by-trade performance and P/L (Profit/Loss) for the most recent backtest, run the view_trades.py utility:
python view_trades.py
This will output a log of every action, the execution price, and the individual percentage return for each closed position:
======================================================================
TRADE LOG
======================================================================
# 1 | 2024-01-10 | BUY @ $42,500
# 2 | 2024-01-15 | SELL @ $45,000 | P/L: +5.88%
# 3 | 2024-01-20 | BUY @ $41,200
======================================================================
Performance Logic
- Trade Execution: Metrics are calculated based on "Closed" trades. Open positions are marked-to-market using the most recent price data.
- Equity Curve: The system generates a timestamped list of portfolio values, allowing the dashboard to render the
EquityCurvecomponent for visual trend analysis.