Esempio n. 1
0
    def test_get_trade_tick_should_send_http_request_correctly(self, mock_get):
        trader = BithumbTrader("BTC")
        expected_url = (
            trader.SERVER_URL +
            f"/public/transaction_history/{trader.market}_{trader.market_currency}"
        )

        trader.get_trade_tick()
        mock_get.assert_called_once_with(expected_url, params={"count": "1"})
Esempio n. 2
0
    def test_get_account_info_should_return_correct_info(self):
        dummy_respone = [
            {
                "currency": "KRW",
                "balance": 123456789
            },
            {
                "currency": "APPLE",
                "balance": 500,
                "avg_buy_price": 23456
            },
        ]
        trader = BithumbTrader()
        trader.balance = 123456789
        trader.asset = (23456, 500)
        trader.market = "APPLE"
        trader.worker = MagicMock()
        trader.get_trade_tick = MagicMock(return_value={
            "status": "0000",
            "data": [{
                "price": 777
            }]
        })
        result = trader.get_account_info()

        self.assertEqual(result["balance"], 123456789)
        self.assertEqual(result["asset"], {"APPLE": (23456, 500)})
        self.assertEqual(result["quote"], {"APPLE": 777})
        self.assertEqual("date_time" in result, True)
        trader.get_trade_tick.assert_called_once_with()