Timestamps are in ms

This commit is contained in:
Matthias
2020-08-13 15:39:29 +02:00
parent 73182bb2dd
commit 0af9e913d4
5 changed files with 15 additions and 7 deletions

View File

@@ -107,7 +107,7 @@ class Order(_DECL_BASE):
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)
symbol = 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.cost = order.get('cost', self.cost)
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
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.order_update_date = datetime.now()
@@ -417,6 +418,9 @@ class Trade(_DECL_BASE):
else:
return False
def update_order(self, order: Dict) -> None:
Order.update_orders(self.orders, order)
def _calc_open_trade_price(self) -> float:
"""
Calculate the open_rate including open_fee.