Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
m5l14i11 committed Sep 11, 2024
1 parent be9a69a commit 7333f93
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/models/position_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 7333f93

Please sign in to comment.