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

# onDetailedPredictionEventStatsUpdated

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

## GraphQL

```
type Subscription {
  # Requires a Growth or Enterprise plan.
  onDetailedPredictionEventStatsUpdated(
    eventId: String!
  ): DetailedSubscriptionPredictionEventStats
}

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

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

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

type WindowedPredictionEventBuySellStats {
  buyVolume: CurrencyValuePair!
  sellVolume: CurrencyValuePair!
}

type WindowedPredictionEventUniqueTraderStats {
  uniqueTraders: Int!
}

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

type WindowedPredictionEventLiquidityStats {
  liquidity: CurrencyOHLC!
}

type WindowedPredictionEventOpenInterestStats {
  openInterest: CurrencyOHLC!
}

type WindowedPredictionEventChangeStats {
  volumeChange: Float!
  tradesChange: Float!
  buyVolumeChange: Float
  sellVolumeChange: Float
  uniqueTradersChange: Float
  liquidityChange: Float
  openInterestChange: Float
}

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

type WindowedPredictionAllTimeStats {
  volume: CurrencyValuePair!
  venueVolume: CurrencyValuePair
}

type EnhancedWindowedPredictionEventStats {
  start: Int!
  end: Int!
  lastTransactionAt: Int!
  core: WindowedPredictionEventCoreStats!
  buySell: WindowedPredictionEventBuySellStats
  uniqueTraders: WindowedPredictionEventUniqueTraderStats
  liquidity: WindowedPredictionEventLiquidityStats
  openInterest: WindowedPredictionEventOpenInterestStats
  statsChange: WindowedPredictionEventChangeStats!
  scores: PredictionEventWindowScores!
  allTimeStats: WindowedPredictionAllTimeStats!
}

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

type PredictionEventAllTimeStats {
  volume: CurrencyValuePair!
  venueVolume: CurrencyValuePair
}

type DetailedSubscriptionPredictionEventStats {
  eventId: String!
  lastTransactionAt: Int!
  lifecycle: PredictionLifecycleStats!
  statsMin5: EnhancedWindowedPredictionEventStats
  statsHour1: EnhancedWindowedPredictionEventStats
  statsHour4: EnhancedWindowedPredictionEventStats
  statsHour12: EnhancedWindowedPredictionEventStats
  statsDay1: EnhancedWindowedPredictionEventStats
  statsWeek1: EnhancedWindowedPredictionEventStats
  trendingScores: DetailedPredictionStatsScores!
  relevanceScores: DetailedPredictionStatsScores!
  allTimeStats: PredictionEventAllTimeStats!
}
```

## Subscription example

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

```graphql theme={null}
subscription {
  onDetailedPredictionEventStatsUpdated(eventId: "67284:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137") {
    lastTransactionAt
    lifecycle {
      ageSeconds
      expectedLifespanSeconds
      timeToResolutionSeconds
      isResolved
      winningOutcomeId
    }
    statsMin5 {
      start
      end
      lastTransactionAt
      core {
        volume {
          usd
          ct
        }
        trades
      }
      buySell {
        buyVolume {
          usd
        }
        sellVolume {
          usd
        }
      }
      uniqueTraders {
        uniqueTraders
      }
      openInterest {
        openInterest {
          open {
            usd
          }
          close {
            usd
          }
        }
      }
      liquidity {
        liquidity {
          open {
            usd
          }
          close {
            usd
          }
        }
      }
      statsChange {
        volumeChange
        buyVolumeChange
        sellVolumeChange
        tradesChange
        uniqueTradersChange
      }
      scores {
        trending
        relevance
      }
    }
    statsHour1 {
      core {
        volume {
          usd
        }
        trades
      }
      buySell {
        buyVolume {
          usd
        }
        sellVolume {
          usd
        }
      }
      uniqueTraders {
        uniqueTraders
      }
    }
    statsDay1 {
      core {
        volume {
          usd
        }
        trades
      }
    }
    allTimeStats {
      volume {
        usd
        ct
      }
      venueVolume {
        usd
      }
    }
  }
}
```

