def __init__(self, feed, instrument, n, m): strategy.BacktestingStrategy.__init__(self, feed) self.__instrument = instrument self.getBroker().setFillStrategy(DefaultStrategy(None)) self.getBroker().setCommission(TradePercentage(0.001)) self.__position = None self.__prices = feed[instrument].getPriceDataSeries() self.__malength1 = int(n) self.__malength2 = int(m) self.__ma1 = ma.SMA(self.__prices, self.__malength1) self.__ma2 = ma.SMA(self.__prices, self.__malength2)
def __init__(self, feed, instrument, mall, mals, masl, mass): strategy.BacktestingStrategy.__init__(self, feed) self.getBroker().setFillStrategy(DefaultStrategy(None)) self.getBroker().setCommission(TradePercentage(0.001)) self.__instrument = instrument self.__close = feed[instrument].getCloseDataSeries() self.__longPos = None self.__shortPos = None self.__mall = ma.SMA(self.__close, int(mall)) self.__mals = ma.SMA(self.__close, int(mals)) self.__masl = ma.SMA(self.__close, int(masl)) self.__mass = ma.SMA(self.__close, int(mass)) self.__position = SequenceDataSeries()
def __init__(self, feed, instrument, short_l, mid_l, long_l, up_cum): strategy.BacktestingStrategy.__init__(self, feed) self.__instrument = instrument self.getBroker().setFillStrategy(DefaultStrategy(None)) self.getBroker().setCommission(TradePercentage(0.001)) self.__position = None self.__prices = feed[instrument].getPriceDataSeries() self.__malength1 = int(short_l) self.__malength2 = int(mid_l) self.__malength3 = int(long_l) self.__circ = int(up_cum) self.__ma1 = ma.SMA(self.__prices, self.__malength1) self.__ma2 = ma.SMA(self.__prices, self.__malength2) self.__ma3 = ma.SMA(self.__prices, self.__malength3)
def __init__(self, feed, instrument, bollingerlength, numStdDev, closelength, ccMAlength, malength, space): strategy.BacktestingStrategy.__init__(self, feed) self.getBroker().setFillStrategy(DefaultStrategy(None)) self.getBroker().setCommission(TradePercentage(0.002)) self.__instrument = instrument self.__bollingerlength = int(bollingerlength) numStdDev = float(numStdDev) / 10 self.__closelength = int(closelength) self.__ccMAlength = int(ccMAlength) self.__malength = int(malength) self.__longPos = None self.__shortPos = None self.__close = feed[instrument].getCloseDataSeries() self.__high = feed[instrument].getHighDataSeries() self.__low = feed[instrument].getLowDataSeries() self.__datetime = feed[instrument].getDateTimes() self.__bollinger = bollinger.BollingerBands(self.__close, self.__bollingerlength, int(numStdDev)) self.__UpperBand = self.__bollinger.getUpperBand() self.__LowerBand = self.__bollinger.getLowerBand() self.__MA = SequenceDataSeries() self.__space = int(space) self.__enter = 0 self.__enterLong1 = 0 self.__enterLong2 = 0 self.__enterShort1 = 0 self.__enterShort2 = 0 self.__exitLong1 = 0 self.__exitLong2 = 0 self.__exitShort1 = 0 self.__exitShort1 = 0 #for test ######################################################################### self.__p = SequenceDataSeries() self.__filterCon = SequenceDataSeries() self.__ccMACon1 = SequenceDataSeries() self.__ccMACon2 = SequenceDataSeries() self.__enterCon = SequenceDataSeries() self.__enterLongCon1 = SequenceDataSeries() self.__enterLongCon2 = SequenceDataSeries() self.__enterShortCon1 = SequenceDataSeries() self.__enterShortCon2 = SequenceDataSeries() self.__exitLongCon1 = SequenceDataSeries() self.__exitLongCon2 = SequenceDataSeries() self.__exitShortCon1 = SequenceDataSeries() self.__exitShortCon2 = SequenceDataSeries()