The TestStrategy class is a backtesting strategy that adds various technical indicators to a given DataFrame of trading data. These indicators include ADX, RSI, stochastic fast %D and %K, MACD, MFI, Bollinger Bands, SAR, TEMA, and Hilbert Transform Sine and Lead Sine. The populate_indicators method populates the DataFrame with these indicators.
It takes a DataFrame of trading data and additional metadata as input and returns a DataFrame with all the mandatory indicators.
The buy and sell strategies are defined as static methods within the TestStrategy class.
The buy strategy is used to generate buy signals based on a set of conditions specified in the input parameters. The conditions can include MFI, %D, ADX, RSI, Bollinger Bands, MACD, and SAR indicators, as well as volume requirements. If the conditions are met, a 'buy' signal is set to 1 in the DataFrame. The sell strategy is used to generate sell signals based on a set of conditions specified in the input parameters. The conditions can include MFI, %D, ADX, RSI, Bollinger Bands, MACD, and SAR indicators, as well as volume requirements. If the conditions are met, a 'sell' signal is set to 1 in the DataFrame. The populate_buy_trend and populate_sell_trend methods use the buy and sell strategy generators to populate the DataFrame with buy and sell signals, respectively. Overall, the TestStrategy class provides a framework for backtesting trading strategies by adding technical indicators and generating buy and sell signals based on specified conditions.