betting_combat.domain.money
Prices, cents and Kalshi’s taker fee.
Kalshi quotes whole cents (0.01 .. 0.99 dollars per contract). Every
comparison of prices happens in integer cents: in floating point
0.46 - 0.41 == 0.050000000000000044, which once made a 5-cent spread fail a
”<= 5 cents” test (live session 2026-09-26).
Two fee views exist on purpose:
- :func:
fee_per_contract— the smooth fee used to evaluate an edge. The research backtests priced every decision this way, so production decisions use it too (parity). - :func:
order_fee— what Kalshi actually charges an order: the same formula over the whole order, rounded UP to the next hundredth of a cent ($0.0001). Used for accounting and P&L. Receipts: the account’s own fills (2026-09-23), e.g. 340 @ 0.28 → raw 4.79808 → charged 4.7981; an order filled in two parts (1.23 @ 0.31 + 147.95 @ 0.32) → raw 2.271991 → charged 2.2720 in total.
Functions
all_in_cost
all_in_cost(price: float, rate: float = TAKER_FEE_RATE) -> floatPrice plus the per-contract fee: the cost an edge is measured against.
fee_per_contract
fee_per_contract(price: float, rate: float = TAKER_FEE_RATE) -> floatThe quadratic taker fee for one contract, unrounded: rate * P * (1 - P) (Kalshi 0.07).
order_fee
order_fee(contracts: float, price: float, venue: str = 'kalshi') -> floatOne order’s fee as the venue charges it.
Kalshi: 0.07 * C * P * (1 - P) rounded UP to $0.0001 (the account’s fills).
spread_cents
spread_cents(bid: float, ask: float) -> intAsk minus bid, in whole cents — never compared as floats.
to_cents
to_cents(price: float) -> intA dollar price as whole cents (Kalshi prices are always whole cents).