Skip to content

Commit

Permalink
Sort My Balance DESC
Browse files Browse the repository at this point in the history
  • Loading branch information
pantunes committed Dec 19, 2021
1 parent 4519b3e commit c4f7a93
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions xtcryptosignals/server/api/exchanges/binance/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def post_dump(self, data):
data["price"] = price
else:
data["price"] = 1.0

if "price" in data:
# the ones configured in `settings_exchanges.py`
data["total_price"] = data["total"] * data["price"]


Expand All @@ -63,6 +65,9 @@ def post_dump(self, data, many):
if "price" in x:
total += x["price"] * x["total"]
rows.append(x)

rows = sorted(rows, key=lambda i: i.get('total_price', 0.0), reverse=True)

return dict(results=dict(rows=rows, total=total))


Expand Down

0 comments on commit c4f7a93

Please sign in to comment.