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 adbfe69
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions xtcryptosignals/server/api/exchanges/binance/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def post_dump(self, data):
data["price"] = price
else:
data["price"] = 1.0
if "price" in data:
data["total_price"] = data["total"] * data["price"]

data["total_price"] = data["total"] * data["price"]

return data


class ExchangeBalanceOutputSchema(Schema):
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['total_price'], reverse=True)

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


Expand Down

0 comments on commit adbfe69

Please sign in to comment.