How to Build a Kalshi Trading Bot With AI

How I used Claude Code to automate Kalshi sports trading: architecture, API key security, fill rate, and a starter prompt to build your own.

Share
How to Build a Kalshi Trading Bot With AI
I built a Kalshi Trading bot...

The September video describes a Kalshi sports-market bot built with Claude Code. It reported hundreds of completed trades across several sports. Fact-checked November 2, 2026: this review did not audit the underlying account ledger, costs, or net returns. A reported trade count demonstrates neither profitability nor a durable advantage.

This guide explains the build process while keeping my private trading rules private. The useful output is a system whose behavior can be tested and reconciled, not a promise that a generated bot will make money.

Disclosure: the original video was not sponsored. This article contains a Kalshi referral link. Check current eligibility and terms at the destination; the recording’s $25 credit is not a guaranteed current offer.

What the bot does

The demonstrated system monitors inputs, evaluates specified rules, and sends permitted orders through an exchange API. A hosted process can operate without the creator’s laptop. That does not make it self-learning or remove supervision: the described implementation used human-defined rules, with AI assisting code development and analysis.

The architecture

Keep six components distinct: a licensed or otherwise permitted sports-data source, Kalshi market data, the strategy rules, an order manager, persistent records, and the runtime. Do not assume a scoreboard visible on a website is a supported real-time API. Verify coverage, access terms, latency, timestamps, and outage behavior for the chosen feed.

The order manager must understand more than “filled or rejected.” Orders can be resting, partially filled, canceled, expired, or uncertain after a timeout. Reconcile exchange state before retrying. A duplicate submission can create exposure even when the first response was lost.

Why automate a defined workflow?

Automation can reduce repeated manual steps and apply consistent checks. It does not remove emotion from selecting rules, changing size, or overriding losses, and it can execute a mistake repeatedly. Monitoring several games also does not guarantee diversification: contracts can share teams, drivers, or correlated outcomes.

Prerequisites

Start with a clearly described research question, public or authorized data access, a development environment, and a coding tool you can supervise. A read-only prototype does not need live trading funds. Kalshi offers a demo environment with mock funds and separate credentials; its market behavior may not match production.

Hosting is a separate budget. The video reported moving from a $6/month to a $24/month DigitalOcean tier. Current regular Basic tiers include those prices, but there is also a smaller $4 tier; capacity depends on the workload. Include data, backups, AI usage, and other charges when estimating cost. DigitalOcean pricing. A local computer avoids a server subscription but still uses electricity, connectivity, and maintenance.

Build and verify in stages

1. Describe the hypothesis

Write down exactly what you think the data predicts and why. A coding agent saying it can build the software establishes feasibility, not a market advantage. Define a baseline comparison and the evidence that would count against your idea.

2. Define observable inputs

Record the exact game or contract identifier, source timestamp, event state, bid and ask, available size, and any derived value. Define what happens when feeds disagree or arrive late. Never allow missing data to silently become a zero, a false condition, or a trading signal.

3. Specify conditions and actions

Translate each condition into examples that should trigger and examples that should not. Include market closure, postponement, settlement changes, stale quotes, and existing exposure. Use contract-specific rules for ties, overtime, cancellations, and rescheduling rather than assuming every sport follows the same convention.

4. Test enforceable limits

Set limits for order size, total exposure per event, aggregate daily exposure, open orders, acceptable price, and data age. Include fees and pending orders in the relevant budget. Test that the implementation actually rejects a violation; a prompt asking for a limit is not proof of enforcement.

For a fully collateralized binary purchase held to resolution, the amount at risk is the acquisition cost plus fees. The earlier blanket “maximum risk is $0.99 per contract” omitted fees and was not a valid universal rule. Repeated small orders can still create substantial cumulative losses. This guide does not apply that binary-payout model to perpetual futures.

5. Protect credentials and match the environment

Follow Kalshi’s API-key documentation. Current keys support Ed25519 and RSA, with the signing method matched to the actual key type. Use separate demo and production credentials and select only necessary permissions.

Keep private keys in a protected secret file or service outside the code repository. Do not paste them into AI chats, screenshots, logs, or source control. “Stored alongside the code” is not a sufficient security instruction. If a key is exposed, revoke it and replace it through the provider’s controls.

6. Test the runtime in non-live mode

Before deployment, test the logic locally. On the server, verify service health, logging, persistent state, and recovery after a restart. Configure failures to stop new decisions when required data or order status is uncertain. A process that restarts automatically can repeat a bug unless its state handling is correct.

