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

# onDetailedPredictionMarketStatsUpdated

> Streams updated detailed stats for a specific prediction market. onDetailedPredictionMarketStatsUpdated subscription reference: arguments and payload fields.

## GraphQL

```
type Subscription {
  # Requires a Growth or Enterprise plan.
  onDetailedPredictionMarketStatsUpdated(
    marketId: String!
  ): DetailedSubscriptionPredictionMarketStats
}

type PredictionLifecycleStats {
  ageSeconds: Int!
  expectedLifespanSeconds: Int
  timeToResolutionSeconds: Int
  isResolved: Boolean!
  winningOutcomeId: String
}

type CurrencyValuePair {
  usd: String!
  ct: String!
}

type WindowedPredictionMarketCoreStats {
  volume: CurrencyValuePair!
  trades: Int!
}

type WindowedPredictionMarketUniqueTraderStats {
  uniqueTraders: Int!
}

type CurrencyOHLC {
  open: CurrencyValuePair!
  close: CurrencyValuePair!
  low: CurrencyValuePair!
  high: CurrencyValuePair!
}

type WindowedPredictionMarketLiquidityStats {
  liquidity: CurrencyOHLC!
}

type WindowedPredictionMarketOpenInterestStats {
  openInterest: CurrencyOHLC!
}

type WindowedPredictionMarketChangeStats {
  volumeChange: Float!
  tradesChange: Float!
  uniqueTradersChange: Float
  liquidityChange: Float
  openInterestChange: Float
}

type PredictionMarketWindowScores {
  trending: Float!
  relevance: Float!
  competitive: Float!
}

type OutcomeVolumeStats {
  usd: String!
  ct: String!
  shares: String!
}

type PriceValuePair {
  usd: String!
  ct: String!
}

type PriceOHLC {
  open: PriceValuePair!
  close: PriceValuePair!
  low: PriceValuePair!
  high: PriceValuePair!
}

type WindowedPredictionOutcomeCoreStats {
  venueOutcomeId: String!
  trades: Int!
  volume: OutcomeVolumeStats!
  price: PriceOHLC!
}

type OutcomeBuySellVolumeStats {
  usd: String!
  ct: String!
  shares: String!
}

type WindowedPredictionOutcomeBuySellStats {
  buys: Int!
  sells: Int!
  buyVolume: OutcomeBuySellVolumeStats!
  sellVolume: OutcomeBuySellVolumeStats!
}

type WindowedPredictionOutcomeLiquidityStats {
  liquidity: CurrencyOHLC!
}

type WindowedPredictionOutcomeOrderbookStats {
  bid: PriceOHLC!
  ask: PriceOHLC!
}

type WindowedPredictionOutcomeDepthStats {
  bidDepth: CurrencyOHLC!
  askDepth: CurrencyOHLC!
}

type WindowedPredictionOutcomeChangeStats {
  volumeChange: Float!
  volumeSharesChange: Float!
  priceChange: Float!
  tradesChange: Float!
  priceRange: Float!
  buysChange: Float
  sellsChange: Float
  liquidityChange: Float
}

type EnhancedWindowedPredictionOutcomeStats {
  core: WindowedPredictionOutcomeCoreStats!
  buySell: WindowedPredictionOutcomeBuySellStats
  liquidity: WindowedPredictionOutcomeLiquidityStats
  orderbook: WindowedPredictionOutcomeOrderbookStats
  depth: WindowedPredictionOutcomeDepthStats
  statsChange: WindowedPredictionOutcomeChangeStats!
}

type WindowedPredictionAllTimeStats {
  volume: CurrencyValuePair!
  venueVolume: CurrencyValuePair
}

type EnhancedWindowedPredictionMarketStats {
  start: Int!
  end: Int!
  lastTransactionAt: Int!
  core: WindowedPredictionMarketCoreStats!
  uniqueTraders: WindowedPredictionMarketUniqueTraderStats
  liquidity: WindowedPredictionMarketLiquidityStats
  openInterest: WindowedPredictionMarketOpenInterestStats
  statsChange: WindowedPredictionMarketChangeStats!
  scores: PredictionMarketWindowScores!
  outcome0Stats: EnhancedWindowedPredictionOutcomeStats!
  outcome1Stats: EnhancedWindowedPredictionOutcomeStats!
  allTimeStats: WindowedPredictionAllTimeStats!
}

type DetailedPredictionStatsScores {
  score5m: Float
  score1: Float
  score4: Float
  score12: Float
  score24: Float
  score1w: Float
}

type PredictionMarketAllTimeStats {
  volume: CurrencyValuePair!
  venueVolume: CurrencyValuePair
}

type DetailedSubscriptionPredictionMarketStats {
  marketId: String!
  lastTransactionAt: Int!
  lifecycle: PredictionLifecycleStats!
  statsMin5: EnhancedWindowedPredictionMarketStats
  statsHour1: EnhancedWindowedPredictionMarketStats
  statsHour4: EnhancedWindowedPredictionMarketStats
  statsHour12: EnhancedWindowedPredictionMarketStats
  statsDay1: EnhancedWindowedPredictionMarketStats
  statsWeek1: EnhancedWindowedPredictionMarketStats
  trendingScores: DetailedPredictionStatsScores!
  relevanceScores: DetailedPredictionStatsScores!
  competitiveScores: DetailedPredictionStatsScores!
  allTimeStats: PredictionMarketAllTimeStats!
}
```

