The StrategyAnalysis class is a part of a backtesting website and is responsible for analyzing trading strategies. It extends the IStrategy interface, which provides methods for confirming trade exits. The confirm_trade_exit method is overridden to include additional functionality for logging and sending notifications.
When a trade exit is confirmed, the method calculates various metrics related to the trade, such as minimum and maximum profit percentages, trade duration, and overall profit.
These metrics are then logged in a table format.
If the profit is negative, it is logged in red color; otherwise, it is logged in green color. If the website is configured to use Telegram, the method also sends a notification message to a specified Telegram chat. The message includes information about the trade, such as the pair, minimum and maximum profits, and open/close fees. Similarly, if the website is configured to use Discord, the method sends an embedded message to a specified Discord webhook. The message includes details about the trade, such as the pair, profit percentage, open rate, and sell reason. Overall, the StrategyAnalysis class enhances the functionality of trading strategy analysis by providing logging and notification capabilities for various platforms.