TypeScript SDK · Schema · PyPI · MCP server
Broker SDK is a LuxAlgo open-source project. Official repository: github.com/LuxAlgo/broker-py
Connect Python to real brokerage and exchange accounts. The same normalized schema, the same 22 brokers, and the same golden conformance vectors as the TypeScript SDK, so the two SDKs are provably identical in behavior. Point it at Charles Schwab, Alpaca, Robinhood Crypto, Binance, Kraken, Interactive Brokers and more. Get back the same clean picture from every one of them: accounts, balances, positions, trade history, and computed performance stats.
It runs where your code runs: no hosted service, no telemetry, and zero dependencies (the standard library is the whole toolbox).
pip install luxalgo-broker-sdk
Your portfolio in five lines
from broker_sdk import connect
kraken = connect("kraken", {"apiKey": api_key, "apiSecret": api_secret})
snapshot = kraken.fetch_snapshot()
print(snapshot.accounts) # normalized: equity, positions, trades
Every broker returns the same shape. Learn it once:
@dataclass
class Account:
id: str # broker-side stable id, safe as an upsert key
name: str
currency: str # ISO 4217
equity: float # total account value
cash: float | None # when the broker reports it separately
environment: str | None # "live" or "paper"
positions: list[Position] # symbol, quantity (negative = short), market_value, ...
trades: list[Trade] # symbol, side, quantity, price, fee, executed_at
Account.to_dict() emits the canonical camelCase JSON shape shared with the TypeScript SDK, omitting unset fields. A missing value is more honest than a guessed one.
Your whole portfolio, every broker at once
from broker_sdk import create_portfolio
from broker_sdk.stats import compute_stats, stats_accounts
portfolio = create_portfolio()
portfolio.add("alpaca", {"apiKey": key, "apiSecret": secret})
portfolio.add("binance", {"apiKey": key2, "apiSecret": secret2})
portfolio.add("hyperliquid", {"walletAddress": address})
result = portfolio.fetch_all()
stats = compute_stats(stats_accounts(result.snapshots))
print(stats.total_equity, stats.trades.win_rate, stats.top_positions)
One broker failing never takes down the sweep: result.failures comes back alongside the snapshots that succeeded. The stats engine does FIFO round-trip matching, win rate, average win and loss, and per-symbol activity. A sell with no recorded buy is ignored, never guessed at.
Import any broker statement
No API? Any account at any institution is importable from a trade-history CSV. The parser is tolerant on headers (brokers disagree on column names) and strict on rows (anything unreadable is skipped and counted, never guessed):
from broker_sdk.statement_csv import parse_statement_csv, positions_from_trades
parsed = parse_statement_csv(csv_text)
print(len(parsed.trades), "trades,", parsed.skipped_rows, "rows skipped")
print(positions_from_trades(parsed.trades)) # net open positions
Supported brokers
The same 22 as the TypeScript SDK: Alpaca, Binance, Bybit, Charles Schwab, Coinbase, Crypto.com Exchange, E*TRADE, Gemini, Hyperliquid, Interactive Brokers (Flex), Kraken, KuCoin, OKX, Public.com, Questrade, Robinhood Crypto, tastytrade, Topstep (ProjectX), TradeStation, Tradier, Trading212, Webull (OpenAPI), plus any broker via CSV import. The full credentials table lives in the broker-sdk README.
list_brokers() returns every adapter with its exact credential fields and a one-line guide to creating the key with read-only scope, which is all this SDK ever needs.
Sanctioned APIs only. If a broker does not officially support programmatic access for its users, it is not in this repo: no scraping, no reverse-engineered private APIs, ever. OAuth brokers where you register your own free developer app (Charles Schwab, TradeStation, E*TRADE, Coinbase) are supported bring-your-own-app style.
Read-only, local-only, by design
- Your keys stay yours. The SDK runs where your code runs. There is no LuxAlgo server in the path, no telemetry, no phoning home.
- Read-only. The Python SDK reads accounts, balances, positions, and history. It has no order placement at all (the TypeScript SDK's experimental write layer has no Python counterpart yet).
- Credential rotation is first-class. Brokers with single-use tokens (Questrade) hand the rotated credentials back through
on_credentials_rotatedso you can persist them before the old ones die. - Fail-soft, never fabricate. A position the broker can't price has no
market_valuerather than a made-up one. A history row that can't be read is skipped and counted, not guessed.
The conformance kit
The vectors in conformance/vectors/ are copied verbatim from the TypeScript SDK: one per adapter, pairing a raw provider payload with the exact normalized output. Every adapter splits into an IO-only fetch_raw and a pure normalize, and CI asserts normalize reproduces every vector byte-for-byte. That is what "the same SDK in two languages" means here: not a similar API, the same proven mapping.
Runtime
Python 3.10+. Zero runtime dependencies (urllib for HTTP, hmac/hashlib for request signing, and a pure-Python RFC 8032 Ed25519 signer for Robinhood Crypto). Fully typed (py.typed). Synchronous API; Portfolio.fetch_all() sweeps connections concurrently with a thread pool. Bring your own persistence: to_dict() makes every snapshot plain JSON.
The suite
| Package | What it is |
|---|---|
@luxalgo/broker-sdk |
The TypeScript SDK and reference implementation |
luxalgo-broker-sdk (this repo) |
The Python SDK, gated by the same conformance vectors |
@luxalgo/mcp |
The LuxAlgo MCP server; its local broker_* tools give AI agents read-only portfolio access |
Contributing
New adapters land in the TypeScript SDK first (that repo owns the schema and the vectors), then port here against the same vector. See CONTRIBUTING.md. Sign your commits with git commit -s.
Disclaimer
This software reports what your broker reports. It is not investment advice, and nothing in it recommends any trade. Use at your own risk; verify important numbers against your broker's own statements.
License
MIT © LuxAlgo Global, LLC. The "Broker SDK" and "LuxAlgo" names and the LuxAlgo logo are trademarks of LuxAlgo Global, LLC; see TRADEMARKS.md. Security reports: SECURITY.md.
Metadata
Release files for luxalgo-broker-sdk 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| luxalgo_broker_sdk-0.2.0.tar.gz | 74.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| luxalgo_broker_sdk-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 154.7 kB
Release files / luxalgo_broker_sdk-0.2.0.tar.gz
| Download URL | luxalgo_broker_sdk-0.2.0.tar.gz |
|---|---|
| Size | 74.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72040481b6a25ac88ee0cf63e692eaa1a7283756d9457cb77ce0c3768be493ea
|
|
BLAKE2b-256 checksum How to use checksums |
cffcec8769331518615c8c04997da50d63a9454d914821f859e61d31ea7cd8e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Release files / luxalgo_broker_sdk-0.2.0-py3-none-any.whl
| Download URL | luxalgo_broker_sdk-0.2.0-py3-none-any.whl |
|---|---|
| Size | 79.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf0c4cb6188994ecb21313e74ddfd29d36b951d8db94fbd20103cfc7d6b832e0
|
|
BLAKE2b-256 checksum How to use checksums |
e145070c1b5c338fb1cd5162721661db8ad49064a330e00d4dd76b8879ec8693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Security for luxalgo-broker-sdk 0.2.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.