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)
print(result.stats["Sharpe"])
result.equity.plot(title="Equity curve")
Install
pip install --pre backtest360-client # while on alpha
Requires Python 3.9+. The only runtime dependencies are httpx and pandas.
Get an API key
Sign up at backtest360.com/dashboard 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— set only what you need - Pandas-native — pass a DataFrame, get a DataFrame back (
result.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
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="trailing_atr", value=2.5, atr_period=14, max_drawdown=0.25),
sizing=Sizing(weight=1.0, vol_target=0.15, leverage_limit=2.0),
)
print(result.stats["Sharpe"], 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
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/dashboard")
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
Contributing / issues
Bug reports and feature requests welcome — open an issue on GitHub or email developers@backtest360.com.
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.1.1.tar.gz.
File metadata
- Download URL: backtest360_client-0.1.1.tar.gz
- Upload date:
- Size: 28.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a69a217f3f58dc9c65a278151261b6efc2deccdb006598cd6f1fd262b448585c
|
|
| MD5 |
3a126feea49422bcbd51633af85c3bf1
|
|
| BLAKE2b-256 |
0a4d73181e59168e6fcd708f47ca89f7c79d3286b74c07368c27ec4f03ee2225
|
File details
Details for the file backtest360_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: backtest360_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fba4ab10a88ef193f529bd6fce84f427b3b674b031427905ed82ba73b1f620f9
|
|
| MD5 |
94cdeddcfe6e3ccac74320c42bb88d46
|
|
| BLAKE2b-256 |
1bd7fea549f13a47934ee5bfe254752d30882c2fa0a4a40bdb5386083e035422
|