Format code with ruff to pass CI format check
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user