Scoring Prediction Accuracy and Execution Fidelity in Market Bot Test Suites
Separate tests for forecast quality and order handling show which half of a trading bot is failing.

Tests of a Kalshi bot need to score prediction accuracy and execution fidelity separately. Historical backtests should score probabilities against declared outcomes, while a stateful, continuously verified API simulator should test order handling, position state, and risk controls. PnL remains an outcome to interpret alongside both tests.
Why prediction accuracy and execution fidelity measure different things in a market bot
Prediction accuracy measures how well the bot estimates outcomes. If the bot assigns a probability to an event, does that estimate match how often comparable events resolve true? Execution fidelity concerns what happens after that belief becomes a trading decision. It covers whether the right order reaches the exchange at the right time and size, and whether the bot manages the resulting position correctly through fills, cancellation, or settlement.
These achievements can fail independently of each other. A well-calibrated bot can misread an open position and place an incorrectly sized order. A bot can also follow every order-handling rule while trading on poor probability estimates. Order placement correctness, position sizing, risk enforcement, and sequencing therefore belong to a different dimension from forecasting. Correct execution does not establish that the underlying belief was sound.
Wang et al.’s Raven-Agent makes this architectural separation explicit. Its forecasting module produces per-contract probabilities, while a separate, composable trading layer turns those probabilities into decisions. That boundary allows improvements to each module to be evaluated independently. It also gives a test suite a clear distinction between the probability the bot expressed and the actions it took.
Why PnL as the sole test signal hides both kinds of failure
PnL combines prediction quality, position sizing, timing, and execution correctness into one number. A loss does not identify which component failed, and a profit does not establish that every component worked. A bot with a real probability edge can lose if its sizing is wrong or it misreads a position, while a miscalibrated bot can profit from lucky timing.
They describe the trading layer as “either omitted or hardcoded, never treated as a designable object. That omission leaves the path from belief to filled order largely unexamined.
A subtler error arises when the evaluator scores at the wrong event. Measuring directional accuracy when a stop or target is hit, rather than at the declared forecast horizon, changes the question being tested. It can inflate apparent accuracy by rewarding an early favorable move. A PnL-only report hides that distortion because it does not tell forecast resolution apart from trade exit.
The production objection is straightforward but incomplete. PnL is the outcome in production, but in testing it is a signal whose causes need to be understood. An unclear signal leaves a team unsure what to fix in the model or the execution layer. The tests need to score each dimension with its own metric against its own ground truth.
What the prediction accuracy dimension requires from a test suite
The prediction layer needs a record of each probability estimate, its declared forecast horizon, and the outcome against which it will be scored. The primary metric should be the Brier score. As a strictly proper scoring rule, it rewards honest probability estimates and penalizes both overconfidence and underconfidence. The score measures the probability estimate and is independent of position size and trade timing.
An aggregate Brier score still leaves useful distinctions hidden. The Murphy decomposition separates calibration from resolution, allowing the report to distinguish a well-calibrated but low-resolution forecaster from an overconfident forecaster with stronger discrimination. Those profiles can otherwise produce similar aggregate scores.
The declared horizon supplies the scoring boundary. A fill, cancellation, stop, or early exit does not replace it, even if the trading layer has finished managing the position. Scoring at an exit rewards being right at that exit. The test record therefore needs to keep the forecast’s original closing point, whatever happens to orders after that.
Unresolved contracts require a separate reporting path. A test suite using that approach should report the provisional results separately from scores based on known resolutions. Silently discarding unresolved positions creates survivorship bias, while combining them with resolved outcomes obscures which ground truth the score uses.
Strategy ranking belongs outside this accuracy score. Time-normalized return rate can distinguish a small edge that resolves quickly from a larger edge that locks capital for months. That is useful for selecting strategies, but it answers a different question from probability accuracy. Folding it into the prediction metric would restore the same conflation that makes PnL difficult to interpret.
What the execution fidelity dimension requires from a test suite
Execution testing needs assertions that check the states along the way as well as the final balances. For each order, the suite should follow the expected lifecycle, including open, partially filled, filled, and settled states, or an open order followed by cancellation. At each transition, the state must match the bot’s internal position register. A position marked filled before a confirmed fill event is an execution defect even if the eventual PnL is correct.
Sequencing needs its own checks within that lifecycle. The bot must not attempt to cancel an order that has already filled, size a new position that breaches drawdown limits in the current open state, or submit a limit price the exchange would immediately reject. These checks depend on what happened before the current call. An otherwise valid operation can be wrong because of its place in the sequence.
Risk controls require equally explicit regression cases. Fractional Kelly sizing must give the right stake for the given edge and bankroll, and stop-loss constraints and drawdown limits must use the position state to which they apply. Concurrent positions cannot be evaluated as isolated exposures when the constraint applies to their aggregate. A test with a set sequence of losses should also check whether a configured circuit breaker blocks the next order attempt.
Raven-Agent enforces stake, exposure, stop-loss, and drawdown constraints outside the language model prompt. These deterministic components should behave identically given the same state, making them suitable for repeatable regression tests. The assertions need to establish enforcement by inspecting when a constraint fired. All of this requires an environment that retains position registers, fill events, and drawdown accumulators between calls.
Why stateless mocks and live sandboxes both fail the execution fidelity tests
A stateless mock answers a request without taking earlier operations into account. It can therefore return a filled order before any fill event, confirm cancellation after settlement, or report an open position after closure. Those responses may pass a test that checks too little. They cannot establish execution fidelity because they bypass the state dependencies the test is supposed to examine.
Record-and-replay cassettes solve only part of that problem. Recorded responses are repeatable, but they remain frozen at the moment of recording rather than responding to the current test’s operations. A recorded sequence cannot establish that a new sequence produced the correct state changes. Deterministic responses are not the same as deterministic state transitions.
Live sandboxes introduce the opposite difficulty for regression testing. They expose the bot to an exchange environment, but shared market state, rate limits, latency, and exchange-specific priority rules can vary between runs. A test can pass on one run and fail on another without a change to the bot’s logic. Credential requirements also introduce exposure that a local or CI execution suite should avoid.
The distinction is between realism and experimental control. A sandbox can expose live-network behavior, but it does not make that behavior reproducible at a chosen point in an order sequence. The required environment must combine persistent state, repeatable transitions, controlled faults, and correspondence with the exchange’s API contract.
What a stateful, verified API simulator makes possible that the alternatives cannot
Creating an order changes the resource returned by the next request, a fill changes the position state, and a losing trade updates the drawdown accumulator. A Kalshi simulator with these properties can exercise placement, partial fill, full fill, and settlement as one controlled sequence. The suite can inspect the state at every step.
APIs evolve through new required fields, changed response shapes, and updated sequencing rules. A simulator that retains old behavior can keep passing tests after the real API has changed. Continuous verification against the live API is therefore necessary to detect drift before stale simulation behavior becomes mistaken evidence of correctness.
The open-source kalshi-python-sdk illustrates the need for contract maintenance. Its nightly hard-fail contract tests check query, body, and WebSocket payload drift. An October 2026 spec-drift failure, issue #529, revealed new required fields, price_level_structure and price_ranges, in MultivariateEventCollection that lacked SDK mappings. This is an example of the kind of contract change continuous checks must expose, rather than a guarantee that any simulator remains correct indefinitely.
Fault injection then becomes a test of stateful recovery. A 429 response mid-sequence, a 503 during fill confirmation, or a latency spike between placement and acknowledgment can interact with the position state already accumulated. The assertion concerns whether the bot’s recovery and risk controls follow the specified contract under those conditions. Neither a calibration score nor a final PnL figure answers that question.
Running these cases locally without credentials makes it practical to test them on every commit. The simulator avoids live rate limits and network variability while allowing the test to inject those conditions deliberately. Among the alternatives described, a stateful simulator continuously checked against the API supplies both repeatability and contract fidelity. The same controllable state also supports reproducible reinforcement-learning environments spread across parallel containers.
How do you test a Kalshi bot before going live with both scores?

