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.
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 tradezero_python-0.1.0.tar.gz.
File metadata
- Download URL: tradezero_python-0.1.0.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14991c6a7674e66e848899289aaa2ee1d9c7a7788336e2722586f10c18975953
|
|
| MD5 |
d84d4f592c3ef36a211e63df68ff4517
|
|
| BLAKE2b-256 |
4f73b9f2f3559e6d620822dc2874eead36394e6786ff63bdc94221bd45ef7c77
|
Provenance
The following attestation bundles were made for tradezero_python-0.1.0.tar.gz:
Publisher:
ci.yml on ssuntoso/tradezero-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tradezero_python-0.1.0.tar.gz -
Subject digest:
14991c6a7674e66e848899289aaa2ee1d9c7a7788336e2722586f10c18975953 - Sigstore transparency entry: 2380706640
- Sigstore integration time:
-
Permalink:
ssuntoso/tradezero-python@d72d10cb4d92604513e9e07332d1b759ebba6c8a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ssuntoso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@d72d10cb4d92604513e9e07332d1b759ebba6c8a -
Trigger Event:
push
-
Statement type:
File details
Details for the file tradezero_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tradezero_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64bd9d98abdb29d91cb31c27e93fef21957880578b73b2de8289965251dcd4a4
|
|
| MD5 |
745d10fbae4005700a303fd87d7450c7
|
|
| BLAKE2b-256 |
5c38f31a40521fcb5538eaa4dcd523e1a14c40da6d7615c2b90573b3575e0793
|
Provenance
The following attestation bundles were made for tradezero_python-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on ssuntoso/tradezero-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tradezero_python-0.1.0-py3-none-any.whl -
Subject digest:
64bd9d98abdb29d91cb31c27e93fef21957880578b73b2de8289965251dcd4a4 - Sigstore transparency entry: 2380707355
- Sigstore integration time:
-
Permalink:
ssuntoso/tradezero-python@d72d10cb4d92604513e9e07332d1b759ebba6c8a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ssuntoso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@d72d10cb4d92604513e9e07332d1b759ebba6c8a -
Trigger Event:
push
-
Statement type: