示例#1
0
    def test__start_trading_should_call_next_setup_message_correctly_when_step_4(
            self):
        tcb = TelegramController()
        tcb.in_progress_step = 4
        tcb._send_text_message = MagicMock()
        tcb.trader = MagicMock()
        tcb.currency = "mango"
        tcb.trader.NAME = "mango trader"
        tcb.strategy = MagicMock()
        tcb.strategy.NAME = "mango strategy"
        tcb.budget = 500
        tcb._start_trading("SMA")

        tcb._send_text_message.assert_called_once_with(
            f"화폐: mango\n전략: {StrategySma0.NAME}\n거래소: mango trader\n예산: 500\n자동 거래를 시작할까요?",
            tcb.setup_list[4]["keyboard"],
        )
        self.assertIsNotNone(tcb.strategy)
        self.assertEqual(tcb.in_progress, tcb._start_trading)
        self.assertEqual(tcb.in_progress_step, 5)
示例#2
0
    def test__stop_trading_should_reset_all_variable_related_operating(self):
        tcb = TelegramController()
        tcb.operator = MagicMock()
        tcb.strategy = "mango_strategy"
        tcb.data_provider = "mango_data_provider"
        tcb.trader = "mango_trader"
        tcb.budget = "mango_budget"
        tcb.operator.stop = MagicMock(
            return_value={
                "summary": (100, 200, 0.5, 0.9, "test.jpg", 0, 0, 0,
                            ("12-01", "12-05", "12-08"))
            })
        tcb._send_text_message = MagicMock()

        tcb._stop_trading("2")
        tcb._send_text_message.assert_called_once_with(
            "자동 거래가 중지되었습니다\n12-05 - 12-08\n자산 100 -> 200\n수익률 0.5\n비교 수익률 0.9\n",
            tcb.main_keyboard)
        self.assertEqual(tcb.operator, None)
        self.assertEqual(tcb.strategy, None)
        self.assertEqual(tcb.data_provider, None)
        self.assertEqual(tcb.trader, None)
        self.assertEqual(tcb.budget, None)