Support having no Amount/Price available from the exchange initially

This commit is contained in:
Matthias 2023-01-08 13:55:09 +01:00
parent fd694f14c2
commit 305b067e48

View File

@ -84,9 +84,13 @@ class Order(_DECL_BASE):
self.order_filled_date.replace(tzinfo=timezone.utc) if self.order_filled_date else None self.order_filled_date.replace(tzinfo=timezone.utc) if self.order_filled_date else None
) )
@property
def safe_amount(self) -> float:
return self.amount or self.ft_amount
@property @property
def safe_price(self) -> float: def safe_price(self) -> float:
return self.average or self.price or self.stop_price return self.average or self.price or self.stop_price or self.ft_price
@property @property
def safe_filled(self) -> float: def safe_filled(self) -> float:
@ -96,7 +100,7 @@ class Order(_DECL_BASE):
def safe_remaining(self) -> float: def safe_remaining(self) -> float:
return ( return (
self.remaining if self.remaining is not None else self.remaining if self.remaining is not None else
self.amount - (self.filled or 0.0) self.safe_amount - (self.filled or 0.0)
) )
@property @property