我想弄点技术上的东西。在此链接中使用其中一些命令:https://github.com/enigmampc/catalyst/blob/master/catalyst/pipeline/factors/equity/technical.py,但在quant.notebook中我无法获得"from numexpr import evaluate",因此未定义evaluate。我该如何解决这个问题呢?
从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: Importing evaluate from numexpr引发了一个ImportError。你是想从numpy导入errstate吗?
发布于 2019-10-28 08:25:24
实际上,我没有找到在Quantopian上导入numexpr的方法,但在Jupyter上它不会给出问题。因此,该问题与在线IDE有关。此外,我只是简单地重写了FastOsc ind。在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)https://stackoverflow.com/questions/58547600
复制相似问题