Python SDK
In one paragraph. trion is the official Python 3.11+ SDK for algorithmic trading, market-data streaming and delegated agent access on Trion. Money is always Decimal (never float), signing is deterministic EIP-712 byte-identical to the TypeScript core, and agent delegation carries the same grant bounds and non-custodial model as the other SDKs.
Publication status
trion is not published yet: the package on PyPI is not this SDK, and publication is pending during the beta. The code below shows the intended usage; you cannot install it today. Access is no longer invite-gated: since 2026-09-26 the Agent Kit is open to any wallet, and the perp matcher's agent routes (/v1/agents) have no invite list. The CMPT-USD perpetual the SDK trades is in open beta.
Client setup
from trion import TrionClient
# Read-only public client
client = TrionClient(base_url="https://api.trion.market", market="CMPT-USD")
markets = client.get_markets()
book = client.get_book(depth=10)
print(f"Top bid: {book['bids'][0]}, Top ask: {book['asks'][0]}")
Money and units (Decimal-only)
Prices are 18-decimal WAD integers on the wire. Helpers convert without ever touching a float:
to_wad("12.50")→12500000000000000000from_wad(w)→Decimal('12.50')to_lots/from_lotsconvert quantities.
Every parser accepts Decimal, str or int; passing a Python float raises TypeError to prevent precision loss.
Direct trading (trader key)
from trion import TrionClient, PrivateKeySigner, Side, Tif, to_wad
signer = PrivateKeySigner("0xYOUR_PRIVATE_KEY")
client = TrionClient(base_url="https://api.trion.market", market="CMPT-USD", signer=signer)
# Place a limit buy order
order = client.place_limit_order(
side=Side.BUY,
price=to_wad("12.50"),
quantity=10,
tif=Tif.GTC,
)
print(f"Order placed: {order['orderHash']}")
# Market order protected by max slippage (50 bps), and a reduce-only close
fill = client.place_market_order(side=Side.BUY, quantity=5, max_slippage_bps=50)
client.close_position(max_slippage_bps=50)
# Cancel a resting order
client.cancel_order(order["orderHash"])
Agent delegation
from trion import TrionClient, PrivateKeySigner, AgentSigner, Side, to_wad
# 1. Trader creates an agent grant with limits
trader_signer = PrivateKeySigner("0xTRADER_KEY")
trader_client = TrionClient(signer=trader_signer)
created = trader_client.agents.create(
market="CMPT-USD",
max_order_qty=50, # max 50 lots per order
max_position_lots=500, # max 500 lots open position
reduce_only=False, # can open and close positions
expiry_days=30, # valid for 30 days
)
# 2. Trader signs the typed data and registers the grant
signature = trader_signer.sign_typed_data(created.typed_data)
trader_client.agents.register(grant=created.grant, signature=signature)
# 3. Agent trades on behalf of the trader
agent_signer = AgentSigner(agent_key=created.agent_key, trader=trader_signer.address)
agent_client = TrionClient(signer=agent_signer)
agent_client.place_limit_order(
side=Side.BUY,
price=to_wad("12.50"),
quantity=10,
strategy_id=created.grant.strategy_id,
)
# 4. Trader or agent revokes at any time
trader_client.agents.revoke(
symbol="CMPT-USD",
trader=trader_signer.address,
agent=created.agent_address,
)
The example prices are illustrative: a real order must sit inside the matcher's ±3% index price band (the CMPT-USD perp index was ~$2.75 on 2026-09-26), so 12.50 would be rejected.
Strategy policies are trader-only. Take-profit, stop-loss and TWAP policies cannot be signed by a delegated agent (
AGENT_POLICY_UNSUPPORTED): their children are submitted later by the scheduler, outside the per-order grant checks. Agents are authorized for immediate limit/market orders and cancellations inside their bounds.
Streaming
import asyncio
from trion import TrionStream
async def main():
stream = TrionStream(ws_url="wss://api.trion.market/perp/v1/ws")
def on_book(msg):
print(f"L2 book event: {msg.get('type')}")
def on_trade(msg):
print(f"Trade event: {msg.get('data')}")
async with stream:
await stream.subscribe_book2("CMPT-USD", callback=on_book)
await stream.subscribe_trades2("CMPT-USD", callback=on_trade)
await asyncio.sleep(10)
asyncio.run(main())
book2 carries automatic sequence-gap detection and resubscription.
Errors
TrionError— base for all SDK errors.TrionApiError— API error withservice,status,code,message,retry_after_ms.RetryableError— rate limits (429), 5xx, or network drops.AgentLimitError— an agent breached a bound set in its grant.AuthenticationError— signature or permission verification failure.
See Agent grants and limits for the bounds, and Agent Kit (beta) for the overview.
Source trail: overdrive/sdk-python/README.md.
Repository-owned documentation · October 2026 · Educational material, not investment advice and not an audit.
Documentation
Options live · Perps in open beta