diff --git a/freqtrade/main.py b/freqtrade/main.py index b92bb69e4..254bed33e 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -130,7 +130,9 @@ def check_handle_timedout(timeoutvalue: int) -> None: for trade in Trade.query.filter(Trade.open_order_id.isnot(None)).all(): order = exchange.get_order(trade.open_order_id) - if order['type'] == "LIMIT_BUY" and order['opened'] < timeoutthreashold: + ordertime = arrow.get(order['opened']) + + if order['type'] == "LIMIT_BUY" and ordertime < timeoutthreashold: # Buy timeout - cancel order exchange.cancel_order(trade.open_order_id) if order['remaining'] == order['amount']: @@ -145,7 +147,7 @@ def check_handle_timedout(timeoutvalue: int) -> None: trade.stake_amount = trade.amount * trade.open_rate trade.open_order_id = None logger.info('Partial buy order timeout for %s.', trade) - elif order['type'] == "LIMIT_SELL" and order['opened'] < timeoutthreashold: + elif order['type'] == "LIMIT_SELL" and ordertime < timeoutthreashold: # Sell timeout - cancel order and update trade if order['remaining'] == order['amount']: # if trade is not partially completed, just cancel the trade diff --git a/freqtrade/tests/conftest.py b/freqtrade/tests/conftest.py index e1e9ab3d7..788585345 100644 --- a/freqtrade/tests/conftest.py +++ b/freqtrade/tests/conftest.py @@ -124,11 +124,11 @@ def limit_buy_order(): 'id': 'mocked_limit_buy', 'type': 'LIMIT_BUY', 'pair': 'mocked', - 'opened': arrow.utcnow().datetime, + 'opened': str(arrow.utcnow().datetime), 'rate': 0.00001099, 'amount': 90.99181073, 'remaining': 0.0, - 'closed': arrow.utcnow().datetime, + 'closed': str(arrow.utcnow().datetime), } @@ -138,7 +138,7 @@ def limit_buy_order_old(): 'id': 'mocked_limit_buy_old', 'type': 'LIMIT_BUY', 'pair': 'BTC_ETH', - 'opened': arrow.utcnow().shift(minutes=-601).datetime, + 'opened': str(arrow.utcnow().shift(minutes=-601).datetime), 'rate': 0.00001099, 'amount': 90.99181073, 'remaining': 90.99181073, @@ -151,7 +151,7 @@ def limit_sell_order_old(): 'id': 'mocked_limit_sell_old', 'type': 'LIMIT_SELL', 'pair': 'BTC_ETH', - 'opened': arrow.utcnow().shift(minutes=-601).datetime, + 'opened': str(arrow.utcnow().shift(minutes=-601).datetime), 'rate': 0.00001099, 'amount': 90.99181073, 'remaining': 90.99181073, @@ -164,7 +164,7 @@ def limit_buy_order_old_partial(): 'id': 'mocked_limit_buy_old_partial', 'type': 'LIMIT_BUY', 'pair': 'BTC_ETH', - 'opened': arrow.utcnow().shift(minutes=-601).datetime, + 'opened': str(arrow.utcnow().shift(minutes=-601).datetime), 'rate': 0.00001099, 'amount': 90.99181073, 'remaining': 67.99181073, @@ -177,11 +177,11 @@ def limit_sell_order(): 'id': 'mocked_limit_sell', 'type': 'LIMIT_SELL', 'pair': 'mocked', - 'opened': arrow.utcnow().datetime, + 'opened': str(arrow.utcnow().datetime), 'rate': 0.00001173, 'amount': 90.99181073, 'remaining': 0.0, - 'closed': arrow.utcnow().datetime, + 'closed': str(arrow.utcnow().datetime), }