Skip to content

Commit

Permalink
Update API dependencies (#614)
Browse files Browse the repository at this point in the history
* Update API dependencies

* Fix missing pair when liquidating margin orders

* Fix margin_liquidation missing arg
  • Loading branch information
carkod authored Oct 22, 2024
1 parent 1a79e80 commit b56c842
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 69 deletions.
4 changes: 2 additions & 2 deletions api/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ pydantic = "==2.7.0"
pymongo = "==4.6.3"
python-jose = "*"
passlib = "*"
pandas = "==1.5.2"
numpy = "==1.26.4"
pandas = "==2.2.3"
requests = "==2.28.1"
websocket-client = "==1.5.0"
scipy = "==1.10.0"
requests-html = "==0.10.0"
py3cw = "==0.0.39"
numpy = "==1.23.5"
apscheduler = "==3.6.3"
requests-cache = "==1.2.0"
python-multipart = "*"
Expand Down
159 changes: 95 additions & 64 deletions api/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion api/account/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from bson.objectid import ObjectId
from fastapi.responses import JSONResponse
from account.controller import AssetsController
from bots.schemas import BotSchema
from deals.controllers import CreateDealController
from tools.handle_error import json_response, json_response_error, json_response_message
from tools.round_numbers import round_numbers
Expand Down Expand Up @@ -355,7 +356,8 @@ def one_click_liquidation(self, pair: str) -> JSONResponse:
"""

try:
active_bot = self._db.bots.find_one({"status": Status.active, "pair": pair})
bot = self._db.bots.find_one({"status": Status.active, "pair": pair})
active_bot = BotSchema.model_validate(bot)
deal = CreateDealController(
active_bot,
db_collection="bots"
Expand Down
4 changes: 2 additions & 2 deletions api/deals/margin.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def execute_stop_loss(self):
# Cancel orders first
# paper_trading doesn't have real orders so no need to check
self.cancel_open_orders(DealType.stop_loss)
res = self.margin_liquidation(self.active_bot.pair, self.qty_precision)
res = self.margin_liquidation(self.active_bot.pair)

stop_loss_order = MarginOrderSchema(
timestamp=res["transactTime"],
Expand Down Expand Up @@ -589,7 +589,7 @@ def execute_take_profit(self):
if self.db_collection.name == "paper_trading":
res = self.simulate_margin_order(self.active_bot.deal.buy_total_qty, "BUY")
else:
res = self.margin_liquidation(self.active_bot.pair, self.qty_precision)
res = self.margin_liquidation(self.active_bot.pair)

if res:
# No res means it wasn't properly closed/completed
Expand Down

0 comments on commit b56c842

Please sign in to comment.