EventTrader
AI-Native Trading
PAPER
Menu
Dark Mode
Plain English Mode
PAPER TRADING MODE — Enable real trading on your Account page
Back
PYTHON SDK

Arena Python SDK

Trade Blue vs Red team shares programmatically. Async-first SDK with 5 production-ready bot examples.

Installation

pip install cymetica-eventtrader
import asyncio
from event_trader import EventTrader

async def main():
    async with EventTrader.production(api_key="evt_...") as client:
        state = await client.arena.market()
        print(f"Blue NAV: ${state['blue_team']['nav']:.2f}")

asyncio.run(main())

Authentication

Pass your API key when creating the client. Public endpoints (market, orderbook, history) work without auth. Trading endpoints require a valid key.

# Public (no auth needed)
async with EventTrader.production() as client:
    state = await client.arena.market()

# Authenticated (required for trading)
async with EventTrader.production(api_key="evt_YOUR_KEY") as client:
    order = await client.arena.place_order("BLUE", "buy", 10.0, price=0.55)

SDK Methods

arena.market()publicGet market state (teams, NAVs, epoch, scoreboard)
arena.teams()publicGet team details + portfolio composition
arena.orderbook(team, levels)publicGet orderbook depth for BLUE or RED
arena.current_epoch()publicGet current epoch + countdown
arena.epoch_result(n)publicGet historical epoch result
arena.history(limit)publicEpoch history with winners
arena.headlines(limit)publicHeadlines driving team performance
arena.trades(limit)publicRecent trade fills
arena.chart(range)publicPrice history for charting (1D, 1W, 1M, ALL)
arena.place_order(team, side, size, price, ...)authPlace limit/market order on BLUE or RED book
arena.cancel_order(order_id)authCancel a resting order
arena.my_orders()authGet your open/resting orders
arena.positions()authGet your positions
arena.close_position(team)authClose entire position at market
arena.balance()authUSDC available, in positions, epoch loss tracking
arena.withdraw(amount)authWithdraw USDC to your wallet

Paper vs Live Mode

Trading mode is determined by your account's simulation_mode flag — not by the SDK. All new accounts start in paper mode.

Paper Mode (Default)

Tracks positions and P&L without real funds. All orders return mode: "paper". Positions tagged is_live: false.

Live Mode

Real USDC debited/credited. Epoch loss limit: $500. Orders return mode: "live". Position is_live flag locked at creation.

# Check your current mode
async with EventTrader.production(api_key="evt_...") as client:
    order = await client.arena.place_order("BLUE", "buy", 1.0, price=0.50)
    print(order["mode"])  # "paper" or "live"

Bot Examples (Copy & Paste)

1. Read Arena State

import asyncio
from event_trader import EventTrader

async def main():
    async with EventTrader.production(api_key="evt_...") as client:
        state = await client.arena.market()
        blue = state["blue_team"]
        red = state["red_team"]
        print(f"BLUE: NAV=${blue['nav']:.2f}  PnL={blue['epoch_pnl_pct']:+.2f}%  Wins={blue['epoch_wins']}")
        print(f"RED:  NAV=${red['nav']:.2f}  PnL={red['epoch_pnl_pct']:+.2f}%  Wins={red['epoch_wins']}")

        book = await client.arena.orderbook("BLUE", levels=5)
        for bid in book.get("bids", [])[:3]:
            print(f"  BID ${float(bid['price']):.2f}  {float(bid['size']):.2f}")

asyncio.run(main())

2. Place Orders

async with EventTrader.production(api_key="evt_...") as client:
    # Buy $10 of BLUE at $0.55 (55% implied probability)
    buy = await client.arena.place_order("BLUE", "buy", 10.0, price=0.55)
    print(f"Buy: {buy['status']}  fills={len(buy['fills'])}")

    # Sell $5 of RED at $0.60
    sell = await client.arena.place_order("RED", "sell", 5.0, price=0.60)

    # Check positions
    pos = await client.arena.positions()
    for p in pos["positions"]:
        if float(p["shares"]) > 0:
            print(f"  {p['team_symbol']}: {p['shares']} shares @ ${p['avg_entry_price']}")

3. Market Maker Bot

import asyncio, contextlib
from dataclasses import dataclass
from event_trader import EventTrader

@dataclass
class Config:
    team: str = "BLUE"
    spread_cents: int = 4
    order_size: float = 25.0
    refresh_sec: float = 5.0

async def run_mm():
    cfg = Config(team="BLUE", spread_cents=4, order_size=25.0)
    bid_id = ask_id = None

    async with EventTrader.production(api_key="evt_...") as client:
        try:
            while True:
                book = await client.arena.orderbook(cfg.team, levels=1)
                bb, ba = book.get("best_bid"), book.get("best_ask")
                mid = (float(bb) + float(ba)) / 2 if bb and ba else 0.50

                half = cfg.spread_cents / 200
                bid_px = max(0.01, round(mid - half, 2))
                ask_px = min(1.00, round(mid + half, 2))

                for oid in (bid_id, ask_id):
                    if oid:
                        with contextlib.suppress(Exception):
                            await client.arena.cancel_order(oid)

                r = await client.arena.place_order(cfg.team, "buy", cfg.order_size, price=bid_px, post_only=True)
                bid_id = r.get("order_id")
                r = await client.arena.place_order(cfg.team, "sell", cfg.order_size, price=ask_px, post_only=True)
                ask_id = r.get("order_id")

                print(f"Mid=${mid:.2f}  Bid=${bid_px:.2f}  Ask=${ask_px:.2f}")
                await asyncio.sleep(cfg.refresh_sec)
        finally:
            for oid in (bid_id, ask_id):
                if oid:
                    with contextlib.suppress(Exception):
                        await client.arena.cancel_order(oid)

asyncio.run(run_mm())

4. Momentum Bot

async with EventTrader.production(api_key="evt_...") as client:
    state = await client.arena.market()
    blue_pnl = state["blue_team"]["epoch_pnl_pct"]
    red_pnl = state["red_team"]["epoch_pnl_pct"]

    if blue_pnl and blue_pnl > red_pnl and blue_pnl > 0:
        team = "BLUE"
    elif red_pnl and red_pnl > blue_pnl and red_pnl > 0:
        team = "RED"
    else:
        print("No momentum signal"); exit()

    book = await client.arena.orderbook(team, levels=1)
    price = float(book["best_ask"])
    order = await client.arena.place_order(team, "buy", 10.0, price=price)
    print(f"Momentum: {team} buy $10 @ ${price:.2f} -> {order['status']}")

5. Epoch Watcher

async with EventTrader.production(api_key="evt_...") as client:
    last = None
    while True:
        ep = await client.arena.current_epoch()
        data = ep.get("epoch")
        if data:
            num = data["epoch_number"]
            if last and num != last:
                result = await client.arena.epoch_result(last)
                print(f"Epoch #{last} resolved: {result['winning_symbol']} wins!")
            last = num
        await asyncio.sleep(30)
Trade on the Arena