quantpylib.hft.features
rolling_vol(mids, n, exp=False)
Calculate rolling volatility of the mid prices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mids
|
ndarray
|
Array of mid prices. |
required |
n
|
int
|
The size of the rolling window. |
required |
exp
|
bool
|
Whether to use exponential weighting. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
np.ndarray: An array of rolling volatilities. |
sample_vamp(bids, asks, notional=None, bid_notional=None, ask_notional=None)
Calculate the Volume Adjusted Mid Price (VAMP).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bids
|
ndarray
|
Array of bid levels as [price, volume]. |
required |
asks
|
ndarray
|
Array of ask levels as [price, volume]. |
required |
notional
|
float
|
The notional amount for both sides of the orderbook (each). Defaults to None. |
None
|
bid_notional
|
float
|
The notional amount for bids. Defaults to |
None
|
ask_notional
|
float
|
The notional amount for asks. Defaults to |
None
|
Returns:
Name | Type | Description |
---|---|---|
float |
The calculated VAMP. |
sample_vol(sample, exp=False)
Calculate the sample volatility.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sample
|
ndarray
|
The input sample. |
required |
exp
|
bool
|
Whether to use exponential weighting. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
float |
The calculated sample volatility. |
volume_weighted_price(ob_levels, notional)
Calculate the volume-weighted price for a given notional amount.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ob_levels
|
ndarray
|
The order book levels as an array of [price, volume]. |
required |
notional
|
float
|
The notional amount. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
The volume-weighted price. |