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

# Resolution Analysis

> LLM-powered resolution condition analysis, ambiguity scoring, and risk assessment for prediction markets.

Resolution Analysis uses LLM reasoning to parse market resolution criteria, identify ambiguity risks, edge cases, and timing issues. It provides a pipeline guard that automatically blocks quoting on markets with high ambiguity scores.

## Standalone Analysis

```python theme={null}
import horizon as hz

analysis = hz.analyze_resolution(
    market_id="will-btc-hit-100k",
    market_title="Will BTC hit $100k by end of 2026?",
)

print(f"Ambiguity: {analysis.ambiguity_score:.2f}")
print(f"Risk level: {analysis.risk_level}")
print(f"Resolution type: {analysis.resolution_type}")
print(f"Source: {analysis.resolution_source}")

for cond in analysis.conditions:
    print(f" - {cond.description} (verifiable={cond.verifiable})")

for edge_case in analysis.edge_cases:
    print(f"  Edge case: {edge_case}")
```

## Kalshi Markets

Resolution analysis works with Kalshi markets via the `exchange` parameter:

```python theme={null}
analysis = hz.analyze_resolution(
    market_id="KXBTC100K",
    exchange="kalshi",
)
```

Batch analysis also supports the `exchange` parameter:

```python theme={null}
analyses = hz.batch_analyze(
    ["KXBTC100K", "KXETH5K"],
    exchange="kalshi",
)
```

## Batch Analysis

```python theme={null}
analyses = hz.batch_analyze(["market-1", "market-2", "market-3"])
for a in analyses:
    print(f"{a.market_id}: ambiguity={a.ambiguity_score:.2f} risk={a.risk_level}")
```

## Pipeline Guard

The `resolution_guard()` blocks quoting on markets with ambiguous resolution conditions:

```python theme={null}
def my_quoter(ctx):
    if ctx.params.get("resolution_blocked"):
        return []  # Skip ambiguous markets
    return hz.quotes(fair=0.50, spread=0.04)

hz.run(
    name="safe-strategy",
    markets=["market-1", "market-2"],
    pipeline=[
        hz.resolution_guard(block_above_ambiguity=0.6),
        my_quoter,
    ],
)
```

### Injected Parameters

| Parameter             | Type                 | Description                         |
| --------------------- | -------------------- | ----------------------------------- |
| `resolution_analysis` | `ResolutionAnalysis` | Full analysis object                |
| `resolution_risk`     | `str`                | Risk level: "low", "medium", "high" |
| `resolution_blocked`  | `bool`               | True if ambiguity exceeds threshold |

## Configuration

```python theme={null}
config = hz.ResolutionConfig(
    provider="anthropic",        # or "openai", or any litellm provider
    model="",                    # empty = provider default; or "openrouter/..."
    ambiguity_threshold=0.6,     # flag markets above this
    cache_ttl=3600.0,            # 1 hour cache (rules rarely change)
)
```

Uses litellm for provider-agnostic LLM calls. Any [litellm-supported model string](https://docs.litellm.ai/docs/providers) works in the `model` field.

## Risk Levels

| Level  | Ambiguity | Description                                |
| ------ | --------- | ------------------------------------------ |
| Low    | 0.0 - 0.3 | Clear, verifiable conditions               |
| Medium | 0.3 - 0.6 | Some subjective elements                   |
| High   | 0.6 - 1.0 | Significant ambiguity, committee-dependent |

## Resolution Types

| Type           | Description                                       |
| -------------- | ------------------------------------------------- |
| `binary_event` | Yes/no outcome from a specific event              |
| `threshold`    | Numeric threshold (price, score, etc.)            |
| `committee`    | Resolved by committee vote or subjective judgment |
| `oracle`       | Resolved by designated oracle or data source      |

## Types

### ResolutionAnalysis

| Field                       | Type                        | Description                    |
| --------------------------- | --------------------------- | ------------------------------ |
| `market_id`                 | `str`                       | Market identifier              |
| `market_title`              | `str`                       | Market question                |
| `resolution_source`         | `str`                       | Primary resolution authority   |
| `conditions`                | `list[ResolutionCondition]` | Resolution conditions          |
| `ambiguity_score`           | `float`                     | 0.0 (clear) to 1.0 (ambiguous) |
| `edge_cases`                | `list[str]`                 | Identified edge cases          |
| `timing_risks`              | `list[str]`                 | Timing-related risks           |
| `resolution_type`           | `str`                       | Resolution mechanism type      |
| `estimated_resolution_date` | `str`                       | Expected date or "unknown"     |
| `risk_level`                | `str`                       | "low", "medium", "high"        |
| `reasoning`                 | `str`                       | LLM reasoning                  |
| `timestamp`                 | `float`                     | Unix timestamp                 |

### ResolutionCondition

| Field             | Type   | Description             |
| ----------------- | ------ | ----------------------- |
| `description`     | `str`  | What needs to happen    |
| `source`          | `str`  | Resolution authority    |
| `verifiable`      | `bool` | Objectively verifiable? |
| `ambiguity_notes` | `str`  | Ambiguity notes         |
