Latest pachinko-pybind: 0.10.0 — betting bots need 0.10.0 or newer.

Betting API

Write a bot that watches live matches and trades the win-probability market— separately from the bots that play them. A betting bot sees exactly what a human spectator sees (the whole map, every seat's army, items and chips, the scoreboard, the poker table and every bet made at it), plus the live odds, the players' public records and its own wallet. During the pre-game betting round the starting cards and the start locations stay hidden, as from the players; both show once the RTS starts. Deterministic script or RL policy — same runtime, online and offline.

Overview

Every match has one winner market: an automated market maker (LMSR) quotes a price for each seat, between 0 and 1, and the prices sum to 1. A YES share on a seat pays 1 credit if that seat wins; a NO position pays 1 if it loses. You buy with an integer spend, you can sell YES shares back, and the market settles at the end of the match. When a seat folds or is eliminated its price goes to 0 and it stops trading.

Your bot runs on your machine with a bbot_… token. It subscribes to a stream with two channels per match. Bet eventsarrive the moment they happen: every round start, every action at the poker table and every round end, with the table as it stands after it — bets are public at the table, so there is no delay. Observations arrive at your cadence (at most twice a second): the spectator view, 3 s behind the live game like the watch page, with the live market attached. The bot sends orders through the REST endpoint. Betting bots have their own wallet, topped up from your account; they can never bet on a match you or your playing bots are in.

Quick start

1. Go to My betting bots, create a bot and copy its token (shown once). Top it up from your wallet.

2. Install the SDK and write a Bettor:

pip install -U pachinko-pybind

from pachinko_sdk import Bettor, Buy, Sell, run_bettor

class Favourite(Bettor):
    """Back the scoreboard leader once the game is a minute in."""

    def on_observation(self, obs):
        m = obs.market
        if m is None or not m.is_open or obs.tick < 24 * 60:
            return []
        scores = obs.view.scoreboard.scores
        leader = max(m.live_outcomes(), key=lambda s: scores[s])
        if obs.account.shares(leader) == 0 and m.price(leader) < 0.5:
            return [Buy(leader, spend=200)]          # YES on the leader
        return []

    def on_fill(self, fill):
        print("filled" if fill.ok else "rejected", fill.order, fill.trade or fill.error)

run_bettor(Favourite(), token="bbot_...paste_your_token_here...")

3. Run it. run_bettor subscribes to every live match (pass matches=[...] for specific ones), calls on_observation for each update (and on_bet for each bet event, if you define it), executes the orders you return and reconnects if the connection drops. Watch the market move on the watch page.

What your bot sees

on_observation(obs) receives a BettingObservation. The game part is the same frame human spectators get, decoded into the playing SDK's own Unit / Building / ResourceNode dataclasses — no fog, every seat.

NameTypeDescription
obs.tick / obs.phase / obs.delay_msint / str / intGame clock (24 ticks = 1 s); waiting · mulligan · running · betting · ended; how far behind live (3000).
obs.seq / obs.server_time_msint / intObservation counter per match, and the server's clock when it was built (0.9.5: also offline, advancing one stride per observation).
obs.view.units, .buildingslistEvery unit and building on the map with its owner slot. units_of(slot), buildings_of(slot), upgrade_levels(slot). Empty during the pre-game (the bases would give the start locations away), and resource nodes show no owner then.
obs.view.resources, .items, .buffsper slotHematite, the items each seat holds (as the Items tab shows them), the buffs they confer. Empty during the pre-game: the starting cards are applied when the RTS starts.
obs.view.scoreboardScoreboardscores (0–400), stakes, bounties, status (0 active, 1 folded, 2 eliminated).
obs.view.tablePokerTable | NoneThe in-match poker round: pot, current bet, each seat's bankroll / committed / bet (this round's chips, in front of the seat) / status. While a resolved round is held on the table (10 s) table.resume_in_ms counts down and table.resolved is True: a seat that folded shows there before the scoreboard, and the market, list it as out. 0.9.8: table.actions is the round's actions so far, in order. Never the cards.
obs.bets / obs.bet_loglist[BetRow]0.9.8: every betting action of every round — round, seq, slot, action (check, call, raise, all_in, fold; the blinds are posted by the table and not listed), amount (chips put in), bankroll_before, pot_after, current_bet_after; stack_frac = amount / bankroll_before. obs.bets holds the actions since your previous observation (none is lost when you read slower than the feed), obs.bet_log the whole match so far. Bets are public at the table: the players see them as they happen, and so does your bot, through on_bet (below) — the observation's copy comes with the delayed frame; dedupe by (round, seq).
obs.view.resource_nodes, .stars, .dropped_items, .eventslistMap state and the events since the last observation.
obs.view.alive, .bankrolls, .cumulative_pot, .winner_slotper slotContention, poker chips, the running pot, the winner once ended.
obs.marketMarketStateLive: prices per seat, dead (collapsed) seats, q, b, volume, status, min/max spend.
obs.accountAccountYour balance, positions (shares per seat), their mark-to-market, and your cost basis on this match: net_spend, yes_spend / no_spend per seat (survives a reconnect).
obs.tradeslist[TapeTrade]Every market trade since the previous observation: outcome, side, action, shares, cost, prices after, and who placed it — house (a house bettor), bot or user. Model the house flows.
obs.rawdictThe observation exactly as it came off the wire, for your own featurizers.
obs.matchMatchInfoSeats with public profiles (the player-stat list, below; profile.account is the same for the seat's whole account — the person's own hands plus all of their bots), the map, the rules: buy-in, blinds, b, spend limits, max_ticks (the time cap — at the cap the highest score wins), lobby_kind (standard 60 min, pybot 15 min, floor = all-AI), idle_end_secs, house_band. obs.match.map_seed is the map's seed. During the pre-game the map has no spawn positions and map_seed is None (the seed regenerates the spawns and deals the starting cards); a second match message brings both when the RTS starts.
obs.view.as_seat(slot, obs.match.map)GameStateThe frame as the playing SDK's GameState from that seat — reuse a playing-bot model or Featurizer on any seat.

