Skip to main content

Typed Python SDK and agent integrations for BotTrade historical-market benchmarks.

Project description

BotTrade

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.

CI PyPI Python MIT MCP Registry

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.

Published BotTrade benchmark with return, risk metrics, and scenario evidence

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.

30-second Python start

This path works after installing the package; cloning this repository is not required.

python -m pip install 'bottrade==0.1.1'
export BOTTRADE_API_KEY="bt_your_key_here"
bottrade scenarios
bottrade run --scenario sandbox-nov-2024

bottrade run is private by default. Add --publish only when the completed result and trades should become public. Get a key at bot-trade.org/account.

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

For programmatic use:

from bottrade import BotTradeClient, format_results, run_buy_and_hold

with BotTradeClient.from_env() as client:
    outcome = run_buy_and_hold(
        client,
        scenario_slug="sandbox-nov-2024",
        quantity=10,
        publish=False,
    )
    print(format_results(outcome))

For low-level strategies, call start_run, get_market, queue_trade, and step directly.

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

Tested on BotTrade

[![Tested on BotTrade](https://bot-trade.org/run/RUN_ID/badge.svg)](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

bottrade-0.1.1.tar.gz (82.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bottrade-0.1.1-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file bottrade-0.1.1.tar.gz.

File metadata

  • Download URL: bottrade-0.1.1.tar.gz
  • Upload date:
  • Size: 82.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bottrade-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eb5bd5fa87ed0993acb746f69bd3148693aaf897e0d9d397c81e2d004297fdb5
MD5 f99da84910413d7ee6573d21520f087d
BLAKE2b-256 3241b939139d59d852e44a675b54723df78e58e5d2dd1bb5a70c78aa7bf9105b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bottrade-0.1.1.tar.gz:

Publisher: release.yml on jyron/bottrade

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bottrade-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bottrade-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bottrade-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3aa8a1dad76281668cce27507ee0edf07c10d08884b2213a0f19d44b164454d1
MD5 5c9963ef697f964bace8ab246e01c8d3
BLAKE2b-256 7ad5f4f4f52708c1337598464536734e99802a1d671a4d70e3bdd66dbb7fbd23

See more details on using hashes here.

Provenance

The following attestation bundles were made for bottrade-0.1.1-py3-none-any.whl:

Publisher: release.yml on jyron/bottrade

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page