```json Example Response theme={null}
{
  "data": {
    "onDetailedPredictionEventStatsUpdated": {
      "lastTransactionAt": 1773357223,
      "lifecycle": {
        "ageSeconds": 11592546,
        "expectedLifespanSeconds": 12027321,
        "timeToResolutionSeconds": 434775,
        "isResolved": false,
        "winningOutcomeId": null
      },
      "statsMin5": {
        "start": 1773356880,
        "end": 1773357240,
        "lastTransactionAt": 1773357223,
        "core": {
          "volume": { "usd": "10297", "ct": "10298" },
          "trades": 25
        },
        "buySell": {
          "buyVolume": { "usd": "9339" },
          "sellVolume": { "usd": "958" }
        },
        "uniqueTraders": {
          "uniqueTraders": 8
        },
        "openInterest": {
          "openInterest": {
            "open": { "usd": "34058066" },
            "close": { "usd": "34058066" }
          }
        },
        "liquidity": {
          "liquidity": {
            "open": { "usd": "40568513" },
            "close": { "usd": "40571490" }
          }
        },
        "statsChange": {
          "volumeChange": -0.3347331696601628,
          "buyVolumeChange": -0.3906831082403601,
          "sellVolumeChange": 5.344370860927152,
          "tradesChange": -0.2647058823529412,
          "uniqueTradersChange": -0.5294117647058824
        },
        "scores": {
          "trending": 0.31540938802070095,
          "relevance": 0.8392556393431304
        }
      },
      "statsHour1": {
        "core": {
          "volume": { "usd": "38025" },
          "trades": 310
        },
        "buySell": {
          "buyVolume": { "usd": "28468" },
          "sellVolume": { "usd": "9556" }
        },
        "uniqueTraders": {
          "uniqueTraders": 81
        }
      },
      "statsDay1": {
        "core": {
          "volume": { "usd": "8622225" },
          "trades": 17230
        }
      },
      "allTimeStats": {
        "volume": { "usd": "183695543", "ct": "184322079" },
        "venueVolume": { "usd": "350591805" }
      }
    }
  }
}
```

### Usage Guidelines

* **Event ID format** varies by platform:
  * **Polymarket**: `<eventSlug>:Polymarket:<exchangeAddress>:<networkId>` (e.g., `67284:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137`)
  * **Kalshi**: `<eventSlug>:Kalshi` (e.g., `KXMVESPORTSMULTIGAMEEXTENDED-S2026350C4EF9BCE:Kalshi`)
* Subscribe using the `eventId` to track real-time stats for a specific prediction event
* Stats are provided across multiple time windows: 5-minute, 1-hour, 4-hour, 12-hour, 1-day, and 1-week
* Updates stream in real-time whenever a new trade occurs on the prediction event

### Troubleshooting Tips

> [accordion] What time windows are available?
>
> Stats are available for 6 time windows: `statsMin5` (5 minutes), `statsHour1` (1 hour), `statsHour4` (4 hours), `statsHour12` (12 hours), `statsDay1` (1 day), and `statsWeek1` (1 week). Each window provides granular metrics for that time period.

> [accordion] What's the difference between volumeUsd and volumeCT?
>
> `volumeUsd` is the trading volume denominated in US dollars, while `volumeCT` is volume in collateral token units. For Polymarket (which uses USDC as collateral), these values are typically the same. For other protocols, they may differ based on the collateral token's USD price.

> [accordion] How are trending, relevance, and competitive scores calculated?
>
> `trending` measures recent activity momentum, `relevance` reflects market importance and liquidity, and `competitive` indicates how contested the outcomes are (closer to 50/50 = higher score). Scores range from 0-100 and are recalculated with each update.

> [accordion] Why are some fields null or zero?
>
> Fields may be null if the data isn't available for older events or if the event hasn't had activity in a particular time window. `winningOutcomeId` is null until the event is resolved. Zero values indicate no activity in that category (e.g., no sells during a time window).


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