> ## 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.

# Market Intelligence

> Market fitness scoring, resolution settlement, event calendar, and universe management.

Market Intelligence helps the LLM decide **which** markets to trade, **when** to enter, and **when** to exit - the research layer that feeds the autonomous decision loop.

## Market Fitness Scoring

Before deploying a strategy on a market, assess whether it's a good fit.

### Scoring Dimensions

| Dimension        | What It Measures                                    | Source                             |
| ---------------- | --------------------------------------------------- | ---------------------------------- |
| **Liquidity**    | Orderbook depth, spread, daily volume               | Exchange orderbook + trade data    |
| **Edge**         | Mispricing vs. LLM forecast                         | LLM signal engine + oracle         |
| **Strategy Fit** | Is this market suitable for MM / directional / arb? | Microstructure analysis            |
| **Risk**         | Correlation with portfolio, tail risk               | Position data + correlation matrix |
| **Time Value**   | Time to resolution vs. capital lockup cost          | Resolution calendar + yield curve  |

```python theme={null}
# Rank markets by fitness
scores = market_scorer.rank(
    markets=discovered_markets,
    strategy_type="market_maker",
    portfolio=fund.positions(),
    top_n=10,
)
# [{"market": "will-x-win", "score": 0.87, "liquidity": 0.92, "edge": 0.75, ...}, ...]
```

## Market Resolution Settlement

Prediction markets have a unique lifecycle: they resolve to 0 or 1. This system automates end-of-life handling.

### Settlement Flow

<Steps>
  <Step title="Market Active">
    Strategy is trading the market normally.
  </Step>

  <Step title="Resolution Detected">
    Exchange confirms the market has resolved to an outcome.
  </Step>

  <Step title="P&L Booked">
    Position settles at 0 or 1. Realized P\&L recorded.
  </Step>

  <Step title="Capital Freed">
    Released capital returns to the fund pool for reallocation.
  </Step>

  <Step title="Post-Analysis">
    Was the edge real? Update models for similar future markets.
  </Step>
</Steps>

| Step                     | What Happens                                         |
| ------------------------ | ---------------------------------------------------- |
| **Resolution Detection** | Poll exchange for resolved markets                   |
| **P\&L Booking**         | Position settles at 0 or 1, realized P\&L recorded   |
| **Capital Recycling**    | Freed capital returns to fund pool                   |
| **Attribution**          | Resolution P\&L tracked separately from trading P\&L |
| **Post-Analysis**        | Was our edge real? Update models for future markets  |

### Near-Resolution Handling

Markets approaching resolution need special treatment:

* **High confidence**: hold to resolution (maximize edge capture)
* **Low confidence**: exit early (reduce variance)
* **Liquidity drying up**: exit before orderbook disappears
* **Cancel open orders**: prevent getting filled at bad prices near resolution

## Event Calendar Intelligence

Track catalysts that move markets and use them for timing.

```python theme={null}
# Upcoming catalysts
catalysts = calendar.upcoming(days=7)
# [
#   {"event": "FOMC Decision", "date": "2026-03-18", "markets_affected": 12},
#   {"event": "CPI Release", "date": "2026-03-20", "markets_affected": 8},
# ]

# Score markets by catalyst proximity
scored = calendar.catalyst_score(markets)
```

## Market Universe Management

The set of markets the fund actively tracks and considers for trading.

### Universe Lifecycle

<Steps>
  <Step title="All Markets">
    Full set of markets across all connected exchanges.
  </Step>

  <Step title="Discovery Filter">
    Apply minimum liquidity, volume, and fitness score thresholds.
  </Step>

  <Step title="Active Universe">
    Markets the fund is actively tracking and considering for strategies.
  </Step>

  <Step title="Strategy Assignment">
    Assign the best-fit strategy template to each market.
  </Step>

  <Step title="Trading">
    Deploy and run strategies. Remove markets that resolve, lose liquidity, or get restricted.
  </Step>
</Steps>

| Action             | Trigger                                                      |
| ------------------ | ------------------------------------------------------------ |
| **Add market**     | New market discovered with fitness score above threshold     |
| **Remove market**  | Market resolved, liquidity dropped, or compliance restricted |
| **Promote market** | Fitness score improved, assign strategy                      |
| **Demote market**  | Fitness score declined, reduce exposure                      |

```python theme={null}
# Configure market universe
universe = MarketUniverse(
    exchanges=["polymarket", "kalshi"],
    min_liquidity=1000,
    min_volume_24h=5000,
    excluded_categories=["adult"],
    max_markets=100,
)
universe.refresh()  # Scan and update
```

## MCP Tools

| Tool                 | Description                                |
| -------------------- | ------------------------------------------ |
| `scan_opportunities` | Scan all markets, return ranked by fitness |
| `research_market`    | Deep analysis of a single market           |
| `resolution_status`  | Check resolution status of active markets  |
| `market_universe`    | Current universe with fitness scores       |
