Kalshi

From mvanhorn/printing-press-library · View interactive version

Kalshi is an AI agent skill from the GitHub repository mvanhorn/printing-press-library. Trade prediction markets, persist tick data, and answer category-level P&L questions Kalshi.com cannot. Trigger phrases: `kalshi market price`, `track prediction market`, `kalshi portfolio P&L`, `kalshi correlate markets`, `use kalshi`, `run kalshi`.

How to use this skill

Skill file

Kalshi — Printing Press CLI

Prerequisites: Install the CLI

This skill drives the kalshi-pp-cli binary. You must verify the CLI is installed before invoking any command from this skill. If it is missing, install it first:

  1. Install via the Printing Press installer. It defaults binaries to $HOME/.local/bin on macOS/Linux and %LOCALAPPDATA%\Programs\PrintingPress\bin on Windows:

```bash

npx -y @mvanhorn/printing-press-library install kalshi --cli-only

```

  1. Verify: kalshi-pp-cli --version
  2. Ensure the reported install directory is on $PATH for the agent/runtime that will invoke this skill.

If the npx install fails (no Node, offline, etc.), fall back to a direct Go install (requires Go 1.26.6 or newer). This installs into $GOPATH/bin (default $HOME/go/bin), so add that directory to $PATH instead:

go install github.com/mvanhorn/printing-press-library/library/payments/kalshi/cmd/kalshi-pp-cli@latest

If --version reports "command not found" after install, the runtime cannot see the binary directory on $PATH. Do not proceed with skill commands until verification succeeds.

Every Kalshi feature, plus a local SQLite store that records market prices on every sync — so movers, correlations, and price history work offline. Honest about read-only vs read/write keys, with --dry-run on every mutator and a global --read-only safe-mode lock for newsroom and bot deployments.

When to Use This CLI

Reach for kalshi-pp-cli when an agent needs price-over-time or category-level analytics on Kalshi markets — the public API only returns current prices and flat positions, so historical and aggregated questions require the local snapshot store. Use it for daily portfolio reconciliation, signal discovery via correlation across markets, and safe scripting against read-only API credentials.

Unique Capabilities

These capabilities aren't available in any other tool for this API.

Local state that compounds

_Use when an agent needs realized P&L sliced by Kalshi taxonomy — the API returns flat fills and settlements; this command joins them with the category metadata required to attribute correctly._

```bash

kalshi-pp-cli portfolio attribution --since 2026-01-01 --by category --json

```

_Use when an agent asks 'how did this market move' or needs price-over-time for backtesting; the API only returns current price._

```bash

kalshi-pp-cli markets history KXPRES-2028-DJT --since 2026-04-01 --sparkline

```

_Use when an agent evaluates trading-strategy performance; no Kalshi tool computes this._

```bash

kalshi-pp-cli portfolio winrate --category sports --since 2026-01-01 --json

```

_Use when an agent needs to plan around upcoming settlements; the API surfaces positions and event expiries on different endpoints._

```bash

kalshi-pp-cli portfolio calendar --days 14

```

_Use when an agent needs to surface notable market activity; the API has no 'recent movers' endpoint._

```bash

kalshi-pp-cli markets movers --window 24h --category politics --json

```

_Use when an agent investigates cross-market relationships; no API endpoint or other tool computes correlation across Kalshi markets._

```bash

kalshi-pp-cli markets correlate KXFEDFUNDS-26FEB KXCPI-26FEB --window 30d --json

```

_Use when an agent needs portfolio-level risk; the API doesn't aggregate exposure by Kalshi taxonomy._

```bash

kalshi-pp-cli portfolio exposure --by category --warn-threshold 0.4 --json

```

_Use when an agent tracks a stable set of markets across runs; the API has no watchlist concept._

```bash

kalshi-pp-cli watch diff --since 24h

```

Honest auth

_Use when an agent runs against an unknown Kalshi key tier — the read-only key tier exists and mid-script 403s are common; this surfaces the constraint client-side before the API is hit._

```bash

kalshi-pp-cli --read-only portfolio create-order --ticker KXTEST --side yes --count 1 --yes-price 50 --dry-run

```

_Use when an FCM-tier user needs aggregate risk across subaccounts; no Kalshi tool surfaces a household view._

```bash

kalshi-pp-cli subaccounts rollup --by category --json

```

Command Reference

account — Manage account

api-keys — API key management endpoints

communications — Request-for-quote (RFQ) endpoints

events — Event endpoints

exchange — Exchange status and information endpoints

fcm — FCM member specific endpoints

historical — Manage historical

incentive-programs — Incentive program endpoints

kalshi-trade-manual-search — Manage kalshi trade manual search

kalshi-trade-manual-search-2 — Manage kalshi trade manual search 2

live-data — Live data endpoints

markets — Market data endpoints

milestones — Milestone endpoints

multivariate-event-collections — Manage multivariate event collections

portfolio — Portfolio and balance information endpoints

series — Manage series

structured-targets — Structured targets endpoints

Finding the right command

When you know what you want to do but not which command does it, ask the CLI directly:

kalshi-pp-cli which "<capability in your own words>"

which resolves a natural-language capability query to the best matching command from this CLI's curated feature index. Exit code 0 means at least one match; exit code 2 means no confident match — fall back to --help or use a narrower query.

Recipes

Politics-category P&L this quarter

kalshi-pp-cli portfolio attribution --since 2026-01-01 --by category --agent --select 'rows.category,rows.realized_pnl,rows.fills'

