- Preface
- What this book is about
- Who it is for
- What "AI-powered" means here
- What this book will not do
- How to read it
- Chapter 1. How a Kalshi contract makes and loses money
- 1.1 The contract
- 1.2 The order book
- 1.3 Fees
- 1.4 Profit and loss on one trade
- 1.5 Expected value: the only number that matters before a trade
- 1.6 Exiting early
- 1.7 Who is on the other side?
- 1.8 Settlement timing and cash
- 1.9 Summary
- Chapter 2. Where edges come from, and where they do not
- 2.1 What an edge is
- 2.2 Efficient where liquid
- 2.3 The exchange scan: there is no free lunch in the prices alone
- 2.4 Edges decay
- 2.5 Why not ask an LLM to pick trades?
- 2.6 A checklist for choosing a market
- 2.7 Summary
- Chapter 3. The shape of the whole system
- 3.1 The components
- 3.2 Design rule 1: one code path for backtest and live
- 3.3 Design rule 2: freeze the model as data
- 3.4 Design rule 3: an append-only ledger is the source of truth
- 3.5 Design rule 4: isolate the outside world
- 3.6 Design rule 5: fail closed
- 3.7 The daily timeline
- 3.8 Where it runs
- 3.9 Repository layout
- 3.10 Summary
- Chapter 4. Data: point-in-time or nothing
- 4.1 The three datasets
- 4.2 A polite, resumable downloader
- 4.3 Settled markets
- 4.4 Quotes at decision time
- 4.5 Forecasts as they were issued
- 4.6 Point-in-time traps, collected
- 4.7 Check the data before you trust it
- 4.8 Short histories and splices
- 4.9 Summary
- Chapter 5. A forecasting model you can explain
- 5.1 What the model has to produce
- 5.2 Step 1: a regression on the four forecasts
- 5.3 Step 2: how wrong is the model, honestly?
- 5.4 Step 3: from a distribution to a bin probability
- 5.5 Measuring a probability model
- 5.6 Why keep the model this simple?
- 5.7 Summary
- Chapter 6. Blending the model with the market
- 6.1 The idea
- 6.2 Fitting it
- 6.3 What the weather blend found
- 6.4 Fitting the blend walk-forward
- 6.5 The trading rule
- 6.6 The blend live
- 6.7 The blend as a universal test
- 6.8 Pitfalls
- 6.9 Summary
- Chapter 7. Backtesting without lying to yourself
- 7.1 The stages
- 7.2 Stage 0: pre-register
- 7.3 Stage 3: walk-forward
- 7.4 Stage 4: try to break it
- 7.5 Stage 5: the holdout, once
- 7.6 Check the engine and the benchmark
- 7.7 Review code you did not write
- 7.8 Keep two documents
- 7.9 Write the verdict before the caveats, and not on the same day
- 7.10 Summary
- Chapter 8. P&L accounting that survives contact with reality
- 8.1 The unit: net cents per contract
- 8.2 From ledger to P&L
- 8.3 How many trades do you need?
- 8.4 Confidence intervals that respect correlation
- 8.5 Expected edge versus realized edge
- 8.6 Calibration: the signal that arrives before P&L
- 8.7 Live minus paper: measuring fills
- 8.8 Equity curves and drawdowns
- 8.9 Watching for decay
- 8.10 Pitfalls, collected
- 8.11 Taxes and records
- 8.12 Summary
- Chapter 9. Sizing, capacity, and the limits of compounding
- 9.1 Start flat
- 9.2 The Kelly fraction for a binary contract
- 9.3 Simulating the bankroll
- 9.4 Capacity: the book decides, not the formula
- 9.5 Variance versus return: the cash-out lesson
- 9.6 Why the backtest edge is an upper bound
- 9.7 Floors and drawdown halts
- 9.8 A sensible progression
- 9.9 Summary
- Chapter 10. From paper to live: the executor
- 10.1 Paper first, and keep paper running
- 10.2 Three modes
- 10.3 An API client that refuses by default
- 10.4 Re-price immediately before ordering
- 10.5 Immediate-or-cancel at the quoted price
- 10.6 Sizing and limits, in order
- 10.7 Idempotency and unknown states
- 10.8 The owner's controls
- 10.9 Test the order path, then test the tests
- 10.10 Going live: a checklist
- 10.11 Summary
- Chapter 11. The AI agent: operator, researcher, never the trader
- 11.1 What the agent does
- 11.2 The supervisor
- 11.3 Actions are text; the human holds the buttons
- 11.4 The policy document
- 11.5 Experiments as pull requests
- 11.6 Deploying merged code safely
- 11.7 Keeping the agent cheap
- 11.8 What the agent is good and bad at here
- 11.9 Building your own
- 11.10 Summary
- Chapter 12. Deployment and day-to-day operation
- 12.1 Where it runs
- 12.2 Secrets
- 12.3 Deploying changes
- 12.4 Frozen means frozen
- 12.5 What to monitor
- 12.6 Incidents
- 12.7 Back up the record
- 12.8 A weekly routine for the owner
- 12.9 Summary
- Chapter 13. What failed, and what it taught
- 13.1 Kalshi experiments
- 13.2 Patterns across the failures
- 13.3 Where the weather strategy stands
- 13.4 What has not been tried
- 13.5 The last lesson
- Appendix A. Pre-registration template
- Appendix B. Checklists
- Appendix C. Kalshi API notes
- Appendix D. Glossary
How to Build an AI-Powered Kalshi Trading System
Build a Kalshi trading system in Python, and learn to tell a real edge from a lucky backtest: point-in-time data, a model blended with the market, honest walk-forward tests, and P&L you can verify.
Minimum price
$9.00
$16.00
You pay
Author earns
About
About the Book
Most trading books show you a backtest that made money. This one shows you how to find out whether yours really did.
How to Build an AI-Powered Kalshi Trading System walks Python developers through building a complete system for Kalshi's event contracts: the data pipeline, the model, the backtest, the P&L accounting, the order executor, and an AI agent that runs the whole thing day to day. You don't need any trading background. Chapter 1 starts from what a contract is and how the fee works.
What you'll build
- A data pipeline that records only what was knowable at decision time: issued weather forecasts, the quote that existed, outcomes already settled
- A forecasting model that turns four global weather models into a probability for each temperature bin
- A blend of that model with the market price, and the single statistical test that tells you whether your model knows anything the market doesn't
- Walk-forward backtests with pre-registered pass/fail criteria, trial counting, and deliberate attempts to break the result
- P&L reported per contract with confidence intervals, plus the arithmetic for how many trades you need before a result means anything
- An executor that fails safe: limits in code, idempotent orders, and a pause only the owner can lift
- An LLM agent that monitors, reports, investigates and drafts research as pull requests, behind guardrails it cannot remove
What makes it different
The book is built on a real research record, failures included. About ten Kalshi market families were tested. The model lost money in the liquid, professionally quoted markets (Bitcoin 15-minute contracts, hourly crypto ladders), found no exploitable bias across nearly 1,000 markets exchange-wide, and failed on gas prices, mention markets and more. Every one of those results is in the book with its numbers, so you can skip them.
One strategy passed: daily high-temperature markets. Its walk-forward backtest earned +5.5 cents per contract after fees (95% confidence interval +3.1 to +8.0, 1,332 trades), and +7.5 cents on 13 cities it was never fitted on. The raw weather model alone earned about zero; the edge came from blending it with the market price. The book explains why, and is just as plain about the caveats: most of the profit came in one winter, the order books are thin, and the forward test was still running at publication.
What "AI-powered" means here
The trading decisions come from a small, explainable statistical model, not a chatbot. The book explains why an LLM is a poor direct trader in these markets, and then puts one to work where it is genuinely useful: operating, monitoring and researching, fenced off from the money.
Who it's for
Python developers who can call an API and write a unit test, and who want a rigorous, honest method rather than a get-rich promise. The method (point-in-time data, blending, walk-forward testing, P&L with intervals) carries over to whatever market you try next.
This book is for education only and is not financial advice. It is independent and not affiliated with or endorsed by Kalshi.
Feedback
Author
About the Author
Contents
Table of Contents
Get the free Community Edition
You can get the free Community Edition in PDF or EPUB just by sharing your name and email address with the author.
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.