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

# Market Lifecycle Channel

> Subscribe to market lifecycle events

### Channel Name

**Channel:** `lifecycle` (Global channel for all markets)

### Subscription

```javascript theme={null}
ws.send(JSON.stringify({
  event: 'subscribe',
  data: 'lifecycle'
}));
```

### Event Types

| Type    | Description                                         |
| ------- | --------------------------------------------------- |
| `OPEN`  | Market has opened and is accepting orders           |
| `START` | The underlying event/game has started               |
| `END`   | The underlying event/game has ended                 |
| `CLOSE` | Market has closed and is no longer accepting orders |

<Warning>
  **Critical:** When a market closes (indicated by a `CLOSE` event), all outstanding orders on that market are **implicitly cancelled**. No individual cancellation messages will be sent for these orders.

  You must use lifecycle events to manage order state for any open orders in the given market.
</Warning>

### Message Format

```json theme={null}
{
  "event": "lifecycle",
  "data": {
    "type": "OPEN",
    "market": {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "description": "KC v BUF Total",
      "status": "OPEN",
      "strike": 26.5,
      "type": "TOTAL",
      "volume": 1000000,
      "eventId": "123e4567-e89b-12d3-a456-426614174001",
      "playerId": null,
      "outcomeIds": [
        "outcome-1",
        "outcome-2"
      ],
      "settledAt": null,
      "event": {
        "id": "123e4567-e89b-12d3-a456-426614174001",
        "description": "KC Chiefs vs BUF Bills - Week 14",
        "type": "REGULAR_SEASON",
        "status": "OPEN_PREGAME",
        "game": {
          "id": "game-001",
          "league": "NFL",
          "status": "SCHEDULED",
          "scheduledStart": "2023-12-10T20:00:00Z",
          "homeTeam": {
            "id": "team-buf",
            "name": "Buffalo Bills",
            "shortName": "Bills",
            "symbol": "BUF",
            "mascot": "Bills"
          },
          "awayTeam": {
            "id": "team-kc",
            "name": "Kansas City Chiefs",
            "shortName": "Chiefs",
            "symbol": "KC",
            "mascot": "Chiefs"
          }
        }
      }
    }
  }
}
```

### Market Object

The `market` object in lifecycle events contains:

| Field         | Type           | Description                                     |
| ------------- | -------------- | ----------------------------------------------- |
| `id`          | string         | UUID of the market                              |
| `description` | string         | Human-readable market description               |
| `status`      | string         | Market status (OPEN, CLOSED, SETTLED)           |
| `strike`      | number         | Market threshold value                          |
| `type`        | string         | Market type (TOTAL, SPREAD, MONEY, etc.)        |
| `volume`      | number         | Total trading volume                            |
| `eventId`     | string         | Associated event UUID                           |
| `playerId`    | string \| null | Associated player UUID (if applicable)          |
| `outcomeIds`  | string\[]      | Array of outcome UUIDs                          |
| `settledAt`   | string \| null | Settlement timestamp (if settled)               |
| `event`       | object         | Complete event details including game and teams |
