示例#1
0
 def __init__(self, feed, instrument, period):
     strategy.BacktestingStrategy.__init__(self, feed)
     self.__instrument = instrument
     self.__position = None
     # We'll use adjusted close values instead of regular close values.
     self.setUseAdjustedValues(True)
     self.__prices = feed[instrument].getPriceDataSeries()
     self.__hurst = hurst.HurstExponent(self.__prices, period)
    def __init__(self, feed, instrument, hurstPeriod):
        strategy.BacktestingStrategy.__init__(self, feed)
        self.__longWindow = 20
        self.__shortWindow = 40
        self.__instrument = instrument
        self.__position = None
        # We'll use adjusted close values instead of regular close values.
        self.setUseAdjustedValues(True)
        self.__adjClosePrices = feed[instrument].getAdjCloseDataSeries()
        self.__prices = feed[instrument].getPriceDataSeries()
        self.__hurst = hurst.HurstExponent(self.__adjClosePrices, hurstPeriod)
        self.__halfLifeHelper = MovingHalfLifeUtil.MovingHalfLifeHelper(
            feed[instrument].getAdjCloseDataSeries(), hurstPeriod)

        self.__longWindowMa = ma.SMA(self.__prices, self.__longWindow)
        self.__shortWindowMa = ma.SMA(self.__prices, self.__shortWindow)
示例#3
0
def build_hurst(values, period, lags):
    ds = dataseries.SequenceDataSeries()
    ret = hurst.HurstExponent(ds, period, lags)
    for value in values:
        ds.append(value)
    return ret