Open order times should be strings, not datetime objectsy
This commit is contained in:
parent
d4fcc38a57
commit
ebe95ba1e1
@ -130,7 +130,9 @@ def check_handle_timedout(timeoutvalue: int) -> None:
|
|||||||
|
|
||||||
for trade in Trade.query.filter(Trade.open_order_id.isnot(None)).all():
|
for trade in Trade.query.filter(Trade.open_order_id.isnot(None)).all():
|
||||||
order = exchange.get_order(trade.open_order_id)
|
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
|
# Buy timeout - cancel order
|
||||||
exchange.cancel_order(trade.open_order_id)
|
exchange.cancel_order(trade.open_order_id)
|
||||||
if order['remaining'] == order['amount']:
|
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.stake_amount = trade.amount * trade.open_rate
|
||||||
trade.open_order_id = None
|
trade.open_order_id = None
|
||||||
logger.info('Partial buy order timeout for %s.', trade)
|
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
|
# Sell timeout - cancel order and update trade
|
||||||
if order['remaining'] == order['amount']:
|
if order['remaining'] == order['amount']:
|
||||||
# if trade is not partially completed, just cancel the trade
|
# if trade is not partially completed, just cancel the trade
|
||||||
|
@ -124,11 +124,11 @@ def limit_buy_order():
|
|||||||
'id': 'mocked_limit_buy',
|
'id': 'mocked_limit_buy',
|
||||||
'type': 'LIMIT_BUY',
|
'type': 'LIMIT_BUY',
|
||||||
'pair': 'mocked',
|
'pair': 'mocked',
|
||||||
'opened': arrow.utcnow().datetime,
|
'opened': str(arrow.utcnow().datetime),
|
||||||
'rate': 0.00001099,
|
'rate': 0.00001099,
|
||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'remaining': 0.0,
|
'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',
|
'id': 'mocked_limit_buy_old',
|
||||||
'type': 'LIMIT_BUY',
|
'type': 'LIMIT_BUY',
|
||||||
'pair': 'BTC_ETH',
|
'pair': 'BTC_ETH',
|
||||||
'opened': arrow.utcnow().shift(minutes=-601).datetime,
|
'opened': str(arrow.utcnow().shift(minutes=-601).datetime),
|
||||||
'rate': 0.00001099,
|
'rate': 0.00001099,
|
||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'remaining': 90.99181073,
|
'remaining': 90.99181073,
|
||||||
@ -151,7 +151,7 @@ def limit_sell_order_old():
|
|||||||
'id': 'mocked_limit_sell_old',
|
'id': 'mocked_limit_sell_old',
|
||||||
'type': 'LIMIT_SELL',
|
'type': 'LIMIT_SELL',
|
||||||
'pair': 'BTC_ETH',
|
'pair': 'BTC_ETH',
|
||||||
'opened': arrow.utcnow().shift(minutes=-601).datetime,
|
'opened': str(arrow.utcnow().shift(minutes=-601).datetime),
|
||||||
'rate': 0.00001099,
|
'rate': 0.00001099,
|
||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'remaining': 90.99181073,
|
'remaining': 90.99181073,
|
||||||
@ -164,7 +164,7 @@ def limit_buy_order_old_partial():
|
|||||||
'id': 'mocked_limit_buy_old_partial',
|
'id': 'mocked_limit_buy_old_partial',
|
||||||
'type': 'LIMIT_BUY',
|
'type': 'LIMIT_BUY',
|
||||||
'pair': 'BTC_ETH',
|
'pair': 'BTC_ETH',
|
||||||
'opened': arrow.utcnow().shift(minutes=-601).datetime,
|
'opened': str(arrow.utcnow().shift(minutes=-601).datetime),
|
||||||
'rate': 0.00001099,
|
'rate': 0.00001099,
|
||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'remaining': 67.99181073,
|
'remaining': 67.99181073,
|
||||||
@ -177,11 +177,11 @@ def limit_sell_order():
|
|||||||
'id': 'mocked_limit_sell',
|
'id': 'mocked_limit_sell',
|
||||||
'type': 'LIMIT_SELL',
|
'type': 'LIMIT_SELL',
|
||||||
'pair': 'mocked',
|
'pair': 'mocked',
|
||||||
'opened': arrow.utcnow().datetime,
|
'opened': str(arrow.utcnow().datetime),
|
||||||
'rate': 0.00001173,
|
'rate': 0.00001173,
|
||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'remaining': 0.0,
|
'remaining': 0.0,
|
||||||
'closed': arrow.utcnow().datetime,
|
'closed': str(arrow.utcnow().datetime),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user