예제 #1
0
    def compute(self, today, assets, out, data):
        drawdowns = fmax.accumulate(data, axis=0) - data
        drawdowns[isnan(drawdowns)] = NINF
        drawdown_ends = nanargmax(drawdowns, axis=0)

        # TODO: Accelerate this loop in Cython or Numba.
        for i, end in enumerate(drawdown_ends):
            peak = nanmax(data[:end + 1, i])
            out[i] = (peak - data[end, i]) / data[end, i]
예제 #2
0
파일: basic.py 프로젝트: t330883522/zipline
    def compute(self, today, assets, out, data):
        drawdowns = fmax.accumulate(data, axis=0) - data
        drawdowns[isnan(drawdowns)] = NINF
        drawdown_ends = nanargmax(drawdowns, axis=0)

        # TODO: Accelerate this loop in Cython or Numba.
        for i, end in enumerate(drawdown_ends):
            peak = nanmax(data[:end + 1, i])
            out[i] = (peak - data[end, i]) / data[end, i]
예제 #3
0
 def compute(self, today, assets, out, lows, highs):
     wl = self.window_length
     high_date_index = nanargmax(highs, axis=0)
     low_date_index = nanargmin(lows, axis=0)
     evaluate(
         '(100 * high_date_index) / (wl - 1)',
         local_dict={
             'high_date_index': high_date_index,
             'wl': wl,
         },
         out=out.up,
     )
     evaluate(
         '(100 * low_date_index) / (wl - 1)',
         local_dict={
             'low_date_index': low_date_index,
             'wl': wl,
         },
         out=out.down,
     )
예제 #4
0
 def compute(self, today, assets, out, lows, highs):
     wl = self.window_length
     high_date_index = nanargmax(highs, axis=0)
     low_date_index = nanargmin(lows, axis=0)
     evaluate(
         '(100 * high_date_index) / (wl - 1)',
         local_dict={
             'high_date_index': high_date_index,
             'wl': wl,
         },
         out=out.up,
     )
     evaluate(
         '(100 * low_date_index) / (wl - 1)',
         local_dict={
             'low_date_index': low_date_index,
             'wl': wl,
         },
         out=out.down,
     )
예제 #5
0
 def compute(self, today, assets, out, lows, highs):
     wl = self.window_length
     high_date_index = nanargmax(highs, axis=0)
     low_date_index = nanargmin(lows, axis=0)
     evaluate(
         "(100 * high_date_index) / (wl - 1)",
         local_dict={
             "high_date_index": high_date_index,
             "wl": wl,
         },
         out=out.up,
     )
     evaluate(
         "(100 * low_date_index) / (wl - 1)",
         local_dict={
             "low_date_index": low_date_index,
             "wl": wl,
         },
         out=out.down,
     )