Example #1
0
    def setUp(self):
        self.clock: Clock = Clock(ClockMode.BACKTEST, 60.0, self.start_timestamp, self.end_timestamp)
        self.clock_tick_size = 60
        self.maker_market: BacktestMarket = BacktestMarket()
        self.maker_data: MockOrderBookLoader = MockOrderBookLoader(*self.maker_symbols)
        self.mid_price = 100
        self.bid_threshold = 0.01
        self.ask_threshold = 0.01
        self.cancel_order_wait_time = 45
        self.maker_data.set_balanced_order_book(mid_price=self.mid_price, min_price=1,
                                                max_price=200, price_step_size=1, volume_step_size=10)
        self.equal_strategy_sizing_delegate = StaggeredMultipleSizeSizingDelegate(order_start_size = 1.0,
                                                                                  order_step_size= 0,
                                                                                  number_of_orders= 5)
        self.staggered_strategy_sizing_delegate = StaggeredMultipleSizeSizingDelegate(order_start_size=1.0,
                                                                                  order_step_size=0.5,
                                                                                  number_of_orders=5)
        self.multiple_order_strategy_pricing_delegate = ConstantMultipleSpreadPricingDelegate(bid_spread=self.bid_threshold,
                                                                                              ask_spread=self.ask_threshold,
                                                                                              order_interval_size=0.01,
                                                                                              number_of_orders=5)
        self.maker_market.add_data(self.maker_data)
        self.maker_market.set_balance("COINALPHA", 500)
        self.maker_market.set_balance("WETH", 5000)
        self.maker_market.set_balance("QETH", 500)
        self.maker_market.set_quantization_param(
            QuantizationParams(
                self.maker_symbols[0], 6, 6, 6, 6
            )
        )

        self.market_info: MarketInfo = MarketInfo(
            *(
                [self.maker_market] + self.maker_symbols
            )
        )

        logging_options: int = (PureMarketMakingStrategyV2.OPTION_LOG_ALL &
                                (~PureMarketMakingStrategyV2.OPTION_LOG_NULL_ORDER_SIZE))
        self.strategy: PureMarketMakingStrategyV2 = PureMarketMakingStrategyV2(
            [self.market_info],
            legacy_order_size=1.0,
            legacy_bid_spread=self.bid_threshold,
            legacy_ask_spread=self.ask_threshold,
            cancel_order_wait_time=45,
            logging_options=logging_options
        )

        self.multi_order_equal_strategy: PureMarketMakingStrategyV2 = PureMarketMakingStrategyV2(
            [self.market_info],
            legacy_order_size=1.0,
            legacy_bid_spread=self.bid_threshold,
            legacy_ask_spread=self.ask_threshold,
            cancel_order_wait_time=45,
            sizing_delegate=self.equal_strategy_sizing_delegate,
            pricing_delegate=self.multiple_order_strategy_pricing_delegate,
            logging_options=logging_options
        )

        self.multi_order_staggered_strategy: PureMarketMakingStrategyV2 = PureMarketMakingStrategyV2(
            [self.market_info],
            legacy_order_size=1.0,
            legacy_bid_spread=self.bid_threshold,
            legacy_ask_spread=self.ask_threshold,
            cancel_order_wait_time=45,
            sizing_delegate=self.staggered_strategy_sizing_delegate,
            pricing_delegate=self.multiple_order_strategy_pricing_delegate,
            logging_options=logging_options
        )

        self.logging_options = logging_options
        self.clock.add_iterator(self.maker_market)
        self.clock.add_iterator(self.strategy)
        self.maker_order_fill_logger: EventLogger = EventLogger()
        self.cancel_order_logger: EventLogger = EventLogger()
        self.maker_market.add_listener(MarketEvent.OrderFilled, self.maker_order_fill_logger)
        self.maker_market.add_listener(MarketEvent.OrderCancelled, self.cancel_order_logger)
