Skip to content

About

Local-first Futu OpenD strategy editor, experiment lab, and stock backtesting workbench.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Strategy Lab

A local-first stock strategy editor, experiment lab, and backtesting workbench powered by Futu OpenD.

简体中文 · Architecture · Futu compatibility

CI License: MIT Python React

Strategy Lab backtesting workbench

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.

What you can do

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.

Quick start

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 serve

Open 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 \
  --sample

Project layout

frontend/                  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

Development

make test
make acceptance
cd frontend && npx playwright install chromium && npm run test:e2e

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

Contributing

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.

License

MIT

About

Local-first Futu OpenD strategy editor, experiment lab, and stock backtesting workbench.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages