Skip to main content

stx-python

The official Python SDK for the STX exchange.

pip install stx-python

Python 3.9 or newer.

Quickstart

You need an API key for the STX exchange you are building against. Environments lists the exchanges and where to get a key, and Authentication shows how to give it to the SDK.

from stx import STX

# Reads your API key and exchange from STX_* environment variables or ~/.stx/credentials.
with STX() as client:
    # status "open": markets that have opened for trading (not scheduled, closed or settled).
    # trading=True: only markets accepting orders right now (an open market can be paused).
    # limit: markets per page. Looping over page gives this page; client.iter_markets() walks every page.
    page = client.markets(status="open", trading=True, limit=5)

    for market in page:
        # bids are what buyers will pay, offers what sellers will accept. Both lists run from the
        # highest price to the lowest: the best bid is bids[0], the best offer is offers[-1].
        # Prices are dollars per contract, as strings; a winning contract pays market.max_price.
        bid = market.bids[0].price if market.bids else "-"  # "-" when nobody is bidding
        offer = market.offers[-1].price if market.offers else "-"
        print(f"{market.event_title}: {market.title}  bid {bid}  offer {offer}")

Sample output:

Edmonton Oilers at San Jose Sharks: NHL EDM @ SJ  bid 0.5800  offer 0.5900
Edmonton Oilers at San Jose Sharks: C. McDavid 3.5 SOG  bid 0.4900  offer 0.5300

A bid of 0.5800 on a market whose winning contract pays 1.0000 means a buyer will pay 58 cents for a contract that pays $1 if the Oilers win.

One market from the response (selected fields)
{
  "market_id": "e00651a3-10cb-4bc1-9e1f-c5ea1796c83b",
  "symbol": "STXNHL-26OCT101600EDMSJ-GAMEEDM",
  "event_title": "Edmonton Oilers at San Jose Sharks",
  "title": "NHL EDM @ SJ",
  "question": "Will the Edmonton Oilers defeat the San Jose Sharks?",
  "status": "open",
  "trading": true,
  "event_start": "2026-10-10T20:00:00.000000Z",
  "max_price": "1.0000",
  "last_traded_price": "0.5800",
  "bids": [
    { "price": "0.5800", "quantity": "210.00" },
    { "price": "0.5700", "quantity": "420.00" },
    { "price": "0.5600", "quantity": "1200.00" }
  ],
  "offers": [
    { "price": "0.6100", "quantity": "900.00" },
    { "price": "0.6000", "quantity": "650.00" },
    { "price": "0.5900", "quantity": "310.00" }
  ]
}

Every market is a stx.models.Market; market.model_dump() gives you the dict. Every field is described in the API reference.

For asyncio, AsyncSTX has the same methods to await, and client.websocket() streams the order book, trades and your own orders, fills and balance.

place_order(..., fill_mode="post_only") places a limit order that only rests on the book, and fill_mode="fill_or_kill" one that fills in full or not at all. Where the exchange has a fill mode switched off, it rejects the order and the call raises STXNotAvailableError. See Trading.

Building an app that STX members connect to? stx.oauth connects members and acts for them, mints app tokens for market data, and creates markets: see Apps. client.capabilities() says what the exchange you are on offers.

Documentation

MIT license. Use of the STX API and exchange is subject to the STX terms of use and privacy policy: United States (terms of use, privacy policy), Ontario (terms of use, privacy policy).

Metadata

Release files for stx-python 0.10.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stx-python 0.10.1
File Size Uploaded Provenance Actions
stx_python-0.10.1.tar.gz 116.9 kB Without provenance Details for stx_python-0.10.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stx-python 0.10.1
File Interpreter ABI Platform Actions
stx_python-0.10.1-py3-none-any.whl Python 3 none any Details for stx_python-0.10.1-py3-none-any.whl

Total release size: 238.1 kB

Release files / stx_python-0.10.1.tar.gz

Download URL stx_python-0.10.1.tar.gz
Size 116.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2e665463bcf5119ef71616422b09d33da5106b5c7594647d3d1fb07c54a3d7ed
BLAKE2b-256 checksum
How to use checksums
8ecfc660d70b6fdb402ce52ac427e6ec32c080a3521a23b2016a3b67f38b2fce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / stx_python-0.10.1-py3-none-any.whl

Download URL stx_python-0.10.1-py3-none-any.whl
Size 121.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3f49181e7e9ffe31e3efa678000a32622d9ac11570f4361babdf4f7e99647d9
BLAKE2b-256 checksum
How to use checksums
8d24f81a40843e16f1887b7703d21ea6ccf29e953dcea4bb5b5528668f06de92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for stx-python 0.10.1

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.

Release history Release notifications | RSS feed

This release

0.10.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page