Skip to content
DraftThis page is known to be incomplete. Treat its contents as provisional.

Examples Catalog

Every example below is a file in this repository that you can execute. The point of this page is that you should not have to trust a snippet: each entry names the file, the command that runs it, and what it demonstrates.

All of them need the Python bindings built first — see Python Bindings Setup. The Rust example needs only cargo.

FileRun it withDemonstrates
crates/openquant/examples/research_notebook_smoke.rscargo run -p openquant --example research_notebook_smokeThe minimum Rust path: CUSUM event sampling → max-Sharpe allocation → VaR/ES/CDaR. ~30 lines, asserts its own invariants.
notebooks/python/scripts/smoke_all.pyjust notebook-smokeExecutes all eight research notebooks headlessly. The broadest single check that the Python surface works.
experiments/run_pipeline.pyjust exp-runA config-driven pipeline run (experiments/configs/futures_oil_baseline.toml) that writes artifacts to experiments/artifacts.
python/benchmarks/benchmark_pipeline.pyjust py-benchTimes the mid-frequency pipeline over 30 iterations at 2048 bars.
python/benchmarks/benchmark_data_processing.pyjust py-bench-dataIngestion and bar-building throughput at 200k rows × 4 symbols. Use this if you want a real memory profile before feeding it production data.
python/tests/just py-testNine test modules that double as usage examples — test_pipeline_api.py and test_bindings_contract.py are the two worth reading first.

The eight notebooks under notebooks/python/ are numbered in reading order, from 01_event_labeling_and_pipeline.ipynb to 08_algo_wheel_experiments.ipynb, and 06_afml_real_data_end_to_end.ipynb is the one that runs on real data rather than synthetic.

Worked example: cleaning a messy OHLCV file

Section titled “Worked example: cleaning a messy OHLCV file”

The repository ships a deliberately awful CSV at python/tests/fixtures/ohlcv_us_equities.csv — non-canonical column names, two symbols interleaved, rows out of chronological order, and a duplicated 2024-01-02 bar for AAPL:

Date,Ticker,Open,High,Low,Close,Volume,Adj Close
2024-01-03,AAPL,186.10,187.00,185.50,186.30,5000,186.10
2024-01-01,AAPL,184.00,185.00,183.50,184.80,8000,184.70
2024-01-02,AAPL,185.00,186.20,184.70,185.90,7000,185.80
2024-01-02,AAPL,185.05,186.30,184.60,186.00,7100,185.90
2024-01-01,MSFT,370.10,372.00,369.90,371.50,6000,371.30
2024-01-03,MSFT,372.20,373.10,371.40,372.00,5500,371.90

load_ohlcv canonicalises the header (Datets, Tickersymbol, Adj Closeadj_close), sorts by symbol and timestamp, and drops the duplicate — keeping the last occurrence by default, which is the convention you want when a vendor restates a bar:

from openquant import data
frame, report = data.load_ohlcv(
"python/tests/fixtures/ohlcv_us_equities.csv",
return_report=True,
)
print(frame)
print(report)

Ask for the report whenever the data is not yours. Silent deduplication is how a survivorship or restatement bug gets into a backtest without anyone noticing.

The end-to-end loops are long enough to deserve their own pages, with the stages explained rather than just listed:

If you want to…Go here
See OpenQuant produce a number, onceQuickstart
Understand the Rust APIRust Core Workflow
Understand the Python APIPython Core Workflow
Look up one moduleModules by AFML chapter
Build and test the repoLocal Build Setup