Official Python client for the Backtest360 backtesting API
Project description
backtest360-client
Official Python client for the Backtest360 backtesting API.
Backtest your trading strategy from every angle, in minutes.
import yfinance as yf
from backtest360 import Client, Strategy
df = yf.download("BTC-USD", period="1y", interval="1d",
auto_adjust=False, multi_level_index=False, progress=False)
df.columns = df.columns.str.lower()
result = Client(api_key="b360_...").backtest(Strategy.rsi_threshold_long(), df)
result.summary()
result.strategy_equity.plot(title="Equity curve")
Install
pip install backtest360-client
Requires Python 3.9+. The only runtime dependencies are httpx and pandas.
Need to install Python first? (Windows / macOS / Linux / WSL)
Windows (native)
- Install Python from python.org/downloads (check "Add to PATH"), or via winget:
winget install Python.Python.3.12
- Open PowerShell and verify:
python --version
- Install the SDK and yfinance for the quickstart:
pip install backtest360-client yfinance
- Run a script:
python quickstart.py
Windows via WSL (recommended for quant work)
- Install WSL:
wsl --install
Restart, then open the Ubuntu terminal. - Install Python:
sudo apt update && sudo apt install python3 python3-pip -y
- Install the SDK:
pip3 install backtest360-client yfinance
- Run a script:
python3 quickstart.py
macOS
# via Homebrew (recommended)
brew install python
# or download from python.org/downloads
Then:
pip3 install backtest360-client yfinance
python3 quickstart.py
Linux
sudo apt install python3 python3-pip -y # Debian/Ubuntu
pip3 install backtest360-client yfinance
python3 quickstart.py
Get an API key
Sign up at backtest360.com/api and copy your key.
Store it in the BACKTEST360_API_KEY environment variable or pass it directly:
client = Client(api_key="b360_...")
# or: export BACKTEST360_API_KEY=b360_...
client = Client()
Features
- Hand-written wrapper over the public REST API — no generated code, no schema sync
- Built-in strategy templates (
Strategy.rsi_threshold_long(),Strategy.ma_crossover(), …) - Grouped-knob classes:
Execution,Costs,Risk,Sizing,MarketHours,Settings— set only what you need - Pre-computed signals path:
client.backtest_signals(series, df)for model-generated signals - Pandas-native — pass a DataFrame, get a DataFrame back (
result.strategy_equity,result.returns) - Raw-API escape hatch for full control (
client.backtest_raw({...})) - Strict type hints +
py.typed— first-class IDE and mypy support - MIT licensed
Common patterns
Custom strategy
from backtest360 import Client, Strategy, Execution, Costs, Risk, Sizing, Settings
strat = Strategy(
name="rsi_mean_reversion",
long_entry="rsi < 30",
long_exit="rsi > 70",
indicators=[Strategy.indicator("rsi", period=14)],
)
result = Client(api_key="b360_...").backtest(
strat, df,
benchmark=spy_df,
execution=Execution(entry="open", exit="close", signal_frequency="daily"),
costs=Costs(slippage_bps=2.5, fee_pct=0.001),
risk=Risk(stop="atr", value=2.5, atr_period=14, max_drawdown=0.25),
sizing=Sizing(weight=1.0, vol_target=0.15, leverage_limit=2.0),
settings=Settings(risk_free_rate=0.04),
)
result.summary()
print(result.stats["Max Drawdown"])
for t in result.trades[:5]:
print(t["entry_date"], t["direction"], t["return_net"])
Indicator library (names, params, output columns): https://api.backtest360.com/docs#tag/Reference/operation/list_indicators_api_indicators_get
Strategy templates (full list): https://api.backtest360.com/docs#tag/Reference/operation/list_strategies_api_strategies_get
Pre-computed signals
import pandas as pd
from backtest360 import Client
# Any signal series of {-1, 0, 1} — your ML model, custom indicator, etc.
signals = pd.Series(..., index=df.index)
result = Client(api_key="b360_...").backtest_signals(signals, df)
print(result.stats["Sharpe"])
Raw API escape hatch
For users who want exact control with the API docs open:
resp = Client(api_key="...").backtest_raw({
"strategy": {"condition_tree": {...}, "indicators": [...]},
"data_source": {"ohlcv": {...}},
"execution": {"signal_frequency": "daily"},
})
Error handling
from backtest360 import Backtest360Error
try:
result = client.backtest(strategy, df)
except Backtest360Error as e:
if e.status == 401:
print("Invalid or expired API key — renew at backtest360.com/api")
elif e.status == 429:
print("Rate limited — retry after a moment")
elif e.status == 422:
print("Strategy validation failed:", e.body)
else:
raise # unexpected — let it propagate
Versioning
MAJOR.MINOR.PATCH. Pre-1.0 (0.x.y): the API may move between minor versions.
Pre-release suffixes: aN (alpha), bN (beta), rcN (release candidate).
See CHANGELOG.md for the release history.
Full documentation
Full documentation → https://backtest360.github.io/backtest360-client/
Engine API reference → https://api.backtest360.com/docs
Questions / feedback
Questions or feedback? hello@backtest360.com — we read everything. The SDK is in active development, so help shape it.
Bug reports and feature requests: open an issue on GitHub.
License
MIT — see LICENSE.
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 Distribution
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 backtest360_client-0.3.0.tar.gz.
File metadata
- Download URL: backtest360_client-0.3.0.tar.gz
- Upload date:
- Size: 34.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
052826808eb3a2e136d7501b6e941ed06ef5eb64a1aaf024f585762cb46f531e
|
|
| MD5 |
d68f5731a09de9cf4efae479201cadf2
|
|
| BLAKE2b-256 |
ebea6e5a0d4bb0549db5ee0d2f4f8710e55b48ff341db063b538b18e069cb6b0
|
Provenance
The following attestation bundles were made for backtest360_client-0.3.0.tar.gz:
Publisher:
release.yml on Backtest360/backtest360-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
backtest360_client-0.3.0.tar.gz -
Subject digest:
052826808eb3a2e136d7501b6e941ed06ef5eb64a1aaf024f585762cb46f531e - Sigstore transparency entry: 1735695301
- Sigstore integration time:
-
Permalink:
Backtest360/backtest360-client@c17dc21e75688755b09efa7681afcaf428b38ecf -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Backtest360
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c17dc21e75688755b09efa7681afcaf428b38ecf -
Trigger Event:
push
-
Statement type:
File details
Details for the file backtest360_client-0.3.0-py3-none-any.whl.
File metadata
- Download URL: backtest360_client-0.3.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7290d9b45e1c7cd32a7f60a34b3aac7fb37aaa75cbea4452255f5a021ad0910
|
|
| MD5 |
266b3a52b4fd16ab0a7ffd729c4ba690
|
|
| BLAKE2b-256 |
c5577dd73fe7f2fceadb6a13d6e6182c1c04f931c54413d762edec825806ad79
|
Provenance
The following attestation bundles were made for backtest360_client-0.3.0-py3-none-any.whl:
Publisher:
release.yml on Backtest360/backtest360-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
backtest360_client-0.3.0-py3-none-any.whl -
Subject digest:
d7290d9b45e1c7cd32a7f60a34b3aac7fb37aaa75cbea4452255f5a021ad0910 - Sigstore transparency entry: 1735695310
- Sigstore integration time:
-
Permalink:
Backtest360/backtest360-client@c17dc21e75688755b09efa7681afcaf428b38ecf -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Backtest360
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c17dc21e75688755b09efa7681afcaf428b38ecf -
Trigger Event:
push
-
Statement type: