# Combos

> What a combo is, how a player and makers agree one in amounts, how price and size follow from those amounts, cash out, and settlement.

Source: https://docs.stxapp.io/concepts/combos/

A combo (a combination) is one market over two or more legs, each an existing market expected to end `won` or `lost`. It pays only if every leg ends the way the combo needs: the `COL @ DAL` market **and** the `NJ @ DET` market **and** the `NY @ TOR` market all ending `won`, for example. A player asks for quotes on the legs and a stake, makers quote, the player accepts, and STX places one ordinary limit order for each side on the combo's market. From then on it is an ordinary market: fills, positions and settlement arrive on the usual feeds.

The negotiation runs over two WebSocket topics: players use `rfq:{user_id}` and makers use `combo_quote:{user_id}`. This page covers the model; the [combo negotiation channels](/websockets/channels/combo-negotiation/) page covers every command, field, refusal and push.

## How it works

## What a combo is

A combo is a set of **legs**. Each leg is an ordinary market plus the outcome the combo needs of it:

| Leg | Outcome needed |
| --- | --- |
| `COL @ DAL` | `won` |
| `NJ @ DET` | `won` |
| `NY @ TOR` | `won` |

- **2 to 5 legs** by default, each a different market. An exchange can set another leg limit.
- **`won` or `lost` per leg.** `lost` is a real requirement: a combo can pay only if a leg's market ends `lost`.
- **Every leg must be `open`** when the request opens and again when it binds.
- **Combos do not nest.** A leg cannot itself be a combo.

**The same legs with the same outcomes are always the same combo**, in any order: the first bind over them creates its market, and every later bind uses that market. A different outcome on any leg is a different market.

A new combo's market has a `max_price` of `$1` and a tick of `0.0001` by default, and keeps both for life. The tick is finer than on an ordinary market because a combo's fair price is the product of its legs and rarely lands on a cent. Makers read both values from each request rather than assuming them.

## Amounts, not prices

Both sides of a negotiation speak in money:

| | Player | Maker |
| --- | --- | --- |
| Names | A **stake**: what they spend at most | An **amount**: what the player wins, at most, if the combo pays |
| Sees | Only the best amount | Every request, and only its own quotes |
| Knows the other side by | Nothing; no payload names a maker | The player's `external_id`, a pseudonym |
| Accepts or cancels | Yes | No; a maker withdraws its own quotes |
| Side of the trade | Buys the combo | Sells the combo |

