Metadata-Version: 2.4
Name: stx-python
Version: 0.6.0rc2
Summary: Official Python SDK for the STX exchange
Author-email: STX <support@stxapp.io>
License-Expression: MIT
Project-URL: Homepage, https://docs.stxapp.io/sdks/python/
Project-URL: Documentation, https://docs.stxapp.io/sdks/python/
Project-URL: Changelog, https://docs.stxapp.io/changelog/
Project-URL: Support, https://docs.stxapp.io/support/
Keywords: stx,exchange,trading,prediction-market,sdk
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Office/Business :: Financial
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx<1,>=0.25
Requires-Dist: websockets>=12.0
Requires-Dist: pydantic<3,>=2.0
Requires-Dist: cryptography>=41.0
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: python-dotenv>=1.0; extra == "dev"
Requires-Dist: ruff==0.16.9; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=5.0; extra == "dev"
Requires-Dist: pre-commit>=3.5; extra == "dev"
Requires-Dist: griffe==2.3.0; python_version >= "3.10" and extra == "dev"
Dynamic: license-file

# stx-python

The official Python SDK for the [STX](https://stxapp.io) exchange.

```bash
pip install stx-python
```

Python 3.9 or newer.

## Quickstart

You need an API key for the STX exchange you are building against. [Environments](https://docs.stxapp.io/environments/) lists the exchanges and where to get a key, and [Authentication](https://docs.stxapp.io/sdks/python/authentication/) shows how to give it to the SDK.

```python
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, best price first.
        # 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[0].price if market.offers else "-"
        print(f"{market.event_title}: {market.title}  bid {bid}  offer {offer}")
```

Sample output:

```text
New York Yankees at San Diego Padres: Padres First Run  bid -  offer -
New York Yankees at San Diego Padres: Yankees First Run  bid 0.4200  offer -
Norfolk State Spartans at Old Dominion Monarchs: Old Dominion Score Last  bid -  offer -
Norfolk State Spartans at Old Dominion Monarchs: Norfolk St Score Last  bid -  offer -
Tampa Bay Rays at Philadelphia Phillies: MLB TB @ PHI  bid -  offer -
```

A bid of `0.4200` on a market whose winning contract pays `1.0000` means a buyer will pay 42 cents for a contract that pays $1 if the Yankees score first.

<details>
<summary>One market from the response (selected fields)</summary>

```json
{
  "market_id": "ddb216af-e752-422c-8688-52f95630b219",
  "symbol": "STXMLB-26SEP042140NYYSD-ESLAWAYFIRSTRUNNA",
  "event_title": "New York Yankees at San Diego Padres",
  "title": "Yankees First Run",
  "question": "Will New York Yankees score the first run of the game?",
  "status": "open",
  "trading": true,
  "event_start": "2026-09-05T01:40:00.000000Z",
  "max_price": "1.0000",
  "last_traded_price": null,
  "bids": [
    { "price": "0.4200", "quantity": "5.00" },
    { "price": "0.2400", "quantity": "4.00" },
    { "price": "0.2300", "quantity": "2.00" }
  ],
  "offers": []
}
```

Every market is a `stx.models.Market`; `market.model_dump()` gives you the dict. Every field is described in the [API reference](https://docs.stxapp.io/api/rest/).

</details>

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

## Documentation

- [Python SDK guide](https://docs.stxapp.io/sdks/python/)
- [API reference](https://docs.stxapp.io/api/rest/)
- [Release notes](https://docs.stxapp.io/changelog/)
- [Support](https://docs.stxapp.io/support/)

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](https://config.stxapp.io/us/terms_of_use.pdf), [privacy policy](https://config.stxapp.io/us/privacy_policy.pdf)), Ontario ([terms of use](https://config.stxapp.ca/on/terms-of-use.pdf), [privacy policy](https://config.stxapp.ca/on/privacy-policy.pdf)).
