Esempio n. 1
0
    def test_start(self):
        exchange = MockExchange()
        marketTuple = MarketTradingPairTuple(exchange, "ETH-USDT", "ETH",
                                             "USDT")
        strategy = TwapTradeStrategy(market_infos=[marketTuple])
        strategy.logger().setLevel(1)
        strategy.logger().addHandler(self)

        start_timestamp = time.time()
        strategy.start(Clock(ClockMode.BACKTEST), start_timestamp)

        self.assertTrue(
            self._is_logged('INFO', 'Waiting for 10.0 to place orders'))
    def test_start(self):
        exchange = MockExchange(
            client_config_map=ClientConfigAdapter(ClientConfigMap()))
        marketTuple = MarketTradingPairTuple(exchange, "ETH-USDT", "ETH",
                                             "USDT")
        strategy = TwapTradeStrategy(market_infos=[marketTuple],
                                     is_buy=True,
                                     target_asset_amount=1,
                                     order_step_size=1,
                                     order_price=1)
        strategy.logger().setLevel(1)
        strategy.logger().addHandler(self)

        start_timestamp = time.time()
        strategy.start(Clock(ClockMode.BACKTEST), start_timestamp)

        self.assertTrue(
            self._is_logged('INFO', 'Waiting for 10.0 to place orders'))
Esempio n. 3
0
    def test_tick_logs_warning_when_market_not_connected(self):
        exchange = MockExchange()
        exchange.ready = True
        marketTuple = MarketTradingPairTuple(exchange, "ETH-USDT", "ETH",
                                             "USDT")
        strategy = TwapTradeStrategy(market_infos=[marketTuple])
        strategy.logger().setLevel(1)
        strategy.logger().addHandler(self)

        start_timestamp = time.time()
        strategy.start(Clock(ClockMode.BACKTEST), start_timestamp)
        strategy.tick(start_timestamp + 1000)

        self.assertTrue(
            self._is_logged('WARNING', (
                "WARNING: Some markets are not connected or are down at the moment. "
                "Market making may be dangerous when markets or networks are unstable."
            )))
Esempio n. 4
0
    def test_tick_logs_warning_when_market_not_ready(self):
        exchange = MockExchange()
        exchange.ready = False
        marketTuple = MarketTradingPairTuple(exchange, "ETH-USDT", "ETH",
                                             "USDT")
        strategy = TwapTradeStrategy(market_infos=[marketTuple])
        strategy.logger().setLevel(1)
        strategy.logger().addHandler(self)

        start_timestamp = time.time()
        strategy.start(Clock(ClockMode.BACKTEST), start_timestamp)
        strategy.tick(start_timestamp + 1000)

        self.assertTrue(
            self._is_logged(
                'WARNING',
                "Markets are not ready. No market making trades are permitted."
            ))
    def test_tick_logs_warning_when_market_not_ready(self):
        exchange = MockExchange(
            client_config_map=ClientConfigAdapter(ClientConfigMap()))
        exchange.ready = False
        marketTuple = MarketTradingPairTuple(exchange, "ETH-USDT", "ETH",
                                             "USDT")
        strategy = TwapTradeStrategy(market_infos=[marketTuple],
                                     is_buy=True,
                                     target_asset_amount=1,
                                     order_step_size=1,
                                     order_price=1)
        strategy.logger().setLevel(1)
        strategy.logger().addHandler(self)

        start_timestamp = time.time()
        strategy.start(Clock(ClockMode.BACKTEST), start_timestamp)
        strategy.tick(start_timestamp + 1000)

        self.assertTrue(
            self._is_logged(
                'WARNING',
                "Markets are not ready. No market making trades are permitted."
            ))