通过一套 SDK 在 Polymarket、Kalshi 与 $SIM 虚拟练习市场间交易预测市场。
文档
Kalshi CLI
试用Use the local kalshi CLI for bounded Kalshi series and market research, keyword discovery, fixed-point portfolio and candlestick reads, order reconciliation, and explicitly confirmed demo or production order operations.
它能做什么
Use the local kalshi CLI for bounded Kalshi series and market research, keyword discovery, fixed-point portfolio and candlestick reads, order reconciliation, and explicitly confirmed demo or production order operations.
技能文档
Kalshi CLI
Use the compiled kalshi binary or go run ./cmd/kalshi from this repository.
Required workflow
- If the command is not already known from the same cached registry/binary version, run
kalshi commands list --fields registry_version,commands.name,commands.output_contract_version,commands.summary --compactonce and cache the result byregistry_versionfor the task. - Before constructing unfamiliar parameters, run
kalshi commands describe --fields command.name,command.output_contract_version,command.summary,command.effect,command.params_schema --compact. Addcommand.response_schema,command.docs_urlonly when response semantics or upstream documentation are needed. - Prefer one strict
--paramsJSON object for generated calls. Convenience flags are safe but must not duplicate fields in--params. - Add the narrowest useful
--fieldsselection to reads. Add every field the task cannot proceed without to--require-fields; this makes the path present and non-null in every returned record. Paths are item-relative for collection commands and data-root-relative otherwise. Discover allowed paths and constraints offline withkalshi commands describe --fields command.response_schema.x-projectable-fields,command.response_schema.x-projected-field-contracts --compact. - Set explicit
--max-pages,--max-items, and--max-byteswhen the defaults do not fit the task. Never emulate an unbounded--allloop. - Parse
schema_version,output_contract_version,ok, stableerror.code,effect, andmeta.truncation. Do not scrape prose. - Treat a non-empty
meta.pagination.next_cursorplus truncation reasons as an explicit continuation decision.
markets.search is a bounded local substring match over documented /markets
pages, not an upstream full-text or relevance-ranked search. A zero-match result
is complete only when its cursor is empty and truncation is false.
portfolio.pnl exposes Kalshi's upstream-reported realized P&L, exposure, and
fees. It does not estimate unrealized P&L, subtract fees, or combine market and
event aggregates. Current and archived candlesticks have separate commands and
field contracts; do not substitute one when the other returns not found.
Authentication
Never place an API private key in argv, --params, output, logs, or prompts. Configure KALSHI_CREDENTIALS_FILE, or configure KALSHI_API_KEY_ID plus KALSHI_PRIVATE_KEY_FILE. Credential and PEM files must be mode 0600 or stricter.
orderbook.get is anonymous by default because current Kalshi public-data guidance and observed behavior allow it, despite the current endpoint schema also declaring authentication. If the server requires authentication, repeat with --authenticated and a configured credential source.
Writes
Never call orders.create or orders.cancel directly on first construction.
- Supply an explicit environment and a write policy. Prefer demo unless the operator explicitly requested production.
- For create, supply a caller-stable
client_order_id, count/notional policy caps, and complete params. - Add
--dry-run. This performs no credential loading, DNS, HTTP, or mutation. - Review the canonical plan and its effect/policy metadata.
- Repeat the identical command without
--dry-runand pass the exactconfirmation_digestto--confirm. - If a write returns
mutation_status: "unknown", do not blindly retry and do not switch client IDs. Runorders.reconcilefor creates ororders.getfor cancels.
--write-policy demo-only permits demo writes; allow is necessary for production. The default is deny. CLI flags may state finite count and notional caps; they are part of the confirmation digest.
Output
Prefer compact JSON for model consumption. Use NDJSON only for external line-oriented processors; it is atomically buffered and repeats the envelope for each collection item, so it is usually more token-expensive. NDJSON's final summary record contains authoritative pagination/truncation metadata. Strings are sanitized so C0/C1 terminal controls, ANSI escapes, invalid UTF-8, and bidi controls appear as visible Unicode escape text.
Projection happens before sanitization and byte accounting. If the result still exceeds --max-bytes, the command fails atomically with OUTPUT_LIMIT; add or narrow fields, or increase the cap. Never treat an output-limit error as a partial page or continue from a cursor copied from error text.
Commands may declare x-default-fields for their canonical v1 view. An
explicit --fields overrides that default; continue to use --require-fields
for every optional value the task cannot proceed without.
Required response fields are validated before projection. Treat UPSTREAM_SCHEMA_MISMATCH as a contract failure, inspect error.details.missing_fields, type_mismatches, format_mismatches, value_mismatches, and unexpected_fields, and do not guess a renamed field. Optional fields selected only with --fields are emitted as null when absent; use --require-fields whenever null would make the task fail later.
Branch on stable error codes and exit categories documented in README.md. A network error is retryable only for reads. Writes are never automatically retried.
Read commands automatically handle bounded HTTP 429 retries within --timeout. Inspect meta.retry when present for attempts, completed retries, exhaustion, and the final server delay. A final UPSTREAM_REJECTED with HTTP 429 and retryable: true means the per-process retry budget was exhausted; back off before starting another CLI process. Rate-limited attempts do not count as fetched pagination pages.
相关技能
Trade Kalshi weather markets using NOAA forecasts via Simmer SDK and DFlow on Solana. Port of the popular polymarket-weather-trader. Use when user wants to trade temperature markets on Kalshi, automate weather bets, or check NOAA forecasts.
Real-time supervisor and control interface for the DRADIS prediction-market trading engine (Polymarket International, Polymarket US, and Kalshi). Full support for DRADIS_API_KEY authentication.
Pulls prediction-market odds, order books, and forecast questions from Polymarket, Kalshi, and Metaculus via the Crawlora API, returning clean JSON. Use when the user asks what the market thinks will happen, wants current odds/prices for an event, wants a market's price history or order book, or wants a forecasting community's aggregate prediction on a question.
Polymarket prediction market edge detector. Compares Polymarket binary-option prices against external reference probabilities (polls, prediction APIs, market...
Trade the KAX prediction markets and manage an agent's play credits — read the joined prediction board, take a position on an LMSR market, check your balance, and understand the hash-chained credit ledger and the 1 credit = 1,000,000 minor units scale (credits are internal accounting, not redeemable for money). Use for 'what markets are open', 'bet on this', 'what's my balance', 'why insufficient funds', 'how do credits work', 'settle by when'.