The NormalizerStrategy is a trading strategy implemented as a class that inherits from the IStrategy interface. It consists of three main functions: populate_indicators, populate_buy_trend, and populate_sell_trend. The populate_indicators function calculates and populates various indicators based on the given dataframe and metadata.
It iterates over a list of lookback periods, including values such as 13, 21, 34, and so on.
For each lookback period, it applies the fischer_norm function to the "close" values in the dataframe to calculate a normalized value, and stores it in a corresponding column named "norm_{look}".
It also creates a list of column names that start with "norm" called collist. Finally, it sums up the values in collist for each row and stores the result in a new column called "pct_sum". The updated dataframe is then returned. The populate_buy_trend function adds a "buy" signal to the dataframe based on certain conditions. It sets the "buy" column to 1 for rows where the "pct_sum" value is less than 0.2 and the "volume" value is greater than 0 (ensuring that the volume is not zero). Similarly, the populate_sell_trend function adds a "sell" signal to the dataframe based on certain conditions. It sets the "sell" column to 1 for rows where the "pct_sum" value is greater than 8 and the "volume" value is greater than 0. Overall, the NormalizerStrategy calculates normalized indicators, and based on the values of these indicators, generates "buy" and "sell" signals in the dataframe, which can be used for backtesting and evaluating trading strategies.