Skip to main content

RollingSpreadModel

RollingSpreadModel(
    window: int = 365,
    minp: int = None,
    upper: float = 0.2,
    lower: float = -0.2,
)
Rolling divergence spread model. The spread represents the relative performance of both instruments. Whenever the two instruments move apart, the spread increases and may reach a certain threshold where we take a long position in the underperformer and a short position in the overachiever. This threshold is set as percentage point. All of this is done in a rolling manner to reduce noise. Method generated by attrs for class RollingSpreadModel.

Ancestors

  • systematica.models.base.BaseStatArb
  • abc.ABC

Static methods

get_feature_expression

get_feature_expression() ‑> systematica.generic.base.FeatureExpression
Returns the expression model for rolling spread strategy. Returns:
TypeDescription
StatArbExprModelThe expression model containing the PTS expression and included packages.

Instance variables

  • lower: float: Lower threshold. Defaults to -0.2.
  • minp: int: Mininim period. Defaults to None, which means no minimum period is applied.
  • upper: float: Upper threshold. Defaults to 0.2.
  • window: int: The size of the rolling window. Defaults to 365.

Methods

plot

plot(
    self,
    data: vectorbtpro.data.base.Data,
    s1: str,
    s2: str,
    use_close: bool = True,
    clean: bool = True,
) ‑> vectorbtpro.utils.figure.Figure
Plot rolling spread scores with entry and exit signals. Parameters:
NameTypeDefaultDescription
datavbt.Data--Input data containing time series data.
s1str--Column name for the first symbol.
s2str--Column name for the second symbol.
use_closeboolTrueUse close price if set to True. Otherwise, use open price. Defaults to True.
cleanboolTrueWhether to clean the entry and exit signals. Defaults to True.
Returns:
TypeDescription
vbt.FigureFigure object with the plot.

RollingZscoreModel

RollingZscoreModel(
    use_returns: bool = False,
    window: int = 365,
    minp: int = None,
    upper_alpha: float = 0.05,
    lower_alpha: float = 0.05,
)
Rolling divergence spread model. The spread represents the relative performance of both instruments. Whenever the two instruments move apart, the spread increases and may reach a certain threshold where we take a long position in the underperformer and a short position in the overachiever. This threshold is set to a number of standard deviations from the mean. All of this is done in a rolling manner, as the linear relationship between the instruments is always changing. We will use the prediction error of the ordinary least squares (OLS), which is the difference between the true value and the predicted value. Method generated by attrs for class RollingZscoreModel.

Ancestors

  • systematica.models.base.BaseStatArb
  • abc.ABC

Static methods

get_feature_expression

get_feature_expression() ‑> systematica.generic.base.FeatureExpression
Returns the expression model for rolling spread strategy. Returns:
TypeDescription
StatArbExprModelThe expression model containing the PTS expression and included packages.

Instance variables

  • lower_alpha: float: Lower tail probability used to compute percent point function (inverse of cdf) at q of the given RV. Defaults to 0.05.
  • minp: int: Mininim period. Defaults to None, which means no minimum period is applied.
  • upper_alpha: float: Upper tail probability used to compute percent point function (inverse of cdf) at q of the given RV. Defaults to 0.05.
  • use_returns: bool: Flag to explicitly use returns as input if True. Otherwise, use log prices Defaults to `False.
  • window: int: The size of the rolling window. Defaults to 365.

Methods

plot

plot(
    self,
    data: vectorbtpro.data.base.Data,
    s1: str,
    s2: str,
    use_close: bool = True,
    clean: bool = True,
) ‑> vectorbtpro.utils.figure.Figure
Plot rolling spread z-scores with entry and exit signals. Parameters:
NameTypeDefaultDescription
datavbt.Data--Input data containing time series data.
s1str--Column name for the first symbol.
s2str--Column name for the second symbol.
use_closeboolTrueUse close price if set to True. Otherwise, use open price. Defaults to True.
cleanboolTrueWhether to clean the entry and exit signals. Defaults to True.
Returns:
TypeDescription
vbt.FigureFigure object with the plot.