Skip to content

Commit

Permalink
Prevent signals opening pairs that are already active
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Wu Fei authored and Carlos Wu Fei committed Jan 4, 2024
1 parent 1b464f1 commit 143c2ca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions api/deals/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,15 @@ def open_deal(self):
- If base order deal is not executed, bot is not activated
"""
# Check if bot with same pair is already active
active_bot = self.db_collection.find_one(
{"pair": self.active_bot.pair, "status": Status.active}
)
if active_bot:
raise CreateDealControllerError(
f"Bot with pair {self.active_bot.pair} is already active"
)

# If there is already a base order do not execute
base_order_deal = next(
(
Expand Down
2 changes: 1 addition & 1 deletion api/orders/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def sell_order(self, symbol, qty, price=None):

data = self.signed_request(url=self.order_url, method="POST", payload=payload)

if data["price"] == 0:
if float(data["price"]) == 0:
total_qty = 0
weighted_avg = 0
for item in data["fills"]:
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/VolumesRanking.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const average = (data) => {
return (acc + parseFloat(x.quoteVolume) + parseFloat(x.volume));
}, 0);

return total / data.length - 1;
return (total / data.length - 1).toLocaleString();
}

export default function VolumesRankingCard({ data, title }) {
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function VolumesRankingCard({ data, title }) {
bg="success"
className="u-float-right"
>
{(parseFloat(x.quoteVolume) + parseFloat(x.volume)).toFixed(2)}
{(parseFloat(x.quoteVolume) + parseFloat(x.volume)).toLocaleString()}
</Badge>
</Col>
</Row>
Expand Down

0 comments on commit 143c2ca

Please sign in to comment.