Rigorous Simulation Toolchain Evaluation for Kalshi Bot Pre-Production Testing
Only a stateful, API-faithful simulator can truly test a Kalshi bot.

A trading bot for Kalshi makes sequential, state-dependent API calls to create an order, poll for fills, check position, and modify or cancel. Each call depends on the state left by the previous one. But the bot may be non-deterministic: an LLM agent could make the calls in a different order, or add a fifth call, or swap two calls around for no apparent reason. To test it rigorously, the bot’s environment must be controllable even though the bot itself isn’t.
Why simulating a Kalshi trading bot’s environment is harder than typical API mocking
WireMock’s 2026 post on simulating agent behavior explains that an LLM agent can behave differently across multiple runs, even with the same prompt, tools, and context. This means that a single run of your tests tells you almost nothing. To have any confidence in the results, you need to run the tests many times.
Kalshi’s own demo sandbox widens the gap. It uses synthetic or delayed market data, and fills in the sandbox do not reflect production liquidity, so it cannot be used to judge strategy edge or realistic slippage. A layered simulation toolchain is necessary for the kind of controlled, repeatable experiments that are characteristic of rigorous pre-production testing.
How statefulness separates a useful simulator from a test that proves nothing
A simulator that isn’t stateful cannot be used to test the core workflows of a prediction market trading bot. A stateless mock returns the same fixture no matter what the bot has done before. The test only proves that the bot can make syntactically correct requests. It does not prove that the bot can behave correctly through a sequence of calls.
The canonical Kalshi test case illustrates this. A bot creates an order, and receives a 201 with an ID. It then polls for the order’s ID until the fill status changes. It then attempts to cancel the order, and gets a 404 because it has already filled. A stateless mock either never changes the fill status (so the polling loop goes on forever, or ends immediately because of the fixture), or it returns a fresh 200 on the cancel request as if nothing had happened before. The conflict path is unreachable. The ID that the mock returns for the poll request may not even match the ID returned for the create request.
The same applies to checks of the bot’s portfolio position. If the simulator doesn’t keep track of the fill, a subsequent GET of the positions will return the position from before the trade, and the bot’s risk management logic will be operating under a false premise.
Mocking tools vary in their capabilities. Some are static, returning one response for each endpoint. Some are conditional, with the response varying based on the parameters of the request. Some are stateful, with data persisting across requests. Some are scripted. But for multi-step workflows like the ones that a trading bot uses, only a stateful simulator is adequate. Handwritten mocks can fail here too, even when they are intended to be stateful. They are based on what someone thought the API would return, and there is no indication when that belief becomes outdated.

What verified fidelity to Kalshi’s current API actually requires
A simulator can be stateful and still give engineers false confidence if it doesn’t accurately reflect the current Kalshi API. The simulator must reflect current Kalshi API behavior to be useful. Since February 2026, market orders have been removed from Kalshi. The only order type is the limit order. As of March 2026, Kalshi uses USD fixed-point dollar strings (e.g., "0.6500"), rather than numeric floats, to represent prices. The order book format only shows bids. Asks must be calculated. Kalshi uses asymmetric key pairs for authentication. Ed25519 is the default, but RSA is also supported.
A simulator that accepts market orders and returns a plausible 201 is testing something that cannot happen in production. A simulator that returns floats will not surface the parsing and formatting issues that will arise in production. A simulator that returns both bids and asks will hide an entire class of client-side calculation errors. And a simulator that accepts any form of authentication will leave the auth failure paths untested.
Passing tests against an inaccurate simulator is worse than no testing at all, because it gives engineers false confidence that their bot is production-ready. The only way to be sure that a simulator is accurate is to continuously verify its fidelity to the real API. Published fidelity scores, such as daily agreement rates between the simulator’s responses and the live API’s responses, are one way to make that commitment to fidelity explicit.

