bt_api_py
bt_api_py is a Python façade for exchange plugins, direct Feed calls, and an optional ZeroMQ forwarding boundary. It is a library and integration framework—not a declaration that every registered plugin or venue is ready for live trading.
Release-blocking CI targets Python 3.11–3.13. Python 3.14 is canary-only.
Install and diagnose
python -m pip install bt_api_py
python -m bt_api_py.doctor --bundle core-reference --format json
The doctor command verifies installed package metadata and reports plugins as installed, disabled, or unavailable. It does not authenticate to an exchange or place orders.
Typed order example
from decimal import Decimal
from bt_api_py import BtApi, OrderRequest, OrderType, Side
api = BtApi(exchange_kwargs={"BINANCE___SPOT": {"testnet": True}})
ack_or_venue_result = api.make_order(
"BINANCE___SPOT",
OrderRequest(
symbol="BTCUSDT",
side=Side.BUY,
order_type=OrderType.LIMIT,
quantity=Decimal("0.001"),
price=Decimal("50000"),
account_id="paper",
client_order_id="example-order-1",
),
)
OrderRequest is the cross-transport contract. The historical positional form remains only as a compatibility layer and must include a side-qualified type such as "buy-limit"; a bare "limit" or "market" cannot safely infer side.
Normalized results and durable execution
The existing BtApi methods accept normalized=True for standard account,
instrument, position and order results. poll_event(exchange_name) returns
standard market, order and trade dictionaries; quantities retain the venue's
native units. Position intent uses position_side, offset, position_mode
and quantity_unit on OrderRequest, including CTP dated closes and native
order references. Unsupported venue capabilities fail explicitly.
Enable a durable execution session with the optional constructor argument:
api = BtApi(
exchange_kwargs=exchange_config, # Supply your configured accounts.
debug=False,
execution_config={
"order_journal": "local-orders.jsonl",
"account_currency": "USDT",
"order_poll_interval": 0.2,
},
)
BtApi remains the only public trading client. Its internal session owns the
exclusive journal lock, intent persistence, client ID uniqueness, uncertain
execution reconciliation and cumulative fill/fee state. Call
new_client_order_id(exchange_name) before binding a local order reference,
submit a typed request with normalized=True, then keep polling poll_event
even when no market bar arrives. A timeout never triggers a replacement order.
An unresolved historical intent blocks new placements until the original order
is reconciled. Reuse the same journal across restarts and call close() when done.
With a session enabled, legacy/raw writes, asynchronous writes and bulk
cancellation are explicitly rejected where they cannot honor its journal
contract. Omitting execution_config preserves the historical API behavior.
get_execution_summary() reports the session's unresolved orders and fees;
get_all_balances(normalized=True) preserves individual account currencies,
and get_portfolio_balance() rejects mixed or nonzero unknown currencies.
The session does not contain Backtrader orders, feeds or strategy accounting.
Direct and forwarding reads
Direct mode preserves the native Feed result shape. In ZMQ mode, typed reads use Consistency:
from bt_api_py import Consistency
# With a configured forwarding service and an active market subscription:
snapshot = api.get_tick("SIM___SPOT", "BTC-USDT", consistency=Consistency.CACHE_OK)
LIVE waits for a post-call event within the configured timeout. CACHE_OK only returns a bounded, explicitly stale snapshot; cache misses and timeouts use different domain errors. ZMQ public trades are not part of the current forwarding protocol and fail explicitly instead of falling back to a local Feed.
Support status
Support status
The entries below are evidence tiers, not a count of production-ready exchanges.
| Scope | Tier | Evidence boundary | Current limitation |
|---|---|---|---|
| core-reference bundle | experimental |
Bundle metadata for BINANCE___SPOT, OKX___SPOT and CTP___FUTURE; not a live-trading or installed-plugin certification. | Current isolated submodule diagnostic has no initialized plugin worktrees, so package install/import/test certification is pending. |
| other registered plugins | unverified |
Registry or submodule presence only. | Do not infer REST, WebSocket, paper-trading, or production readiness from registration alone. |
Blocking CI supports Python 3.11, 3.12, 3.13; Python 3.14 is canary-only.
See docs/operations/support-status-policy.md for the evidence and expiry rules.
Contributing and verification
- Installation
- Runtime architecture
- BtApi reference
- Support-status policy
- Submodule validation profiles
Use a clean checkout and retain JSON/JUnit/log artifacts when validating exchange plugins. A registry entry, source directory, or historical test number is not release evidence.
Metadata
Release files for bt-api-py 0.15.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bt_api_py-0.15.3.tar.gz | 790.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bt_api_py-0.15.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.6 MB
Release files / bt_api_py-0.15.3.tar.gz
| Download URL | bt_api_py-0.15.3.tar.gz |
|---|---|
| Size | 790.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5839ded73386f44ad097d88843b3c6f16de85a1a5817d54eadc55d0a24a393d8
|
|
BLAKE2b-256 checksum How to use checksums |
462e535aac9f042bfd4a79b639a0706c0b38a45a4944a79490a1bdda8632b0a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logRelease files / bt_api_py-0.15.3-py3-none-any.whl
| Download URL | bt_api_py-0.15.3-py3-none-any.whl |
|---|---|
| Size | 821.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efb1b9a07c3d38fc4e77805b62d1abaa944b1fb48a73b6ed49641e06cfb27bc3
|
|
BLAKE2b-256 checksum How to use checksums |
49376b2dd12afadb9ca169723125fa673d07518649aba746eee1ea3e43db0620
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency log