Exemple #1
0
    def create_from_settings(configuration: Configuration,
                             data_handler: DataHandler,
                             events_per_symbol: Dict[str, queue.Queue],
                             logger: Logger) -> ExecutionHandler:

        if configuration.execution_handler_name == SimulatedExecutionHandler:
            return ExecutionHandlerFactory.create_historic_csv_execution_handler(
                data_handler, events_per_symbol)

        if configuration.execution_handler_name == OandaExecutionHandler:
            return ExecutionHandlerFactory.create_oanda_execution_handler(
                data_handler, events_per_symbol,
                configuration.get_option(Configuration.OPTION_ACCOUNT_ID),
                configuration.get_option(Configuration.OPTION_ACCESS_TOKEN),
                logger)

        raise Exception('Unknown ExecutionHandler for {}'.format(
            configuration.execution_handler_name))
    def create_from_settings(configuration: Configuration, events_per_symbol: Dict[str, queue.Queue],
                             symbol_list: list, logger: Logger) -> DataHandler:

        if configuration.data_handler_name == HistoricCSVDataHandler:
            csv_dir = Configuration.OPTION_CSV_DIR
            return DataHandlerFactory.create_historic_csv_data_handler(events_per_symbol, symbol_list,
                                                                       configuration.get_option(csv_dir))

        if configuration.data_handler_name == OandaDataHandler:
            bars_from_history = Configuration.OPTION_NUMBER_OF_BARS_PRELOAD_FROM_HISTORY
            access_token = Configuration.OPTION_ACCESS_TOKEN
            timeframe = Configuration.OPTION_TIMEFRAME

            return DataHandlerFactory.create_oanda_data_handler(events_per_symbol, symbol_list,
                                                                configuration.get_option(access_token),
                                                                configuration.get_option(timeframe),
                                                                int(configuration.get_option(bars_from_history)),
                                                                logger)

        raise Exception('Unknown DataHandler for {}'.format(configuration.data_handler_name))