Example #2
0
def start(self):
    try:
        order_size = pure_market_making_config_map.get("order_amount").value
        cancel_order_wait_time = pure_market_making_config_map.get(
            "cancel_order_wait_time").value
        bid_place_threshold = pure_market_making_config_map.get(
            "bid_place_threshold").value
        ask_place_threshold = pure_market_making_config_map.get(
            "ask_place_threshold").value
        mode = pure_market_making_config_map.get("mode").value
        number_of_orders = pure_market_making_config_map.get(
            "number_of_orders").value
        order_start_size = pure_market_making_config_map.get(
            "order_start_size").value
        order_step_size = pure_market_making_config_map.get(
            "order_step_size").value
        order_interval_percent = pure_market_making_config_map.get(
            "order_interval_percent").value
        maker_market = pure_market_making_config_map.get(
            "maker_market").value.lower()
        raw_maker_trading_pair = pure_market_making_config_map.get(
            "maker_market_trading_pair").value
        inventory_skew_enabled = pure_market_making_config_map.get(
            "inventory_skew_enabled").value
        inventory_target_base_percent = pure_market_making_config_map.get(
            "inventory_target_base_percent").value
        filled_order_replenish_wait_time = pure_market_making_config_map.get(
            "filled_order_replenish_wait_time").value
        enable_order_filled_stop_cancellation = pure_market_making_config_map.get(
            "enable_order_filled_stop_cancellation").value
        best_bid_ask_jump_mode = pure_market_making_config_map.get(
            "best_bid_ask_jump_mode").value
        best_bid_ask_jump_orders_depth = pure_market_making_config_map.get(
            "best_bid_ask_jump_orders_depth").value
        add_transaction_costs_to_orders = pure_market_making_config_map.get(
            "add_transaction_costs").value

        pricing_delegate = None
        sizing_delegate = None
        filter_delegate = PassThroughFilterDelegate()

        if mode == "multiple":
            pricing_delegate = ConstantMultipleSpreadPricingDelegate(
                bid_place_threshold, ask_place_threshold,
                order_interval_percent, number_of_orders)
            if inventory_skew_enabled:
                sizing_delegate = InventorySkewMultipleSizeSizingDelegate(
                    order_start_size, order_step_size, number_of_orders,
                    inventory_target_base_percent)
            else:
                sizing_delegate = StaggeredMultipleSizeSizingDelegate(
                    order_start_size, order_step_size, number_of_orders)
        else:  # mode == "single"
            pricing_delegate = ConstantSpreadPricingDelegate(
                bid_place_threshold, ask_place_threshold)
            if inventory_skew_enabled:
                sizing_delegate = InventorySkewSingleSizeSizingDelegate(
                    order_size, inventory_target_base_percent)
            else:
                sizing_delegate = ConstantSizeSizingDelegate(order_size)

        try:
            trading_pair: str = self._convert_to_exchange_trading_pair(
                maker_market, [raw_maker_trading_pair])[0]
            maker_assets: Tuple[str, str] = self._initialize_market_assets(
                maker_market, [trading_pair])[0]
        except ValueError as e:
            self._notify(str(e))
            return

        market_names: List[Tuple[str,
                                 List[str]]] = [(maker_market, [trading_pair])]

        self._initialize_wallet(token_trading_pairs=list(set(maker_assets)))
        self._initialize_markets(market_names)
        self.assets = set(maker_assets)

        maker_data = [self.markets[maker_market], trading_pair
                      ] + list(maker_assets)
        self.market_trading_pair_tuples = [MarketTradingPairTuple(*maker_data)]

        strategy_logging_options = PureMarketMakingStrategyV2.OPTION_LOG_ALL

        self.strategy = PureMarketMakingStrategyV2(
            market_infos=[MarketTradingPairTuple(*maker_data)],
            pricing_delegate=pricing_delegate,
            filter_delegate=filter_delegate,
            sizing_delegate=sizing_delegate,
            filled_order_replenish_wait_time=filled_order_replenish_wait_time,
            enable_order_filled_stop_cancellation=
            enable_order_filled_stop_cancellation,
            cancel_order_wait_time=cancel_order_wait_time,
            best_bid_ask_jump_mode=best_bid_ask_jump_mode,
            best_bid_ask_jump_orders_depth=best_bid_ask_jump_orders_depth,
            add_transaction_costs_to_orders=add_transaction_costs_to_orders,
            logging_options=strategy_logging_options)
    except Exception as e:
        self._notify(str(e))
        self.logger().error("Unknown error during initialization.",
                            exc_info=True)
