Throughput Ceiling and Order Burst Profiling for Kalshi Event Contract Algorithms Under Market Spike Conditions
Model your throughput ceiling and test burst recovery with a stateful simulator before trading live.

Testing a Kalshi bot before going live requires a stateful simulator that reproduces token billing, bucket refill, and order state under spike load. Preserving position integrity when Write tokens run out requires burst capacity, shard routing, and recovery behavior as well as sustainable throughput. The engineering task is to model that limit, profile it, and test recovery before relying on it live.
How Kalshi's token-bucket rate limiter actually works, and why it matters more than a request cap
Kalshi's rate-limits documentation describes a continuous token bucket. Every authenticated request consumes tokens, while the account's budget replenishes them over time. Most calls cost 10 tokens, but cancels cost 2, and GET /account/endpoint_costs supplies the authoritative non-default costs. Request counts alone therefore misrepresent available throughput. Two sequences with the same number of calls can consume different budgets.
Read and Write have independent balances. Read covers GET endpoints and operations not routed to Write, while Write covers placements, amends, cancels, order groups, RFQ quote flow, and block trade proposal accepts. The distinction follows operation type rather than protocol, so REST and FIX order writes share Write capacity. GET /portfolio/balance instead has an isolated, non-burst bucket allowing one call per second on Basic and Advanced and five on higher tiers. Kalshi's documentation tells clients to use events such as the WebSocket user-fills channel for balance updates.
What the seven-tier budget table means for a spike algorithm's sustainable and peak throughput
Basic has 100 Write tokens per second, Advanced has 300, and Expert has 600. At the default create cost, sustainable order throughput is the Write budget divided by 10. Premier supports 120 orders per second at that cost.
The Basic-to-Advanced step triples Write capacity but increases Read capacity by only half. Advancement requires a self-serve API call with no volume threshold, provided some recent Predictions orders were created through the API. Above Advanced, advancement depends on trailing 30-day volume share, so planning should use the tier the algorithm can realistically hold.
Perps budgets remain separate from event-contract budgets and do not subsidize Predictions throughput. A mixed-book algorithm therefore needs distinct capacity models. Even within Predictions, sustainable rate gives only half the picture of throughput because stored tokens allow a larger burst at the start.
The 3× burst multiplier and its tier-and-bucket exceptions
Kalshi's documentation assigns three seconds of capacity to Basic and Advanced Predictions Read buckets and to Write buckets above Basic. Predictions Read buckets above Advanced, all Perps Read buckets, and Basic Write hold only one second. Burst eligibility is therefore specific to each bucket. Idle time cannot build a three-second reserve where capacity permits only one.
An eligible Write bucket that starts empty is full after three idle seconds. Premier's Write bucket holds 3,600 tokens, enough for 360 default-cost creates before counting the tokens that refill it during dispatch. That reserve lets activity bunch up for a short time without raising the rate for good. After depletion, throughput depends on replenishment.
An Expert-or-higher algorithm polling depth aggressively consumes a Read bucket without the three-second reserve, even while its Write bucket supports bursts. Read exhaustion can constrain a simultaneous flurry of book requests while leaving Write capacity intact. Kalshi's documentation describes the burst design as favoring event-driven clients that wait and then place a block of orders when the market moves.
Two billing behaviors that silently destroy burst headroom
Batch endpoints cut request overhead but cost the same number of tokens. A 25-order create batch costs 250 tokens, and the entire batch is rejected if its full cost is unavailable on arrival. There is no partial execution within that batch. Batch cancels cost 2 tokens per order, but a cancel followed by a replacement still includes the new create's cost. These distinctions belong in the dispatch audit before load testing.
Routing can widen the draw on available budgets. Auto-routed writes using exchange_index: -1, or omitting it when market_ticker is provided, bill every shard's Write bucket simultaneously. Explicit targeting with exchange_index >= 1 bills only the targeted shard, while shard 0 traffic bills the unscoped bucket. RFQ and quote writes share shard 1's budget with its order writes. Explicit routing therefore requires known shard topology and testing of assignment stability, rather than an assumption that all writes consume one common balance.
Modeling the throughput ceiling before writing a load test
The analytic model should begin with the current account's limits. GET /account/limits returns the Predictions usage tier, refill rates, and bucket capacities, while the endpoint-cost listing supplies non-default operation costs. Routing determines which balances each operation debits. These inputs give a testable bound before any load is generated.
Premier provides a concrete worked example. Its sustainable rate of 120 default-cost orders per second determines its token refill rate, and its capacity is 3,600 tokens. The largest burst that stored tokens can cover is capacity divided by create cost, which gives 360 orders. From empty, replenishing the 10 tokens for one create takes approximately 8.3 ms. Restoring a full burst reserve takes three seconds without intervening consumption.
For a requested burst, the minimum wait is its token shortfall divided by refill rate, assuming no competing consumption. A full initial burst followed by one second of replenishment cannot support demand beyond the reserve plus that second's sustainable throughput. A model that mixes operations must use separate costs for creates and cancels. Otherwise, order-management-heavy workloads receive an artificially low limit, while optimistic tier assumptions produce the opposite error.
What to simulate when profiling burst capacity, and why a stateful simulator is necessary
Burst profiling depends on cumulative state across requests. A stateless mock cannot reproduce a partially depleted bucket, a batch rejected at its arrival balance, or divergent shard balances after mixed routing. Nor can it distinguish recovery with no position from recovery after some orders have filled. Returning a scheduled 429 is not equivalent to enforcing the billing model.
A stateful simulator must keep token balances and update them with every call. It also needs the state of open, filled, and cancelled orders so that later queries and cancel-replace operations take earlier activity into account. Market data and depth loaded in advance let the read path run without using up live limits.
Live load generation risks real trading consequences. The Kalshi demo environment is an alternative, but its rate limits remain an externally controlled part of the experiment. A resettable local simulator is preferable for systematic profiling because the same starting balances and order state can be reproduced. Its value depends on fidelity to the documented billing rules.
Designing a burst profiling harness to test a Kalshi bot before going live
The harness should start Premier's Write bucket full after three idle seconds, then submit 360 creates in one dispatch tick. The first observation is whether dispatch uses the available reserve or fragments the burst unnecessarily. A second burst at T+1s tests operation after partial refill. A separate configurable mid-burst 429 exercises recovery after some orders have landed.
Record the balance at dispatch through simulator visibility or analytic tracking, then measure elapsed time from a 429 to the first successful retry. At rejection, capture accepted orders, rejected orders, fill state, and net open position. Record full-batch rejections as well, especially when available balance changes between the dispatch check and arrival.
A healthy result accepts the first burst and paces the second at refill rate without full-batch rejections. Injected throttling should preserve the open-position recovery path, with exponential backoff resolving within two retry cycles in the planned test. Absence of errors is not sufficient evidence. A dispatcher that serializes too conservatively can report no 429s while leaving burst capacity unused and delaying its response to the event.
Dispatching orders under spike conditions, including pacing, batching, and cancel-replace economics
The dispatch design should follow the measured balance. Size bursts to available tokens rather than a fixed batch count, then pace creates at refill rate once the reserve is spent. For Premier, the planning interval is approximately 8.3 ms per default-cost create. Local balance estimation should add refill rate multiplied by elapsed time, cap the result at capacity, and subtract billed operations. A 429 is a lagging indication of failed admission.
If the estimated balance cannot cover the batch, dispatch should fall back to individual orders rather than submit a request destined for complete rejection. At the same create cost, this prevents an oversized atomic draw from blocking the entire group when some individual operations could proceed.
Cancellation is cheaper than creation, but cancellation plus replacement is not cheaper than cancellation alone. Amend costs should be checked in the endpoint-cost listing before an amend is assumed to save tokens. For known shard-pinned markets, explicit targeting confines consumption to the intended shard's budget. Algorithms that use fixed shard assignments should check them again after market structure changes and allow for quote traffic that shares the budget on shard 1.
Designing graceful degradation when the Write bucket is exhausted mid-spike
Write exhaustion is an expected operating condition under spikes. Kalshi's documented 429 response provides neither Retry-After nor X-RateLimit-* headers and imposes no cooldown penalty. Refill keeps going, and the next operation can go through once the bucket it uses has enough tokens. Recovery should therefore depend on cost, refill, and order state.
On a throttle error, the dispatcher should reconcile whether the intended order landed before reissuing it. Tracking in-flight state prevents recovery from duplicating creates that were already accepted elsewhere in the sequence. Exponential backoff should wait, double after subsequent failures, and cap the maximum delay. For Premier, an empty bucket takes approximately 8.3 ms to refill enough for a create, so the initial wait under those conditions must be at least that long.
An exit order must stay pending until its execution is confirmed. If throttling interrupts the exit, recovery should retain the original parameters and queue the retry. Explicit operating states make this behavior auditable. Burst-full permits maximum available dispatch, burst-depleted paces at refill rate, and exhausted invokes backoff with cancel-first handling and no new creates until a minimum balance returns. Cancels still require their own tokens.
Testing the recovery path in CI with a stateful Kalshi simulator
CI should exercise four distinct recovery failures. First, inject a throttle error after some burst orders land and require reconciliation that retries only the missing orders. Second, throttle an exit and require the algorithm to retain the position until the queued exit executes. Both tests need order state that carries over between calls as well as a recorded error response.
Third, drive repeated 429s through the configured backoff cap and require a holding state. Fourth, reject a batch after available balance falls below its cost between the local check and arrival. The expected fallback is individual dispatch of its contents. Accurate refill enforcement must reject premature retries and admit funded ones, while persistent balance state must preserve the batch-arrival race.
The simulated WebSocket market-data feed must accompany the REST surface so that recovery does not operate on an order book that has stopped updating. Otherwise, repricing decisions can be wrong even when retry timing passes. The next step is to script these four fault scenarios and run them in CI against the stateful simulator. Any divergence between its billing behavior and Kalshi's documentation should be reported as a fidelity gap.


