Spread and Price Impact#
Quoted Spread#
The percentage quoted spread is
where \(m_{it}=(Ask_{it}+Bid_{it})/2\) is the bid-ask midpoint at time \(t\).
Alternatively, the log spread is
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
Alternatively, the log spread is
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
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
Alternatively, the log spread is
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
Simple Price Impact#
(Simple) Price impact is the permanent component of the effective spread.
The percentage price impact is
Alternatively, the log version is
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
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 ofN
bidsask (np.ndarray) –
(N,)
array ofN
askspct_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 ofN
trade pricesmidpoint (np.ndarray) –
(N,)
array ofN
bid-ask midpointsvolume (np.ndarray) –
(N,)
array ofN
trade sizestrade_direction (np.ndarray, optional) –
(N,)
array ofN
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 ofN
trade pricesmidpoint_later (np.ndarray) –
(N,)
array ofN
bid-ask midpoints some time (e.g., 5min) after corresponding trademidpoint (np.ndarray) –
(N,)
array ofN
bid-ask midpoints at tradevolume (np.ndarray) –
(N,)
array ofN
trade sizestrade_direction (np.ndarray, optional) –
(N,)
array ofN
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 ofN
trade pricesmidpoint_later (np.ndarray) –
(N,)
array ofN
bid-ask midpoints some time (e.g., 5min) after corresponding trademidpoint (np.ndarray) –
(N,)
array ofN
bid-ask midpoints at tradevolume (np.ndarray) –
(N,)
array ofN
trade sizestrade_direction (np.ndarray, optional) –
(N,)
array ofN
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