Test YES and NO Contract Logic Before Paper Deployment
Most strategy bugs on binary prediction markets are not pricing bugs. They are side bugs. You meant to go long NO and your code went long YES, or you confused selling YES with buying NO and ended up with the opposite exposure. On a market where YES and NO prices are linked, a flipped side quietly inverts your whole thesis. This post explains the semantics, shows where buy/sell direction and YES/NO side are the same fact in two vocabularies, and gives a bounded way to check both sides before you commit to a paper run.
YES and NO are two sides of one book
Kalshi markets are binary. A contract settles to a fixed value if the event happens and zero if it does not, and it settles in US dollars on a CFTC-registered exchange.
The key structural fact: there is one book, not two. The orderbook endpoint returns bids on both legs and no asks at all. As Kalshi's docs put it, the book shows all active bid orders for both YES and NO sides, and it returns YES bids and NO bids only.
That works because a bid on one side is an ask on the other. Kalshi documents the reciprocal relationship directly: a YES bid at a given price equals a NO ask at the complementary price, for identical contract sizes. A YES bid at 7 cents is the same resting liquidity as a NO ask at 93 cents. So when you read the book, remember you are looking at two bid ladders that together describe the full set of offers. There is no separate ask ladder to consult.
Side selection is not buy/sell direction
This is the distinction that trips people up. 'Which outcome am I positioned for' and 'am I buying or selling' are separate axes, and some of their combinations collapse to the same exposure.
Kalshi's order-direction reference spells out the equivalence. Buy-YES and sell-NO both produce long YES exposure. Buy-NO and sell-YES both produce long NO. In other words, you can reach the same position from either direction, which is exactly why a careless flip is easy to ship and hard to notice.
Kalshi has also normalized this into explicit fields. Order, fill, and trade responses now carry an outcome_side field (yes or no) describing the outcome you profit from, and book_side (bid or ask) carrying the same bit in book vocabulary. Per the Kalshi changelog and order-direction reference, bid is equivalent to yes and ask is equivalent to no. outcome_side describes directional exposure only and does not change the order's price. The legacy action, side, is_yes, purchased_side, and taker_side fields were deprecated in favor of outcome_side and book_side; the announced removal deadline of May 28, 2026 has passed, so new integrations should not rely on those fields being present.
A short way to hold it in your head:
- Buy YES = sell NO = long YES (you profit if the event happens).
- Buy NO = sell YES = long NO (you profit if it does not).
- bid is equivalent to YES; ask is equivalent to NO, per Kalshi's direction docs.
- outcome_side is the canonical exposure bit; it does not move the order price.
Watch the price scale when you toggle sides
Side selection can also change which price scale you are reading, and that is a second place logic breaks. By default, Kalshi reports NO-side levels in NO-leg pricing, so a NO level at 0.30 corresponds to an offer of 'NO at 30 cents' that matches against 'YES at 70 cents'. Toggling sides flips the price. Kalshi offers an alternative where NO-side levels are reported in YES-leg pricing so both sides carry the same scale, and in that mode a level that would read 0.30 in NO-leg pricing reads 0.70 instead. Kalshi has signaled it will eventually make the unified yes-leg pricing the default and remove the legacy no-leg option.
Practical consequence: if your code compares a NO price to a YES price without agreeing on one convention, your edge calculation is wrong by construction. Pin the convention before you compute anything, and assert it in a test.
Check both sides as a bounded research exercise
The point of testing contract-side logic is to prove, on real market data, that your strategy positions the side you intended, without putting real money at risk. Banger (bangertrades.com) is a paper-research beta for exactly this kind of check: you write a Python strategy, inspect versioned historical backtests, and run bounded paper experiments. Hosted historical backtesting currently supports Kalshi binary markets. Public live deployments and local --live are blocked, so there is no path here to send a real order.
Treat a paper result as evidence under a specific data, fill, fee, and valuation model, not proof of profitable or real-venue execution. The forward-paper simulator in the public 0.1.7 release can fill a non-crossing requested limit at that limit and logs paper.fill.resting-assumed when it does, and its volume-based quantity cap is not full book depth or passive queue reconstruction. That is fine for verifying side logic. It is not a promise about real fills.
A reasonable side-check loop, staying inside paper research:
- Pick one exact current Kalshi market ticker and keep it fixed across runs. Taking the first discovery result is not reproducible; name the ticker.
- Write two tiny strategies, or one parameterized by side, that place on YES in one and NO in the other using the same signal.
- Run each locally as a short, supervised check and read back which outcome you actually hold, then stop it with Ctrl+C.
- Confirm the held side matches intent, and confirm your price comparison used one leg convention.
In the 0.1.7 SDK the strategy callback is on_market_tick(self, market, tick, ctx), with an optional on_start(ctx). Tick prices are Decimal, bid and ask can be absent, and the timestamp is a datetime. You import the Kalshi adapter from banger_adapter_kalshi (banger.venues.kalshi is a valid compatibility re-export). To open a position, Context.place(venue, market, side, size, price=None) takes a USD notional size; Context.close uses the held-contract quantity. The side argument is where your YES-versus-NO intent lives, so it is the exact line your test should pin down.
from decimal import Decimal
from banger import Strategy
from banger_adapter_kalshi import Kalshi
# Conceptual sketch of a side-check strategy.
# TICKER must be a real current market you selected and preserved.
class SideCheck(Strategy):
name = "side_check"
SIDE = "no" # flip to "yes" for the paired run
async def on_market_tick(self, market, tick, ctx):
# bid/ask can be absent; handle missing quotes before using them.
if tick.bid is None or tick.ask is None:
return
# size is USD notional for ctx.place, not a contract count.
await ctx.place(Kalshi(), market, side=self.SIDE, size=Decimal("5"))
# Then read back the held position and assert outcome matches SIDE.Run it with banger run strategy.py --paper to create a local paper record after account setup, or use banger deploy strategy.py --paper for the separate hosted path, which is subject to admission and capacity. Note that --venue belongs to banger init, not run. Stopping a run preserves your research history and says nothing about any real account's positions, and a stopped badge can precede completed resource cleanup, so confirm the stopped record before assuming cleanup finished.
On risk limits, read them literally
If you add a RiskEnvelope to bound the experiment, read the fields for what they do. max_position_usd limits cumulative position cost basis, not a generic per-order stake. The forward-paper daily-loss control rejects new exposure once mark-to-market loss from the current UTC-day baseline reaches max_daily_loss_usd; it does not automatically flatten existing holdings, guarantee an eventual loss ceiling, or stop a worker on a timer. A per-context limit is not an account-wide guarantee. For a side-logic check this matters less, but do not mistake these controls for a stop that liquidates for you.
The takeaway
Before any paper deployment, prove two things on real data: that your strategy holds the outcome side you meant to hold, and that every price comparison uses one consistent leg convention. YES and NO sit on one linked book, buy and sell can reach the same exposure from opposite directions, and the price scale can flip when you toggle sides. Pin all three in a bounded paper check, keep a fixed ticker, and read the result as model-conditioned evidence rather than proof. Get the side right first. Everything downstream depends on it.
Sources
- Get Market Orderbook - Kalshi API Documentation
- Order direction (outcome_side and book_side) - Kalshi API Documentation
- Orderbook Responses - Kalshi API Documentation
- API Changelog - Kalshi API Documentation
- Quick Start: Market Data - Kalshi API Documentation
- bangertrades 0.1.7 - PyPI
- Banger CLI Documentation - bangertrades.com