from numexpr import evaluate on Quantopian

71 views Asked by At

I'm trying to get some technical ind. with some of those commands in this link:https://github.com/enigmampc/catalyst/blob/master/catalyst/pipeline/factors/equity/technical.py, but in the quant.notebook I'm not able to get "from numexpr import evaluate", so evaluate is not defined. How can I solve this?

from numexpr import evaluate

class FastochasticOscillator(CustomFactor):  
inputs=(USEquityPricing.close,USEquityPricing.high,USEquityPricing.low)  
window_safe=True  
window_length=14  

def compute(self, today, assets, out, closes, highs, lows):  
    highest_high= nanmax(highs, axis=0)  
    lowest_low= nanmin(lows, axis=0)  
    latest_close= closes[-1]  

    evaluate(  
        '((tc - ll) / (hh - ll)) * 100',  
        local_dict={  
            'tc':latest_close,  
            'll':lowest_low,  
            'hh':highest_high,  
        },  
        global_dict={},  
    out=out,  
    )  

K= FastochasticOscillator(window_length=14)

return Pipeline(columns={
'K':K,

},screen=base)

I'm working on the Quantopian notebook and when I attempt to import it gives me this: InputRejected: Importing evaluate from numexpr raised an ImportError. Did you mean to import errstate from numpy?

1

There are 1 answers

0
BloomShell On

Actually I do not find a way to import numexpr on Quantopian but on Jupyter it do not give problems. Therefore the problem is related to the online IDE. Moreover, I simply re-write the FastOsc ind. in another way to use it inside the pipeline in the quantopian online IDE.

class Fast(CustomFactor):
    inputs=(USEquityPricing.close,USEquityPricing.high,USEquityPricing.low)  
    window_length=14  
    def compute(self, today, assets, out, close, high, low):
        highest_high= nanmax(high, axis=0)  
        lowest_low= nanmin(low, axis=0)  
        latest_close= close[-1] 

        out[:]= ((latest_close - lowest_low) / (highest_high - lowest_low)*100)