> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ancha.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These docs describe the Ancha CLI, npm package @ancha-labs/cli version 0.1.4, and the hosted workspace at app.ancha.io. Coding agents should start at https://docs.ancha.io/coding-agents. Run the CLI as `ancha` after `npm install -g @ancha-labs/cli`, or as `npx -y @ancha-labs/cli@0.1.4` without installing. Pass --json for machine-readable output, or set ANCHA_JSON=1. Every command ends with a `next:` line naming the next command. Exit codes: 0 pass, 1 a check failed or a comparison regressed, 2 usage, config or authentication error, 3 infrastructure error, 4 unimplemented endpoint with --strict.

# Kalshi

> A stateful replica of Kalshi's Trade API v2: series, events and markets, order books, orders and fills, positions and settlements for one trading account.

The Kalshi replica implements 25 endpoints of the Trade API v2 for one trading account. Orders trade against other traders' resting bids seeded with the scene, with Kalshi's fee, and no money moves. Its key is `kalshi`. It was tested with `kalshi-typescript`.

## Connect

| Variable | Value |
| - | - |
| `KALSHI_API_URL` | Base URL, ending in `/trade-api/v2`. Pass it as the SDK's `basePath`. |
| `KALSHI_API_KEY_ID` | Fake API key ID (`apiKey` in the SDK). |
| `KALSHI_PRIVATE_KEY` | Fake RSA private key in PEM form (`privateKeyPem` in the SDK). Requests are signed with RSA-PSS over the timestamp, method and path, as on Kalshi. |

```js Node theme={null}
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);
```

This is what `ancha connect kalshi --lang ts` prints. The timestamp's age is not checked.

## Endpoints

All 25 endpoints are partial. Anything else returns HTTP 501 with `x-ancha-gap: 1`.

| Method | Path | Notes |
| - | - | - |
| `GET` | `/trade-api/v2/exchange/status` | |
| `GET` | `/trade-api/v2/exchange/schedule` | Open around the clock; no maintenance windows. |
| `GET` | `/trade-api/v2/series` | `category` and `tags` filters. |
| `GET` | `/trade-api/v2/series/{series_ticker}` | |
| `GET` | `/trade-api/v2/events` | `status`, `series_ticker`, `tickers` and `with_nested_markets`; cursor pagination. |
| `GET` | `/trade-api/v2/events/{event_ticker}` | |
| `GET` | `/trade-api/v2/markets` | Event, series, status, tickers and close, created and settled time filters; cursor pagination. |
| `GET` | `/trade-api/v2/markets/trades` | The public tape, including the account's own executions. |
| `GET` | `/trade-api/v2/markets/{ticker}` | Quotes from the order book; status follows the scene clock (active, closed, finalized). |
| `GET` | `/trade-api/v2/markets/{ticker}/orderbook` | Yes and No bids as fixed-point dollars and counts, with depth. |
| `GET` | `/trade-api/v2/portfolio/balance` | Cash less what resting orders hold. |
| `GET` | `/trade-api/v2/portfolio/positions` | Netted Yes/No positions with exposure, realized P\&L and fees; `settlement_status` and `count_filter`. |
| `GET` | `/trade-api/v2/portfolio/fills` | |
| `GET` | `/trade-api/v2/portfolio/settlements` | Markets the scene settles pay 1 USD per winning contract. |
| `GET` | `/trade-api/v2/portfolio/orders` | Status, ticker, event and time filters. |
| `POST` | `/trade-api/v2/portfolio/orders` | The older yes/no endpoint; limit orders only. |
| `GET`, `DELETE` | `/trade-api/v2/portfolio/orders/{order_id}` | |
| `POST` | `/trade-api/v2/portfolio/events/orders` | A bid or ask on one Yes book. Takes other traders' bids at their price, charges Kalshi's fee, then rests or cancels. Fill-or-kill, immediate-or-cancel, post-only, reduce-only and self-trade prevention. |
| `DELETE` | `/trade-api/v2/portfolio/events/orders` | |
| `POST`, `DELETE` | `/trade-api/v2/portfolio/events/orders/batched` | Up to 20, each with its own result or error. |
| `DELETE` | `/trade-api/v2/portfolio/events/orders/{order_id}` | |
| `POST` | `/trade-api/v2/portfolio/events/orders/{order_id}/amend` | Price, total count and expiration; a crossing price trades. |
| `POST` | `/trade-api/v2/portfolio/events/orders/{order_id}/decrease` | |

## Starter data

The `kalshi-starter` dataset is the account **Acme treasury**, funded with one 20,000 USD deposit, and three series with open markets whose books hold other traders' resting bids.

| Series | Event | Markets |
| - | - | - |
| `KXFEDDECISION` Fed rate decision | `KXFEDDECISION-26DEC`, "Fed decision in December 2026", mutually exclusive, strikes 940 hours after start | Hold rates (last 0.38), Cut 25bps (0.57), Cut more than 25bps (0.04) and Hike 25bps (0.02). |
| `KXCPIYOY` CPI year-over-year | `KXCPIYOY-26OCT`, "CPI year-over-year in October 2026" | Above 2.7% (0.71), above 2.9% (0.36) and above 3.1% (0.12). |
| `KXHIGHNY` Highest temperature in NYC | `KXHIGHNY-26NOV01`, "Highest temperature in NYC on Nov 1, 2026", closing 38 hours after start | Five temperature ranges from 53° or below to 60° or above. |

The account holds five orders on the Fed and CPI markets: two filled bids and one filled ask on "Cut 25bps", a partly filled and canceled bid on "Above 3.1%", and a resting bid on "Above 2.9%". Their fills, positions and fees are in the portfolio.

## Checks

Kalshi has no state checks. Use trace checks, for example `{ called: "POST /trade-api/v2/portfolio/events/orders" }` or `{ not_called: "DELETE /trade-api/v2/portfolio/events/orders*" }`.

## Limits

* Requests are signed with RSA-PSS as on Kalshi; the timestamp's age is not checked.
* Orders trade against other traders' resting bids seeded with the scene, at the resting price, with Kalshi's fee. Nobody else trades unless the scene says so, and no money moves.
* Primary subaccount only. No order groups, RFQs or quotes, candlesticks, historical data, WebSockets or FIX.


## Related topics

- [Tools](https://docs.ancha.io/tools/overview.md)
- [Test file (scene.yaml)](https://docs.ancha.io/reference/test-file.md)
- [ancha connect](https://docs.ancha.io/cli/connect.md)
- [Environment variables](https://docs.ancha.io/reference/environment-variables.md)
- [Introduction](https://docs.ancha.io/index.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.