def __buildWMA(self,
                weights,
                values,
                seqMaxLen=dataseries.DEFAULT_MAX_LEN,
                wmaMaxLen=dataseries.DEFAULT_MAX_LEN):
     seqDS = dataseries.SequenceDataSeries(maxLen=seqMaxLen)
     ret = ma.WMA(seqDS, weights, wmaMaxLen)
     for value in values:
         seqDS.append(value)
     return ret
Exemple #2
0
    def __init__(self, feed, instrument, bBandsPeriod):
        strategy.BacktestingStrategy.__init__(self, feed)
        self.setDebugMode(False)
        self.__instrument = instrument
        self.__feed = feed
        self.__position = None
        self.__sma = ma.WMA(feed[instrument].getCloseDataSeries(), 15)

        self.__col = [
            "buyPrice", "buyTime", "sellPrice", "sellTime", "returns"
        ]
        self.__msdf = pd.DataFrame(columns=self.__col)
        self.__buyPrice = 0
        self.__buyTime = None
        self.setUseAdjustedValues(True)
Exemple #3
0
 def __buildWMA(self, weights, values):
     from pyalgotrade import dataseries
     return ma.WMA(dataseries.SequenceDataSeries(values), weights)