Skip to content

Commit 50f0daf

Browse files
authored
Fix inconsistent tabs issue kernc#316
1 parent fc62a86 commit 50f0daf

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

backtesting/test/_test.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -861,31 +861,31 @@ def next(self):
861861
self.buy()
862862

863863
stats = Backtest(GOOG, S).run()
864-
self.assertEqual(stats['# Trades'], 57)
864+
self.assertEqual(stats['# Trades'], 57)
865865

866866
def test_TrailingStrategy_should_not_raise_Assert_error(self):
867-
class Breakout(TrailingStrategy):
868-
timeperiod = 10
869-
position_size_decimal = 0.2
870-
min_close = []
871-
max_close = []
872-
def init(self):
873-
super().init()
874-
self.ema20 = self.I(EMA,self.data.Close,20,overlay=True)
875-
self.atr14 = self.I(ATR,self.data.High,self.data.Low,self.data.Close,14)
876-
self.set_atr_periods(20)
877-
self.set_trailing_sl(1.5)
878-
print(type(self.data.Close))
879-
self.min_close, self.max_close = MINMAX(self.data.Close, timeperiod=self.timeperiod)
880-
881-
def next(self):
882-
super().next()
883-
index = len(self.data)-1
884-
if not self.position.is_long and self.min_close[index] > (self.max_close[index] * 0.98) and self.max_close[index] < (self.min_close[index] * 1.02):
885-
self.buy(size=self.position_size_decimal)
886-
887-
stats = Backtest(AMZN,Breakout).run()
888-
self.assertEqual(stats['# Trades'], 23)
867+
class Breakout(TrailingStrategy):
868+
timeperiod = 10
869+
position_size_decimal = 0.2
870+
min_close = []
871+
max_close = []
872+
def init(self):
873+
super().init()
874+
self.ema20 = self.I(EMA,self.data.Close,20,overlay=True)
875+
self.atr14 = self.I(ATR,self.data.High,self.data.Low,self.data.Close,14)
876+
self.set_atr_periods(20)
877+
self.set_trailing_sl(1.5)
878+
print(type(self.data.Close))
879+
self.min_close, self.max_close = MINMAX(self.data.Close, timeperiod=self.timeperiod)
880+
881+
def next(self):
882+
super().next()
883+
index = len(self.data)-1
884+
if not self.position.is_long and self.min_close[index] > (self.max_close[index] * 0.98) and self.max_close[index] < (self.min_close[index] * 1.02):
885+
self.buy(size=self.position_size_decimal)
886+
887+
stats = Backtest(AMZN,Breakout).run()
888+
self.assertEqual(stats['# Trades'], 23)
889889

890890

891891
class TestUtil(TestCase):

0 commit comments

Comments
 (0)