The Kalshi-specific call sequences a simulator must handle to be worth evaluating
The most important workflows for a Kalshi trading bot include creating an order, polling for fill status until the order fills (or partially fills, or is cancelled), and then attempting to cancel it and getting the correct conflict response. The bot should also be able to check its portfolio position and see that the fill is reflected. It should be able to fetch the order book and see that it is in the bids-only format, with asks calculated client-side. All prices should be fixed-point dollar strings. It should be able to authenticate with an RSA key pair. It should be able to receive WebSocket events, in a believable sequence, for market status changes, fills, and order book updates. If a simulator cannot support these workflows, it is not worth evaluating any further.
Why fault injection is not an optional add-on for an LLM-driven trading bot
Testing a bot’s fault tolerance is important, but testing an LLM agent’s fault tolerance is essential. An LLM agent’s response to a fault is itself non-deterministic. It might handle a 503 correctly most of the time, but occasionally hallucinate an alternative response. Or it might get stuck in a loop that consumes its context window. Only by running the test many times, and injecting faults, can you get any idea of the distribution of outcomes. WireMock’s agent simulation post explains that adversarial testing — contradictory data, excessively long responses, injecting irrelevant information — is necessary to surface failure modes that would not be apparent in clean-path testing.
For a Kalshi trading bot, relevant faults include rate-limit responses, 503s, and latency spikes. The bot should be tested with a rate limit response in the middle of a sequence, to see if it handles it correctly without abandoning a live position. It should be tested with a 503 while polling for order status, to see if it can distinguish “unknown” from “failed”. It should be tested with a latency spike on fill notifications, to see if it acts on a stale position because it timed out waiting for confirmation. It should be tested with contradictory data, such as an order book that shows a price available but an order submission that returns a rejection for that price. It should be tested with malformed or truncated responses that consume context window, to see if it can extract what it needs or if it veers off task.
Fault injection must be protocol-aware and timed to realistic call depths. If the fault is injected before the agent’s call chain reaches the relevant step, the results will be misleading. A simulator that only supports clean happy paths and static error codes is not capable of testing these scenarios. Fault injection must be a first-class feature of the toolchain.
Reproducibility and seeded state as the prerequisite for meaningful evaluation under non-determinism
Non-determinism in the agent means that a single run of the tests is not a reliable indicator of the agent’s behavior. To get meaningful results, the tests must be run many times, and the distribution of outcomes must be measured. This is only possible if the simulator can be reset to a known state before each run.
A simulator should also come with realistic data pre-seeded. An empty sandbox requires engineers to create setup fixtures before each test, which is a source of bugs and maintenance overhead. A simulator that comes with a pre-seeded market, populated order books at realistic price levels, and realistic position histories allows engineers to start testing scenarios immediately, rather than building state from scratch.
For RL training environments, reproducibility is a requirement. The Gymnasium/PettingZoo interface requires that reset(seed=N) returns a reproducible initial observation when given the same seed, and that step(action) produces reproducible transitions when the environment’s RNG state is controlled via seeding. A simulator that cannot reliably reset to a known state cannot be used as an RL training environment. Horizontal scaling across many parallel training containers requires that each container gets an identical, independent environment. Seeded fault schedules — faults that occur at the same call positions in the same run number — allow engineers to attribute performance differences to the agent’s behavior.
How the Kalshi demo sandbox fits into this toolchain and where it stops being useful
Kalshi’s demo sandbox is a useful tool for testing authentication, order creation, error handling, and other basic functionality. It uses the same endpoints as the production API, with separate API keys and fake funds. Its limitations include the inability to inject faults, reset state, or run tests offline or in a CI pipeline. A well-designed simulation toolchain uses the demo sandbox for final validation, and a local simulator for development, fault testing, and CI. Small production orders with tight limits can be used to test slippage and liquidity before full deployment.
Evaluating simulator candidates against these criteria in practice
To evaluate a simulator for use with a Kalshi trading bot, first check that it is stateful. Create an order, poll for its status, and attempt to cancel it. Failure to return the correct conflict response demonstrates the simulator’s lack of statefulness and disqualifies it from further evaluation. Next, check that it is faithful to the current Kalshi API. Try to create a market order, and see if it is rejected. Check that all prices are fixed-point dollar strings. Check that the order book is in the bids-only format. Ask the simulator’s vendor or project maintainer how they verify fidelity to the API, and how often. A simulator that does not have a process for continuous verification will drift out of sync with the API over time. Published fidelity scores, such as daily agreement rates with the live API, are a good sign that the simulator is being maintained with fidelity in mind.
Next, check that the simulator supports fault injection. Can you inject a 429 or a 503 at a specific point in the call sequence? Can you introduce latency? Can you seed the fault schedule, so that the same faults occur in the same places on each run? Finally, check that the simulator can be run in a CI pipeline. Can it be initialized to a known state, without manual setup? Can it be run without live credentials or network access? If the answer to any of these questions is no, the simulator is not suitable for the kind of rigorous testing that a Kalshi trading bot requires.
Running the simulator in CI and in RL training environments
A simulator that meets the criteria above is also suitable for use in a CI pipeline or as an RL training environment, because those use cases have the same requirements: controllable state, no live credentials, deterministic reset, and horizontal scalability. To use a simulator in a CI pipeline, start it as a containerized service in the pipeline’s test step, point the bot’s API client at the simulator’s endpoint, run the tests, and tear it down. The simulator should be able to be initialized to a known state, so that the tests are reproducible. No live credentials or rate limits should be involved. The same tests should be able to be run on any developer’s machine, and in any CI pipeline, with the same results.
To use a simulator as an RL training environment, it must meet the Gymnasium interface requirements. The reset() method must return the same initial observation each time it is called, and the step(action) method must advance the state in a deterministic way. This is the same requirement as for CI reproducibility, so a simulator that can be used in CI can also be used for RL training. Horizontal scaling across many containers requires that each container can run its own instance of the simulator, with its own state. A shared, stateful sandbox cannot be used for this purpose. Fault injection is also useful in an RL training environment, to train the agent to handle environments where its tools sometimes fail.


