The data parameter in the augment_qsmomentum function is expected to be a pandas DataFrame or a pandas DataFrameGroupBy object. This parameter represents the input data on which the momentum calculations will be performed.
required
date_column
str
The date_column parameter in the augment_qsmomentum function refers to the column in your input data that contains the dates associated with the financial data. This column is used for time-based operations and calculations within the function.
required
close_column
str
The close_column parameter in the augment_qsmomentum function refers to the column in the input DataFrame that contains the closing prices of the financial instrument or asset for which you want to calculate the momentum.
required
roc_fast_period
Union[int, Tuple[int, int], List[int]]
The roc_fast_period parameter in the augment_qsmomentum function determines the period used for calculating the fast Rate of Change (ROC) momentum indicator.
21
roc_slow_period
Union[int, Tuple[int, int], List[int]]
The roc_slow_period parameter in the augment_qsmomentum function represents the period used for calculating the slow rate of change (ROC) in momentum analysis.
252
returns_period
Union[int, Tuple[int, int], List[int]]
The returns_period parameter in the augment_qsmomentum function determines the period over which the returns are calculated.
126
reduce_memory
bool
The reduce_memory parameter in the augment_qsmomentum function is a boolean flag that indicates whether memory reduction techniques should be applied to the input data before and after the momentum calculation process. If set to True, memory reduction methods will be used to optimize memory usage, potentially reducing
False
engine
str
The engine parameter in the augment_qsmomentum function specifies the computation engine to be sed for calculating momentum. It can have two possible values: βpandasβ or βpolarsβ.
'pandas'
Returns
Type
Description
The function augment_qsmomentum returns a pandas DataFrame that has been augmented with columns
representing the Quant Science Momentum (QSM) calculated based on the specified parameters such as roc_fast_period, roc_slow_period, and returns_period.
Notes
The Quant Science Momentum (QSM) is a momentum indicator that is calculated based on the Slow Rate of Change (ROC) usually over a 252-day period and the Fast Rate of Change (ROC) usually over a 21-day period.
The QSM is calculated as the difference between the slow and fast ROCs divided by the standard deviation of the returns over a specified period.
This provides a measure of momentum that is normalized by the rolling volatility of the returns.
Examples
import pandas as pdimport polars as plimport pytimetk as tkdf = tk.load_dataset("stocks_daily", parse_dates = ['date'])df.glimpse()