Esempio n. 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]
Esempio n. 2
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]
Esempio n. 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,
     )
Esempio n. 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,
     )
Esempio n. 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,
     )