Spread and Price Impact#

Quoted Spread#

The percentage quoted spread is

(1)#\[\text{Q-spread}=\frac{Ask_{it}-Bid_{it}}{m_{it}} \times 100\]

where \(m_{it}=(Ask_{it}+Bid_{it})/2\) is the bid-ask midpoint at time \(t\).

Alternatively, the log spread is

(2)#\[\text{Q-spread}=\ln Ask_{it}- \ln Bid_{it}\]

Effective Spread#

The effective spread measures a round trip cost for liquidity trader selling the stock immediately after the purchase, so it is defined as two times the absolute difference between the natural logarithms of the transaction price and the quoted midpoint at the trading time.

The percentage effective spread is

(3)#\[\text{E-spread}=\frac{2\times|P_{it}-m_{it}|}{m_{it}} \times 100\]

Alternatively, the log spread is

(4)#\[\text{E-spread (log)}=2\times|\ln P_{it}-\ln m_{it}|\]

Trade directions can be included into the calculation of effective spread. Specifically, if \(q_{it}=1\) means a buy and \(q_{it}=-1\) means a sell, then we have

(5)#\[\text{E-spread}=\frac{2 q_{it} (P_{it}-m_{it})}{m_{it}} \times 100\]
(6)#\[\text{E-spread (log)}=2 q_{it} (\ln P_{it}-\ln m_{it})\]

Note

JFE 2021: Bias in the effective bid-ask spread https://doi.org/10.1016/j.jfineco.2021.04.018

Realized Spread#

Realized spread is the temporary component of the effective spread. The realized spread measures the profit or loss to a liquidity provider assuming the she can close her position at the quoted bid-ask midpoint sometime after the trade. Typically, this time difference between opening and closing the position is set to five minutes (\(\tau=5\text{min}\)).

The percentage realized spread is

(7)#\[\text{R-spread}=\frac{2\times|P_{it}-m_{it+\tau}|}{m_{it}} \times 100\]

Alternatively, the log spread is

(8)#\[\text{R-spread (log)}=2\times|\ln P_{it}-\ln m_{it+\tau}|\]

It is also common to include trade direction into the calculation of realized spread. Specifically, if \(q_{it}=1\) means a buy and \(q_{it}=-1\) means a sell, then we have

(9)#\[\text{R-spread}=\frac{2 q_{it} (P_{it}-m_{it+\tau})}{m_{it}} \times 100\]
(10)#\[\text{R-spread (log)}=2 q_{it} (\ln P_{it}-\ln m_{it+\tau})\]

Simple Price Impact#

(Simple) Price impact is the permanent component of the effective spread.

The percentage price impact is

(11)#\[\text{Simple Price Impact}=\frac{2\times|m_{it+\tau}-m_{it}|}{m_{it}} \times 100\]

Alternatively, the log version is

(12)#\[\text{Simple Price Impact (log)}=2\times|\ln m_{it+\tau}-\ln m_{it}|\]

To include trade direction into the calculation of realized spread, where \(q_{it}=1\) means a buy and \(q_{it}=-1\) means a sell, we have

(13)#\[\text{Simple Price Impact}=\frac{2 q_{it} (m_{it+\tau}-m_{it})}{m_{it}} \times 100\]
(14)#\[\text{Simple Price Impact (log)}=2 q_{it} (\ln m_{it+\tau}-\ln m_{it})\]

Note

Basically, effective spread is the sum of realized spread and price impact.

API#

frds.measures.spread.quoted_spread(bid: ndarray, ask: ndarray, pct_spread=True) float[source]#

Quoted bid-ask spread (simple weighted)

Parameters:
  • bid (np.ndarray) – (N,) array of N bids

  • ask (np.ndarray) – (N,) array of N asks

  • pct_spread (bool, optional) – whether to return percentage spread. Defaults to True. If False, return log spread.

Returns:

quoted spread

Return type:

float

frds.measures.spread.effective_spread(price: ndarray, midpoint: ndarray, volume: ndarray, trade_direction: ndarray = None, pct_spread=True) float[source]#

Effective spread (dollar volume weighted)

Parameters:
  • price (np.ndarray) – (N,) array of N trade prices

  • midpoint (np.ndarray) – (N,) array of N bid-ask midpoints

  • volume (np.ndarray) – (N,) array of N trade sizes

  • trade_direction (np.ndarray, optional) – (N,) array of N trade directions. Defaults to None. If None, use equation (3) or (4). If set, use equation (5) or (6).

  • pct_spread (bool, optional) – whether to return percentage spread. Defaults to True. If False, return log spread.

Returns:

effective spread

Return type:

float

frds.measures.spread.realized_spread(price: ndarray, midpoint_later: ndarray, midpoint: ndarray, volume: ndarray, trade_direction: ndarray = None, pct_spread=True) float[source]#

Realized spread (dollar volume weighted)

Parameters:
  • price (np.ndarray) – (N,) array of N trade prices

  • midpoint_later (np.ndarray) – (N,) array of N bid-ask midpoints some time (e.g., 5min) after corresponding trade

  • midpoint (np.ndarray) – (N,) array of N bid-ask midpoints at trade

  • volume (np.ndarray) – (N,) array of N trade sizes

  • trade_direction (np.ndarray, optional) – (N,) array of N trade directions. Defaults to None. If None, use equation (7) or (8). If set, use equation (9) or (10).

  • pct_spread (bool, optional) – whether to return percentage spread. Defaults to True. If False, return log spread.

Returns:

realized spread

Return type:

float

frds.measures.price_impact.simple_price_impact(price: ndarray, midpoint_later: ndarray, midpoint: ndarray, volume: ndarray, trade_direction: ndarray = None, pct_spread=True) float[source]#

Simple Price Impact (dollar volume weighted)

Parameters:
  • price (np.ndarray) – (N,) array of N trade prices

  • midpoint_later (np.ndarray) – (N,) array of N bid-ask midpoints some time (e.g., 5min) after corresponding trade

  • midpoint (np.ndarray) – (N,) array of N bid-ask midpoints at trade

  • volume (np.ndarray) – (N,) array of N trade sizes

  • trade_direction (np.ndarray, optional) – (N,) array of N trade directions. Defaults to None. If None, use equation (11) or (12). If set, use equation (13) or (14).

  • pct_spread (bool, optional) – whether to return percentage spread. Defaults to True. If False, return log spread.

Returns:

simple price impact

Return type:

float

Examples#