Example #1
0
    def _log_global_report(self, exchange_manager):
        _, profitability, _, market_average_profitability, _ = trading_api.get_profitability_stats(
            exchange_manager)
        reference_market = trading_api.get_reference_market(
            self.backtesting_config)
        end_portfolio = trading_api.get_portfolio(exchange_manager)
        end_portfolio_value = trading_api.get_current_portfolio_value(
            exchange_manager)
        starting_portfolio = trading_api.get_origin_portfolio(exchange_manager)
        starting_portfolio_value = trading_api.get_origin_portfolio_value(
            exchange_manager)

        self.logger.info(
            f"[End portfolio]      value {round(end_portfolio_value, 5)} {reference_market} "
            f"Holdings: {pretty_printer.global_portfolio_pretty_print(end_portfolio, ' | ')}"
        )

        self.logger.info(
            f"[Starting portfolio] value {round(starting_portfolio_value, 5)} {reference_market} "
            f"Holdings: {pretty_printer.global_portfolio_pretty_print(starting_portfolio, ' | ')}"
        )

        self.logger.info(
            f"Global market profitability (vs {reference_market}) : "
            f"{market_average_profitability}% | Octobot : {profitability}%")

        self.logger.info(
            f"Simulation lasted "
            f"{round(backtesting_api.get_backtesting_duration(self.octobot_backtesting.backtesting), 3)} sec"
        )
Example #2
0
    def _get_exchanges_report(self, reference_market, trading_mode):
        SYMBOL_REPORT = "symbol_report"
        BOT_REPORT = "bot_report"
        CHART_IDENTIFIERS = "chart_identifiers"
        ERRORS_COUNT = "errors_count"
        report = {
            SYMBOL_REPORT: [],
            BOT_REPORT: {},
            CHART_IDENTIFIERS: [],
            ERRORS_COUNT: logging.get_backtesting_errors_count()
        }
        profitabilities = {}
        market_average_profitabilities = {}
        starting_portfolios = {}
        end_portfolios = {}
        for exchange_id in self.octobot_backtesting.exchange_manager_ids:
            exchange_manager = trading_api.get_exchange_manager_from_exchange_id(
                exchange_id)
            _, profitability, _, market_average_profitability, _ = trading_api.get_profitability_stats(
                exchange_manager)
            min_timeframe = time_frame_manager.find_min_time_frame(
                trading_api.get_watched_timeframes(exchange_manager))
            exchange_name = trading_api.get_exchange_name(exchange_manager)
            for symbol in self.symbols_to_create_exchange_classes[
                    exchange_name]:
                market_delta = self._get_market_delta(symbol, exchange_manager,
                                                      min_timeframe)
                report[SYMBOL_REPORT].append({symbol: market_delta * 100})
                report[CHART_IDENTIFIERS].append({
                    "symbol":
                    symbol,
                    "exchange_id":
                    exchange_id,
                    "exchange_name":
                    exchange_name,
                    "time_frame":
                    min_timeframe.value
                })
            profitabilities[exchange_name] = profitability
            market_average_profitabilities[
                exchange_name] = market_average_profitability
            starting_portfolios[
                exchange_name] = trading_api.get_origin_portfolio(
                    exchange_manager)
            end_portfolios[exchange_name] = trading_api.get_portfolio(
                exchange_manager)

        report[BOT_REPORT] = {
            "profitability": profitabilities,
            "market_average_profitability": market_average_profitabilities,
            "reference_market": reference_market,
            "end_portfolio": end_portfolios,
            "starting_portfolio": starting_portfolios,
            "trading_mode": trading_mode
        }
        return report