Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:HKUDS AI Trader Analyze CD5

From Leeroopedia


Knowledge Sources
Domains Financial_Analysis, Cryptocurrency, Benchmarking
Last Updated 2026-02-09 14:00 GMT

Overview

Python script that computes performance metrics for the CD5 cryptocurrency index benchmark, aligned with agent simulation dates for fair comparison.

Description

The analyze_cd5.py script reads the pre-computed CD5 (Crypto Diversified 5) index data and calculates standard portfolio performance metrics: cumulative return, annualized return, Sharpe ratio, maximum drawdown, volatility, and win rate. It uses the same result_tools functions as the agent evaluation pipeline to ensure metric consistency. The CD5 index is a market-cap-weighted basket of 5 cryptocurrencies (BTC 74.56%, ETH 15.97%, XRP 5.20%, SOL 3.53%, ADA 0.76%). Results are saved to timestamped JSON files and a fixed CD5_for_comparison.json for use in agent comparison reports.

Usage

Run this script after generating the CD5 index data via synthesize_crypto_index_daily.py. It produces benchmark metrics files used by the performance visualization and comparison workflows.

Code Reference

Source Location

Signature

# Script-level execution (no class)
# Key operations:
# 1. Load CD5_crypto_index.json
# 2. Filter dates to align with agent simulation start (2025-11-02)
# 3. Compute metrics via tools.result_tools functions:
#    - calculate_daily_returns(portfolio_values)
#    - calculate_sharpe_ratio(daily_returns, trading_days=365)
#    - calculate_max_drawdown(portfolio_values)
#    - calculate_cumulative_return(portfolio_values)
#    - calculate_volatility(daily_returns, trading_days=365)
#    - calculate_win_rate(daily_returns)
# 4. Save results to CD5_metrics_{timestamp}.json and CD5_for_comparison.json

Import

# Run as script:
# cd data/crypto && python analyze_cd5.py

I/O Contract

Inputs

Name Type Required Description
CD5_crypto_index.json JSON file Yes Pre-computed CD5 index daily price data
tools.result_tools Python module Yes Shared metrics calculation functions

Outputs

Name Type Description
CD5_metrics_{timestamp}.json JSON file Full metrics with composition details
CD5_latest_metrics.json JSON file Latest metrics (overwritten each run)
CD5_for_comparison.json JSON file Simplified metrics for agent comparison reports
stdout text Formatted metrics summary

Usage Examples

# Run the CD5 analysis
cd data/crypto
python analyze_cd5.py

# Output example:
# === CD5指数数据分析 (与Agent时间对齐) ===
# 数据日期范围: 2025-11-02 到 2025-11-16
# 累计收益率: 5.23%
# 夏普比率: 2.1234
# 最大回撤: -3.45%

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment