Skip to content

Commit f954742

Browse files
committed
updated variable name as per code review comment kernc#223
1 parent a7732f2 commit f954742

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

backtesting/lib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ class PercentageTrailingStrategy(Strategy):
464464
Remember to call `super().init()` and `super().next()` in your
465465
overridden methods.
466466
"""
467-
_sl_percent = 5.
467+
_sl_pct = 5.
468468

469469
def init(self):
470470
super().init()
@@ -475,18 +475,18 @@ def set_trailing_sl(self, percentage: float = 5):
475475
Sets the future trailing stop-loss as some (`percentage`)
476476
percentage away from the current price.
477477
"""
478-
self._sl_percent = percentage
478+
self._sl_pct = percentage/100
479479

480480
def next(self):
481481
super().next()
482482
index = len(self.data)-1
483483
for trade in self.trades:
484484
if trade.is_long:
485485
trade.sl = max(trade.sl or -np.inf,
486-
self.data.Close[index]*(1-(self._sl_percent/100)))
486+
self.data.Close[index]*(1-self._sl_pct))
487487
else:
488488
trade.sl = min(trade.sl or np.inf,
489-
self.data.Close[index]*(1+(self._sl_percent/100)))
489+
self.data.Close[index]*(1+self._sl_pct))
490490

491491

492492
# Prevent pdoc3 documenting __init__ signature of Strategy subclasses

0 commit comments

Comments
 (0)