From 866b7aee8ec2ec964bf14eab7a8aedbe2f9d38c1 Mon Sep 17 00:00:00 2001 From: misagh Date: Sun, 9 Dec 2018 16:22:21 +0100 Subject: [PATCH] tests fixed --- freqtrade/freqtradebot.py | 4 ++-- freqtrade/tests/exchange/test_exchange.py | 27 +++++++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 9a7975e17..3a124568e 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -403,13 +403,13 @@ class FreqtradeBot(object): ' zero amount is fulfilled.', order_tif, order_type, pair_s, order_status, self.exchange.name) return False - else: # the order is partially fulfilled + else: # the order is partially fulfilled logger.warning('Buy %s order with time in force %s for %s is %s by %s.' ' %s amount fulfilled out of %s (%s remaining which is canceled).', order_tif, order_type, pair_s, order_status, self.exchange.name, order['filled'], order['amount'], order['remaining'] ) - + return False self.rpc.send_msg({ 'type': RPCMessageType.BUY_NOTIFICATION, diff --git a/freqtrade/tests/exchange/test_exchange.py b/freqtrade/tests/exchange/test_exchange.py index d1f391266..e021b2de8 100644 --- a/freqtrade/tests/exchange/test_exchange.py +++ b/freqtrade/tests/exchange/test_exchange.py @@ -426,7 +426,8 @@ def test_buy_dry_run(default_conf, mocker): default_conf['dry_run'] = True exchange = get_patched_exchange(mocker, default_conf) - order = exchange.buy(pair='ETH/BTC', ordertype='limit', amount=1, rate=200) + order = exchange.buy(pair='ETH/BTC', ordertype='limit', + amount=1, rate=200, time_in_force='gtc') assert 'id' in order assert 'dry_run_buy_' in order['id'] @@ -435,6 +436,7 @@ def test_buy_prod(default_conf, mocker): api_mock = MagicMock() order_id = 'test_prod_buy_{}'.format(randint(0, 10 ** 6)) order_type = 'market' + time_in_force = 'gtc' api_mock.create_order = MagicMock(return_value={ 'id': order_id, 'info': { @@ -446,7 +448,9 @@ def test_buy_prod(default_conf, mocker): mocker.patch('freqtrade.exchange.Exchange.symbol_price_prec', lambda s, x, y: y) exchange = get_patched_exchange(mocker, default_conf, api_mock) - order = exchange.buy(pair='ETH/BTC', ordertype=order_type, amount=1, rate=200) + order = exchange.buy(pair='ETH/BTC', ordertype=order_type, + amount=1, rate=200, time_in_force=time_in_force) + assert 'id' in order assert 'info' in order assert order['id'] == order_id @@ -458,7 +462,12 @@ def test_buy_prod(default_conf, mocker): api_mock.create_order.reset_mock() order_type = 'limit' - order = exchange.buy(pair='ETH/BTC', ordertype=order_type, amount=1, rate=200) + order = exchange.buy( + pair='ETH/BTC', + ordertype=order_type, + amount=1, + rate=200, + time_in_force=time_in_force) assert api_mock.create_order.call_args[0][0] == 'ETH/BTC' assert api_mock.create_order.call_args[0][1] == order_type assert api_mock.create_order.call_args[0][2] == 'buy' @@ -469,22 +478,26 @@ def test_buy_prod(default_conf, mocker): with pytest.raises(DependencyException): api_mock.create_order = MagicMock(side_effect=ccxt.InsufficientFunds) exchange = get_patched_exchange(mocker, default_conf, api_mock) - exchange.buy(pair='ETH/BTC', ordertype=order_type, amount=1, rate=200) + exchange.buy(pair='ETH/BTC', ordertype=order_type, + amount=1, rate=200, time_in_force=time_in_force) with pytest.raises(DependencyException): api_mock.create_order = MagicMock(side_effect=ccxt.InvalidOrder) exchange = get_patched_exchange(mocker, default_conf, api_mock) - exchange.buy(pair='ETH/BTC', ordertype=order_type, amount=1, rate=200) + exchange.buy(pair='ETH/BTC', ordertype=order_type, + amount=1, rate=200, time_in_force=time_in_force) with pytest.raises(TemporaryError): api_mock.create_order = MagicMock(side_effect=ccxt.NetworkError) exchange = get_patched_exchange(mocker, default_conf, api_mock) - exchange.buy(pair='ETH/BTC', ordertype=order_type, amount=1, rate=200) + exchange.buy(pair='ETH/BTC', ordertype=order_type, + amount=1, rate=200, time_in_force=time_in_force) with pytest.raises(OperationalException): api_mock.create_order = MagicMock(side_effect=ccxt.BaseError) exchange = get_patched_exchange(mocker, default_conf, api_mock) - exchange.buy(pair='ETH/BTC', ordertype=order_type, amount=1, rate=200) + exchange.buy(pair='ETH/BTC', ordertype=order_type, + amount=1, rate=200, time_in_force=time_in_force) def test_sell_dry_run(default_conf, mocker):