Skip to content

Commit adbfe69

Browse files
committed
Sort My Balance DESC
1 parent 4519b3e commit adbfe69

File tree

1 file changed

+7
-2
lines changed
  • xtcryptosignals/server/api/exchanges/binance

1 file changed

+7
-2
lines changed

xtcryptosignals/server/api/exchanges/binance/schemas.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ def post_dump(self, data):
4646
data["price"] = price
4747
else:
4848
data["price"] = 1.0
49-
if "price" in data:
50-
data["total_price"] = data["total"] * data["price"]
49+
50+
data["total_price"] = data["total"] * data["price"]
51+
52+
return data
5153

5254

5355
class ExchangeBalanceOutputSchema(Schema):
@@ -63,6 +65,9 @@ def post_dump(self, data, many):
6365
if "price" in x:
6466
total += x["price"] * x["total"]
6567
rows.append(x)
68+
69+
rows = sorted(rows, key=lambda i: i['total_price'], reverse=True)
70+
6671
return dict(results=dict(rows=rows, total=total))
6772

6873

0 commit comments

Comments
 (0)