Skip to content
 
 

Repository files navigation

Active Portfolio

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.

Repository Layout

  • 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.

Setup

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 activepm

Backtest Workflow

Run a configured backtest:

conda run -n activepm python tools/run_backtest.py \
  --config-json research/configs/backtest_csi300_baseline_relaxed.json

Run 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.json

Market Data Workflows

Refresh the current CSI300 universe:

conda run -n activepm python tools/csi300_symbols.py

Download 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-error

If 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.

Docs

Start with docs/README.md.

Useful guides:

Validation

Run the full test suite:

conda run -n activepm python -m pytest -q

Run the portfolio/backtest subset:

conda run -n activepm python -m pytest -q tests/test_portfolio_pipeline.py tests/test_backtest_engine.py

TradingAgents Reference

The original TradingAgents project remains available as a submodule:

git -C vendor/TradingAgents status

Keep active portfolio code in activeportfolio/. Use the submodule for reference, comparison, or deliberate upstream sync work.

About

TradingAgents: Multi-Agents LLM Financial Trading Framework

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages