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

# onPredictionMarketBarsUpdated

> Live-streamed bar chart data to track price changes over time for a prediction market. Codex API GraphQL subscription reference.

## GraphQL

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

type PredictionMarketBarOhlc {
  o: String!
  h: String!
  l: String!
  c: String!
}

type PredictionOutcomeBar {
  venueOutcomeId: String!
  trades: Int
  buys: Int
  sells: Int
  volumeShares: String
  buyVolumeShares: String
  sellVolumeShares: String
  volumeUsd: String
  buyVolumeUsd: String
  sellVolumeUsd: String
  volumeCollateralToken: String
  buyVolumeCollateralToken: String
  sellVolumeCollateralToken: String
  priceUsd: PredictionMarketBarOhlc
  priceCollateralToken: PredictionMarketBarOhlc
  liquidityUsd: PredictionMarketBarOhlc
  liquidityCollateralToken: PredictionMarketBarOhlc
  bidUsd: PredictionMarketBarOhlc
  bidCollateralToken: PredictionMarketBarOhlc
  askUsd: PredictionMarketBarOhlc
  askCollateralToken: PredictionMarketBarOhlc
  twoPercentBidDepthUsd: PredictionMarketBarOhlc
  twoPercentBidDepthCollateralToken: PredictionMarketBarOhlc
  twoPercentAskDepthUsd: PredictionMarketBarOhlc
  twoPercentAskDepthCollateralToken: PredictionMarketBarOhlc
}

type PredictionMarketBar {
  t: Int!
  volumeUsd: String
  volumeCollateralToken: String
  volumeShares: String
  uniqueTraders: Int
  lastEventTimestamp: Int
  trades: Int
  allTimeVolumeUsd: String
  allTimeVenueVolumeUsd: String
  allTimeVolumeCollateralToken: String
  allTimeVenueVolumeCollateralToken: String
  openInterestUsd: PredictionMarketBarOhlc
  outcome0: PredictionOutcomeBar
  outcome1: PredictionOutcomeBar
}

type PredictionMarketResolutionBarData {
  min1: PredictionMarketBar
  min5: PredictionMarketBar
  min15: PredictionMarketBar
  min30: PredictionMarketBar
  hour1: PredictionMarketBar
  hour4: PredictionMarketBar
  hour12: PredictionMarketBar
  day1: PredictionMarketBar
  week1: PredictionMarketBar
}

