Python bindings for the yuzu backtest engine and the lemon strategy DSL.
Project description
yuzu — Python bindings
Python bindings for the citrusinvest
backtest engine: the yuzu backtest core plus the lemon strategy DSL,
compiled from Rust. The engine boundary is pure data —
(strategy, panels, config) → report — so the bindings are thin and fast.
import yuzu
report = yuzu.run_backtest(
"close > sma(close, 20)", # lemon source (or a JSON Expr dict/string)
panels={
"close": df_close, # DataFrame (dates × symbols), or a
# {"dates": [...], "symbols": [...], "data": [[...]]} dict
},
config={"fee_ratio": 0.001, "benchmark_key": "spy"},
)
report["equity"] # NAV curve, base 1.0
report["metrics"]["sharpe"] # headline metrics
report["monthly_returns"] # calendar tables, trades, bootstrap bands, ...
The report is the same JSON contract the engine's WASM and server boundaries
emit — see docs/backtest-engine.md in the repository for the full schema and
the BacktestConfig knobs (fees, slippage, square-root market impact,
liquidity cap, delisting handling, benchmark comparison, bootstrap bands).
DSL tooling is included:
yuzu.parse("close > sma(close, 20)") # -> Expr tree as a dict
yuzu.format(tree) # -> canonical lemon source
yuzu.lint("clsoe > 1", ["close", "pe"]) # -> [{"line": 1, "col": 1, "message": "unknown series `clsoe` — did you mean `close`?"}]
Panels
A panel is a dense dates × symbols matrix of floats (None/NaN = missing):
- DataFrame (pandas/polars duck-type): index = dates (
intYYYYMMDD, strings, or anything withstrftime), columns = symbols. - dict:
{"dates": [20240102, ...], "symbols": ["AAPL", ...], "data": [[...], ...]}.
Series names are the engine's (close, high, low, volume, pe, …); a
volume panel is required for the liquidity cap / market-impact features, and
high/low enable per-trade MAE/MFE.
Install
pip install yuzu-backtest # from PyPI (distribution name), imports as `yuzu`
Build from source
pip install maturin
pip install ./crates/yuzu-py # or: maturin develop -m crates/yuzu-py/Cargo.toml
Wheels are abi3 (Python ≥ 3.9). License: MIT.
Versioning: major.minor mirrors the engine workspace version (a
0.2.x wheel is built from the 0.2 engine series); the patch segment is
the bindings' own, so binding-only fixes can ship without an engine release.
Each wheel is a snapshot of the whole repository at its release tag.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yuzu_backtest-0.2.0.tar.gz.
File metadata
- Download URL: yuzu_backtest-0.2.0.tar.gz
- Upload date:
- Size: 101.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0452a7dc27cb7723bdd3ce752652293a0203e3d28d86e64e9ca2ac52f605822f
|
|
| MD5 |
96ac02731bb6e1111d5382d1908c754a
|
|
| BLAKE2b-256 |
d81030eeafd30070fed20fedf2c69b0f50fcffd81fa6e5571b953fa964003a0b
|
Provenance
The following attestation bundles were made for yuzu_backtest-0.2.0.tar.gz:
Publisher:
release-python.yml on imgarylai/citrusinvest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yuzu_backtest-0.2.0.tar.gz -
Subject digest:
0452a7dc27cb7723bdd3ce752652293a0203e3d28d86e64e9ca2ac52f605822f - Sigstore transparency entry: 2132078146
- Sigstore integration time:
-
Permalink:
imgarylai/citrusinvest@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Branch / Tag:
refs/tags/yuzu-py-v0.2.0 - Owner: https://github.com/imgarylai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Trigger Event:
push
-
Statement type:
File details
Details for the file yuzu_backtest-0.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: yuzu_backtest-0.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 593.6 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
773155529ec9e795cc702c63399335ed2c819dee9648bdc8b5160440a9075bf9
|
|
| MD5 |
f1beac3418ba380959fca4fc89aa0973
|
|
| BLAKE2b-256 |
48f0637f4bc50d9cb07a59e6f4023118fafd92e23e3a948d680d89773359ad09
|
Provenance
The following attestation bundles were made for yuzu_backtest-0.2.0-cp39-abi3-win_amd64.whl:
Publisher:
release-python.yml on imgarylai/citrusinvest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yuzu_backtest-0.2.0-cp39-abi3-win_amd64.whl -
Subject digest:
773155529ec9e795cc702c63399335ed2c819dee9648bdc8b5160440a9075bf9 - Sigstore transparency entry: 2132078853
- Sigstore integration time:
-
Permalink:
imgarylai/citrusinvest@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Branch / Tag:
refs/tags/yuzu-py-v0.2.0 - Owner: https://github.com/imgarylai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Trigger Event:
push
-
Statement type:
File details
Details for the file yuzu_backtest-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: yuzu_backtest-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 703.8 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
590fcb5a3af2e788a62c821f014b57287d56c6732048d9aa335f96f6f8868bad
|
|
| MD5 |
f0bae22e62e3756cb2857356428cbde2
|
|
| BLAKE2b-256 |
e73ce6ce8ac4c480c7ffec0166a23df09ddff50934ea8c8b57dae4b408f3568c
|
Provenance
The following attestation bundles were made for yuzu_backtest-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-python.yml on imgarylai/citrusinvest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yuzu_backtest-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
590fcb5a3af2e788a62c821f014b57287d56c6732048d9aa335f96f6f8868bad - Sigstore transparency entry: 2132078273
- Sigstore integration time:
-
Permalink:
imgarylai/citrusinvest@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Branch / Tag:
refs/tags/yuzu-py-v0.2.0 - Owner: https://github.com/imgarylai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Trigger Event:
push
-
Statement type:
File details
Details for the file yuzu_backtest-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: yuzu_backtest-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 674.4 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad7f70ff894e542a2140fcceb0a07c89469054675231e5c44bef58f6e3656407
|
|
| MD5 |
27c11e55b8808cd5442a995dc0c42a15
|
|
| BLAKE2b-256 |
8fcd777fa1cbcef2aea19418a5391c387288d96b35dd4aaa0cdc02a641f1bd4a
|
Provenance
The following attestation bundles were made for yuzu_backtest-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release-python.yml on imgarylai/citrusinvest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yuzu_backtest-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
ad7f70ff894e542a2140fcceb0a07c89469054675231e5c44bef58f6e3656407 - Sigstore transparency entry: 2132078642
- Sigstore integration time:
-
Permalink:
imgarylai/citrusinvest@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Branch / Tag:
refs/tags/yuzu-py-v0.2.0 - Owner: https://github.com/imgarylai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Trigger Event:
push
-
Statement type:
File details
Details for the file yuzu_backtest-0.2.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: yuzu_backtest-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 620.9 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aca2d9ec9e48bf24ce516cf12f3f3722f44a165ade27638200b7e334771bf9c
|
|
| MD5 |
fde4025b60329ce390eee8ffcb43e138
|
|
| BLAKE2b-256 |
90004e1c57a27a554d05c78206e9d10e658b4e63e25870c97ca3164483a953f4
|
Provenance
The following attestation bundles were made for yuzu_backtest-0.2.0-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release-python.yml on imgarylai/citrusinvest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yuzu_backtest-0.2.0-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
7aca2d9ec9e48bf24ce516cf12f3f3722f44a165ade27638200b7e334771bf9c - Sigstore transparency entry: 2132079126
- Sigstore integration time:
-
Permalink:
imgarylai/citrusinvest@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Branch / Tag:
refs/tags/yuzu-py-v0.2.0 - Owner: https://github.com/imgarylai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Trigger Event:
push
-
Statement type:
File details
Details for the file yuzu_backtest-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: yuzu_backtest-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 658.8 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11780643c22256e66fd853794acb6673134a476c353f7fbfd82f6e145ed136ea
|
|
| MD5 |
6af4f5fa633fff9893c3b41f1e7cb947
|
|
| BLAKE2b-256 |
afb2e19d7ec9539c77ceb585cfee4a94ce9bb9b2802f4015cbfca4104925b7dd
|
Provenance
The following attestation bundles were made for yuzu_backtest-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release-python.yml on imgarylai/citrusinvest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yuzu_backtest-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
11780643c22256e66fd853794acb6673134a476c353f7fbfd82f6e145ed136ea - Sigstore transparency entry: 2132078455
- Sigstore integration time:
-
Permalink:
imgarylai/citrusinvest@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Branch / Tag:
refs/tags/yuzu-py-v0.2.0 - Owner: https://github.com/imgarylai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@1973937f7ec4cec156db0fca4c5098af9d79ee16 -
Trigger Event:
push
-
Statement type: