From 7333f93b6a72fa648ee5d9a914cb4d9719049943 Mon Sep 17 00:00:00 2001 From: m5l14i11 Date: Wed, 11 Sep 2024 12:48:24 +0300 Subject: [PATCH] upd --- core/models/position_risk.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/models/position_risk.py b/core/models/position_risk.py index a60a979f..bd2bbcd5 100644 --- a/core/models/position_risk.py +++ b/core/models/position_risk.py @@ -413,13 +413,17 @@ def sl_ats(self, side: PositionSide, ta: TechAnalysis, sl: float) -> "float": if side == PositionSide.LONG: l_constr = low_smooth[-1] - volatility_smooth[-1] - adjusted_sl = min(l_constr, np.max(ats)) if bullish else min(l_constr, ats[-1]) + adjusted_sl = ( + min(l_constr, np.max(ats)) if bullish else min(l_constr, ats[-1]) + ) return max(sl, adjusted_sl) if side == PositionSide.SHORT: h_constr = high_smooth[-1] + volatility_smooth[-1] - adjusted_sl = max(h_constr, np.min(ats)) if bearish else max(h_constr, ats[-1]) + adjusted_sl = ( + max(h_constr, np.min(ats)) if bearish else max(h_constr, ats[-1]) + ) return min(sl, adjusted_sl)