The StrategyAnalysis class is a part of a backtesting website that performs backtesting on trading strategies. It extends the IStrategy interface, indicating that it implements the required methods for a trading strategy. One of the important methods in this class is confirm_trade_exit().
It takes several parameters related to a trade and determines whether the trade should be exited.
Within this method, there are additional actions performed when the backtesting mode is active.
In backtesting mode, a table is logged for each trading pair. The table contains information such as the pair itself, the minimum and maximum profit percentages, the duration of the trade in minutes, the profit percentage, and the stop-loss percentage. If the profit is negative, the table entry is logged in red color; otherwise, it is logged in green color. If the Telegram integration is enabled and the backtesting mode is active, a message is sent via Telegram. The message includes the pair, minimum and maximum profit percentages, open and close fees, and other relevant information. There are two helper methods used within the class: telegram_send() and log(). The telegram_send() method sends a message to a specified Telegram chat if the backtesting mode is dry run or live, and the Telegram integration is enabled. The log() method logs a message with a specified color (red or green) using the logger. Overall, the StrategyAnalysis class performs analysis and logging of trade exit confirmation, generates tables with trade information in backtesting mode, sends Telegram messages, and logs messages with different colors.