# Dynamic spreads

{% hint style="warning" %}
These docs are deprecated and may be outdated. Please use the new docs: [docs.ostium.com](https://docs.ostium.com/)
{% endhint %}

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 **US500** 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ostium-labs.gitbook.io/ostium-docs/dynamic-spreads.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
