예제 #1
0
    def run(self):
        self.ts = pf.fetch_timeseries(self.symbol,
                                      use_cache=self.options['use_cache'])
        self.ts = pf.select_tradeperiod(self.ts, self.start, self.end,
                                        self.options['use_adj'])

        # Add calendar columns
        self.ts = pf.calendar(self.ts)

        # Add momentum indicator for 3...18 months
        lookbacks = range(3, 18 + 1)
        for lookback in lookbacks:
            self.ts['mom' + str(lookback)] = pf.MOMENTUM(self.ts,
                                                         lookback=lookback,
                                                         time_frame='monthly',
                                                         price='close',
                                                         prevday=False)

        self.ts, self.start = pf.finalize_timeseries(self.ts, self.start)

        self.tlog = pf.TradeLog(self.symbol)
        self.dbal = pf.DailyBal()

        self._algo()
        self._get_logs()
        self._get_stats()
예제 #2
0
 def _momentum(ts, ta_param, input_column):
     return pf.MOMENTUM(ts,
                        lookback=ta_param,
                        time_frame='monthly',
                        price=input_column,
                        prevday=False)