Skip to content

Class InverseFisherRelativeStrengthIndex

  • Jump right in for a hands-on Open In Colab

Import

from NitroFE import InverseFisherRelativeStrengthIndex

InverseFisherRelativeStrengthIndex

Inverse Fisher Relative Strength Index is calculated as (IFRSI)

\[ RSI = Relative\_Strength\_Index \]
\[ ranged\_RSI = 0.1 * (RSI - 50) \]
\[ wRSI = weighted \ moving \ average \ of ranged\_RSI \ of \ size \ 'lookback\_for\_inverse\_fisher' \]
\[ IFRSI = \frac{\exp(2*wRSI)-1}{\exp(2*wRSI)+1} \]

For your training/initial fit phase (very first fit) use fit_first=True, and for any production/test implementation pass fit_first=False

Methods

__init__(self, lookback_period=8, lookback_for_inverse_fisher=8) special

Parameters:

Name Type Description Default
lookback_period int

Size of the rolling window for lookback, by default 8

8
lookback_for_inverse_fisher int

Size of the rolling window for lookback for weighted moving average of rsi, by default 8

8
Source code in nitrofe\time_based_features\indicator_features\_inversefisherrelativestrengthindex.py
def __init__(self, lookback_period: int = 8, lookback_for_inverse_fisher: int = 8):
    """
    Parameters
    ----------
    lookback_period : int, optional
        Size of the rolling window for lookback, by default 8
    lookback_for_inverse_fisher : int, optional
        Size of the rolling window for lookback for weighted moving average of rsi, by default 8
    """
    self.lookback_period = lookback_period
    self.lookback_for_inverse_fisher = lookback_for_inverse_fisher

fit(self, dataframe, first_fit=True)

Parameters:

Name Type Description Default
dataframe Union[pandas.core.frame.DataFrame, pandas.core.series.Series]

dataframe containing column values to create feature over

required
first_fit bool

Indicator features require past values for calculation. Use True, when calculating for training data (very first fit) Use False, when calculating for subsequent testing/production data { in which case the values, which were saved during the last phase, will be utilized for calculation }, by default True

True
Source code in nitrofe\time_based_features\indicator_features\_inversefisherrelativestrengthindex.py
def fit(self, dataframe: Union[pd.DataFrame, pd.Series], first_fit: bool = True):
    """
    Parameters
    ----------
    dataframe : Union[pd.DataFrame, pd.Series]
        dataframe containing column values to create feature over
    first_fit : bool, optional
        Indicator features require past values for calculation.
        Use True, when calculating for training data (very first fit)
        Use False, when calculating for subsequent testing/production data { in which case the values, which
        were saved during the last phase, will be utilized for calculation }, by default True
    """

    if first_fit:
        self._rsi_object = RelativeStrengthIndex(
            lookback_period=self.lookback_period
        )
        self._ww_object = weighted_window_features()

    rsi_value = self._rsi_object.fit(dataframe, first_fit=first_fit)

    rsi_value = 0.1 * (rsi_value - 50)

    rsi_value = self._ww_object.caluclate_weighted_moving_window_feature(
        dataframe=rsi_value,
        first_fit=first_fit,
        window=self.lookback_for_inverse_fisher,
        operation=np.sum,
    )

    rsi_value = (np.exp(2 * rsi_value) - 1) / (np.exp(2 * rsi_value) + 1)
    return rsi_value

References