This repository is now focused on active portfolio management research: local market data workflows, alpha signal experiments, benchmark-relative portfolio construction, and repeatable backtests.
The project started as a fork of TradingAgents. The original TradingAgents code is kept as a pinned git submodule at vendor/TradingAgents for reference and future upstream comparison. The active portfolio runtime lives in the activeportfolio Python package.
activeportfolio/alpha/: alpha signal classes, signal registry, and profile helpers.activeportfolio/portfolio/: risk model, optimizer, rebalancer, discretionary portfolio helpers, and attribution.activeportfolio/backtest/: local parquet data loader, accounting, metrics, and backtest engine.activeportfolio/dataflows/: market data download, local storage, vendor routing, and classification helpers.activeportfolio/regime/: rule-based regime model for optional alpha/profile routing.activeportfolio/core/: local technical indicator support.research/: repeatable research scripts and experiment utilities.tools/: command-line utilities for data refreshes, backtests, audits, and demos.notebooks/: viewers for research and backtest outputs.docs/: runbooks, guides, and implementation plans.vendor/TradingAgents/: upstream TradingAgents submodule.
Use the existing project environment when working in this checkout:
conda run -n activepm python -m pip install -r requirements.txt
conda run -n activepm python -m pip install -e .For a fresh environment:
conda env create -f environment.yml
conda activate activepmRun a configured backtest:
conda run -n activepm python tools/run_backtest.py \
--config-json research/configs/backtest_csi300_baseline_relaxed.jsonRun a matched A/B backtest pair:
conda run -n activepm python tools/run_ab_backtest_pair.py \
--baseline-config research/configs/signal_daily_laggard_band_default.json \
--candidate-config research/configs/signal_trailing_1y_worst50.jsonRefresh the current CSI300 universe:
conda run -n activepm python tools/csi300_symbols.pyDownload five years of CSI300 A-share history:
conda run -n activepm python tools/download_market_data.py \
--vendor ashare \
--symbols-file data/universe/csi300/current/csi300_symbols.txt \
--years 5 \
--continue-on-errorIf technical indicators should use local parquet history instead of online yfinance, set:
config["tool_vendors"]["get_indicators"] = "mytt"
config["data_root"] = "data/market"See docs/guides/csi300-ashare-data-guide.md for the full A-share workflow and output layout.
Start with docs/README.md.
Useful guides:
- Backtest config workflow
- Alpha signal registry guide
- CSI300 A-share data guide
- Active portfolio plan
Run the full test suite:
conda run -n activepm python -m pytest -qRun the portfolio/backtest subset:
conda run -n activepm python -m pytest -q tests/test_portfolio_pipeline.py tests/test_backtest_engine.pyThe original TradingAgents project remains available as a submodule:
git -C vendor/TradingAgents statusKeep active portfolio code in activeportfolio/. Use the submodule for reference, comparison, or deliberate upstream sync work.