use safe_value_fallback when parsing orders

closes #9591
This commit is contained in:
Matthias 2023-12-25 11:44:04 +01:00
parent 17a538b5ba
commit 1e5d353cf7

View File

@ -156,20 +156,20 @@ class Order(ModelBase):
if self.order_id != str(order['id']):
raise DependencyException("Order-id's don't match")
self.status = order.get('status', self.status)
self.symbol = order.get('symbol', self.symbol)
self.order_type = order.get('type', self.order_type)
self.side = order.get('side', self.side)
self.price = order.get('price', self.price)
self.amount = order.get('amount', self.amount)
self.filled = order.get('filled', self.filled)
self.average = order.get('average', self.average)
self.remaining = order.get('remaining', self.remaining)
self.cost = order.get('cost', self.cost)
self.stop_price = order.get('stopPrice', self.stop_price)
if 'timestamp' in order and order['timestamp'] is not None:
self.order_date = datetime.fromtimestamp(order['timestamp'] / 1000, tz=timezone.utc)
self.status = safe_value_fallback(order, 'status', default_value=self.status)
self.symbol = safe_value_fallback(order, 'symbol', default_value=self.symbol)
self.order_type = safe_value_fallback(order, 'type', default_value=self.order_type)
self.side = safe_value_fallback(order, 'side', default_value=self.side)
self.price = safe_value_fallback(order, 'price', default_value=self.price)
self.amount = safe_value_fallback(order, 'amount', default_value=self.amount)
self.filled = safe_value_fallback(order, 'filled', default_value=self.filled)
self.average = safe_value_fallback(order, 'average', default_value=self.average)
self.remaining = safe_value_fallback(order, 'remaining', default_value=self.remaining)
self.cost = safe_value_fallback(order, 'cost', default_value=self.cost)
self.stop_price = safe_value_fallback(order, 'stopPrice', default_value=self.stop_price)
order_date = safe_value_fallback(order, 'timestamp')
if order_date:
self.order_date = datetime.fromtimestamp(order_date / 1000, tz=timezone.utc)
self.ft_is_open = True
if self.status in NON_OPEN_EXCHANGE_STATES: