Add more info on status message

This commit is contained in:
Stefano Ariestasia
2022-01-22 06:54:49 +00:00
parent 3925e8a7e3
commit 05046b9eef
5 changed files with 87 additions and 3 deletions

View File

@@ -282,6 +282,20 @@ class LocalTrade():
return self.close_date.replace(tzinfo=timezone.utc)
def to_json(self) -> Dict[str, Any]:
fill_buy = self.select_filled_orders('buy')
buys_json = dict()
if len(fill_buy) > 0:
for x in range(len(fill_buy)):
buy = dict(
cost=fill_buy[x].cost if fill_buy[x].cost else 0.0,
amount=fill_buy[x].amount,
price=fill_buy[x].price,
average=round(fill_buy[x].average, 8) if fill_buy[x].average else 0.0,
order_filled_date=fill_buy[x].order_filled_date.strftime(DATETIME_PRINT_FORMAT)
if fill_buy[x].order_filled_date else None
)
buys_json[str(x)] = buy
return {
'trade_id': self.id,
'pair': self.pair,
@@ -345,6 +359,7 @@ class LocalTrade():
'max_rate': self.max_rate,
'open_order_id': self.open_order_id,
'filled_buys': buys_json,
}
@staticmethod