|
28 | 28 | plot_heatmaps,
|
29 | 29 | random_ohlc_data,
|
30 | 30 | )
|
31 |
| -from backtesting.test import GOOG, EURUSD, SMA, AMZN |
| 31 | +from backtesting.test import GOOG, EURUSD, SMA |
32 | 32 | from backtesting._util import _Indicator, _as_str, _Array, try_
|
33 |
| -from talib import RSI,EMA,ATR,MINMAX |
34 | 33 |
|
35 | 34 | SHORT_DATA = GOOG.iloc[:20] # Short data for fast tests with no indicator lag
|
36 | 35 |
|
@@ -862,31 +861,6 @@ def next(self):
|
862 | 861 | stats = Backtest(GOOG, S).run()
|
863 | 862 | self.assertEqual(stats['# Trades'], 57)
|
864 | 863 |
|
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) |
888 |
| - |
889 |
| - |
890 | 864 | class TestUtil(TestCase):
|
891 | 865 | def test_as_str(self):
|
892 | 866 | def func():
|
|
0 commit comments