on_match_start(match) gives you the MatchInfo when you subscribe; on_match_end(obs, end) the result, with end.end_reason (battle_out, fold_out, time_limit, abandoned, draw) from 0.9.5. Profiles are the same numbers, labels and definitions as the cards at the betting table, the watch page, the leaderboard and the profile pages, built by the same code, and nothing else (0.10.0):

NameTypeDescription
matchesintHands. Hands played. A hand is one match: the deal, the betting, the battle and the payout. Read by the house AI and the house market.
hands_won_ratefloatHands won. Share of hands won outright: the last seat standing, by battle or by everyone else folding. Read by the house market.
net_pnlintP&L. Chips won minus chips staked, over finished hands.
pnl_per_handfloatP&L per hand. P&L divided by hands played.
recent_pnllist[int]Last 10 hands. P&L of each of the last 10 finished hands, newest first.
vpipfloatPlays hands (VPIP). Share of hands where the seat put chips in before the match by choice: a call, raise or all-in.
pfrfloatRaises first (PFR). Share of hands with a raise or all-in before the match.
three_bet_ratefloatRe-raises (3-bet). Share of betting rounds where the seat raised after someone else had raised.
check_raise_ratefloatCheck-raises. Share of betting rounds where the seat checked, then raised after someone bet.
fold_ratefloatFolds. Share of hands the seat folded out of.
affloat | NoneAggression (AF). Raises and all-ins divided by calls. Empty for a seat that has never called.
pressure_success_ratefloatWins by pressure. Share of the seat's raises and all-ins that made someone fold.
shove_ratefloat | NoneShoves. Share of recent rated hands with a raise of 35% of the stack or more before the match. Read by the house AI.
open_sizefloat | NoneOpens for. The seat's average raise before the match, as a share of its stack, over recent rated hands. Read by the house AI.
window_matches / samplesfloat / dictThe recent rated hands (decayed) behind Shoves and Opens for, and their sample sizes.
accountPlayerProfile | NoneThe account behind the seat, the same fields; None for house AIs.

The full field list, with shrunk() and wideness(), is on the bots page.

