예제 #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
    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, highs, lows, closes):
     high_to_low = highs[1:] - lows[1:]
     high_to_prev_close = abs(highs[1:] - closes[:-1])
     low_to_prev_close = abs(lows[1:] - closes[:-1])
     out[:] = nanmax(
         dstack((
             high_to_low,
             high_to_prev_close,
             low_to_prev_close,
         )), 2)
예제 #4
0
 def compute(self, today, assets, out, highs, lows, closes):
     high_to_low = highs[1:] - lows[1:]
     high_to_prev_close = abs(highs[1:] - closes[:-1])
     low_to_prev_close = abs(lows[1:] - closes[:-1])
     out[:] = nanmax(
         dstack((
             high_to_low,
             high_to_prev_close,
             low_to_prev_close,
         )),
         2
     )
예제 #5
0
    def compute(self, today, assets, out, closes, lows, highs):

        highest_highs = nanmax(highs, axis=0)
        lowest_lows = nanmin(lows, axis=0)
        today_closes = closes[-1]

        evaluate(
            '((tc - ll) / (hh - ll)) * 100',
            local_dict={
                'tc': today_closes,
                'll': lowest_lows,
                'hh': highest_highs,
            },
            global_dict={},
            out=out,
        )
예제 #6
0
    def compute(self, today, assets, out, closes, lows, highs):

        highest_highs = nanmax(highs, axis=0)
        lowest_lows = nanmin(lows, axis=0)
        today_closes = closes[-1]

        evaluate(
            '((tc - ll) / (hh - ll)) * 100',
            local_dict={
                'tc': today_closes,
                'll': lowest_lows,
                'hh': highest_highs,
            },
            global_dict={},
            out=out,
        )