## Subscription example

[Test this query in the Explorer →](https://docs.codex.io/explore.md)

```graphql theme={null}
subscription {
  onDetailedPredictionMarketStatsUpdated(
    marketId: "0x25aa90b3cd98305e849189b4e8b770fc77fe89bccb7cf9656468414e01145d38:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137"
  ) {
    lastTransactionAt
    lifecycle {
      ageSeconds
      expectedLifespanSeconds
      timeToResolutionSeconds
      isResolved
      winningOutcomeId
    }
    statsMin5 {
      start
      end
      core {
        volume {
          usd
          ct
        }
        trades
      }
      uniqueTraders {
        uniqueTraders
      }
      openInterest {
        openInterest {
          open {
            usd
          }
          close {
            usd
          }
        }
      }
      statsChange {
        volumeChange
        tradesChange
      }
      scores {
        trending
        relevance
        competitive
      }
    }
    statsHour1 {
      core {
        volume {
          usd
        }
        trades
      }
      uniqueTraders {
        uniqueTraders
      }
    }
    statsDay1 {
      core {
        volume {
          usd
        }
        trades
      }
    }
    trendingScores {
      score5m
      score1
      score4
      score12
      score24
      score1w
    }
    allTimeStats {
      volume {
        usd
        ct
      }
      venueVolume {
        usd
      }
    }
  }
}
```

```json Example Response theme={null}
{
  "data": {
    "onDetailedPredictionMarketStatsUpdated": {
      "lastTransactionAt": 1773356943,
      "lifecycle": {
        "ageSeconds": 11592478,
        "expectedLifespanSeconds": 12027533,
        "timeToResolutionSeconds": 435055,
        "isResolved": false,
        "winningOutcomeId": null
      },
      "statsMin5": {
        "start": 1773356640,
        "end": 1773357000,
        "core": {
          "volume": { "usd": "2441", "ct": "2442" },
          "trades": 4
        },
        "uniqueTraders": {
          "uniqueTraders": 1
        },
        "openInterest": {
          "openInterest": {
            "open": { "usd": "8219750" },
            "close": { "usd": "8219750" }
          }
        },
        "statsChange": {
          "volumeChange": 151.5625,
          "tradesChange": 3
        },
        "scores": {
          "trending": 0.3179737717217025,
          "relevance": 0.7518398963622758,
          "competitive": 0.00028312879456631314
        }
      },
      "statsHour1": {
        "core": {
          "volume": { "usd": "3679" },
          "trades": 485
        },
        "uniqueTraders": {
          "uniqueTraders": 23
        }
      },
      "statsDay1": {
        "core": {
          "volume": { "usd": "2787963" },
          "trades": 4884
        }
      },
      "trendingScores": {
        "score5m": 0.3179737717217025,
        "score1": 0.2784615419805427,
        "score4": 0.38295093043975303,
        "score12": 0.46375984101869644,
        "score24": 0.40366629545667476,
        "score1w": 0.4400265051438401
      },
      "allTimeStats": {
        "volume": { "usd": "71642660", "ct": "71839682" },
        "venueVolume": { "usd": "124698659" }
      }
    }
  }
}
```

### Usage Guidelines

* **Market ID format**:
  * **Polymarket**: `<marketAddress>:Polymarket:<exchangeAddress>:<networkId>` (e.g., `0x25aa90b3cd98305e849189b4e8b770fc77fe89bccb7cf9656468414e01145d38:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137`)
  * **Kalshi**: `<marketSlug>:Kalshi` (e.g., `KXMVECROSSCATEGORY-S2026A4A05B370DF-F1FBA451AA9:Kalshi`)
* Subscribe using `marketId` to track real-time stats for a specific prediction market (outcome)
* Price values range from 0.00 to 1.00, representing 0% to 100% probability
* Updates stream in real-time whenever a trade occurs on this specific market

### Troubleshooting Tips

> [accordion] What do the price values represent?
>
> Prices represent the probability of that outcome occurring. A price of 0.65 means the market thinks there's a 65% chance of this outcome. Prices are denominated in the collateral token (usually \$1 = 1 share if this outcome wins).

> [accordion] What's the difference between market stats and event stats?
>
> Event stats ([`onDetailedPredictionEventStatsUpdated`](https://docs.codex.io/api-reference/subscriptions/ondetailedpredictioneventstatsupdated)) aggregate data across all outcomes in an event, while market stats track a single specific outcome. Use event stats for overall market activity and market stats for outcome-specific price movements.

> [accordion] How is competitive score calculated for a single market?
>
> For individual markets, the competitive score measures how close the price is to 0.50 (maximum uncertainty). Prices near 0.50 indicate highly contested outcomes, while prices near 0.00 or 1.00 show strong consensus.

> [accordion] Why would I track individual markets instead of events?
>
> Track individual markets when you care about specific outcome probabilities and price movements. This is useful for charting outcome odds, triggering alerts on probability thresholds, or building trading bots focused on specific outcomes.

> [accordion] Can multiple markets for the same event have different activity?
>
> Yes. In multi-outcome events (e.g., "Who will win the election?" with 5 candidates), some outcomes may be heavily traded while others are ignored. Each market streams updates independently based on its own trading activity.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.