# Dynamic spreads

Dynamic spreads are a **per-pair execution mechanism** that scales execution cost as a function of **short-term order flow** (buy and sell volume). This allows Ostium to support **higher OI caps** for less liquid assets.

Execution cost has two parts:

**price impact = market spread + dynamic component**

* **Market spread** is always charged as the baseline.
* **Dynamic component** is charged on top, based on short-term pressure and trade size.

> For liquid assets like **SPX** or **EURUSD**, price impact is typically minimal compared to pairs like **LINKUSD**.

***

### Modes: ON / OFF

* **OFF** → price impact = market spread → executed at bid/ask
* **ON** → price impact = market spread + dynamic component

***

### Dynamic component

The dynamic component uses:

* **Initial volume**: short-term buy or sell pressure *before* the trade executes
* **Trade size (USD)**: notional (collateral × leverage)
* **priceImpactK**: a parameter extrapolated from the underlying market order book (based on L2/L3 data)

For a given initialVolume, tradeSize, and priceImpactK, the function returns the **average price impact** for that order size under those market conditions.

***

### Short-term pressure and decay

Ostium tracks two independent pressure signals:

* **buyVolume** (decays over time)
* **sellVolume** (decays over time)

Decay velocity is approximated by a **negative exponential**. The UI displays how long it will take for buy/sell volume to decay.

***

### Buy vs sell equivalence

Whether a trade uses buyVolume or sellVolume depends on the action:

|       | Open | Close |
| ----- | ---- | ----- |
| Long  | Buy  | Sell  |
| Short | Sell | Buy   |

* **Buy-equivalent:** opening a long, closing a short
* **Sell-equivalent:** closing a long, opening a short

***

### Recommendations

* Use **slippage protection** (always).
* **Split large trades** into smaller chunks.
* **Wait between chunks** so pressure can decay.
* Monitor **Simulated spread** before sending the next chunk to avoid trading into peak pressure.
