Skip to content

Commit bd2c7bb

Browse files
authored
Removed Tabs and used Spaces kernc#316
1 parent 50f0daf commit bd2c7bb

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

backtesting/test/_test.py

+25-26
Original file line numberDiff line numberDiff line change
@@ -859,33 +859,32 @@ def next(self):
859859
super().next()
860860
if not self.position and self.data.Close > self.sma:
861861
self.buy()
862-
863862
stats = Backtest(GOOG, S).run()
864-
self.assertEqual(stats['# Trades'], 57)
865-
866-
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)
863+
self.assertEqual(stats['# Trades'], 57)
864+
865+
def test_TrailingStrategy_should_not_raise_Assert_error(self):
866+
class Breakout(TrailingStrategy):
867+
timeperiod = 10
868+
position_size_decimal = 0.2
869+
min_close = []
870+
max_close = []
871+
def init(self):
872+
super().init()
873+
self.ema20 = self.I(EMA,self.data.Close,20,overlay=True)
874+
self.atr14 = self.I(ATR,self.data.High,self.data.Low,self.data.Close,14)
875+
self.set_atr_periods(20)
876+
self.set_trailing_sl(1.5)
877+
print(type(self.data.Close))
878+
self.min_close, self.max_close = MINMAX(self.data.Close, timeperiod=self.timeperiod)
879+
880+
def next(self):
881+
super().next()
882+
index = len(self.data)-1
883+
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):
884+
self.buy(size=self.position_size_decimal)
885+
886+
stats = Backtest(AMZN,Breakout).run()
887+
self.assertEqual(stats['# Trades'], 23)
889888

890889

891890
class TestUtil(TestCase):

0 commit comments

Comments
 (0)