The concrete suite should contain two separately gated layers. The prediction layer presents a fixed historical or held-out event set to the forecasting module in isolation, without sizing or order placement. It computes Brier scores at declared resolution times and reports calibration and resolution separately. Known resolutions and provisional mark-to-market results remain distinct, and a degradation beyond the configured Brier tolerance fails the build.
The execution layer uses scripted sequences against the stateful simulator. Lifecycle cases follow placement through partial fill, full fill, and settlement, and also test placement followed by cancellation or rejection when a constraint is violated. At every step, assertions check the market-side state and the bot’s position register. Sizing and risk cases check the drawdown accumulator and control triggers, so a wrong transition along the way is caught even if the ending position is correct.
Fault recovery is a required execution sub-suite. Its cases inject a 429 mid-sequence, a 503 during fill confirmation, and latency between placement and acknowledgment, each with assertions against the specified recovery contract. Selection, sizing, and risk control each have their own deterministic cases, which follow the modular separation used by Raven-Agent. A sizing regression is caught even when the selection test passes, and the build fails if any state-transition assertion fails.
Both layers run on every CI commit. The combined report shows the prediction score beside the execution assertion results, but the layers share no metric. Brier score is not computed on execution tests, and PnL is not a pass/fail criterion in either layer. Stable accuracy with degraded fidelity directs investigation toward execution.
The results must show whether the simulator has passed verification. When verification detects a changed field, response shape, or sequencing rule, execution cases touching the affected endpoint should be treated as blocked because they rely on stale behavior. The two-score framework depends on the environment beneath it remaining faithful to the exchange. Continuous verification is a required part of the maintenance contract.