Example #3
0
    def setUp(self):
        self.clock_tick_size = 1
        self.clock: Clock = Clock(ClockMode.BACKTEST, self.clock_tick_size,
                                  self.start_timestamp, self.end_timestamp)
        self.maker_market: BacktestMarket = BacktestMarket()
        self.maker_data: MockOrderBookLoader = MockOrderBookLoader(
            *self.maker_trading_pairs)
        self.mid_price = 100
        self.bid_spread = 0.01
        self.ask_spread = 0.01
        self.order_refresh_time = 30
        self.maker_data.set_balanced_order_book(mid_price=self.mid_price,
                                                min_price=1,
                                                max_price=200,
                                                price_step_size=1,
                                                volume_step_size=10)
        self.constant_pricing_delegate = ConstantSpreadPricingDelegate(
            Decimal(self.bid_spread), Decimal(self.ask_spread))
        self.constant_sizing_delegate = ConstantSizeSizingDelegate(
            Decimal("1.0"))
        self.filter_delegate = PassThroughFilterDelegate()
        self.maker_market.add_data(self.maker_data)
        self.maker_market.set_balance("COINALPHA", 500)
        self.maker_market.set_balance("WETH", 5000)
        self.maker_market.set_balance("QETH", 500)
        self.maker_market.set_quantization_param(
            QuantizationParams(self.maker_trading_pairs[0], 6, 6, 6, 6))
        self.market_info: MarketTradingPairTuple = MarketTradingPairTuple(
            *([self.maker_market] + self.maker_trading_pairs))

        logging_options: int = (
            PureMarketMakingStrategyV2.OPTION_LOG_ALL &
            (~PureMarketMakingStrategyV2.OPTION_LOG_NULL_ORDER_SIZE))

        self.one_level_strategy: PureMarketMakingStrategyV2 = PureMarketMakingStrategyV2(
            [self.market_info],
            filter_delegate=self.filter_delegate,
            pricing_delegate=self.constant_pricing_delegate,
            sizing_delegate=self.constant_sizing_delegate,
            order_refresh_time=4,
            filled_order_delay=8,
            hanging_orders_enabled=True,
            logging_options=logging_options,
            hanging_orders_cancel_pct=0.05,
            order_refresh_tolerance_pct=0)
        self.multiple_order_pricing_delegate = ConstantMultipleSpreadPricingDelegate(
            bid_spread=Decimal(self.bid_spread),
            ask_spread=Decimal(self.ask_spread),
            order_level_spread=Decimal("0.01"),
            order_levels=Decimal("5"))
        self.equal_sizing_delegate = StaggeredMultipleSizeSizingDelegate(
            order_start_size=Decimal("1.0"),
            order_step_size=Decimal("0"),
            order_levels=Decimal("5"))
        self.multi_levels_strategy: PureMarketMakingStrategyV2 = PureMarketMakingStrategyV2(
            [self.market_info],
            filter_delegate=self.filter_delegate,
            pricing_delegate=self.multiple_order_pricing_delegate,
            sizing_delegate=self.equal_sizing_delegate,
            order_refresh_time=4,
            filled_order_delay=8,
            hanging_orders_enabled=True,
            logging_options=logging_options,
            hanging_orders_cancel_pct=0.1,
            order_refresh_tolerance_pct=0)

        self.hanging_order_multiple_strategy: PureMarketMakingStrategyV2 = PureMarketMakingStrategyV2(
            [self.market_info],
            filter_delegate=self.filter_delegate,
            pricing_delegate=self.multiple_order_pricing_delegate,
            sizing_delegate=self.equal_sizing_delegate,
            order_refresh_time=4,
            filled_order_delay=8,
            hanging_orders_enabled=True,
            logging_options=logging_options,
            order_refresh_tolerance_pct=0)
        self.logging_options = logging_options
        self.clock.add_iterator(self.maker_market)
        self.maker_order_fill_logger: EventLogger = EventLogger()
        self.cancel_order_logger: EventLogger = EventLogger()
        self.maker_market.add_listener(MarketEvent.OrderFilled,
                                       self.maker_order_fill_logger)
        self.maker_market.add_listener(MarketEvent.OrderCancelled,
                                       self.cancel_order_logger)
