Skip to main content

TradeZero Python SDK

PyPI Python License: MIT

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/:
    • ShortLocateWorkflow automates 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

tradezero_python-0.1.0.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

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

tradezero_python-0.1.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

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

Hashes for tradezero_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 14991c6a7674e66e848899289aaa2ee1d9c7a7788336e2722586f10c18975953
MD5 d84d4f592c3ef36a211e63df68ff4517
BLAKE2b-256 4f73b9f2f3559e6d620822dc2874eead36394e6786ff63bdc94221bd45ef7c77

See more details on using hashes here.

Provenance

The following attestation bundles were made for tradezero_python-0.1.0.tar.gz:

Publisher: ci.yml on ssuntoso/tradezero-python

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

File details

Details for the file tradezero_python-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tradezero_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64bd9d98abdb29d91cb31c27e93fef21957880578b73b2de8289965251dcd4a4
MD5 745d10fbae4005700a303fd87d7450c7
BLAKE2b-256 5c38f31a40521fcb5538eaa4dcd523e1a14c40da6d7615c2b90573b3575e0793

See more details on using hashes here.

Provenance

The following attestation bundles were made for tradezero_python-0.1.0-py3-none-any.whl:

Publisher: ci.yml on ssuntoso/tradezero-python

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 Sentry Error logging StatusPage Status page