A local-first stock strategy editor, experiment lab, and backtesting workbench powered by Futu OpenD.
简体中文 · Architecture · Futu compatibility
Strategy Lab connects directly to a local OpenD instance, runs Python stock strategies in isolated backtest processes, and binds each new run to immutable strategy and market-data snapshots. It does not access trading accounts or place live orders.
| Capability | Description | |
|---|---|---|
| 📈 | Backtest | Run stock strategies against OpenD OHLCV data with costs, slippage, drawdown, and trade-level results. |
| 🧪 | Experiment | Compare parameter grids on a shared market-data cache and rank candidates by return, Sharpe, or drawdown. |
| ✍️ | Build strategies | Create, edit, validate, save, and reuse Python strategies from the browser. |
| 🔌 | Use OpenD directly | Search US/HK stocks, resolve names, and request paginated historical K-lines without a web-data fallback. |
| 🧾 | Reproduce evidence | Keep the request, strategy revision, runtime manifest, market-data hash, JSON, CSV, and SVG evidence with each run. |
Requirements: Python 3.11+, Node.js 22+, npm 11+, and OpenD listening on 127.0.0.1:11111.
git clone https://github.com/hengistchan/stock-strategy.git
cd stock-strategy
make install
make doctor
make serveOpen http://127.0.0.1:8000/backtests.
The server binds to loopback by default. A remote bind requires both
--allow-remote and a 32+ character STRATEGY_LAB_API_TOKEN; read
SECURITY.md before enabling it.
The workbench also provides stable routes for /experiments and /strategies. To run the deterministic sample without OpenD:
.venv/bin/python -m stock_strategy \
--strategy examples/ma_cross.py \
--samplefrontend/ React + TypeScript workbench
backend/stock_strategy/ FastAPI, OpenD adapter, and backtest engine
examples/ Read-only strategy examples
strategies/ User-editable strategies
docs/ Architecture, compatibility, and acceptance notes
make test
make acceptance
cd frontend && npx playwright install chromium && npm run test:e2eOpenD integration never silently falls back to simulated or third-party web data. Backtest semantics and supported Futu stock APIs are documented in FUTU_COMPATIBILITY.md.
Issues and pull requests are welcome. Read CONTRIBUTING.md, follow the Code of Conduct, and report vulnerabilities privately through SECURITY.md.
Strategy Lab is a research tool, not investment advice. The Web service is local-only by default, and strategy files should be treated as trusted executable Python code.
