Skip to content

Commit

Permalink
Merge pull request #19 from Pasta-fantasia/16-error-cant-create-stop-…
Browse files Browse the repository at this point in the history
…loss-grouped_amount_canceled_orders_and_new_trades

16 error cant create stop loss grouped amount canceled orders and new trades
  • Loading branch information
fransimo committed Jul 9, 2024
2 parents 3d626fb + 04884d7 commit 222f82d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.1.5
- fix: [ERROR] Can't create stop loss grouped_amount_canceled_orders_and_new_trades #16. Cancel, balance check, sells.

# 0.1.4
- fix: [ERROR] Can't create stop loss grouped_amount_canceled_orders_and_new_trades #16. Balance check before sells.

Expand Down
10 changes: 5 additions & 5 deletions elena_basics/strategies/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ def next(self) -> BotStatus:
# - if it's partial?

if sell_size > 0:
for order_id in orders_to_cancel:
cancelled_order = self.cancel_order(order_id)
if not cancelled_order:
self._logger.error(f"Error canceling order: {order_id}.")

# verify balance, it needs to be checked after any cancellation
balance = self.get_balance()
if not balance:
Expand All @@ -169,11 +174,6 @@ def next(self) -> BotStatus:
trade.size = self.amount_to_precision(trade.size - sale_diff)
sell_size = max_sell

for order_id in orders_to_cancel:
cancelled_order = self.cancel_order(order_id)
if not cancelled_order:
self._logger.error(f"Error canceling order: {order_id}.")

sell_order = self.create_market_sell_order(sell_size, trades_to_close)

if sell_order:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = elena_basics
version = 0.1.4
version = 0.1.5
author = "L Software Foundation"
author_email = "fransimo@gmail.com, pjover@gmail.com"
description = Sample project to link L + CCTX + Backtesting.py
Expand Down

0 comments on commit 222f82d

Please sign in to comment.