type OnPredictionMarketBarsUpdatedResponse {
  marketId: String!
  bars: PredictionMarketResolutionBarData!
}
```

## Subscription example

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

```graphql theme={null}
subscription {
  onPredictionMarketBarsUpdated(marketId: "0x25aa90b3cd98305e849189b4e8b770fc77fe89bccb7cf9656468414e01145d38:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137") {
    bars {
      min1 {
        t
        volumeUsd
        volumeCollateralToken
        volumeShares
        uniqueTraders
        trades
        lastEventTimestamp
        allTimeVolumeUsd
        openInterestUsd {
          o
          h
          l
          c
        }
        outcome0 {
          venueOutcomeId
          trades
          buys
          sells
          volumeShares
          buyVolumeShares
          sellVolumeShares
          volumeUsd
          buyVolumeUsd
          sellVolumeUsd
          priceUsd {
            o
            h
            l
            c
          }
          liquidityUsd {
            o
            h
            l
            c
          }
        }
        outcome1 {
          venueOutcomeId
          trades
          volumeShares
          volumeUsd
          priceUsd {
            o
            h
            l
            c
          }
        }
      }
      hour1 {
        t
        volumeUsd
        allTimeVolumeUsd
        outcome0 {
          volumeUsd
          priceUsd {
            o
            h
            l
            c
          }
        }
      }
      day1 {
        t
        volumeUsd
        allTimeVolumeUsd
        outcome0 {
          priceUsd {
            o
            c
          }
        }
      }
    }
  }
}
```

```json Example Response theme={null}
{
  "data": {
    "onPredictionMarketBarsUpdated": {
      "bars": {
        "min1": {
          "t": 1773357420,
          "volumeUsd": "1.999905",
          "volumeCollateralToken": "2",
          "volumeShares": "1000000000",
          "uniqueTraders": 1,
          "trades": 1,
          "lastEventTimestamp": 1773357437,
          "allTimeVolumeUsd": "124698566.079866",
          "openInterestUsd": {
            "o": "8218458.66957",
            "h": "8218458.66957",
            "l": "8218458.66957",
            "c": "8218458.66957"
          },
          "outcome0": {
            "venueOutcomeId": "54073086346734626735797775941991553522163760164405051969883391401961188364109:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137",
            "trades": 1,
            "buys": 1,
            "sells": 0,
            "volumeShares": "1000000000",
            "buyVolumeShares": "1000000000",
            "sellVolumeShares": "0",
            "volumeUsd": "1.999905",
            "buyVolumeUsd": "1.999905",
            "sellVolumeUsd": "0",
            "priceUsd": {
              "o": "0.002",
              "h": "0.002",
              "l": "0.002",
              "c": "0.002"
            },
            "liquidityUsd": {
              "o": "7899206.931142",
              "h": "7899206.931142",
              "l": "7897876.523427",
              "c": "7897876.523427"
            }
          },
          "outcome1": {
            "venueOutcomeId": "111080671036126109659854287535401661966194360665829017654832975124868412594547:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137",
            "trades": 0,
            "volumeShares": "0",
            "volumeUsd": "0",
            "priceUsd": {
              "o": "0.998954",
              "h": "0.998954",
              "l": "0.998954",
              "c": "0.998954"
            }
          }
        },
        "hour1": {
          "t": 1773356400,
          "volumeUsd": "6583.556291",
          "allTimeVolumeUsd": "124698566.079866",
          "outcome0": {
            "volumeUsd": "1.999905",
            "priceUsd": {
              "o": "0.002",
              "h": "0.002",
              "l": "0.002",
              "c": "0.002"
            }
          }
        },
        "day1": {
          "t": 1773273600,
          "volumeUsd": "2790868.223935",
          "allTimeVolumeUsd": "124698566.079866",
          "outcome0": {
            "priceUsd": {
              "o": "0.002",
              "c": "0.002"
            }
          }
        }
      }
    }
  }
}
```

### 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 receive live bar chart data for a specific prediction market (outcome)
* Price OHLC values range from 0.00 to 1.00, representing the probability (0% to 100%) of that outcome
* Updates stream in real-time as trades occur on the specific market

### Troubleshooting Tips

> [accordion] What's the difference between market bars and event bars?
>
> Market bars ([`onPredictionMarketBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/onpredictionmarketbarsupdated)) track individual outcomes with price OHLC data, while event bars ([`onPredictionEventBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/onpredictioneventbarsupdated)) aggregate data across all outcomes. Use market bars for charting outcome probabilities and event bars for overall event activity.

> [accordion] How do I interpret outcome0, outcome1, etc.?
>
> Each `outcomeX` field represents one possible result in the market. For binary markets, `outcome0` is typically "Yes" and `outcome1` is "No". For multi-outcome markets, there may be `outcome2`, `outcome3`, etc. Check the market metadata via `getPredictionMarkets` to see outcome labels.

> [accordion] Why do outcome prices not always sum to 1.00?
>
> In theory, all outcome prices should sum to 1.00 (representing 100% probability across all possibilities). In practice, prices may not sum exactly to 1.00 due to spreads, liquidity, and arbitrage opportunities. Large deviations indicate market inefficiency or low liquidity.

> [accordion] What's the difference between volumeShares and volumeUsd?
>
> `volumeShares` tracks the number of outcome shares traded, while `volumeUsd` tracks the USD value of those shares. Since share prices fluctuate (e.g., 0.65 per share), the same number of shares has different USD values over time. Use `volumeShares` for share-based analysis and `volumeUsd` for monetary analysis.

> [accordion] Which resolution should I use for price charts?
>
> For real-time price tracking, use `min1` or `min5`. For intraday charts, use `min15` or `hour1`. For daily overviews, use `hour4` or `day1`. Higher resolutions reduce noise but may miss short-term price movements. Request only needed resolutions to minimize data transfer.

> [accordion] How do I track buy vs. sell pressure?
>
> Use the `buys` and `sells` counts along with `buyVolumeUsd` and `sellVolumeUsd` within each outcome's data. More buys than sells (or higher buy volume) indicates bullish sentiment on that outcome, while the opposite suggests bearish sentiment.


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