# Creating markets and capabilities

> Market types, event players, the markets to create, results, and what an exchange offers.

Source: https://docs.stxapp.io/sdks/python/reference/markets-and-capabilities/

## `PlayerStatLine`

A player stat line market: over/under one player's stat in one event.

`line` is a positive number ending in `.5`, e.g. `18.5`. Whole
numbers, quarter lines, zero and negatives are rejected with
`invalid_line`.

### Attributes

| Attribute | Type | Description |
|---|---|---|
| `player_id` | `str` |  |
| `stat` | `str` |  |
| `line` | `Union[float, int, Decimal]` |  |
| `rule` | `str` |  |

## `CreateMarketResult`

The outcome for one requested market.

`index` is its position in the list given to `create_markets`.
`status` is `created` or `exists` (both with `market_id`),
`valid` (a dry run that would create it) or `rejected` (with
`reason`: `invalid_line`, `unsupported_stat`, `unknown_player`,
`unsupported_rule`, `event_not_open`, `not_created`...).

### Attributes

| Attribute | Type | Description |
|---|---|---|
| `index` | `int` |  |
| `status` | `str` |  |
| `market_id` | `Optional[str]` |  |
| `reason` | `Optional[str]` |  |
| `ok` | `bool` | True for `created`, `exists` and `valid`. |

## `EventPlayers`

`GET /api/v1/events/{event_id}/players`: rosters and the stats on offer.

`teams` is empty until the rosters are published, or when the event's
type has no player props.

### Attributes

| Attribute | Type | Description |
|---|---|---|
| `event_id` | `Optional[str]` |  |
| `teams` | `List[EventTeam]` |  |
| `stats` | `List[EventStat]` |  |

### Methods

#### `players()`

```python
players() -> List[EventPlayer]
```

Every player on every team.

#### `stat_keys()`

```python
stat_keys() -> List[str]
```

The stat keys this event accepts, e.g. `["ASSISTS", "GOALS"]`.

## `EventTeam`

One team's roster, sorted by player name.

### Attributes

| Attribute | Type | Description |
|---|---|---|
| `team` | `Optional[str]` |  |
| `players` | `List[EventPlayer]` |  |

## `EventPlayer`

One player on an event's roster.

### Attributes

| Attribute | Type | Description |
|---|---|---|
| `player_id` | `Optional[str]` |  |
| `name` | `Optional[str]` |  |
| `jersey` | `Optional[str]` |  |
| `position` | `Optional[str]` |  |

## `EventStat`

A stat a market on the event can be created on.

### Attributes

| Attribute | Type | Description |
|---|---|---|
| `stat` | `Optional[str]` |  |
| `name` | `Optional[str]` |  |

## `MarketType`

One market type from `market_types()`, keyed there by rule.

`partner_create` says whether `create_markets` takes it. A creatable
type lists the `fields` an entry takes and, in `event_types`, the
event types it runs on (each with its `sport` and `stats`); one an
app cannot create lists its event types as plain names.

### Attributes

| Attribute | Type | Description |
|---|---|---|
| `partner_create` | `Optional[bool]` |  |
| `event_types` | `Any` |  |
| `fields` | `Optional[Dict[str, Any]]` |  |

## `Capabilities`

What one exchange offers. Get it from `client.capabilities()`.

`features` maps each id in `stx.FEATURES` to a `Feature`.
`api_version` is the exchange build, `oauth_metadata` its RFC 8414
document when it publishes one, `scopes_supported` that document's
scopes and `checked_at` when it was asked (Unix seconds).

### Attributes

| Attribute | Type | Description |
|---|---|---|
| `host` | `str` |  |
| `api_version` | `Optional[str]` |  |
| `features` | `Dict[str, Feature]` |  |
| `oauth_metadata` | `Optional[Dict[str, Any]]` |  |
| `scopes_supported` | `List[str]` |  |
| `checked_at` | `float` |  |

### Methods

#### `available()`

```python
available(feature: str) -> bool
```

True only when the exchange showed it has `feature`.

| Parameter | Type | Description |
|---|---|---|
| `feature` | `str` |  |

#### `require()`

```python
require(feature: str) -> None
```

Raise `STXNotAvailableError` when `feature` is known to be absent.

| Parameter | Type | Description |
|---|---|---|
| `feature` | `str` |  |

#### `to_dict()`

```python
to_dict() -> Dict[str, Optional[bool]]
```

`{feature: True | False | None}`.

## `Feature`

One feature: `available` is True, False, or None when unknown.
`how` says what the exchange answered.

### Attributes

| Attribute | Type | Description |
|---|---|---|
| `id` | `str` |  |
| `available` | `Optional[bool]` |  |
| `how` | `str` |  |
