Exemple #1
0
    def run_strategy(self, market_data, portfolio):
        
        
        if (pd.isnull(market_data)).any()[0]:
            #Raise this error to make sure there's no gaps in data
            raise ValueError("Series XY = {0}, {1} do not have equal date range".format(self.series_x_label, self.series_y_label)) 
        
        reg_params = [self.intercept, self.scaling]
        
        md = pairs_md(market_data, 
                      xInd = self.series_x_label,
                      yInd = self.series_y_label)
        
        
        md.generateTradeSigs(windowLength = self.window_length,
                              entryScale= self.entry_scale, 
                              exitScale = self.exit_scale, 
#                               ewma_par= 100,
                              reg_params = reg_params
                              )
        
        
        Reversion_EntryExitTechnical.run_strategy(self, 
                                                  md,
                                                  portfolio)
        
        
        if self.plot_flag:
            md.plot_spreadAndSignals()
Exemple #2
0
 def __init__(self,
              series_x_label,
              series_y_label, 
              window_length,
              scaling_initial = 1, 
              intercept_initial = 0,
              entry_scale = 2 ,
              exit_scale = 0, ):
     '''
     Constructor
     '''
     #initialise super
     Reversion_EntryExitTechnical.__init__(self)
     
     self.series_x_label = series_x_label
     self.series_y_label = series_y_label
     self.window_length = window_length
     self.scaling = scaling_initial
     self.intercept = intercept_initial
     self.entry_scale = entry_scale
     self.exit_scale = exit_scale
     self.plot_flag = False