Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
m5l14i11 committed Sep 10, 2024
1 parent e41f5ee commit 9990437
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions core/models/position_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .side import PositionSide
from .ta import TechAnalysis

TIME_THRESHOLD = 15000
TIME_THRESHOLD = 10000
LOOKBACK = 6


Expand Down Expand Up @@ -412,20 +412,14 @@ def sl_ats(self, side: PositionSide, ta: TechAnalysis, sl: float) -> "float":
)

if side == PositionSide.LONG:
adjusted_sl = (
min(low_smooth[-1], np.max(ats))
if bullish
else min(low_smooth[-1], ats[-1])
)
l_constr = low_smooth[-1] - volatility_smooth[-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:
adjusted_sl = (
max(high_smooth[-1], np.min(ats))
if bearish
else max(high_smooth[-1], ats[-1])
)
h_constr = high_smooth[-1] + volatility_smooth[-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 9990437

Please sign in to comment.