7. Begin with dry-run and demo checks

The earlier article recommended skipping paper trading for a live one-contract test. That has been corrected. Dry-run and demo tests can expose logic, authentication, sizing, and duplicate-order defects before real funds are involved.

These tests cannot establish production fill quality. If you later choose a live test, separately review its maximum aggregate exposure, costs, monitoring, and shutdown procedure. A small position can still lose its full cost and fees; it is not a harmless substitute for testing.

8. Reconcile the records

Save input snapshots, code and parameter versions, intended actions, client and exchange order identifiers, acknowledgments, fills, fees, cancellations, and settlement outcomes. Compare the ledger with the exchange account. An assistant’s “done” message is not a trade receipt.

A starter prompt framework

Help me build a research prototype for a Kalshi strategy.
Do not place real orders or enable live trading.

First clarify:
1. The exact contracts, settlement rules, and data sources.
2. The hypothesis, measurable inputs, and timestamp requirements.
3. Entry and exit conditions, including examples that must be skipped.
4. Exposure limits, fees, pending orders, and a shutdown condition.
5. What records will allow independent reconciliation.

Build a read-only decision log first. Then create tests for stale data,
missing fields, partial fills, duplicate messages, timeouts, and restart
recovery. Use separate demo credentials for any supported order tests.
Keep secrets outside the repository and never print them.

Document model versions and evaluate on new data. Prepare any production
configuration as a proposal only, with live trading disabled. Stop and
report unresolved assumptions before moving to another stage.

The improvement loop

Observe, inspect, and decide what the evidence supports. Fix software defects immediately. Treat changes intended to improve returns as new research hypotheses, retain the old results, and evaluate on fresh data. Repeatedly tuning the same small sample can overfit it.

What a small sample can tell you

Four trades can reveal a wrong symbol, an unexpected fee, or a duplicate-order bug. They ordinarily cannot establish a durable edge or capacity at larger size. There is no universal trade-count threshold: dependence among trades, payoff variation, and uncertainty all matter.

Changing a rule does not erase historical observations, but the old record is not a clean forward test of the new rule. Keep versions separate rather than blending them into one headline performance number.

What to review

Check whether the bot did what the rules specified, whether orders filled, which orders did not, what fees applied, and how exposure changed. Examine missed fills and adverse selection as well as completed trades. Separate operational failures from a strategy losing according to its intended rules.

Fees and fills belong in the model

An order that immediately matches resting liquidity is a taker, including a marketable limit order. A resting limit order is not guaranteed to fill, and some markets charge maker fees. Check the contract’s current schedule and actual transaction records. Kalshi fee guidance.

For an illustrative $1 binary payout, a 45¢ purchase with a true 50% win probability has a 5¢ gross expected value before costs. The true probability is not known simply because a model says 50%. Fees, execution, and selection among filled orders can remove the apparent advantage. Holding through settlement and selling before settlement also have different cash-flow paths; do not automatically charge an exit trade that never occurred.

Why the private rules remain private

This tutorial teaches the build process without publishing my live strategy. That choice does not prove that the strategy has an edge or that any reader can reproduce its reported results. The evidence required to evaluate performance remains the same.

Alpha decay has several causes

Crowding and market impact can reduce a strategy’s advantage, but so can a changed market regime, higher costs, or a mistaken original estimate. Decay can be abrupt or gradual. A freely published method is not automatically worthless, and a private method is not automatically profitable.

Set expectations from evidence

No universal win rate or edge size is established here. A high win rate can coexist with a negative expectation if losses are large or prices are unfavorable. Capacity depends on the specific market’s executable liquidity and how the strategy changes prices, not a fixed dollar ceiling for every game.

Mistakes to avoid

Avoid untested live execution, omitted fees, unprotected credentials, stale data, and blind retries. Do not treat an AI-generated explanation as proof the implementation matches it. Review actual behavior and account records.

Frequently asked questions

Can AI write the bot? It can help write and explain code. Human review and tests are still necessary.

Should I paper trade first? Begin with read-only and demo checks, while recognizing their limits for predicting live fills.

Does the bot learn by itself? The version described in the video used rules set by a human. Do not infer adaptive learning from the use of AI to write code.

Is a successful connection enough to go live? No. It verifies access, not strategy performance or correct order handling.

The first deliverable

Build a reproducible decision log and a tested order-state workflow with live trading disabled. Evaluate the hypothesis and execution assumptions separately. Software that runs without your laptop is not evidence of passive income.