Example #4
0
def start(self):
    try:
        order_size = pure_market_making_config_map.get("order_amount").value
        cancel_order_wait_time = pure_market_making_config_map.get(
            "cancel_order_wait_time").value
        bid_place_threshold = pure_market_making_config_map.get(
            "bid_place_threshold").value
        ask_place_threshold = pure_market_making_config_map.get(
            "ask_place_threshold").value
        mode = pure_market_making_config_map.get("mode").value
        number_of_orders = pure_market_making_config_map.get(
            "number_of_orders").value
        order_start_size = pure_market_making_config_map.get(
            "order_start_size").value
        order_step_size = pure_market_making_config_map.get(
            "order_step_size").value
        order_interval_percent = pure_market_making_config_map.get(
            "order_interval_percent").value
        maker_market = pure_market_making_config_map.get(
            "maker_market").value.lower()
        raw_maker_symbol = pure_market_making_config_map.get(
            "maker_market_symbol").value.upper()
        pricing_delegate = None
        sizing_delegate = None

        if mode == "multiple":
            pricing_delegate = ConstantMultipleSpreadPricingDelegate(
                bid_place_threshold, ask_place_threshold,
                order_interval_percent, number_of_orders)
            sizing_delegate = StaggeredMultipleSizeSizingDelegate(
                order_start_size, order_step_size, number_of_orders)

        try:
            maker_assets: Tuple[str, str] = self._initialize_market_assets(
                maker_market, [raw_maker_symbol])[0]
        except ValueError as e:
            self._notify(str(e))
            return

        market_names: List[Tuple[str, List[str]]] = [(maker_market,
                                                      [raw_maker_symbol])]

        self._initialize_wallet(token_symbols=list(set(maker_assets)))
        self._initialize_markets(market_names)
        self.assets = set(maker_assets)

        maker_data = [self.markets[maker_market], raw_maker_symbol
                      ] + list(maker_assets)
        self.market_symbol_pairs = [MarketSymbolPair(*maker_data)]

        strategy_logging_options = PureMarketMakingStrategyV2.OPTION_LOG_ALL

        self.strategy = PureMarketMakingStrategyV2(
            market_infos=[MarketSymbolPair(*maker_data)],
            pricing_delegate=pricing_delegate,
            sizing_delegate=sizing_delegate,
            legacy_order_size=order_size,
            legacy_bid_spread=bid_place_threshold,
            legacy_ask_spread=ask_place_threshold,
            cancel_order_wait_time=cancel_order_wait_time,
            logging_options=strategy_logging_options)
    except Exception as e:
        self._notify(str(e))
        self.logger().error("Unknown error during initialization.",
                            exc_info=True)
    def setUp(self):
        self.clock_tick_size = 1
        self.clock: Clock = Clock(ClockMode.BACKTEST, self.clock_tick_size,
                                  self.start_timestamp, self.end_timestamp)
        self.maker_market: BacktestMarket = BacktestMarket()
        self.maker_data: MockOrderBookLoader = MockOrderBookLoader(
            *self.maker_symbols)
        self.mid_price = 100
        self.bid_threshold = 0.01
        self.ask_threshold = 0.01
        self.cancel_order_wait_time = 30
        self.maker_data.set_balanced_order_book(mid_price=self.mid_price,
                                                min_price=1,
                                                max_price=200,
                                                price_step_size=1,
                                                volume_step_size=10)
        self.filter_delegate = PassThroughFilterDelegate()
        self.constant_pricing_delegate = ConstantSpreadPricingDelegate(
            self.bid_threshold, self.ask_threshold)
        self.multiple_order_strategy_pricing_delegate = ConstantMultipleSpreadPricingDelegate(
            bid_spread=self.bid_threshold,
            ask_spread=self.ask_threshold,
            order_interval_size=0.01,
            number_of_orders=5)
        self.inventory_skew_single_size_sizing_delegate = InventorySkewSingleSizeSizingDelegate(
            order_size=1, inventory_target_base_percent=0.5)
        self.inventory_skew_multiple_size_sizing_delegate = InventorySkewMultipleSizeSizingDelegate(
            order_start_size=1.0,
            order_step_size=0.5,
            number_of_orders=5,
            inventory_target_base_percent=0.5)

        self.maker_market.add_data(self.maker_data)
        self.maker_market.set_balance("COINALPHA", 500)
        self.maker_market.set_balance("WETH", 5000)
        self.maker_market.set_balance("QETH", 500)
        self.maker_market.set_quantization_param(
            QuantizationParams(self.maker_symbols[0], 6, 6, 6, 6))

        self.market_info: MarketSymbolPair = MarketSymbolPair(
            *([self.maker_market] + self.maker_symbols))

        logging_options: int = (
            PureMarketMakingStrategyV2.OPTION_LOG_ALL &
            (~PureMarketMakingStrategyV2.OPTION_LOG_NULL_ORDER_SIZE))

        self.inventory_skew_single_order_strategy: PureMarketMakingStrategyV2 = PureMarketMakingStrategyV2(
            [self.market_info],
            filter_delegate=self.filter_delegate,
            sizing_delegate=self.inventory_skew_single_size_sizing_delegate,
            pricing_delegate=self.constant_pricing_delegate,
            cancel_order_wait_time=45,
            filled_order_replenish_wait_time=0,
            logging_options=logging_options)

        self.inventory_skew_single_order_strategy_delayed_fill: PureMarketMakingStrategyV2 = PureMarketMakingStrategyV2(
            [self.market_info],
            filter_delegate=self.filter_delegate,
            sizing_delegate=self.inventory_skew_single_size_sizing_delegate,
            pricing_delegate=self.constant_pricing_delegate,
            cancel_order_wait_time=45,
            filled_order_replenish_wait_time=15,
            logging_options=logging_options)

        self.inventory_skew_multiple_order_strategy: PureMarketMakingStrategyV2 = PureMarketMakingStrategyV2(
            [self.market_info],
            filter_delegate=self.filter_delegate,
            sizing_delegate=self.inventory_skew_multiple_size_sizing_delegate,
            pricing_delegate=self.multiple_order_strategy_pricing_delegate,
            cancel_order_wait_time=45,
            logging_options=logging_options)

        self.logging_options = logging_options
        self.clock.add_iterator(self.maker_market)
        self.maker_order_fill_logger: EventLogger = EventLogger()
        self.cancel_order_logger: EventLogger = EventLogger()
        self.maker_market.add_listener(MarketEvent.OrderFilled,
                                       self.maker_order_fill_logger)
        self.maker_market.add_listener(MarketEvent.OrderCancelled,
                                       self.cancel_order_logger)
