首页 > 解决方案 > 从 numexpr 导入评估 Quantopian

问题描述

我正在尝试获得一些技术信息。在此链接中使用其中一些命令:https ://github.com/enigmampc/catalyst/blob/master/catalyst/pipeline/factors/equity/technical.py ,但在 quant.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)

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

},屏幕=基础)

我正在使用 Quantopian 笔记本,当我尝试导入它时,它给了我这个:InputRejected:从 numexpr 导入评估引发了 ImportError。你的意思是从 numpy 导入 errstate 吗?

标签: pipelinequantopian

解决方案


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)

推荐阅读