Back to blog
Risk4 min read

Your Bot Needs a Ledger

The quiet failure mode in prediction market bots is bad state: ghost positions, fake P&L, stale responses, and missing reconciliation.

A prediction market bot can survive a bad forecast. It may not survive bad memory.

The obvious fantasy is that a bot needs a better model. Sometimes it does. More often, after reading enough builder postmortems, the problem is stranger. The bot does not quite know what happened.

It sent an order. The API response was ambiguous. The chain settled later. The local database recorded an exit at the last visible price. A balance updated after the bot had already reasoned about the next trade. Somewhere between intention and ownership, the state forked.

A request is not a position

This sentence should be printed above every trading bot repository: a request is not a position.

There are several different objects pretending to be one object: intent, accepted order, rejected order, partial fill, full fill, cancellation, settlement, balance, and local portfolio state. The bot should not merge them because it is impatient.

The clean architecture is boring. Record the intent. Record the exchange response. Record fills separately. Apply fees. Reconcile the portfolio against the venue. If something disagrees, freeze the next trade before the bot compounds the confusion.

Fake P&L is worse than no P&L

Bad accounting is comforting because it produces numbers. The chart keeps moving. The bot keeps explaining itself. But if exits are logged at stale prices, if rejected orders mutate state, or if leftover balances become phantom positions, the P&L is not merely wrong. It is training the builder to trust the wrong system.

This is why the ledger should be more detailed than the strategy feels. Keep order ids, client ids, tickers, side, size, intended price, average fill price, fees, status, error codes, timestamps, and the source of truth used for reconciliation. A bot you cannot replay is still partly a rumor.

The quiet gates

Good bots have unglamorous gates: balance, reserve, liquidity, concentration, correlation, max slippage, minimum viable exit size, market status, and cooldowns after uncertain exits. These do not make a weak model strong. They keep a confused system from acting confident.

The ledger is also where the bot learns humility. A rejection is not noise. A partial fill is not a failure to hide. A stale book is not a reason to guess harder. Each is a fact about the world the bot is trading in.

The model is the bot's voice. The ledger is its memory. Without memory, even a smart bot starts dreaming. In markets, dreams are an expensive data structure.

Research sources

Test your prediction market agent before live capital

Route supported market orders to PredArena and inspect fills, slippage, fees, balances, and order history against live Kalshi-style order book depth.

Create a free sandbox keyRead the API docs

Related reading

ExecutionThe Fill Is the StrategyAgentsThe Dangerous Part of an AI Trading Agent