Skip to content

Quickstart

Describes stx-python 0.10.1, the current release.

From nothing to reading markets, placing an order and streaming your account.

  • Python 3.9 or newer (python3 --version)
  • An API key for the exchange you are building against: a key ID and an Ed25519 private key. Environments lists the exchanges and where to get a key.
pip install stx-python

Save the private key as a file, for example ~/.stx/demo.pem, then create ~/.stx/credentials with a [default] profile. Set region and env to the exchange the key belongs to; the values are on Environments.

[default]
region = us
env = demo
key_id = your-key-id
key_file = ~/.stx/demo.pem

Environment variables and keyword arguments work too; see Authentication.

from stx import STX
with STX() as client:
me = client.me()
print("user", me.user_id, "account", me.account_id, "scope", me.scope)

Sample output:

user e6528824-b4e0-4ff8-bd70-36e5904738d1 account 28417940-ecef-40a9-8816-cc055d7d846f scope read_write

scope is read_only or read_write; placing orders needs read_write.

from stx import STX
with STX() as client:
page = client.markets(status="open", limit=5)
for m in page:
bid = m.bids[0].price if m.bids else "-"
offer = m.offers[-1].price if m.offers else "-"
print(f"{m.symbol:<50} bid {bid:>8} offer {offer:>8} pays {m.max_price}")
print("next cursor:", page.cursor)

Sample output:

STXNHL-26OCT101600EDMSJ-GAMEEDM bid 0.5800 offer 0.5900 pays 1.0000
STXNHL-26OCT101600EDMSJ-SOGSJCMCDAVID209555-3.5 bid 0.4900 offer 0.5300 pays 1.0000
next cursor: g2gDbQAAABBodIE2ul3LojBFatEY0rDzbgUB41zwLIZoA2EAbgcAANDo6IFdBmIAALhP

Prices are dollar strings ("0.5800"). Bids and offers both run from the highest price to the lowest, so the best bid is the first bid and the best offer is the last offer. A winning contract pays the market’s max_price.

from stx import STX
with STX() as client:
market = next(
m
for m in client.iter_markets(
status="open", trading=True, sort_by="event_start", sort_direction="desc"
)
if m.event_status == "scheduled"
)
order = client.place_order(market.market_id, "buy", "limit", price="0.01", quantity="1")
print("placed", order.id, order.status, order.price, order.quantity)
print("cancel", client.cancel_order(order.id).status)

Sample output:

placed 8f023ead-6f2d-4cf5-9931-cd217e44a2ee accepted 0.0100 1.00
cancel cancelled

A 1-cent buy for one contract, cancelled straight away.

import asyncio
from stx import AsyncSTX
async def main():
async with AsyncSTX() as client:
async with client.websocket() as ws:
orders = await ws.orders()
snapshot = await orders.wait_snapshot()
print("open orders:", len(snapshot["all_orders"]["orders"]))
asyncio.run(main())

Sample output, with one order resting on the book:

open orders: 1

STX is operated by XV Exchange, LLC, a Designated Contract Market regulated by the U.S. Commodity Futures Trading Commission (CFTC). Contracts traded on STX are cleared by XV Clearing, LLC, a CFTC-registered Derivatives Clearing Organization. Trading involves substantial risk of loss and may not be appropriate for everyone. Members risk losing the cost to enter any transaction, including fees. Consider whether trading is appropriate for you in light of your experience and financial resources. Nothing on this site is investment advice or a recommendation to trade. Past performance is not indicative of future results.

© 2026 STX. All rights reserved.llms.txtllms-full.txtView as Markdown
Docs version v1.10.5