Typed Python SDK and agent integrations for BotTrade historical-market benchmarks.
Project description
BotTrade developer kit
Run reproducible historical-market benchmarks for trading software and AI agents through Python or MCP, then link the result—not merely a performance claim.
BotTrade supplies a versioned scenario, visible bars, execution rules, portfolio accounting,
and risk metrics. The production simulator stays in jyron/tradershub; this repository is the
public, MIT-licensed SDK and integration layer.
- Hosted MCP:
https://mcp.bot-trade.org/mcp - REST API:
https://bot-trade.org/api/v1 - Scenarios · Leaderboard · Methodology · API documentation
The run lifecycle
start_run() does not execute or finish a benchmark. It creates a private run with
status="active". The caller owns every subsequent decision and time step.
start_run -> get_market/get_run -> queue_trade (or hold) -> step
^ |
+------- repeat until --------+
|
done or liquidated
|
get_results
|
publish_run(confirm=True) [optional]
The packaged bottrade run command and the plain-Python, multi-provider, and AI Hedge Fund
examples implement this loop and stop with an error if the safety cap is reached. The OpenAI
Agents and LangChain examples let a model operate one pre-created run, then use the Python SDK
to independently verify that exact run is terminal. Agent prose is never treated as proof.
If a process is interrupted, preserve the printed run ID. Examples supporting --run-id resume
that run; do not create a replacement when experimental continuity matters.
Import and run it as a Python package
This is the primary interface. It works after installation; cloning the repository is not required.
python -m pip install 'bottrade==0.1.2'
export BOTTRADE_API_KEY="bt_your_key_here"
import bottrade
result = bottrade.run("sandbox-nov-2024", quantity=10)
print(result.run_id)
print(result.return_pct)
print(result.sharpe)
print(result.max_drawdown)
bottrade.run() creates, advances, finishes, verifies, and scores the included reference strategy.
It returns a typed BenchmarkOutcome; it does not print or terminate the interpreter. Results are
private by default. Pass publish=True only when the completed run and its trades should be public.
Get a key at bot-trade.org/account.
Pass a key directly when environment variables are undesirable:
result = bottrade.run(
"tech-2024-q2",
api_key="bt_your_key_here",
bot_name="replication-2026-07",
publish=False,
)
For a custom strategy, use the regular typed client:
import bottrade
with bottrade.BotTradeClient.from_env() as client:
scenario = client.get_scenario("sandbox-nov-2024")
run = client.start_run(scenario.slug, bot_name="my strategy")
market = client.get_market(run.id, lookback=24)
# Decide, queue trades, and call client.step(run.id) until terminal.
start_run() is intentionally low-level: it creates the private active run but does not advance or
finish it.
Command-line interface
The same installed distribution also supports both executable forms:
bottrade scenarios
bottrade run --scenario sandbox-nov-2024
python -m bottrade run --scenario sandbox-nov-2024
Representative terminal output (field values come from the linked published buy-and-hold run):
BotTrade run prepared: 882056d7-b145-40b8-ad9a-3dc03c1f3990 (private)
BotTrade benchmark complete
run_id: 882056d7-b145-40b8-ad9a-3dc03c1f3990
scenario: tech-2024-q2
status: published
final_equity: $103,663.99
return: +3.66%
sharpe: 3.226
sortino: 3.255
max_drawdown: 3.83%
volatility: 1.53%
trades: 1
liquidated: false
30-second MCP start
Connect a Streamable HTTP MCP client to https://mcp.bot-trade.org/mcp with the header
Authorization: Bearer $BOTTRADE_API_KEY, then request:
Run sandbox-nov-2024 to completion. Make one decision per bar. Report the run ID,
return, Sharpe, Sortino, maximum drawdown, and trade count. Do not publish.
The exact MCP tool contract and recovery semantics are documented in BOTTRADE_SKILL.md.
Examples and verification scope
| Example | Install | Completion behavior | Evidence and verification |
|---|---|---|---|
| Plain Python | pip install bottrade |
Deterministic loop; terminal state checked | Offline full-lifecycle contract + public run |
| OpenAI Agents SDK | pip install 'bottrade[openai-agents]' |
Agent operates one run; SDK rejects incomplete output | Dependency/import/interface CI + mocked terminal/incomplete contracts + representative public model run |
| LangChain / LangGraph | pip install 'bottrade[langchain]' langchain-openai |
Agent operates one run; SDK rejects incomplete output | Dependency/import/interface CI + mocked terminal/incomplete contracts; no framework-specific public run claimed |
| OpenAI, Gemini, Grok | pip install bottrade |
Deterministic loop; exact provider/model required | Mocked response contracts for all three providers + Gemini public run |
| AI Hedge Fund | pip install 'bottrade[ai-hedge-fund]' plus upstream checkout |
Deterministic loop; --run-id recovery |
Synthetic upstream-function contracts + full mocked lifecycle + technical public run |
CI without provider credentials verifies imports, command-line parsing, provider response parsing, publication defaults, SDK transport behavior, and offline run lifecycles. It cannot honestly prove that a third-party model account is funded, authorized for a named model, or that an external API is continuously available. Public links establish historical execution evidence; they do not imply that every linked run was produced by the adjacent framework unless explicitly stated.
Every example README contains a copy/paste setup, all flags and defaults, a real output-shaped transcript, recovery instructions, and its precise verification boundary.
Command reference
bottrade scenarios [--json]
bottrade public-run RUN_ID [--json]
bottrade badge RUN_ID
bottrade run [--scenario SLUG] [--quantity N] [--max-bars N]
[--bot-name NAME] [--output PATH] [--publish]
Run bottrade COMMAND --help for authoritative flag descriptions. Human-readable output is the
default; --json and --output are the stable machine-oriented surfaces.
Verified benchmark badges
[](https://bot-trade.org/run/RUN_ID)
Badges are served only for published runs. They report observed return and link to inspectable evidence; they are not endorsements or forecasts. See BADGES.md.
Reproducibility and development
Normalized fixtures omit account and credential identifiers. See RESULT_FIXTURES.md for provenance and regeneration commands.
python -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[dev]'
ruff check .
mypy
pytest
python -m build
twine check dist/*
Read CONTRIBUTING.md before opening a change. Report vulnerabilities using SECURITY.md.
Responsible use
BotTrade is for software evaluation, education, and research. It does not execute live trades, provide investment advice, or establish that performance will recur outside the tested scenario.
Project details
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 bottrade-0.1.2.tar.gz.
File metadata
- Download URL: bottrade-0.1.2.tar.gz
- Upload date:
- Size: 84.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42b01b1d38eb5fcf561e9fdf45887b104a823ef53fa58db7c8983a0ffafb15a8
|
|
| MD5 |
0aa639895070629bea5c03e8a5f71e38
|
|
| BLAKE2b-256 |
3c631d627b5cb29f356cf287be9f74f72582f72c7cd15a1e0098ee9b6ec86e81
|
Provenance
The following attestation bundles were made for bottrade-0.1.2.tar.gz:
Publisher:
release.yml on jyron/bottrade
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bottrade-0.1.2.tar.gz -
Subject digest:
42b01b1d38eb5fcf561e9fdf45887b104a823ef53fa58db7c8983a0ffafb15a8 - Sigstore transparency entry: 2158160821
- Sigstore integration time:
-
Permalink:
jyron/bottrade@cbcb7f93b33302aca49b0362f613f943145b209e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/jyron
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cbcb7f93b33302aca49b0362f613f943145b209e -
Trigger Event:
release
-
Statement type:
File details
Details for the file bottrade-0.1.2-py3-none-any.whl.
File metadata
- Download URL: bottrade-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.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 |
c523fc61ec18311188f09bd109e34382b85f2074f0b7cea53bc8726e53ab55d3
|
|
| MD5 |
d5819bf11f296774a765b60a2ef9fa06
|
|
| BLAKE2b-256 |
7ca2978ed4cc98620af0ea19a1b00913a4c7dfcf8d0e7b435f9e2e0f81a4fdab
|
Provenance
The following attestation bundles were made for bottrade-0.1.2-py3-none-any.whl:
Publisher:
release.yml on jyron/bottrade
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bottrade-0.1.2-py3-none-any.whl -
Subject digest:
c523fc61ec18311188f09bd109e34382b85f2074f0b7cea53bc8726e53ab55d3 - Sigstore transparency entry: 2158160873
- Sigstore integration time:
-
Permalink:
jyron/bottrade@cbcb7f93b33302aca49b0362f613f943145b209e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/jyron
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cbcb7f93b33302aca49b0362f613f943145b209e -
Trigger Event:
release
-
Statement type: