TradeZero Python SDK
A Python client for the TradeZero Trading API. This SDK wraps the TradeZero REST endpoints with typed models, organized services, and a high-level short-locate workflow helper.
What it provides
TradeZeroClient— the main entry point for all API calls.- Service categories exposed via
TradeZeroClient:client.accounts— list accounts, account details, account PnL.client.cash— cash transaction history (paginated).client.positions— open and closed positions.client.orders— create/read/cancel orders, routes, easy-to-borrow checks, historical paging.client.locates— quote/accept/cancel/sell locates, inventory, history.
- Typed models split by category under
tradezero/models/. - Extension helpers under
tradezero.ext/:ShortLocateWorkflowautomates the async ETB check → quote → poll → accept → inventory workflow for short selling.
Installation
Install from PyPI:
python -m pip install tradezero-python
Or install the latest development version directly from GitHub:
python -m pip install git+https://github.com/ssuntoso/tradezero-python.git
If you are working from a local checkout, install in editable mode:
git clone https://github.com/ssuntoso/tradezero-python.git
cd tradezero-python
python -m pip install -e .
Configuration
Set the required environment variables:
export TZ_API_KEY_ID="your-api-key-id"
export TZ_API_SECRET_KEY="your-api-secret-key"
Optional values:
export TZ_ACCOUNT="your-account-id"
export TZ_BASE_URL="https://webapi.tradezero.com"
export TZ_TIMEOUT="30"
You can also create a .env file in the working directory; the bundled examples load it automatically via python-dotenv.
Quick start
from tradezero import TradeZeroClient
client = TradeZeroClient.from_env()
accounts = client.accounts.list_accounts()
print(accounts)
account_id = accounts[0].account
details = client.accounts.get_account(account_id)
print(details)
See the examples/ directory and docs/USAGE.md for more detailed usage, including the short-locate workflow.
Examples
Run the bundled examples after setting your environment variables:
python examples/account_services_example.py
python examples/short_locate_example.py
Testing
Run the unit tests with the standard library test runner:
python -m unittest discover -s test -p "test_*.py"
Or with pytest:
python -m pytest
Documentation
- Usage guide — detailed examples for accounts, orders, positions, cash, locates, and the short-locate workflow.
- API reference — browse the source code for service and model definitions.
Development
Install the package with development and test dependencies:
python -m pip install -e ".[dev,test]"
Build the distribution artifacts:
python -m build
This produces dist/tradezero_python-*.whl and dist/tradezero_python-*.tar.gz.
Publishing
See docs/PUBLISHING.md for step-by-step instructions on uploading a new release to PyPI and publishing a GitHub release.
License
This project is licensed under the MIT License.
Metadata
Release files for tradezero-python 0.1.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 | |
|---|---|---|---|
| tradezero_python-0.1.0.tar.gz | 21.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tradezero_python-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.7 kB
Release files / tradezero_python-0.1.0.tar.gz
| Download URL | tradezero_python-0.1.0.tar.gz |
|---|---|
| Size | 21.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14991c6a7674e66e848899289aaa2ee1d9c7a7788336e2722586f10c18975953
|
|
BLAKE2b-256 checksum How to use checksums |
4f73b9f2f3559e6d620822dc2874eead36394e6786ff63bdc94221bd45ef7c77
|
| 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 Aug 8, 2026.
Transparency logRelease files / tradezero_python-0.1.0-py3-none-any.whl
| Download URL | tradezero_python-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64bd9d98abdb29d91cb31c27e93fef21957880578b73b2de8289965251dcd4a4
|
|
BLAKE2b-256 checksum How to use checksums |
5c38f31a40521fcb5538eaa4dcd523e1a14c40da6d7615c2b90573b3575e0793
|
| 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 Aug 8, 2026.
Transparency log