首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Quantopian上从numexpr导入求值

在Quantopian上从numexpr导入求值
EN

Stack Overflow用户
提问于 2019-10-25 02:55:38
回答 1查看 59关注 0票数 1

我想弄点技术上的东西。在此链接中使用其中一些命令:https://github.com/enigmampc/catalyst/blob/master/catalyst/pipeline/factors/equity/technical.py,但在quant.notebook中我无法获得"from numexpr import evaluate",因此未定义evaluate。我该如何解决这个问题呢?

从numexpr导入求值

代码语言:javascript
复制
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={

代码语言:javascript
复制
 'K':K,  

},screen=base)

我正在处理Quantopian笔记本,当我尝试导入它时,我得到了这样的结果: InputRejected: Importing evaluate from numexpr引发了一个ImportError。你是想从numpy导入errstate吗?

EN

回答 1

Stack Overflow用户

发布于 2019-10-28 08:25:24

实际上,我没有找到在Quantopian上导入numexpr的方法,但在Jupyter上它不会给出问题。因此,该问题与在线IDE有关。此外,我只是简单地重写了FastOsc ind。在quantopian online IDE的管道中使用它的另一种方式。

代码语言:javascript
复制
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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58547600

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档