Timestamps are in ms
This commit is contained in:
parent
73182bb2dd
commit
0af9e913d4
@ -486,7 +486,7 @@ class Exchange:
|
|||||||
'side': side,
|
'side': side,
|
||||||
'remaining': _amount,
|
'remaining': _amount,
|
||||||
'datetime': arrow.utcnow().isoformat(),
|
'datetime': arrow.utcnow().isoformat(),
|
||||||
'timestamp': arrow.utcnow().timestamp,
|
'timestamp': int(arrow.utcnow().timestamp * 1000),
|
||||||
'status': "closed" if ordertype == "market" else "open",
|
'status': "closed" if ordertype == "market" else "open",
|
||||||
'fee': None,
|
'fee': None,
|
||||||
'info': {}
|
'info': {}
|
||||||
|
@ -817,6 +817,9 @@ class FreqtradeBot:
|
|||||||
except InvalidOrderException as exception:
|
except InvalidOrderException as exception:
|
||||||
logger.warning('Unable to fetch stoploss order: %s', exception)
|
logger.warning('Unable to fetch stoploss order: %s', exception)
|
||||||
|
|
||||||
|
if stoploss_order:
|
||||||
|
trade.update_order(stoploss_order)
|
||||||
|
|
||||||
# We check if stoploss order is fulfilled
|
# We check if stoploss order is fulfilled
|
||||||
if stoploss_order and stoploss_order['status'] in ('closed', 'triggered'):
|
if stoploss_order and stoploss_order['status'] in ('closed', 'triggered'):
|
||||||
trade.sell_reason = SellType.STOPLOSS_ON_EXCHANGE.value
|
trade.sell_reason = SellType.STOPLOSS_ON_EXCHANGE.value
|
||||||
@ -1260,7 +1263,7 @@ class FreqtradeBot:
|
|||||||
except InvalidOrderException as exception:
|
except InvalidOrderException as exception:
|
||||||
logger.warning('Unable to fetch order %s: %s', order_id, exception)
|
logger.warning('Unable to fetch order %s: %s', order_id, exception)
|
||||||
return False
|
return False
|
||||||
Order.update_order(order)
|
trade.update_order(order)
|
||||||
# Try update amount (binance-fix)
|
# Try update amount (binance-fix)
|
||||||
try:
|
try:
|
||||||
new_amount = self.get_real_amount(trade, order, order_amount)
|
new_amount = self.get_real_amount(trade, order, order_amount)
|
||||||
|
@ -107,7 +107,7 @@ class Order(_DECL_BASE):
|
|||||||
|
|
||||||
ft_order_side = Column(String, nullable=False)
|
ft_order_side = Column(String, nullable=False)
|
||||||
|
|
||||||
order_id = Column(String, nullable=False, unique=True, index=True)
|
order_id = Column(String, nullable=False, index=True)
|
||||||
status = Column(String, nullable=True)
|
status = Column(String, nullable=True)
|
||||||
symbol = Column(String, nullable=True)
|
symbol = Column(String, nullable=True)
|
||||||
order_type = Column(String, nullable=True)
|
order_type = Column(String, nullable=True)
|
||||||
@ -144,13 +144,14 @@ class Order(_DECL_BASE):
|
|||||||
self.remaining = order.get('remaining', self.remaining)
|
self.remaining = order.get('remaining', self.remaining)
|
||||||
self.cost = order.get('cost', self.cost)
|
self.cost = order.get('cost', self.cost)
|
||||||
if 'timestamp' in order and order['timestamp'] is not None:
|
if 'timestamp' in order and order['timestamp'] is not None:
|
||||||
self.order_date = datetime.fromtimestamp(order['timestamp'])
|
self.order_date = datetime.fromtimestamp(order['timestamp'] / 1000)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_order(order: Dict[str, Any]):
|
def update_orders(orders: List['Order'], order: Dict[str, Any]):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
oobj = Order.query.filter(Order.order_id == order['id']).first()
|
filtered_orders = [o for o in orders if o.order_id == order['id']]
|
||||||
|
oobj = filtered_orders[0] if filtered_orders else None
|
||||||
oobj.update_from_ccxt_object(order)
|
oobj.update_from_ccxt_object(order)
|
||||||
oobj.order_update_date = datetime.now()
|
oobj.order_update_date = datetime.now()
|
||||||
|
|
||||||
@ -417,6 +418,9 @@ class Trade(_DECL_BASE):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def update_order(self, order: Dict) -> None:
|
||||||
|
Order.update_orders(self.orders, order)
|
||||||
|
|
||||||
def _calc_open_trade_price(self) -> float:
|
def _calc_open_trade_price(self) -> float:
|
||||||
"""
|
"""
|
||||||
Calculate the open_rate including open_fee.
|
Calculate the open_rate including open_fee.
|
||||||
|
@ -807,7 +807,7 @@ def test_dry_run_order(default_conf, mocker, side, exchange_name):
|
|||||||
assert f'dry_run_{side}_' in order["id"]
|
assert f'dry_run_{side}_' in order["id"]
|
||||||
assert order["side"] == side
|
assert order["side"] == side
|
||||||
assert order["type"] == "limit"
|
assert order["type"] == "limit"
|
||||||
assert order["pair"] == "ETH/BTC"
|
assert order["symbol"] == "ETH/BTC"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("side", [
|
@pytest.mark.parametrize("side", [
|
||||||
|
@ -1194,6 +1194,7 @@ def test_handle_stoploss_on_exchange(mocker, default_conf, fee, caplog,
|
|||||||
assert trade
|
assert trade
|
||||||
|
|
||||||
stoploss_order_hit = MagicMock(return_value={
|
stoploss_order_hit = MagicMock(return_value={
|
||||||
|
'id': 100,
|
||||||
'status': 'closed',
|
'status': 'closed',
|
||||||
'type': 'stop_loss_limit',
|
'type': 'stop_loss_limit',
|
||||||
'price': 3,
|
'price': 3,
|
||||||
|
Loading…
Reference in New Issue
Block a user