0.9.8: on_bet(event) is called for every bet event the moment it happens, before the delayed observation that shows it, and may return orders like on_observation (default: none). A BetEvent has kind (round_start, action, round_end), round, tick, server_time_ms, table (the PokerTable right after the event), action (the BetRow, on kind action) and match_id. Bet events are never thinned by your hz; the rest of the view stays 3 s behind. Offline, the local runners send the same events at the moment of each action, ahead of the delayed frames, as live.

The market & orders

Prices

LMSR with liquidity b = 2500: cost C(q) = b · ln Σ e^(q_k/b), price p_i = e^(q_i/b) / Σ e^(q_k/b). A trade moves the price; the whole state (q, b) is public, so BettingClient.preview_buy(market, outcome, spend)tells you exactly what you'd get before you trade. The house seeds each market with ⌈b·ln N⌉ credits and takes no fee; whatever is left after settlement returns to the house.

Trading is open from the moment the market exists (the pre-game betting round, while the seats' buy-ins settle) until the match ends or the result is decided — including the paused phases (mulligan, the poker rounds), during which frames keep arriving with the table's statuses while prices stay live. The closed forms for sizing — the credits that move a price to a target, the shares to sell to reach one, the legs that move the whole vector — ship in pachinko_sdk.lmsr (yes_spend_to_price, no_spend_to_price, yes_shares_to_price, trade_to_legs).

Orders

NameTypeDescription
Buy(outcome, spend, side="yes", max_price=None)10 ≤ spend ≤ 100,000 creditsYES shares on that seat (pay 1 each if it wins). max_price rejects the order (409) instead of filling it if the average price per share would be higher — the slippage guard.
Buy(outcome, spend, side="no", max_price=None)sameA NO bundle: one YES share on every other live seat — pays 1 if this seat loses. Priced at 1 − p; max_price applies per bundle.
Sell(outcome, shares, side="yes", min_price=None)YES shares you holdRefunded at the current price, rounded down to whole credits; min_price rejects a worse average refund.
Sell(outcome, shares, side="no")NO bundles you holdSells one YES share of every other live seat in a single order (one rate-limit token, not one per leg).
Batch([legs…])1–8 Buy/SellAtomic: every leg fills or none does, prices move leg by leg, one rate-limit token. A Buy leg may name shares instead of spend.
TradeTo(prices, spend=None)a price vectorMove the live prices to your estimate in one atomic batch of YES buys sized by the closed form; costs exactly the minimum unless you pass a larger spend.

Trades are rejected on seats that are out (price 0), once the result is decided, and after the match ends. Draws and cancelled matches void the market: everyone gets their net spend back.

Offline testing

run_local_bettorsplays a match of built-in AIs with your bettors watching and trading an offline copy of the market. By default it is the live setup: the spectator frame is built by the server's own code, delivered 3 s (72 ticks) behind the game twice a second, seats drop out of the market the moment the delayed frame shows them folded or eliminated, and the market seeds, prices, fills, refunds and settles like the live one. Deterministic by seed.

from pachinko_sdk import run_local_bettors

res = run_local_bettors({"mine": Favourite()}, num_players=8, seed=42, balance=20_000)
print(res)            # winner, ticks, market status, trades, P&L per bettor
print(res.pnl["mine"], res.house)   # the house line-up traded against you

From 0.9.5 the offline stream has the shape of the live one, pauses included: it opens on the mulligan, the pre-game betting round arrives action by action (each house-AI action for the three observations it takes live), and a resolved round is held for its 10 s as 20 observations with table.resume_in_ms counting down. The market closes when the game ends, as live: orders on the last delayed frames get Match is not open for trading. Earlier versions played the pre-game round before the first frame and left those last three seconds tradable, so results measured on them were better than a live market would give.

NameTypeDescription
opponents="house"str | dict | NoneWho else trades the market. Default: the live house line-up (five linear bettors, wallets house-linear-<key>, marked house on the tape). A {name: Bettor} dict is your own line-up; None is nobody — prices then move only on your trades, which no live market does.
max_ticks=Noneint | NoneThe time cap. None = the live cap of the lobby: 86400 (60 min) for an all-AI match, 21600 (15 min) with seat_bots. A 60-minute match is slower to simulate; pass 21600 for the old length.
seat_bots=None{slot: Bot}Seat playing bots (your pybot) in the match; they are driven every tick as in run_local and reported as pybot. The live idle rule (360 s) applies, and your bettors are refused with the live 403 — a betting bot cannot trade a match its owner's pybot is in. self_trade_ban=False models someone else's pybot.
profiles=None{slot: profile}Public profiles per seat (the wire shape of the match message). They reach the seated AIs' betting as well as obs.match.
trade_rate_limit=NoneintTrades per minute per bettor (live and default: 60, a batch counting once). 0 = unlimited.
pause_frames=TrueboolThe paced shape described above. False = one observation per betting action and one for the hold.
collapse_on_table_fold=TrueboolTrue (live since 0.9.8): a folded seat leaves the market the moment it folds, before its bet event reaches any bettor. False: when the scoreboard marks it out, after the round and its hold (live before 0.9.8).
delay_ticks=72, stride_ticks=12, lmsr_b=2500int / int / floatThe live delay, cadence and liquidity; change them for experiments only. The engine's scenario keywords pass through as in run_local.

For reinforcement learning, pachinko_gym.BettingEnv wraps the same simulator as a Gymnasium environment. Its observation vector is built by BettingFeaturizer from the observation alone and its actions by order_for_action, so PolicyBettor(policy) runs a trained policy unchanged through run_local_bettors and run_bettor. Each seat's profile part is the player-stat list in the cards' order, for the seat and for its account (PROFILE_FEATURES), plus the house's wideness read: 52 numbers per seat (0.10.0). A policy trained on the 0.9.8–0.9.10 layout runs with features="v1" on BettingEnv, BettingFeaturizer and PolicyBettor for this release; the stats that left the profile read 0 there.

House bettors

Five deterministic bettors trade every live market under the House account, and are the default opponents offline. They are variants of one small fitted linear model of what every bettor is shown (pachinko_sdk.linear_bettor) that look at different parts of the board and trade at different speeds, so the house's prices carry information without being five copies of one opinion. Since 0.9.8 every variant also reads who is playing — each seat's Hands won, shrunk toward its account's and toward 1/n, at a weight fitted on 8,000 live matches — and prices the pre-game and the betting rounds as well as the RTS; a seat folded on the table is out at once, and every bet event makes them re-price (on_bet), trading when an estimate has moved by 3 points, with price limits. Each sizes an order from the market itself: it never moves a price by more than a set fraction of the gap to its own estimate, under a Kelly budget and a hard cap, and only closes a position once its edge has clearly flipped. Their wallets live in a band (obs.match.rules.house_band): refilled to 20,000 when below 5,000, skimmed back to 20,000 when above 40,000, so house money cycles rather than piling up. Read the code, extend it, beat it.

NameTypeDescription
fullevery feature, 30 sThe reference estimate: score, army and building shares, production, nodes, hematite, upgrades, threat in and out, army rank — and, like every variant, the seats' records and the betting.
tacticalno scoreboard, 30 sBlind to the score and the rank: what the armies, buildings, nodes and threats say.
economyno threat or rank, 45 sWhat each seat owns and produces.
scoreboardscore, army share, rank, 60 sThe board at a glance; smaller Kelly fraction.
patientevery feature, 90 sSlow and sure: a wider edge threshold, smaller price moves, lower cap.

The whole line-up runs from one stream at a frame every 5 s (pachinko_sdk.run_bettors) and acts every 30–90 s, and on bet events as they happen. The simple bettors of the first releases (FormBettor, ScoreboardBettor,MomentumBettor, NoiseBettor) stay in the SDK assimple_house_bettors() if you want them as opponents.

Fairness

Everything game-derived is delayed 3 s on the server before anyone— human or bot — sees it; the sidebar on the watch page and the bettor stream read the same frames. Prices are live for everyone. Bets are public at the table, so they reach you as they happen; a seat that folds leaves the market at that moment, before the bet event reaches anyone (0.9.8), and a seat eliminated in battle leaves it with the delayed frame that shows it, before that frame is sent out — nobody can race the market maker to a dead seat. Hands are never visible until items are applied. You cannot trade on a match that you, or a playing bot you author, are seated in.

API reference

Base URL https://pachinko-rts.com/betting-api/v1. Reads need no token; trades, /me and the stream need Authorization: Bearer bbot_…. pachinko_sdk.markets.BettingClient wraps all of it.

REST

NameTypeDescription
GET /matches—Running matches: seats, market summary, feed (stream up), tick, phase.
GET /matches?status=ended&limit=50&before=—Finished matches, newest first: winner, end reason, placements, seats, the settled market with its final prices. Page with before (ISO time). For backtests.
GET /matches/:id—One match: every seat with its public profile (and its account's), the market, bets (every betting action so far, undelayed), table_live (the poker table right after the last bet event, undelayed; null before the first) with table_live_at (kind, round, tick, server_time_ms), and while the feed is up the map, rules and mapSeed — spawn positions and mapSeed only once the RTS has started. Works after the match too.
GET /matches/:id/live—The newest BettingObservation (JSON, 3 s behind), account omitted; its bets are every action up to that observation.
GET /markets/:id—Market state: q, b, prices, dead, volume, status, min/max spend.
GET /markets/:id/history—Price series (every trade and collapse), thinned to ≤ 300 points.
GET /markets/:id/trades—Last 50 trades, anonymous.
POST /markets/:id/tradetoken{outcome, side: yes|no, action: buy|sell, spend | shares, maxPrice?, minPrice?}. A buy may name shares instead of spend. Idempotency-Key header honoured.
POST /markets/:id/tradestoken{legs: [1–8 of the above]}, executed atomically; one rate-limit token; the Idempotency-Key covers the whole batch.
GET /metokenYour wallet, open positions, last 50 trades.
GET /players/:name/stats?kind=—Full public profile; kind=pybot for bot-authored seats.

Stream

wss://pachinko-rts.com/betting-api/v1/stream with the same bearer token (or ?token=). Send JSON; receive JSON messages:

NameTypeDescription
{"subscribe": {"all": true}}→ serverEvery live match, including ones that start later. Or {"matches": [ids]} (≤ 10).
{"unsubscribe": {...}}, {"hz": 1}→ serverDrop matches; cap the cadence (feed max 2 Hz).
hello← serverYour bot, the cadence, the matches with a live feed, the SDK floor.
match← serverMatchInfo on subscribe: seats + profiles, map, rules. Sent again when the RTS starts, with the spawn positions and the map seed.
bet← serverReal time: {match_id, data: {kind: round_start | action | round_end, round, tick, server_time_ms, table, action}} the moment it happens — table is the poker table right after the event (table.actions: the round so far; resume_in_ms set on round_end), action the row on kind action. Undelayed, in order, never dropped or thinned, whatever your hz.
observation← serverA BettingObservation, ≤ 2/s per match (your hz), 3 s behind, with trades (the tape since the previous one) and bets (the actions since the previous one: the same rows the bet events brought, again — dedupe by (round, seq); after a reconnect they also fill anything the events missed). account is null here —
account← server— your balance and positions arrive separately: on subscribe, after each of your fills and after a settlement. You have one wallet behind every match, so each of these is sent for every match you are subscribed to.
end← serverThe match ended: phase, winner slot, market status, end_reason.
error← servercode + message (401 token, 404 no feed, 426 SDK too old, 429 too many subscriptions).

One stream per bot: a new connection replaces the old one. Orders still go through POST /markets/:id/trade; the SDK does that for you.

Limits & versions

Reads: 120 requests/min per IP. Trades: 60/min per bot, a batch counting once. Stream: one connection per bot, observations at most twice a second per match. Up to 5 betting bots per account.

The stream checks the SDK version you announce (X-Pachinko-SDK, sent by the SDK) and refuses versions below its floor with code 426 and an upgrade message: pip install -U pachinko-pybind. Hand-written clients that send no version are let through.