def setUp(self):

        self.clock: Clock = Clock(ClockMode.BACKTEST, self.clock_tick_size,
                                  self.start_timestamp, self.end_timestamp)
        self.market: BacktestMarket = BacktestMarket()
        self.maker_data: MockOrderBookLoader = MockOrderBookLoader(
            *self.maker_trading_pairs)
        self.mid_price = 100
        self.time_delay = 15
        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.market.add_data(self.maker_data)
        self.market.set_balance("COINALPHA", 500)
        self.market.set_balance("WETH", 5000)
        self.market.set_balance("QETH", 500)
        self.market.set_quantization_param(
            QuantizationParams(self.maker_trading_pairs[0], 6, 6, 6, 6))

        self.market_info: MarketTradingPairTuple = MarketTradingPairTuple(
            *([self.market] + self.maker_trading_pairs))

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

        # Define strategies to test
        self.limit_buy_strategy: PerformTradeStrategy = PerformTradeStrategy(
            [self.market_info],
            order_type="limit",
            order_price=99,
            is_buy=True,
            order_amount=1.0,
            logging_options=logging_options)
        self.limit_sell_strategy: PerformTradeStrategy = PerformTradeStrategy(
            [self.market_info],
            order_type="limit",
            order_price=101,
            is_buy=False,
            order_amount=1.0,
            logging_options=logging_options)
        self.market_buy_strategy: PerformTradeStrategy = PerformTradeStrategy(
            [self.market_info],
            order_type="market",
            order_price=None,
            is_buy=True,
            order_amount=1.0,
            logging_options=logging_options)
        self.market_sell_strategy: PerformTradeStrategy = PerformTradeStrategy(
            [self.market_info],
            order_type="market",
            order_price=None,
            is_buy=False,
            order_amount=1.0,
            logging_options=logging_options)
        self.logging_options = logging_options
        self.clock.add_iterator(self.market)
        self.maker_order_fill_logger: EventLogger = EventLogger()
        self.cancel_order_logger: EventLogger = EventLogger()
        self.buy_order_completed_logger: EventLogger = EventLogger()
        self.sell_order_completed_logger: EventLogger = EventLogger()

        self.market.add_listener(MarketEvent.BuyOrderCompleted,
                                 self.buy_order_completed_logger)
        self.market.add_listener(MarketEvent.SellOrderCompleted,
                                 self.sell_order_completed_logger)
        self.market.add_listener(MarketEvent.OrderFilled,
                                 self.maker_order_fill_logger)
        self.market.add_listener(MarketEvent.OrderCancelled,
                                 self.cancel_order_logger)
    def setUp(self):
        self.clock: Clock = Clock(ClockMode.BACKTEST, self.clock_tick_size,
                                  self.start_timestamp, self.end_timestamp)
        self.mid_price = 100
        self.time_delay = 15
        self.cancel_order_wait_time = 45

        self.market: MockPaperExchange = MockPaperExchange(
            client_config_map=ClientConfigAdapter(ClientConfigMap()))
        self.market.set_balanced_order_book(trading_pair=self.trading_pair,
                                            mid_price=self.mid_price,
                                            min_price=1,
                                            max_price=200,
                                            price_step_size=1,
                                            volume_step_size=10)

        self.market.set_balance("COINALPHA", 500)
        self.market.set_balance("WETH", 5000)
        self.market.set_quantization_param(
            QuantizationParams(self.trading_pair, 6, 6, 6, 6))

        self.market_info: MarketTradingPairTuple = MarketTradingPairTuple(
            self.market, self.trading_pair, self.base_asset, self.quote_asset)

        # Define strategies to test
        self.buy_mid_price_strategy: PerformTradeStrategy = PerformTradeStrategy(
            exchange=self.market,
            trading_pair=self.trading_pair,
            is_buy=True,
            spread=self.spread,
            order_amount=Decimal("1.0"),
            price_type=PriceType.MidPrice)

        self.sell_mid_price_strategy: PerformTradeStrategy = PerformTradeStrategy(
            exchange=self.market,
            trading_pair=self.trading_pair,
            is_buy=False,
            spread=self.spread,
            order_amount=Decimal("1.0"),
            price_type=PriceType.MidPrice)

        self.buy_last_price_strategy: PerformTradeStrategy = PerformTradeStrategy(
            exchange=self.market,
            trading_pair=self.trading_pair,
            is_buy=True,
            spread=self.spread,
            order_amount=Decimal("1.0"),
            price_type=PriceType.LastTrade)

        self.sell_last_price_strategy: PerformTradeStrategy = PerformTradeStrategy(
            exchange=self.market,
            trading_pair=self.trading_pair,
            is_buy=False,
            spread=self.spread,
            order_amount=Decimal("1.0"),
            price_type=PriceType.LastTrade)

        self.buy_last_own_trade_price_strategy: PerformTradeStrategy = PerformTradeStrategy(
            exchange=self.market,
            trading_pair=self.trading_pair,
            is_buy=True,
            spread=self.spread,
            order_amount=Decimal("1.0"),
            price_type=PriceType.LastOwnTrade)

        self.sell_last_own_trade_price_strategy: PerformTradeStrategy = PerformTradeStrategy(
            exchange=self.market,
            trading_pair=self.trading_pair,
            is_buy=False,
            spread=self.spread,
            order_amount=Decimal("1.0"),
            price_type=PriceType.LastOwnTrade)

        self.clock.add_iterator(self.market)
        self.maker_order_fill_logger: EventLogger = EventLogger()
        self.cancel_order_logger: EventLogger = EventLogger()
        self.buy_order_completed_logger: EventLogger = EventLogger()
        self.sell_order_completed_logger: EventLogger = EventLogger()

        self.market.add_listener(MarketEvent.BuyOrderCompleted,
                                 self.buy_order_completed_logger)
        self.market.add_listener(MarketEvent.SellOrderCompleted,
                                 self.sell_order_completed_logger)
        self.market.add_listener(MarketEvent.OrderFilled,
                                 self.maker_order_fill_logger)
        self.market.add_listener(MarketEvent.OrderCancelled,
                                 self.cancel_order_logger)