Open source · edge detection and risk-gated execution for Kalshi markets.

View source
Edge-Radar
How it worksGatesPipelineCoverageScheduleQuick start Jump to…

Open source · Kalshi · sports and futures markets · dry run by default

Research first. Execute second.

Edge-Radar compares Kalshi's price against an independent fair value built from sportsbook consensus and public data feeds. A bet fires only when the gap clears the exchange fee and every risk gate, and it is sized by fractional Kelly.

Not financial advice. The repository documents its losing segments as carefully as its winning ones, and the model's own calibration study says the market is usually right. Risk and eligibility.

illustrative sample · hover · click to inspect
Defaults DRY_RUN=true 22 risk gates 7 pipeline stages 31 sport filters fee-aware Kelly python ≥ 3.11 · no telemetry

How it works

One equation, guarded by 22 gates.

Pull Kalshi's ask. Pull an independent fair value from sportsbooks and data feeds. The difference is the claimed edge. The exchange fee comes off before anything else is judged, and only then does the order meet the gates.

fair_value − market_ask = edge · edge − fee(price) ≥ floor and every gate passes → bet

Gate lab

Move the price. Watch the gates.

illustrative
Side
Confidence
Presets

Result

A 52c YES against a 58c fair value

Claimed edge+6.0%fair − ask
Fee / contract1.8c0.07 · p · (1 − p), rounded up
Net edge+4.2%edge − fee
Required4.8%floor + fee (Gate 3)
Kelly stake2.2%¼ · net / (1 − p), batch of 1
Edge score6.0min(edge / 0.01, 10)
Clears the static gates · portfolio gates still apply at execution

Code defaults from AGENTS.md: floor + fee (3), edge ≤ 0.50 (3.05), price ≥ 0.12 (3.5), confidence ≥ medium (4.5), NO below 25c needs 25% edge and high confidence (4.6), every NO needs ≥ 8% (4.6b). Gates that need a live book (daily loss, exposure, dedup, opposing side) are not modelled here.

Reference price
independent fair values from public APIs
The Odds API GET
api.the-odds-api.com /v4/sports/…/odds
8–20 sportsbook lines → no-vig consensus
Sports stats
statsapi.mlb.com · api-web.nhle.com · site.api.espn.com
Venue weather
api.weather.gov
wind, rain and temperature at outdoor NFL and MLB venues
Edge engine
finds the gap, nets the fee, sizes the bet
Kalshi market data GET
api.elections.kalshi.com /markets · /orderbook
live ask, bid, volume, expiry
Fair-value model
ticker → ML · SP · TO · FU · PR · de-vig, CDF spreads and totals, calibrated stdevs
Edge, net of fee
fair − ask, with a confidence tier · edge ≥ floor + fee
22 risk gates
daily loss · exposure caps · liquidity · lead time · cheap-NO rules · opposing side · dedup · 10% hard stop
Kelly sizing
edge / (1 − price), fractional, divided by batch size · half-Kelly on NO at both price ends
Execute & track
orders, settlement, the calibration loop
Kalshi trade API POST
api.elections.kalshi.com /portfolio/orders
RSA-PSS signed limit order · venue eligibility checked first, fails closed
Positions & fills GET
/portfolio/positions · /fills
exposure, resting-order cleanup, measured fees
Settle & calibrate
27-field settlement record · model-vs-market Brier pair · stdev refit
Watch
daily digest · drift check against Kalshi's wording · post-kickoff order alarm
Outcomes loop back: settled results re-fit the stdevs and re-judge the thresholds. DRY_RUN=true is the default · gate spec ↗

Risk gates

Every order meets 22 gates. Most candidates fail here, cheaply.

The chain runs in order before any order is placed. Reject drops the bet, Cap trims it. Gates that read a market fact fail open when the fact is missing; the venue-eligibility check fails closed.

No gate matches that. Clear the filter or try another word.

Before the chain: venue eligibility, fails closedA live order needs a recorded ok for the venue and product. unknown blocks exactly like blocked; a structural rejection aborts the batch and nothing clears it automatically.
After the chain: the 10% hard stopThe last step of sizing caps any single position at 10% of bankroll and rejects it if even one contract would breach. Enforced in code, not only in the rules.

Pipeline

Seven stages. Scan, size, execute, settle.

One entry point, scripts/scan.py, runs the chain for sports or futures. A preview stops after stage 5 and prints what the gates said about every row it saw.

01FetchKalshi markets and order books, plus the Odds API and data feeds, through a short-TTL cache.
02CategorizeTicker → market type. ML · SP · TO · FU · PR each pick a model.
03CompareFair value against the ask, net of fee, with a confidence tier and a composite score.
04CapBracket dedup keeps the sibling that can clear the gates; per-event caps apply.
05Risk22 gates in order. Reject or trim. Preview prints the verdicts.
06ExecuteFractional Kelly size, shard funding, RSA-signed limit order. Dry run logs identically.
07SettleOutcomes, measured fees, Brier pair, drift and post-kickoff alarms. make settle
The betting path as data flow. Every box links to the code it describes; Route and Lens trace paths.

Coverage

What the scanner prices.

Each segment carries its own edge floor, and a floor of 1.0 is the idiom for switching a segment off. A segment with no settled history runs in dry run or on a pilot floor until it has evidence.

Sports

Moneylines, spreads, totals

Sportsbook consensus, de-vigged and weighted by book tier, against Kalshi's game markets. Thirty-one game filters across the major leagues, college, soccer, combat sports, motorsport, golf, tennis and esports.

NBANHLMLBNFL · pilotNCAAF · pilotNCAABMLS · soccerUFC · boxingF1 · NASCARPGAtennisesportsWorld Cup
Per-sport floors: MIN_EDGE_THRESHOLD_<SPORT>, narrowed by market type when needed.
Futures

Championship outrights

Outright odds across books, de-vigged into a field that sums to one, against each team's title market. Outcomes partition one event, so the per-event cap is its own knob.

NFLNBANHLMLBPGA majors
Exempt from the lead-time gate by category: a season is the event.

Schedule it

Every unattended job, as a Cronsole template.

The scans, settlement and upkeep this repo runs on a timer, published as templates for Cronsole. Import one, point it at your clone, and it runs on your own schedule. The two that can place orders start in preview.

Loading the templates…

Quick start

Clone, validate, preview. Nothing is risked.

Python 3.11 or later. A preview places nothing, and DRY_RUN=true is the default even with --execute, so the first live order is a decision you make in .env, not a side effect.


        
      

Copied