Example #6
0
def start(self):
    try:
        order_amount = c_map.get("order_amount").value
        order_refresh_time = c_map.get("order_refresh_time").value
        bid_spread = c_map.get("bid_spread").value / Decimal('100')
        ask_spread = c_map.get("ask_spread").value / Decimal('100')
        order_expiration_time = c_map.get("order_expiration_time").value
        order_levels = c_map.get("order_levels").value
        order_level_amount = c_map.get("order_level_amount").value
        order_level_spread = c_map.get("order_level_spread").value / Decimal(
            '100')
        exchange = c_map.get("exchange").value.lower()
        raw_trading_pair = c_map.get("market").value
        inventory_skew_enabled = c_map.get("inventory_skew_enabled").value
        inventory_target_base_pct = 0 if c_map.get("inventory_target_base_pct").value is None else \
            c_map.get("inventory_target_base_pct").value / Decimal('100')
        inventory_range_multiplier = c_map.get(
            "inventory_range_multiplier").value
        filled_order_delay = c_map.get("filled_order_delay").value
        hanging_orders_enabled = c_map.get("hanging_orders_enabled").value
        hanging_orders_cancel_pct = c_map.get(
            "hanging_orders_cancel_pct").value / Decimal('100')
        order_optimization_enabled = c_map.get(
            "order_optimization_enabled").value
        order_optimization_depth = c_map.get("order_optimization_depth").value
        add_transaction_costs_to_orders = c_map.get(
            "add_transaction_costs").value
        price_source_enabled = c_map.get("price_source_enabled").value
        price_source_type = c_map.get("price_source_type").value
        price_source_exchange = c_map.get("price_source_exchange").value
        price_source_market = c_map.get("price_source_market").value
        price_source_custom = c_map.get("price_source_custom").value

        pricing_delegate = None
        sizing_delegate = None
        filter_delegate = PassThroughFilterDelegate()

        if order_levels > 1:
            pricing_delegate = ConstantMultipleSpreadPricingDelegate(
                bid_spread, ask_spread, order_level_spread, order_levels)
            if inventory_skew_enabled:
                sizing_delegate = InventorySkewMultipleSizeSizingDelegate(
                    order_amount, order_level_amount, order_levels,
                    inventory_target_base_pct, inventory_range_multiplier)
            else:
                sizing_delegate = StaggeredMultipleSizeSizingDelegate(
                    order_amount, order_level_amount, order_levels)
        else:  # mode == "single"
            pricing_delegate = ConstantSpreadPricingDelegate(
                bid_spread, ask_spread)
            if inventory_skew_enabled:
                sizing_delegate = InventorySkewSingleSizeSizingDelegate(
                    order_amount, inventory_target_base_pct,
                    inventory_range_multiplier)
            else:
                sizing_delegate = ConstantSizeSizingDelegate(order_amount)
        try:
            trading_pair: str = self._convert_to_exchange_trading_pair(
                exchange, [raw_trading_pair])[0]
            maker_assets: Tuple[str, str] = self._initialize_market_assets(
                exchange, [trading_pair])[0]
        except ValueError as e:
            self._notify(str(e))
            return

        market_names: List[Tuple[str,
                                 List[str]]] = [(exchange, [trading_pair])]
        self._initialize_wallet(token_trading_pairs=list(set(maker_assets)))
        self._initialize_markets(market_names)
        self.assets = set(maker_assets)
        maker_data = [self.markets[exchange], trading_pair
                      ] + list(maker_assets)
        self.market_trading_pair_tuples = [MarketTradingPairTuple(*maker_data)]
        asset_price_delegate = None
        if price_source_enabled:
            if price_source_type == "exchange":
                asset_trading_pair: str = self._convert_to_exchange_trading_pair(
                    price_source_exchange, [price_source_market])[0]
                ext_market = create_paper_trade_market(price_source_exchange,
                                                       [asset_trading_pair])
                self.markets[price_source_exchange]: MarketBase = ext_market
                asset_price_delegate = OrderBookAssetPriceDelegate(
                    ext_market, asset_trading_pair)
            elif price_source_type == "custom_api":
                asset_price_delegate = APIAssetPriceDelegate(
                    price_source_custom)
        else:
            asset_price_delegate = None

        strategy_logging_options = PureMarketMakingStrategyV2.OPTION_LOG_ALL

        self.strategy = PureMarketMakingStrategyV2(
            market_infos=[MarketTradingPairTuple(*maker_data)],
            pricing_delegate=pricing_delegate,
            filter_delegate=filter_delegate,
            sizing_delegate=sizing_delegate,
            filled_order_delay=filled_order_delay,
            hanging_orders_enabled=hanging_orders_enabled,
            order_refresh_time=order_refresh_time,
            order_optimization_enabled=order_optimization_enabled,
            order_optimization_depth=order_optimization_depth,
            add_transaction_costs_to_orders=add_transaction_costs_to_orders,
            logging_options=strategy_logging_options,
            asset_price_delegate=asset_price_delegate,
            expiration_seconds=order_expiration_time,
            hanging_orders_cancel_pct=hanging_orders_cancel_pct)
    except Exception as e:
        self._notify(str(e))
        self.logger().error("Unknown error during initialization.",
                            exc_info=True)
