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

# Workflow: Market Analysis

> Agent-friendly workflow to analyze a Polymarket market before execution using the canonical MCP surface.

## Goal

Produce a repeatable, machine-friendly market brief before placing a trade:

* current market state
* liquidity and spread context
* execution impact estimate
* explicit go/no-go and constraints

## Inputs

* `condition_id` (required)
* optional thesis horizon (`intraday`, `1d`, `1w`, `event_horizon`)
* planned side (`BUY` or `SELL`)
* intended size in USDC

## Recommended tool sequence

### 1) Pull market and event context

* `get_market` with `condition_id`
* `get_event` from the related event id when available

Capture status, outcomes, timing, and event risk windows.

### 2) Pull batched market data

Use the canonical pluralized tools:

* `get_order_books`
* `get_prices`
* `get_midpoints`
* `get_spreads`
* `get_last_trade_prices`

Example:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "tool": "get_prices",
  "input": {
    "items": [{ "token_id": "<target_token_id>", "side": "BUY" }]
  }
}
```

Focus on:

* spread regime (tight/normal/wide)
* visible depth near midpoint
* last trade versus current best price

### 3) Estimate execution impact

Run `calculate_market_price` for the intended side and amount.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "tool": "calculate_market_price",
  "input": {
    "token_id": "<target_token_id>",
    "side": "BUY",
    "amount": "250"
  }
}
```

Use the result to set max slippage and a candidate limit price.

### 4) Gather execution metadata

* `get_fee_rate_bps`
* `get_tick_size`
* `get_neg_risk`

These values should flow directly into downstream order validation and execution policy.

### 5) If execution is approved, hand off to trading wrappers

* `prepare_order` to locally prepare/sign a draft without posting
* `place_order` with `confirm: true` only at the final execution step
* `cancel_orders` if you need an explicit unwind/cancel path

## Suggested output contract

Have the agent return a strict structure like:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "thesis": "short rationale",
  "confidence": 0.0,
  "market_state": {
    "status": "active|closed|...",
    "best_price": 0.0,
    "midpoint": 0.0,
    "spread": 0.0,
    "last_trade": 0.0
  },
  "execution": {
    "side": "BUY",
    "amount_usdc": "250",
    "estimated_price": 0.0,
    "max_slippage_bps": 0,
    "suggested_limit_price": 0.0
  },
  "risks": ["liquidity", "event timing"],
  "go_no_go": "GO|NO_GO",
  "fallback_plan": "what to do if liquidity degrades"
}
```

## Optional: use the built-in prompt

You can bootstrap this workflow with prompt `market-analysis` using:

* `condition_id`
* `horizon`
* `include_orderbook_depth`
* `include_recent_trades`

The prompt is registered by the server and already encodes the same analysis sequence.
