Format code with ruff to pass CI format check
Some checks failed
CI/CD Pipeline / build-and-push (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled

This commit is contained in:
bnair123
2025-12-27 19:12:19 +04:00
parent 524e6d7498
commit 30af8e7c70
5 changed files with 28 additions and 7 deletions

View File

@@ -45,7 +45,9 @@ class SupertrendStrategy(Strategy):
multiplier=float(self._multiplier),
)
direction_col = next((col for col in supertrend.columns if col.startswith("SUPERTd_")), None)
direction_col = next(
(col for col in supertrend.columns if col.startswith("SUPERTd_")), None
)
if direction_col is None:
logger.debug("Supertrend direction series missing", strategy=self.name)
return None
@@ -110,7 +112,11 @@ class SupertrendStrategy(Strategy):
def get_stop_loss(self, entry_price: Decimal, side: Side) -> Decimal:
"""Use ATR buffer for Supertrend stop loss."""
atr_buffer = self._last_atr if self._last_atr and self._last_atr > Decimal("0") else entry_price * Decimal("0.02")
atr_buffer = (
self._last_atr
if self._last_atr and self._last_atr > Decimal("0")
else entry_price * Decimal("0.02")
)
if side == Side.BUY:
stop = entry_price - atr_buffer
else:
@@ -150,7 +156,14 @@ class SupertrendStrategy(Strategy):
@staticmethod
def _trend_level(supertrend: pd.DataFrame) -> Decimal | None:
trend_col = next((col for col in supertrend.columns if col.startswith("SUPERT_") and not col.startswith("SUPERTd_")), None)
trend_col = next(
(
col
for col in supertrend.columns
if col.startswith("SUPERT_") and not col.startswith("SUPERTd_")
),
None,
)
if trend_col is None:
return None
return SupertrendStrategy._decimal_from_series_tail(supertrend[trend_col])