Short answer:Yes, ChatGPT and Codex can build a trading bot, but they can't make it profitable, and they often remember outdated API endpoints. The safe way is to give the model the official Kalshi docs, put the BotCookery rules in AGENTS.md, run on Kalshi's demo exchange, keep keys in env vars, and enforce limits and a kill switch in code.
Chat vs agent: in chat you copy code by hand (slower, you see every line). An agent like Codex edits files and runs commands (faster, so rules matter more).
Put the BotCookery rules in AGENTS.md in the repo root. Many coding agents, Codex included, read it for project instructions.
Give the model the docs. Paste or link the Kalshi pages you're using. Models often remember old endpoints, and Kalshi moved order creation to POST /portfolio/events/orders (V2).
Use Kalshi's demo exchange: https://external-api.demo.kalshi.co/trade-api/v2, with mock funds and separate keys.
Never paste keys into ChatGPT. Use env vars and a key-file path that lives outside the project.
DifficultyBeginner
Time1–2 hours
Cost$0 API · ChatGPT subscription
Works withChatGPT, Codex
What will you build?
Use ChatGPT (chat) or Codex (agent) to build a small Kalshi bot that runs on the demo exchange, with the BotCookery rules in AGENTS.md and every safety layer in place.
Who is it for?
ChatGPT users who want to turn "write me a trading bot" into something that won't hurt them.
Not for:Asking ChatGPT which trades to make. That's not what this is, and it's not reliable.
What prompt do you paste into your AI coding tool?
Works in Claude Code, Cursor, Codex/ChatGPT, Grok or any agent that can write files. Paste it into an empty folder. Read what it builds before you run anything.
Act as a careful senior Python developer. I'm building a small Kalshi bot
that runs ONLY on the Kalshi demo exchange. Follow AGENTS.md (pasted below).
Use only endpoints from the Kalshi docs pages I paste below. If something
isn't in them, say so instead of guessing.
Build, one file at a time, waiting for my "next" between files:
1. kalshi_client.py: signed requests. Headers KALSHI-ACCESS-KEY,
KALSHI-ACCESS-TIMESTAMP (milliseconds), KALSHI-ACCESS-SIGNATURE =
base64(sign(timestamp + METHOD + path)), path starting /trade-api/v2,
query string removed. RSA keys: RSA-PSS + SHA-256 (salt = digest length);
Ed25519 keys: sign directly. Base URL fixed to
https://external-api.demo.kalshi.co/trade-api/v2. Key id and key FILE PATH
from env vars.
2. risk.py: limits.json (1 contract/order, $5 exposure, $2 daily loss,
3 orders/min) + KILL file check. With tests.
3. bot.py: watch one ticker (GET /markets/{ticker}); if the best YES ask is
<= my max price in config.toml, propose a 1-contract limit bid; call
risk.check_order; place with POST /portfolio/events/orders using ticker,
side "bid", count "1", price as a dollar string like "0.4500",
time_in_force "good_till_canceled", self_trade_prevention_type
"taker_at_cross", client_order_id uuid4. Log to logs/decisions.jsonl.
4. cancel_all.py: DELETE /portfolio/events/orders.
5. README + .gitignore (.env, *.pem, KILL, logs/).
After each file, explain it in plain English and list risks.
--- AGENTS.md ---
[PASTE THE SAFETY PACK RULES FILE]
--- KALSHI DOCS ---
[PASTE: Quick Start authenticated requests + Create Order V2 pages]
How do you build it, step by step?
Get Kalshi demo keys at demo.kalshi.co and save the key file outside your project.
Create AGENTS.md from the Safety Pack rules file in a new folder, along with the .gitignore.
Paste the prompt with the rules and the two Kalshi docs pages filled in. In Codex, point it at the repo and let it read AGENTS.md.
Go file by file. The "wait for next" instruction keeps changes small enough to actually read.
Run the tests after risk.py, before any code that places orders.
Run on demo with python bot.py, then drill touch KILL and python cancel_all.py.
Ask ChatGPT to review its own code for security issues: "List every place a secret could leak or an unintended order could be sent." Then fix what it finds and check the fixes yourself.
How do you test it in paper or demo mode first?
The client hardcodes Kalshi's demo URL. Demo uses mock funds and separate credentials, so you can make every beginner mistake for free. Kalshi notes demo prices may not reflect real markets, so judge your code there, not your strategy.
Keep a simple log: what the bot saw, what it proposed, what risk decided, what the exchange returned. Review it daily for a week before considering anything else.
What safety checks does it need before real money?
Tick every box before the bot touches real money. The full rules file, .gitignore and pre-commit hook are in the Safety Pack.
Key handling: API keys and private-key files live in environment variables or a secrets manager. Never in code, prompts, chat logs, screenshots or git. .env and *.pem are in .gitignore, and your AI tool is blocked from reading them (see the Safety Pack).
Position limits: hard caps in config (max contracts per order, max total exposure, max daily loss). The bot refuses any order above them, and the caps are checked in code, not just in the prompt.
Kill switch: one command or one file (touch KILL) stops new orders immediately, and a second command cancels every resting order through the venue's cancel-all endpoint.
Paper first: paper or demo mode is the default. Live trading needs an explicit --live flag and a typed confirmation, and you only flip it after days of clean paper logs.
Don't paste keys, key files or account screenshots into ChatGPT.
Make sure the model uses POST /portfolio/events/orders (V2). If it writes the legacy /portfolio/orders, it's working from old memory, so re-paste the docs.
Review every command an agent wants to run, especially git push, curl to unknown hosts, and anything touching ~/.ssh or key files.
Endpoints and rules were checked against these pages on Oct 19, 2026. APIs change, so if something here disagrees with the official docs, trust the docs and tell us.
Frequently asked questions
Can ChatGPT make a trading bot?
ChatGPT can write the code for a trading bot, including API clients, risk checks and tests, especially if you give it the official docs. It can't make the bot profitable or guarantee it's bug-free, so run it in demo or paper mode and review the code.
Is a ChatGPT trading bot profitable?
There's no evidence that asking ChatGPT for trades produces reliable profits, and BotCookery doesn't make profit claims. Use ChatGPT to build tools; make trading decisions yourself, carefully, with limits.
Should I use ChatGPT chat or Codex?
Chat is slower but you see every line you copy. Codex edits your project directly, which is faster, so put the safety rules in AGENTS.md and review its changes before running them.
Why does ChatGPT write old Kalshi endpoints?
Models learn from older documentation. Kalshi's current order endpoint is POST /portfolio/events/orders (Create Order V2), and the docs say the legacy /portfolio/orders will be deprecated no earlier than May 6, 2026. Paste the current docs into your prompt.
The Daily Bot Recipe
One new build recipe, one safety tip, and API changes worth knowing about. Free. No picks, ever.
Get started with the Kalshi API using an AI coding tool: public market data with no key, then RSA-PSS or Ed25519 signed requests against the Kalshi demo environment. Endpoints checked against the official docs.
Use an AI coding tool to build your own Kalshi trading bot that runs on the Kalshi demo environment first, with order groups, reduce-only exits, a kill switch and optional LLM-assisted research that never sees your keys.
An honest guide to building a trading bot with Claude, Claude Code or Claude AI: where it helps, where it fails, and a safe Kalshi-demo starter prompt with a rules file, deny settings, limits and a kill switch.