def execute(self, strategy):
     forecasts = {}
     for forecaster in self.forecasters:
         forecasts[forecaster.name] = forecaster(strategy).data
     forecasts = Panel(forecasts)
     mean_fcst = self.normalise(forecasts.mean(axis = 'items'))
     return Signal(mean_fcst, [-20, 20], forecasts)
 def execute(self, strategy):
     prices = strategy.indicator_prices
     slow = self.slow(prices)
     fast = self.fast(prices)
     vol = self.vol(prices)
     forecast = self.normalise((fast - slow) / vol)
     return Signal(forecast, [-20, 20], Panel({"Fast" : fast, "Slow" : slow, "Volatility" : vol}))
 def execute(self, strategy):
     measures = {}
     for pars in self.par_pairs:
         name = "ewmac_{}_{}".format(max(pars), min(pars))
         ewmac = EWMAC(EMA(max(pars)), EMA(min(pars)), self.vol)
         measures[name] = ewmac(strategy).data
     measures = Panel(measures)
     return Signal(measures.mean(axis = 'items'), [-20, 20], measures)
Ejemplo n.º 4
0
    def execute(self, strategy):
        prices = strategy.indicator_prices
        fast_ema = self.fast(prices)
        slow_ema = self.slow(prices)

        ind_data = strategy.get_empty_dataframe(fill_data = 'Down')
        ind_data[fast_ema > slow_ema] = 'Up'

        return Signal(ind_data, ['Up', 'Down'], {'Fast':fast_ema, 'Slow':slow_ema})
Ejemplo n.º 5
0
    def execute(self, strategy):
        prices = strategy.indicator_prices
        fast_ema = self.fast(prices)
        mid_ema = self.mid(prices)
        slow_ema = self.slow(prices)
        levels = (fast_ema > mid_ema) & (mid_ema > slow_ema)

        ind_data = strategy.get_empty_dataframe(fill_data = 'Down')
        ind_data[levels] = 'Up'
        return Signal(ind_data, ['Up', 'Down'], {'Fast':fast_ema, 'Mid':mid_ema, 'Slow':slow_ema})
Ejemplo n.º 6
0
    def execute(self, strategy):
        prices = strategy.indicator_prices
        breakout = self.breakout(prices)
        high = breakout["high"]
        low = breakout["low"]

        ind_data = strategy.get_empty_dataframe()
        # Note: dataframe.where returns the existing values where the
        #       mask is True, and replaces them with other where False.
        #       So we need to invert the mask.
        #       Counterintuitive I think...
        ind_data = ind_data.where(~(prices.data == high), 'Up')
        ind_data = ind_data.where(~(prices.data == low), 'Down')
        ind_data = ind_data.ffill()
        # We need to remove any remaining Nans (at the start of the df), 
        # otherwise later string comparisons will throw an error because
        # it thinks it is a mixed datatype.
        ind_data = ind_data.fillna('-')

        return Signal(ind_data, ['Up', 'Down'], breakout)
 def execute(self, strategy):
     prices = strategy.indicator_prices
     indicator = self.measure(prices)
     vol = self.vol(prices)
     forecast = self.normalise((self.base - indicator) / vol)
     return Signal(forecast, [-20, 20], Panel({"Base" : self.base, "Ind" : indicator, "Volatility" : vol}))
Ejemplo n.º 8
0
 def execute(self, strategy):
     prices = strategy.indicator_prices
     fast = self.fast(prices)
     slow = self.slow(prices)
     return Signal(fast - slow, ['forecast'], {'fast':fast, 'slow':slow})