Realized P&L attributed to Kalshi taxonomy; --select narrows the response to the three fields agents need.

Track the Fed-cut market on a watchlist

kalshi-pp-cli watch add KXFEDFUNDS-26FEB && kalshi-pp-cli watch diff --since 24h --agent

Add ticker to local watchlist, then ask for the per-ticker delta since yesterday.

Correlate inflation and rate-cut markets

kalshi-pp-cli markets correlate KXFEDFUNDS-26FEB KXCPI-26FEB --window 30d --agent

Pearson r computed locally over snapshot price series for both markets.

Safe paper-trading session

kalshi-pp-cli portfolio create-order --ticker KXTEST-2026 --side yes --count 1 --yes-price 50 --action buy --dry-run

Both safety floors engaged: client-side read-only lock + dry-run; never reaches the API. (Pair with KALSHI_READ_ONLY=1 to engage the client-side safe-mode lock.)

Movers in sports markets, last 24h

kalshi-pp-cli markets movers --window 24h --category sports --limit 5 --agent

Computes price deltas from market_price_history snapshots; works offline after a sync.

Auth Setup

Kalshi requires composed RSA-PSS signature auth: a UUID access key id (KALSHI_API_KEY) plus an RSA private key file (KALSHI_PRIVATE_KEY_PATH or KALSHI_PRIVATE_KEY). Kalshi issues two key tiers — read-only and read/write — and the CLI honors KALSHI_READ_ONLY=1 (or --read-only) as a client-side lock that blocks every POST/PUT/PATCH/DELETE before signing, regardless of which tier is loaded. Write commands run against a read-only key will surface a 403 from Kalshi; pair with --dry-run while debugging.

Run kalshi-pp-cli doctor to verify setup.

Agent Mode

Add --agent to any command. Expands to: --json --compact --no-input --no-color --yes.

```bash

kalshi-pp-cli api-keys get --agent --select id,name,status

```

Response envelope

Commands that read from the local store or the API wrap output in a provenance envelope:

{
  "meta": {"source": "live" | "local", "synced_at": "...", "reason": "..."},
  "results": <data>
}

Parse .results for data and .meta.source to know whether it's live or local. A human-readable N results (live) summary is printed to stderr only when stdout is a terminal — piped/agent consumers get pure JSON on stdout.

Agent Feedback

When you (or the agent) notice something off about this CLI, record it:

kalshi-pp-cli feedback "the --since flag is inclusive but docs say exclusive"
kalshi-pp-cli feedback --stdin < notes.txt
kalshi-pp-cli feedback list --json --limit 10

Entries are stored locally at ~/.kalshi-pp-cli/feedback.jsonl. They are never POSTed unless KALSHI_FEEDBACK_ENDPOINT is set AND either --send is passed or KALSHI_FEEDBACK_AUTO_SEND=true. Default behavior is local-only.

Write what surprised you, not a bug report. Short, specific, one line: that is the part that compounds.

Output Delivery

Every command accepts --deliver <sink>. The output goes to the named sink in addition to (or instead of) stdout, so agents can route command results without hand-piping. Three sinks are supported:

| Sink | Effect |

|------|--------|

| stdout | Default; write to stdout only |

| file:<path> | Atomically write output to <path> (tmp + rename) |

| webhook:<url> | POST the output body to the URL (application/json or application/x-ndjson when --compact) |

Unknown schemes are refused with a structured error naming the supported set. Webhook failures return non-zero and log the URL + HTTP status on stderr.

Named Profiles

A profile is a saved set of flag values, reused across invocations. Use it when a scheduled agent calls the same command every run with the same configuration - HeyGen's "Beacon" pattern.

kalshi-pp-cli profile save briefing --json
kalshi-pp-cli --profile briefing api-keys get
kalshi-pp-cli profile list --json
kalshi-pp-cli profile show briefing
kalshi-pp-cli profile delete briefing --yes

Explicit flags always win over profile values; profile values win over defaults. agent-context lists all available profiles under available_profiles so introspecting agents discover them at runtime.

Exit Codes

| Code | Meaning |

|------|---------|

| 0 | Success |

| 2 | Usage error (wrong arguments) |

| 3 | Resource not found |

| 4 | Authentication required |

| 5 | API error (upstream issue) |

| 7 | Rate limited (wait and retry) |

| 10 | Config error |

Argument Parsing

Parse $ARGUMENTS:

  1. Empty, help, or --help → show kalshi-pp-cli --help output
  2. Starts with install → ends with mcp → MCP installation; otherwise → see Prerequisites above
  3. Anything else → Direct Use (execute as CLI command with --agent)

MCP Server Installation

  1. Install the MCP server:

```bash

go install github.com/mvanhorn/printing-press-library/library/payments/kalshi/cmd/kalshi-pp-mcp@latest

```

  1. Register with Claude Code:

```bash

claude mcp add kalshi-pp-mcp -- kalshi-pp-mcp

```

  1. Verify: claude mcp list

Direct Use

  1. Check if installed: which kalshi-pp-cli

If not found, offer to install (see Prerequisites at the top of this skill).

  1. Match the user query to the best command from the Unique Capabilities and Command Reference above.
  2. Execute with the --agent flag:

```bash

kalshi-pp-cli <command> [subcommand] [args] --agent

```

  1. If ambiguous, drill into subcommand help: kalshi-pp-cli <command> --help.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.