quant
Evolve, test and optimise trading strategies.
The engine behind the Quant Workbench extension, usable on its own from the command line. Everything it reports is JSON on stdout, with diagnostics on stderr, so it composes with whatever you already run.
Install
pip install sophostechne-quant
The distribution is sophostechne-quant; the import package and the command are both quant.
It pulls in NautilusTrader and pandas, so
the install is not small.
The idea
A backtest that reports only a return is a sales pitch. Three questions have to be answered
together, and evaluate always answers all three — there is no flag to omit the awkward two:
- Did it make money? Net return, drawdown, profit factor, win rate, time in drawdown.
- Was the drawdown real? A Monte Carlo resample of the strategy's own trades, so the observed drawdown can be placed in the distribution of drawdowns it could have had.
- Was any of it better than chance? A noise floor of random strategies on the same bars. A strategy that does not beat its noise floor did not find an edge, whatever it returned.
Use
quant evaluate --strategy my.strategy --product BTC-USD --timeframe 6h --bars 2000
Searching emits NDJSON — one object per generation, then a done object carrying the
survivors. Every survivor is scored twice: on the bars it was fitted to, and on a held-out tail
the search never saw. The gap between the two is the entire result.
quant evolve --population 250 --generations 20 --survivors 5 --holdout 0.3
Walk-forward tests the method rather than any one strategy. The whole search re-runs in every training window and its winner is applied, untouched, to the window after.
quant walkforward --train-bars 1200 --test-bars 400
Costs are charged on every path: --fee (default 0.001) and --slippage (default 0.0005).
--seed makes a run reproducible, and --regimes conditions the search on market regime.
Output
One JSON object per line, always with an ok field on terminal results. Failures are reported
as JSON too, so a caller parsing the stream never has to strip a traceback out of it:
{"ok": false, "type": "error", "error": "FileNotFoundError: my.strategy"}
Development
uv sync
uv run pytest
License
MIT
Metadata
Release files for sophostechne-quant 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sophostechne_quant-1.0.0.tar.gz | 63.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sophostechne_quant-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 105.9 kB
Release files / sophostechne_quant-1.0.0.tar.gz
| Download URL | sophostechne_quant-1.0.0.tar.gz |
|---|---|
| Size | 63.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a161971f1c995c3a8b1f5cb93a54c6b170927b2c76cc0c1e517bdd50baabb346
|
|
BLAKE2b-256 checksum How to use checksums |
0c15ce3c4d67e515013c09a793238e25c9450a146858f33a1c34da152fb19be9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / sophostechne_quant-1.0.0-py3-none-any.whl
| Download URL | sophostechne_quant-1.0.0-py3-none-any.whl |
|---|---|
| Size | 42.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
57dc12450521c2a95cad9327a78e8348e517f9897b4f077271eca249c6114fbb
|
|
BLAKE2b-256 checksum How to use checksums |
bd41ece19cae8b1e6942676f6f949c534738e7dbe3e8e840cd0a7c9c5294fe6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|