Example #1
0
    async def _init_exchanges(self):
        self.backtesting = await backtesting_api.initialize_backtesting(
            self.backtesting_config,
            exchange_ids=self.exchange_manager_ids,
            matrix_id=self.matrix_id,
            data_files=self.backtesting_files)
        # modify_backtesting_channels before creating exchanges as they require the current backtesting time to
        # initialize
        await backtesting_api.adapt_backtesting_channels(
            self.backtesting,
            self.backtesting_config,
            importers.ExchangeDataImporter,
            run_on_common_part_only=self.run_on_common_part_only,
            start_timestamp=self.start_timestamp,
            end_timestamp=self.end_timestamp)

        for exchange_class_string in self.symbols_to_create_exchange_classes.keys(
        ):
            exchange_builder = trading_api.create_exchange_builder(self.backtesting_config, exchange_class_string) \
                .has_matrix(self.matrix_id) \
                .use_tentacles_setup_config(self.tentacles_setup_config) \
                .set_bot_id(self.bot_id) \
                .is_simulated() \
                .is_rest_only() \
                .is_backtesting(self.backtesting)
            try:
                await exchange_builder.build()
            finally:
                # always save exchange manager ids and backtesting instances
                self.exchange_manager_ids.append(
                    trading_api.get_exchange_manager_id(
                        exchange_builder.exchange_manager))
Example #2
0
def get_currencies_with_status():
    evaluations_by_exchange_by_pair = {}
    for exchange_manager in interfaces.get_exchange_managers():
        trading_modes = trading_api.get_trading_modes(exchange_manager)
        for pair in trading_api.get_trading_pairs(exchange_manager):
            if pair not in evaluations_by_exchange_by_pair:
                evaluations_by_exchange_by_pair[pair] = {}
            status_explanation = "N/A"
            status = "N/A"
            for trading_mode in trading_modes:
                if trading_api.get_trading_mode_symbol(trading_mode) == pair:
                    status_explanation, status = trading_api.get_trading_mode_current_state(
                        trading_mode)
                    try:
                        status = round(status, 3)
                    except TypeError:
                        pass
                    break
            evaluations_by_exchange_by_pair[pair][trading_api.get_exchange_manager_id(exchange_manager)] = \
                [status_explanation.replace("_", " "), status,
                 trading_api.get_exchange_name(exchange_manager).capitalize()]
    return evaluations_by_exchange_by_pair
Example #3
0
def _get_first_exchange_identifiers():
    for exchange_manager in interfaces_util.get_exchange_managers():
        return exchange_manager, trading_api.get_exchange_name(
            exchange_manager), trading_api.get_exchange_manager_id(
                exchange_manager)
    raise KeyError("No exchange to be found")