quantframe
quantframe is a lightweight Python backtesting framework extracted from the
deribit-arb backtest engine.
It provides:
backtest(weights, prices, config)for DataFrame-based target weights.run_strategy(strategy, prices, config)for event-style strategies, with optional metadata for explicit symbol lifetimes.- TWAP and VWAP execution models.
- gross PnL, fee PnL, optional funding PnL, and common performance metrics.
BacktestResult.plot()for quick result inspection.
Install
uv sync
Yahoo Finance downloads are optional:
pip install quantframe-lib[yfinance]
Run Tests
uv run pytest
Minimal Usage
import pandas as pd
from quantframe.backtest import BacktestConfig, backtest
prices = pd.DataFrame(
{
"timestamp": pd.date_range("2024-01-01", periods=3, freq="1min", tz="UTC"),
"symbol": ["ETH-PERPETUAL"] * 3,
"close": [100.0, 101.0, 102.0],
}
)
weights = pd.DataFrame(
{
"timestamp": [pd.Timestamp("2024-01-01", tz="UTC")],
"symbol": ["ETH-PERPETUAL"],
"weight": [1.0],
}
)
result = backtest(weights, prices, BacktestConfig(exec_horizon=1))
print(result.metrics)
Use compound cumulative returns and CAGR-style APR when needed:
result = backtest(
weights,
prices,
BacktestConfig(exec_horizon=1, return_mode="compound"),
)
Loading Bar Data
from quantframe.data.yfinance import YahooFinanceProvider
from quantframe.data import prices
bars = YahooFinanceProvider().load_bars(
["BTC-USD", "GC=F"],
start="2016-01-01",
end="2026-04-30",
interval="1d",
)
aligned = prices.merge(bars, symbols=["BTC-USD", "GC=F"], how="inner")
Custom providers can subclass DataProvider and implement fetch_bars().
Returned bars are validated and normalized before use.
Use prices.merge(..., how="outer") when you want to keep the union of trading
calendars and handle missing market bars yourself.
Release files for quantframe-lib 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| quantframe_lib-0.1.9.tar.gz | 21.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quantframe_lib-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.8 kB
Release files / quantframe_lib-0.1.9.tar.gz
| Download URL | quantframe_lib-0.1.9.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea8a5ab88ea6e85a250cdf3f7b0846865a10295e545744a04b5688f7cc8cd278
|
|
BLAKE2b-256 checksum How to use checksums |
53f7372fa0af2b873a31d4d65e6a4be8e1d39fb58108d7949a23a54eceb8b5fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / quantframe_lib-0.1.9-py3-none-any.whl
| Download URL | quantframe_lib-0.1.9-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8efafb2bd5648e63acc0fba0c174da79978cd6345ed6475de420006fb1d9a158
|
|
BLAKE2b-256 checksum How to use checksums |
5daec51a31f2428d47afc06284924852ba540145e6bfe51cb1adef4d30eaf4ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|