The Problem
Quantitative‑trading teams need a reproducible stack that ties together market data, RL environments, model definitions, and deployment scripts. Most open‑source kits stop at a single algorithm; they lack a unified way to switch between high‑frequency, portfolio‑management, and market‑dynamics use cases while keeping training, evaluation, and serving consistent.
What This Does
TradeMaster bundles eight related projects (e.g., FinAgent, EarnMore, EarnHFT) under a common folder layout. Core RL components live in trademaster/ – environments (trademaster/environments/*), agents (trademaster/agents/*), networks (trademaster/nets/*), and trainers (trademaster/trainers/*). Configuration files in configs/_base_/ describe every combination of dataset, model, optimizer, and trainer, so a new experiment is a matter of selecting a YAML‑style Python config. The tools/finagent/ CLI (main.py) is the primary entry point for end‑to‑end runs: it parses a config, builds the environment, constructs the agent, and kicks off training or inference.
How It Is Wired
Execution starts at tools/finagent/main.py (line 62 main). main parses command‑line arguments, then calls run (line 149) which:
- Calls
init_path→ creates the output directory (os.makedirs). - Calls
build_environment(viatrademaster/environments/builder.py) – the most‑referenced builder (25 inbound imports). - Calls
build_from_cfg(intrademaster/utils/utils.py) to instantiate the selected agent, net, and trainer from the config. - Enters the training loop (
run_step→run_mdmfor market‑dynamics labeling, etc.).
Key blast‑radius modules:
| Module | Inbound (Ca) | Outbound (Ce) | Instability |
|---|---|---|---|
trademaster/utils/__init__.py | 70 | 7 | 0.09 |
finagent/registry.py | 29 | 0 | 0 |
pm/registry.py | 28 | 0 | 0 |
These hubs host utility functions (print, get_attr, build_from_cfg) that are invoked from 82 distinct call sites (e.g., print is the most‑used builtin). Changing a hub file can ripple through dozens of modules.
Four circular import groups were detected (e.g., finagent/provider/__init__.py ↔ finagent/query/__init__.py ↔ finagent/prompt/__init__.py). The cycle inflates import time and hampers refactoring; breaking it by extracting shared types into a new module would reduce coupling.
Filesystem interaction is limited to a few paths: os.makedirs for output folders, shutil.copy in plot_kline, and dataset CSV reads in pm/utils/replay_buffer.py. No external network calls are made from the core CLI.
How To Use It
# Clone the repo
git clone https://github.com/moses-y/TradeMaster
cd TradeMaster
# Install Python deps (pip, no lockfile)
pip install -r requirements.txt
pip install -e . # editable install registers entry points
# Optional: build the Docker image (base image: nvidia/cuda:11.3.0-cudnn8-devel-ubuntu20.04)
docker build -t trademaster .
# Run a training job (example config)
python tools/finagent/main.py \
--config configs/_base_/agents/algorithmic_trading/deepscalper.py \
--work-dir ./outputs/deepscalper
The --config argument points to a Python file under configs/_base_/ that selects dataset, model, optimizer, and trainer. Output artifacts (model checkpoints, logs) are written under the supplied --work-dir.
Real‑World Use
A quant team can plug their own market‑data CSV into data/high_frequency_trading/ and reference it via a custom config that inherits from configs/_base_/datasets/high_frequency_trading/BTC.py. Running the CLI trains a DQN agent (trademaster/nets/dqn.py) on the new data, logs performance to TensorBoard, and produces a Docker‑ready inference service (deploy/backend_service.py) that can be deployed behind a REST API.
Code Health & Issues
- High – CI missing – 450 source files, no
.github/workflows(affects every change). - High – Docker build gate missing – Dockerfile present but never validated automatically.
- Medium – Dependabot not configured – 4 requirement files, no automated updates.
- Medium – Base image not pinned –
nvidia/cuda:11.3.0-cudnn8-devel-ubuntu20.04mutable; use digest. - Medium – Notebook outputs –
trademaster/evaluation/market_dynamics_labeling/example.ipynbstores >7 MB of output. - Medium – Large data blobs – CSVs in
data/high_frequency_trading/...exceed 5 MB; should move to Git LFS or external storage. - Medium – Test coverage – 11 test files for ~450 source files (ratio 0.024); expand, starting with the high‑fan‑in modules listed above.
No license or secret issues were found; a LICENSE file is present.
The Bottom Line
TradeMaster delivers a cohesive, config‑driven RL pipeline for multiple trading paradigms, with clear entry points and reusable utilities. Its main weaknesses are the lack of automated CI/CD, a mutable Docker base, and limited test coverage, which together raise the risk of regression when the hub modules are modified. Teams comfortable managing their own CI pipelines and willing to refactor the identified import cycles can extract substantial value from the platform.