Effective Spread
Install and import
npm install fintech-algorithmsimport { effectiveSpread } from "fintech-algorithms/market-microstructure/liquidity-and-spreads/effective-spread";Signature
effectiveSpread(bid, ask, tradePrice, side)Twice the signed distance from the midpoint to the trade price — what the trade actually paid. Narrower than the quoted spread when trades execute inside it, wider when they sweep.
Parameters
| Name | Type | Notes |
|---|---|---|
bid | number | Best bid at the time of the trade. |
ask | number | Best ask at the time of the trade. |
tradePrice | number | Executed price. |
side | "buy" | "sell" | Trade direction, usually from a classifier in D11-F01. |
Returns
{ effective_spread, relative, midpoint, price_improvement }
The effective spread and the price improvement against the quote.
Errors
- When side is not buy or sell, or ask is below bid — throws
Complexity: time O(1),
space O(1).
Worked example
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input
100100.08100.07"buy"Call
effectiveSpread(bid, ask, tradePrice, side)Returns
object with 17 fields: model, bid, ask, midpoint, quoted_spread, quoted_spread_relative, quoted_spread_bps, state, …
{
"model": "effective-spread",
"bid": 100,
"ask": 100.08,
"midpoint": 100.03999999999999,
"quoted_spread": 0.0799999999999983,
"quoted_spread_relative": 0.0007996801279488034,
"quoted_spread_bps": 7.996801279488034,
"state": "inside-quote",
"trade_price": 100.07,
"side": "buy",
"direction": 1,
"effective_spread": 0.060000000000002274,
"effective_spread_relative": 0.0005997600959616381,
"effective_spread_bps": 5.997600959616381
}Showing 14 of 17 fields.
Other exports
This module also exports
quotedSpread, realizedSpread, rollSpread, amihudIlliquidity, corwinSchultzSpread, calculate. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams
How it works
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References
- SEC Rule 605 adopting release — U.S. Securities and Exchange Commission
- NYSE Daily TAQ product description — New York Stock Exchange
- 2024 Rule 605 Amendments adopting release — U.S. Securities and Exchange Commission
- Rule 605 staff frequently asked questions — U.S. Securities and Exchange Commission, Division of Trading and Markets staff
- Rule 605 staff FAQ transition — U.S. Securities and Exchange Commission, Division of Trading and Markets staff