Example #7
0
def start(self):
    try:
        order_size = c_map.get("order_amount").value
        cancel_order_wait_time = c_map.get("cancel_order_wait_time").value
        bid_place_threshold = c_map.get("bid_place_threshold").value
        ask_place_threshold = c_map.get("ask_place_threshold").value
        expiration_seconds = c_map.get("expiration_seconds").value
        mode = c_map.get("mode").value
        number_of_orders = c_map.get("number_of_orders").value
        order_start_size = c_map.get("order_start_size").value
        order_step_size = c_map.get("order_step_size").value
        order_interval_percent = c_map.get("order_interval_percent").value
        maker_market = c_map.get("maker_market").value.lower()
        raw_maker_trading_pair = c_map.get("maker_market_trading_pair").value
        inventory_skew_enabled = c_map.get("inventory_skew_enabled").value
        inventory_target_base_percent = c_map.get(
            "inventory_target_base_percent").value / Decimal('100')
        inventory_range_multiplier = c_map.get(
            "inventory_range_multiplier").value
        filled_order_replenish_wait_time = c_map.get(
            "filled_order_replenish_wait_time").value
        enable_order_filled_stop_cancellation = c_map.get(
            "enable_order_filled_stop_cancellation").value
        cancel_hanging_order_pct = c_map.get("cancel_hanging_order_pct").value
        best_bid_ask_jump_mode = c_map.get("best_bid_ask_jump_mode").value
        best_bid_ask_jump_orders_depth = c_map.get(
            "best_bid_ask_jump_orders_depth").value
        add_transaction_costs_to_orders = c_map.get(
            "add_transaction_costs").value
        external_pricing_source = c_map.get("external_pricing_source").value
        external_price_source_type = c_map.get(
            "external_price_source_type").value
        external_price_source_exchange = c_map.get(
            "external_price_source_exchange").value
        external_price_source_exchange_trading_pair = c_map.get(
            "external_price_source_exchange_trading_pair").value
        external_price_source_feed_base_asset = c_map.get(
            "external_price_source_feed_base_asset").value
        external_price_source_feed_quote_asset = c_map.get(
            "external_price_source_feed_quote_asset").value
        external_price_source_custom_api = c_map.get(
            "external_price_source_custom_api").value

        pricing_delegate = None
        sizing_delegate = None
        filter_delegate = PassThroughFilterDelegate()

        if mode == "multiple":
            pricing_delegate = ConstantMultipleSpreadPricingDelegate(
                bid_place_threshold, ask_place_threshold,
                order_interval_percent, number_of_orders)
            if inventory_skew_enabled:
                sizing_delegate = InventorySkewMultipleSizeSizingDelegate(
                    order_start_size, order_step_size, number_of_orders,
                    inventory_target_base_percent, inventory_range_multiplier)
            else:
                sizing_delegate = StaggeredMultipleSizeSizingDelegate(
                    order_start_size, order_step_size, number_of_orders)
        else:  # mode == "single"
            pricing_delegate = ConstantSpreadPricingDelegate(
                bid_place_threshold, ask_place_threshold)
            if inventory_skew_enabled:
                sizing_delegate = InventorySkewSingleSizeSizingDelegate(
                    order_size, inventory_target_base_percent,
                    inventory_range_multiplier)
            else:
                sizing_delegate = ConstantSizeSizingDelegate(order_size)
        try:
            trading_pair: str = self._convert_to_exchange_trading_pair(
                maker_market, [raw_maker_trading_pair])[0]
            maker_assets: Tuple[str, str] = self._initialize_market_assets(
                maker_market, [trading_pair])[0]
        except ValueError as e:
            self._notify(str(e))
            return

        market_names: List[Tuple[str,
                                 List[str]]] = [(maker_market, [trading_pair])]
        self._initialize_wallet(token_trading_pairs=list(set(maker_assets)))
        self._initialize_markets(market_names)
        self.assets = set(maker_assets)
        maker_data = [self.markets[maker_market], trading_pair
                      ] + list(maker_assets)
        self.market_trading_pair_tuples = [MarketTradingPairTuple(*maker_data)]
        asset_price_delegate = None
        if external_pricing_source:
            if external_price_source_type == "exchange":
                asset_trading_pair: str = self._convert_to_exchange_trading_pair(
                    external_price_source_exchange,
                    [external_price_source_exchange_trading_pair])[0]
                ext_market = create_paper_trade_market(
                    external_price_source_exchange, [asset_trading_pair])
                self.markets[
                    external_price_source_exchange]: MarketBase = ext_market
                asset_price_delegate = OrderBookAssetPriceDelegate(
                    ext_market, asset_trading_pair)
            elif external_price_source_type == "feed":
                asset_price_delegate = DataFeedAssetPriceDelegate(
                    external_price_source_feed_base_asset,
                    external_price_source_feed_quote_asset)
            elif external_price_source_type == "custom_api":
                asset_price_delegate = APIAssetPriceDelegate(
                    external_price_source_custom_api)
        else:
            asset_price_delegate = None

        strategy_logging_options = PureMarketMakingStrategyV2.OPTION_LOG_ALL

        self.strategy = PureMarketMakingStrategyV2(
            market_infos=[MarketTradingPairTuple(*maker_data)],
            pricing_delegate=pricing_delegate,
            filter_delegate=filter_delegate,
            sizing_delegate=sizing_delegate,
            filled_order_replenish_wait_time=filled_order_replenish_wait_time,
            enable_order_filled_stop_cancellation=
            enable_order_filled_stop_cancellation,
            cancel_order_wait_time=cancel_order_wait_time,
            best_bid_ask_jump_mode=best_bid_ask_jump_mode,
            best_bid_ask_jump_orders_depth=best_bid_ask_jump_orders_depth,
            add_transaction_costs_to_orders=add_transaction_costs_to_orders,
            logging_options=strategy_logging_options,
            asset_price_delegate=asset_price_delegate,
            expiration_seconds=expiration_seconds,
            cancel_hanging_order_pct=cancel_hanging_order_pct)
    except Exception as e:
        self._notify(str(e))
        self.logger().error("Unknown error during initialization.",
                            exc_info=True)