A Kalshi API mock for testing order placement.
Your agent reads seeded markets and its portfolio balance, then places an order. A trace check confirms the order request.
order_placedCalls POST /trade-api/v2/portfolio/orders
Starting records
orders
- market
KXFEDDECISION-26DEC-C25- price
0.47
series
- ticker
KXFEDDECISION- title
Fed rate decision
Connect your agent to the Kalshi mock
When ancha runs your agent, it sets:
KALSHI_API_URLKALSHI_API_KEY_IDKALSHI_PRIVATE_KEY
Point the client you already use at them.
import { Configuration, MarketApi, PortfolioApi } from 'kalshi-typescript';
const config = new Configuration({ apiKey: process.env.KALSHI_API_KEY_ID, privateKeyPem: process.env.KALSHI_PRIVATE_KEY, basePath: process.env.KALSHI_API_URL, baseOptions: { proxy: false } });
const { data } = await new PortfolioApi(config).getBalance();
const { data: markets } = await new MarketApi(config).getMarkets(100);Locally, ancha runs your agent as an ordinary process, so keep real Kalshi credentials out of its environment.
See all 25 endpoints
trade-api
/trade-api/v2/events/trade-api/v2/events/{event_ticker}/trade-api/v2/exchange/schedule/trade-api/v2/exchange/status/trade-api/v2/markets/trade-api/v2/markets/{ticker}/trade-api/v2/markets/{ticker}/orderbook/trade-api/v2/markets/trades/trade-api/v2/portfolio/balance/trade-api/v2/portfolio/events/orders/trade-api/v2/portfolio/events/orders/trade-api/v2/portfolio/events/orders/{order_id}/trade-api/v2/portfolio/events/orders/{order_id}/amend/trade-api/v2/portfolio/events/orders/{order_id}/decrease/trade-api/v2/portfolio/events/orders/batched/trade-api/v2/portfolio/events/orders/batched/trade-api/v2/portfolio/fills/trade-api/v2/portfolio/orders/trade-api/v2/portfolio/orders/trade-api/v2/portfolio/orders/{order_id}/trade-api/v2/portfolio/orders/{order_id}/trade-api/v2/portfolio/positions/trade-api/v2/portfolio/settlements/trade-api/v2/series/trade-api/v2/series/{series_ticker}Seed your own data
The data the Kalshi mock starts with on every run, cut to a few records. ancha twins seed kalshi prints every field.
Full seed YAML
twins:
- kalshi
seed:
kalshi:
account:
name: Acme treasury
deposits:
- amount: 20000
at: -2000h
series:
- ticker: KXFEDDECISION
title: Fed rate decision
category: Economics
tags:
- Fed
settlementSources:
- name: Federal Reserve
url: https://www.federalreserve.gov/monetarypolicy.htm
events:
- ticker: KXFEDDECISION-26DEC
series: KXFEDDECISION
title: Fed decision in December 2026
subTitle: Dec 9, 2026
mutuallyExclusive: true
strikeDate: 940h
markets:
- suffix: C25
subtitle: Cut 25bps
yesSubTitle: Cut 25bps
noSubTitle: Not cut 25bps
open: -1400h
close: 939h55m
rulesPrimary: If the Federal Reserve’s upper bound for the federal funds target range after its December 2026 meeting is 0.25 percentage points lower, the market resolves to Yes.
lastPrice: 0.57
previousPrice: 0.53
openInterest: 251000
volume: 910000
book:
yes:
- - 0.55
- 6000
no:
- - 0.41
- 6000
trades:
- at: -5h
count: 1200
yesPrice: 0.56
takerSide: yes
orders:
- market: KXFEDDECISION-26DEC-C25
side: bid
price: 0.47
count: 1000
created: -300h
clientOrderId: fed-cut-hedge-1
fills:
- at: -300h
count: 1000
price: 0.46
Check what your agent did
Checks YAML
checks:
- id: order_placed
trace:
called: POST /trade-api/v2/portfolio/ordersA test can name Kalshi with any of the other tools, and your agent works across them in one run.
All 43 toolsKalshi API mock FAQ
What does a Kalshi agent read from the simulated order book?
GET / returns orderbook_fp with yes_dollars and no_dollars price-and-size pairs. A positive depth returns up to that many best price levels on each side, listed from lowest price to highest.
What if my trading agent submits the same client order ID twice?
Ancha’s Kalshi mock rejects an order whose client_order_id is already in use with 409 and order_already_exists.
Can I test immediate-or-cancel orders against seeded liquidity?
Set time_in_force to immediate_or_cancel when creating an order in the Kalshi mock. An accepted order takes matching liquidity within its price limit and cancels any unfilled quantity.
Install the CLI and run your agent against the Kalshi mock.
Ancha is not affiliated with Kalshi.