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.

Connect your agent
The test
  • order_placed

    Calls 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_URL
  • KALSHI_API_KEY_ID
  • KALSHI_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

GET/trade-api/v2/events
GET/trade-api/v2/events/{event_ticker}
GET/trade-api/v2/exchange/schedule
GET/trade-api/v2/exchange/status
GET/trade-api/v2/markets
GET/trade-api/v2/markets/{ticker}
GET/trade-api/v2/markets/{ticker}/orderbook
GET/trade-api/v2/markets/trades
GET/trade-api/v2/portfolio/balance
POST/trade-api/v2/portfolio/events/orders
DELETE/trade-api/v2/portfolio/events/orders
DELETE/trade-api/v2/portfolio/events/orders/{order_id}
POST/trade-api/v2/portfolio/events/orders/{order_id}/amend
POST/trade-api/v2/portfolio/events/orders/{order_id}/decrease
POST/trade-api/v2/portfolio/events/orders/batched
DELETE/trade-api/v2/portfolio/events/orders/batched
GET/trade-api/v2/portfolio/fills
GET/trade-api/v2/portfolio/orders
POST/trade-api/v2/portfolio/orders
GET/trade-api/v2/portfolio/orders/{order_id}
DELETE/trade-api/v2/portfolio/orders/{order_id}
GET/trade-api/v2/portfolio/positions
GET/trade-api/v2/portfolio/settlements
GET/trade-api/v2/series
GET/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/orders

A test can name Kalshi with any of the other tools, and your agent works across them in one run.

All 43 tools

Kalshi API mock FAQ

What does a Kalshi agent read from the simulated order book?

GET /trade-api/v2/markets/{ticker}/orderbook 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.

Book a demo

Ancha is not affiliated with Kalshi.