从numexpr导入对Quantopian进行评估

时间:2019-10-24 18:55:37

标签: pipeline quantopian

我正在尝试获取一些技术指标。并在此链接中包含其中一些命令:https://github.com/enigmampc/catalyst/blob/master/catalyst/pipeline/factors/equity/technical.py, 但在quantum.notebook中,我无法从“从numexpr导入评估”中获取信息,因此未定义评估。 我该怎么解决?

从numexpr导入评估

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)

返回管道(columns = {
    'K':K,

},screen = base)

我正在使用Quantopian笔记本,当我尝试导入它时,会给我以下信息:InputRejected:从numexpr导入评估会引发ImportError。您是要从numpy导入errstate吗?

1 个答案:

答案 0 :(得分:0)

实际上,我找不到在Quantopian上导入numexpr的方法,但是在Jupyter上却没有问题。因此,问题与在线IDE有关。而且,我只是简单地重写了FastOsc ind。以另一种方式在Quantopian在线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)