The best quote is the **largest** amount: more for the player to win on the same stake. Neither side names a price or a size. STX derives both from the stake and the bound amount, on the combo's own grid, rounding in the maker's favour (see [How price and size are derived](#how-price-and-size-are-derived)).

Any account whose connection can place orders can request or quote: an API key with `read_write` scope, or an OAuth token with [`orders.write`](/oauth/scopes/). An account can join both topics, but cannot quote on its own request.

## Player and maker flow

1. **Request.** The player sends the legs and a stake. The reply is an `rfq_id`. The request lives **5 minutes**; the player does not choose this. Nothing is reserved and no market is created yet; STX checks only that the available balance covers the stake.
2. **Feed.** Every connected maker is pushed `rfq_opened`: the legs, the stake, the player's `external_id`, and the `max_price` and `tick_size` to price against. Requests opened before a maker joined are not replayed.
3. **Quote.** Makers send amounts against the `rfq_id`, each with its own lifetime in milliseconds. A quote holds no funds and checks no balance. A maker may hold several quotes on one request; to change one, withdraw it and quote again.
4. **Best quote.** The player is pushed the best amount as it changes: nothing in the first 500 ms, so makers can compete, then at most one push every 250 ms.
5. **Accept.** The player accepts an amount. It is a floor, not an exact match: the best live quote binds if its amount is at least the one accepted, whichever maker made it. If the best has fallen below it, the answer is `price_moved` with the new best, and the request stays open.
6. **Bind.** Both balances are checked again, the combo's market is found or created, and STX places the player's limit order, then the maker's order at the same price and size, which cancels whatever it does not fill at once. The player and the bound maker are pushed `placed`; every other maker's quote is closed `placed_elsewhere`, and the feed hears `rfq_closed`.

**The reply says what was placed, not what filled.** The book decides the fills: the player's order takes any better resting price first, and whatever the maker does not fill stays on the book as the player's ordinary open order. Read fills from the [fills](/websockets/channels/fills/) channel.

The player can cancel any time before a bind. Closing the channel that opened a request, or logging out, cancels it too, and closing a maker's channel withdraws the quotes placed on it.

[Quote combos as a maker](/websockets/combo-maker/) is a complete maker for steps 2 to 6, in Python, TypeScript, C# and over a plain socket.

## How price and size are derived

On a buy, the player stakes `stake` and the bound maker quoted `amount`:

```text
price    = max_price × stake / (stake + amount), rounded UP to the tick
quantity = floor(stake / price)
```

Rounding up favours the maker: the player pays a little more per contract, so the maker never owes more than it quoted. From the captured buy on the [channel page](/websockets/channels/combo-negotiation/#a-buy), a `$5` stake bound against a `$10` quote:

| | Value |
| --- | --- |
| Stake | `5.00` |
| Bound amount | `10.00` |
| Price | `5 / 15 = 0.33333…`, rounded up to `0.3334` |
| Quantity | `floor(5 / 0.3334)` = `14` |
| Player pays, at most | `14 × 0.3334` = `4.6676`, plus fees |
| Player wins if the combo pays | `(1 − 0.3334) × 14` = `9.3324` |
| Maker owes, at most | `9.3324`, against the `10.00` it quoted |

Contracts are whole, so the stake is not always spent to the cent: here `0.3324` of it stays in the player's account. The stake is accepted to the cent and no finer.

**Maker exposure.** The maker's risk is not the player's stake. Against a buy, a maker selling `quantity` at `price` owes, if the combo settles at its ceiling:

```text
(max_price − price) × quantity
```

That is what the maker's balance is checked against at the bind, and it is never more than the maker's amount. A maker that cannot fund it at the bind loses every quote it holds on the request, and the next best quote is tried.

## Cash out

A holder sells a combo position back through the same negotiation, in the other direction. The holder sends `cash_out` naming only the combo's market; STX sets the size; makers quote what they pay for the whole size; the holder accepts.

| | Entering | Cashing out |
| --- | --- | --- |
| Player's side | Buy | Sell |
| Maker's side | Sell | Buy |
| Player names | A stake | Nothing: STX sets the size |
| Maker's amount is | What the player wins | What the maker pays for the whole size |
| Best quote is the | Largest amount | Largest amount |
| Price | `max_price × stake / (stake + amount)`, rounded up | `amount / quantity`, rounded down |
| Maker's exposure | `(max_price − price) × quantity` | `price × quantity` |

In the [captured cash out](/websockets/channels/combo-negotiation/#a-cash-out) the player sells the 14 contracts against quotes of `$3.73` and `$4.20`. An accept at `$3.73` binds the `$4.20`: `4.20 / 14 = 0.3000`, so the player's sell of 14 brings in `4.2000`, never more than the maker quoted. An amount that does not divide evenly is rounded down: `$4.19` would price at `4.19 / 14 = 0.299285…`, so `0.2992`.

- **The size** is what the account can sell now: its position less what its own resting sells already offer, in whole contracts. A fill counts once the trade is recorded, so a cash out sent straight after buying can be refused `nothing_to_sell` for a moment. Retry it.
- **The size is fixed when the request opens.** If the holding no longer covers it at the bind, the request ends.
- **Every leg must still be `open`.** Once a leg resolves, the position cannot be cashed out. The combo keeps trading until its price is decided, so the holder can still sell on its ordinary book, or hold to settlement.

## Settlement

A combo closes as soon as its price is decided: when one leg makes it worthless, or when every leg has settled. It results 60 seconds later at:

```text
price = max_price × ∏ (leg factor), rounded down to 7 decimal places
```

The result is not rounded to the tick. Each leg's factor comes from that leg's settled value, its result price over its own `max_price` (`1` for won, `0` for lost, `0.5` for a push):

- A leg the combo needs to **win** contributes its settled value.
- A leg the combo needs to **lose** contributes one minus its settled value.

So a leg that lands as needed contributes `1`, a leg that misses contributes `0`, and a push contributes `0.5`.

For the 14 contracts bought at `0.3334` above:

| Legs | Combo price | Player (gross) | Maker (gross) |
| --- | --- | --- | --- |
| Both land as needed | `1.0000` | `+9.3324` | `−9.3324` |
| One pushes, the other lands | `0.5000` | `+2.3324` | `−2.3324` |
| Either misses | `0.0000` | `−4.6676` | `+4.6676` |

- **A voided leg** is referred to operators, and the combo keeps its status until it is settled manually. Its trading stops once the event completes. A combo that a missed leg has already closed settles at zero.
- Fees follow the [fee schedule](/concepts/fees/) as for any order. Neither negotiation topic reports them. In a bind the player's order takes the liquidity and the maker's provides it, so the player pays the taker rate and the maker the provider rate. What is left of the player's order keeps that role: it takes against a later bind's maker order and provides to every other order.

## After the bind: an ordinary market

From the first bind, a combo is a real market with real orders, and everything downstream works as for any other market:

| You want | REST | WebSocket |
| --- | --- | --- |
| Your orders | [List orders](/api/rest/orders/list-orders/) | [Orders channel](/websockets/channels/orders/) |
| Your fills | [List fills](/api/rest/fills/list-fills/) | [Fills channel](/websockets/channels/fills/) |
| Your position | [List open positions](/api/rest/account/list-open-positions/) | [Positions channel](/websockets/channels/positions/) |
| The settlement | [List settlements](/api/rest/portfolio/list-settlements/) | [Settlements channel](/websockets/channels/settlements/) |
| Your balance | [Get account balance](/api/rest/account/get-account-balance/) | [Balances channel](/websockets/channels/balances/) |

Two differences from a listed market:

- **A combo is not listed.** No market list, tree or filter includes it, and it is not on the market catalogue channels. Track it by the `market_id` that `placed` returned.
- **Its book is open to anyone who has its id.** Ordinary orders on a combo's market are accepted like any other, and its order book is on the [order book channel](/websockets/order-book/) at the market's own precision. A bind's orders trade against whatever rests there.
