Documentation Index
Fetch the complete documentation index at: https://mintlify.com/deniszidbaev-cmyk/polyclaw-cmyk/llms.txt
Use this file to discover all available pages before exploring further.
polyclaw hedge finds pairs of Polymarket prediction markets where a logically necessary relationship exists between outcomes. Unlike correlation-based approaches, PolyClaw’s hedge scanner only accepts implications that are definitionally or physically impossible to violate — not merely “likely”. When such an implication exists, a covering portfolio can be constructed using contrapositive logic, producing a position that limits downside regardless of the outcome.
polyclaw hedge scan
Scans a set of Polymarket markets for hedging opportunities by asking an LLM to identify logically necessary relationships.
Full usage
Filter markets by keyword before scanning. Uses
markets search instead of markets trending. Pass a quoted phrase to narrow the topic (e.g. --query "election").Number of markets to fetch and scan. Each market becomes a target and all others are candidates for cover relationships.
Minimum coverage threshold (0.0–1.0). Portfolios below this threshold are discarded before output. The default of
0.85 filters out Tier 4 (LOW) results.Maximum tier number to include.
1 = T1 only, 2 = T1 + T2, 3 = T1 + T2 + T3, etc. Tiers are assigned based on coverage percentage.OpenRouter model ID to use for implication analysis. See the model selection note below.
Output results as a JSON array instead of the formatted table. Progress messages are written to stderr regardless.
How it works
Fetch markets
PolyClaw fetches markets from Polymarket Gamma API — either trending (default) or search-filtered if
--query is set.LLM implication extraction
For each market (the “target”), all other fetched markets are sent to the LLM with a strict logical implication prompt. The model is instructed to find only relationships where one event outcome logically guarantees another — correlations, likelihoods, and political predictions are explicitly rejected. The model must also attempt to construct a counterexample for each relationship; if a counterexample exists, the relationship is excluded.
Contrapositive derivation
From the LLM’s
implied_by and implies lists, PolyClaw derives cover positions using contrapositive logic:implied_by(other → target): contrapositive gives a YES cover (buy NO on the other market)implies(target → other): direct relationship gives a NO cover (buy YES on the other market)
Coverage calculation and tier assignment
Each portfolio’s coverage is computed as
p_target + p_not_target × cover_probability, where cover_probability is set to 0.98 for necessary implications. Portfolios are classified into T1–T4 based on the result.Example
polyclaw hedge analyze <id1> <id2>
Analyzes a specific pair of markets for hedging relationships in both directions.
Usage
First market ID.
Second market ID.
Minimum coverage threshold for a portfolio to be included.
OpenRouter model ID.
Output as a JSON array.
Relationships: section that prints the explanation returned by the LLM for each portfolio.
Output format
Table
| Column | Description |
|---|---|
Tier | T1–T3 coverage tier label |
Cov | Coverage percentage (higher is better) |
Cost | Total combined cost of target + cover positions ($1 each) |
Target | Side and price for the target position + truncated question |
Cover | Side and price for the covering position + truncated question |
JSON
Each element in the JSON array is a portfolio object with fields includingtier, coverage, total_cost, target_position, target_price, target_question, cover_position, cover_price, cover_question, and relationship.
Coverage tiers
T1 HIGH — ≥95%
Near-arbitrage quality. The logical relationship is extremely tight. Very low residual risk. These are the highest-confidence hedges PolyClaw can find.
T2 GOOD — 90–95%
Strong hedge with a small residual gap. Suitable for most risk-managed positions. Included by default (
--tier 2).T3 MODERATE — 85–90%
Decent hedge but with a noticeable coverage gap. Requires more careful position sizing. Excluded by default; include with
--tier 3.T4 LOW — <85%
Speculative coverage. Filtered out by the
--min-coverage 0.85 default. Only visible if you lower --min-coverage manually.Model selection
Model quality matters significantly for hedge discovery. The scan prompt is designed to be strict, but some models still return false positives (spurious correlations) or fail to produce parseable output.
- Default (
nvidia/nemotron-nano-9b-v2:free) — works well; good balance of strictness and output format compliance - Models with reasoning fields (e.g. DeepSeek R1) — may return the response in a
reasoning_contentfield rather than the standardcontentfield, causing JSON parse failures - Smaller or less capable models — may find spurious correlations, inflating the result count with low-quality hedges
--model <model_id> to experiment. Model IDs follow the OpenRouter format (e.g. openai/gpt-4o, anthropic/claude-3-5-haiku).