Skip to content

Commit

Permalink
fix(Strategy): simplify boolean checks for execution and short condit…
Browse files Browse the repository at this point in the history
…ions

- Refactored boolean checks in the Strategy class to remove unnecessary comparisons with True.
- Updated validation logic to ensure 'should_short' is not True when the exchange type is 'spot', enhancing code clarity and maintainability.
  • Loading branch information
saleh-mir committed Dec 19, 2024
1 parent 93791c9 commit 85d77cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jesse/strategies/Strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def _check(self) -> None:

should_short = self.should_short()
# validate that should_short is not True if the exchange_type is spot
if self.exchange_type == 'spot' and should_short is True:
if self.exchange_type == 'spot' and should_short:
raise exceptions.InvalidStrategy(
'should_short cannot be True if the exchange type is "spot".'
)
Expand Down Expand Up @@ -963,7 +963,7 @@ def _execute(self) -> None:
Handles the execution permission for the strategy.
"""
# make sure we don't execute this strategy more than once at the same time.
if self._is_executing is True:
if self._is_executing:
return

self._is_executing = True
Expand Down

0 comments on commit 85d77cf

Please sign in to comment.