Python NotImplementedError()这意味着什么,事件探查器pyalgotrade

Python NotImplementedError()这意味着什么,事件探查器pyalgotrade,python,trading,algorithmic-trading,pyalgotrade,Python,Trading,Algorithmic Trading,Pyalgotrade,我正在尝试运行pyalgotrade的事件探查器。我使用的是自定义数据,当我使用默认的stratergy/谓词“BuyOnGap”运行它时,它会工作,但是当我尝试使用简单的自定义策略运行它时,它会抛出错误: Traceback (most recent call last): File "C:\Users\David\Desktop\Python\Coursera\Computational Finance\Week2\PyAlgoTrade\Bitfinex\FCT\FCT_single_

我正在尝试运行pyalgotrade的事件探查器。我使用的是自定义数据,当我使用默认的stratergy/谓词“BuyOnGap”运行它时,它会工作,但是当我尝试使用简单的自定义策略运行它时,它会抛出错误:

Traceback (most recent call last):
  File "C:\Users\David\Desktop\Python\Coursera\Computational Finance\Week2\PyAlgoTrade\Bitfinex\FCT\FCT_single_event_test.py", line 43, in <module>
    main(True)
  File "C:\Users\David\Desktop\Python\Coursera\Computational Finance\Week2\PyAlgoTrade\Bitfinex\FCT\FCT_single_event_test.py", line 35, in main
    eventProfiler.run(feed, True)
  File "C:\Python27\lib\site-packages\pyalgotrade\eventprofiler.py", line 215, in run
    disp.run()
  File "C:\Python27\lib\site-packages\pyalgotrade\dispatcher.py", line 102, in run
    eof, eventsDispatched = self.__dispatch()
  File "C:\Python27\lib\site-packages\pyalgotrade\dispatcher.py", line 90, in __dispatch
    if self.__dispatchSubject(subject, smallestDateTime):
  File "C:\Python27\lib\site-packages\pyalgotrade\dispatcher.py", line 68, in __dispatchSubject
    ret = subject.dispatch() is True
  File "C:\Python27\lib\site-packages\pyalgotrade\feed\__init__.py", line 105, in dispatch
    self.__event.emit(dateTime, values)
  File "C:\Python27\lib\site-packages\pyalgotrade\observer.py", line 59, in emit
    handler(*args, **kwargs)
  File "C:\Python27\lib\site-packages\pyalgotrade\eventprofiler.py", line 172, in __onBars
    eventOccurred = self.__predicate.eventOccurred(instrument, self.__feed[instrument])
  File "C:\Python27\lib\site-packages\pyalgotrade\eventprofiler.py", line 89, in eventOccurred
    raise NotImplementedError()
NotImplementedError
回溯(最近一次呼叫最后一次):
文件“C:\Users\David\Desktop\Python\Coursera\computative Finance\Week2\PyAlgoTrade\Bitfinex\FCT\FCT\u single\u event\u test.py”,第43行,在
主(真)
文件“C:\Users\David\Desktop\Python\Coursera\computative Finance\Week2\PyAlgoTrade\Bitfinex\FCT\FCT\u single\u event\u test.py”,主文件第35行
eventProfiler.run(提要,True)
文件“C:\Python27\lib\site packages\pyalgotrade\eventprofiler.py”,第215行,正在运行
disp.run()
文件“C:\Python27\lib\site packages\pyalgotrade\dispatcher.py”,第102行,正在运行
eof,eventsDispatched=self.\u dispatch()
文件“C:\Python27\lib\site packages\pyalgotrade\dispatcher.py”,第90行,在调度中
如果self.\u dispatchSubject(subject,smallestDateTime):
文件“C:\Python27\lib\site packages\pyalgotrade\dispatcher.py”,第68行,在调度主题中
ret=subject.dispatch()为True
文件“C:\Python27\lib\site packages\pyalgotrade\feed\ \uuuu init\uuuuu.py”,第105行,在分派中
self.\u event.emit(日期时间、值)
文件“C:\Python27\lib\site packages\pyalgotrade\observer.py”,第59行,在emit中
处理程序(*args,**kwargs)
文件“C:\Python27\lib\site packages\pyalgotrade\eventprofiler.py”,第172行,在工具栏中
EventOccursed=self.\uuuu谓词.EventOccursed(仪器,自我.\uuuu馈送[仪器])
EventOccursed中第89行的文件“C:\Python27\lib\site packages\pyalgotrade\eventprofiler.py”
引发未实现的错误()
未实现错误
我的代码是:

from pyalgotrade import eventprofiler
from pyalgotrade.technical import stats
from pyalgotrade.technical import roc
from pyalgotrade.technical import ma
from pyalgotrade.barfeed import csvfeed

class single_event_strat( eventprofiler.Predicate ):
    def __init__(self,feed):
        self.__returns = {} # CLASS ATTR
        for inst in feed.getRegisteredInstruments():

            priceDS = feed[inst].getAdjCloseDataSeries() # STORE: priceDS ( a temporary representation )

            self.__returns[inst] = roc.RateOfChange( priceDS, 1 )
            # CALC:  ATTR <- Returns over the adjusted close values, consumed priceDS 
            #( could be expressed as self.__returns[inst] = roc.RateOfChange( ( feed[inst].getAdjCloseDataSeries() ), 1 ), 
            #but would be less readable

    def eventOccoured( self, instrument, aBarDS):
        if (aBarDS[-1].getVolume() > 10 and aBarDS[-1].getClose() > 5 ):
            return True
        else: 
            return False

def main(plot):
    feed = csvfeed.GenericBarFeed(0)

    feed.addBarsFromCSV('FCT', "FCT_daily_converted.csv")


    predicate = single_event_strat(feed)

    eventProfiler = eventprofiler.Profiler( predicate, 5, 5)

    eventProfiler.run(feed, True)

    results = eventProfiler.getResults()
    print "%d events found" % (results.getEventCount())
    if plot:
        eventprofiler.plot(results)

if __name__ == "__main__":
    main(True)
从pyalgotrade导入事件档案器
来自pyalgotrade.technical import stats
来自pyalgotrade.technical import中华民国
来自pyalgotrade.technical import ma
从pyalgotrade.barfeed导入csvfeed
类single_event_strat(eventprofiler.Predicate):
def u u初始(自,馈送):
self._返回={}#类属性
对于提要中的inst.getRegisteredInstruments():
priceDS=feed[inst].getAdjCloseDataSeries()#存储:priceDS(临时表示)
self.\uu returns[inst]=中华民国汇率变动率(priceDS,1)
#计算:ATTR 10和aBarDS[-1]。getClose()>5):
返回真值
其他:
返回错误
def主(绘图):
feed=csvfeed.GenericBarFeed(0)
feed.addBarsFromCSV('FCT',“FCT\u daily\u converted.csv”)
谓词=单个事件层(提要)
eventProfiler=eventProfiler.Profiler(谓词,5,5)
eventProfiler.run(提要,True)
结果=eventProfiler.getResults()
打印找到“%d个事件”%(results.getEventCount())
如果绘图:
eventprofiler.plot(结果)
如果名称=“\uuuuu main\uuuuuuuu”:
主(真)
这个错误意味着什么

有人知道哪里出了问题以及如何解决吗

以下是eventprofiler代码的链接:


作为奖励,有人知道我在哪里可以找到使用分析器的示例吗?除了pyalgotrade给出的示例之外,

我认为您刚才在EventOccurrend方法定义中犯了一个拼写错误

def eventOccoured( self, instrument, aBarDS):
应该由

def eventOccurred( self, instrument, aBarDS):

我认为您刚才在EventOccurrend方法定义中犯了一个拼写错误

def eventOccoured( self, instrument, aBarDS):
应该由

def eventOccurred( self, instrument, aBarDS):

NotImplementedError
用于超类定义子类应该自己定义的方法。因此,当子类自动继承一个方法,但没有为其提供指令时,会引发该问题。我不熟悉您正在使用的库,所以我不确定这是您应该做的事情(您没有正确地对其内容进行子类化)还是他们应该做的事情(这不应该在其稳定的分支上)。
NotImplementedError
是为超类定义子类应该定义自己的方法而设计的。因此,当子类自动继承一个方法,但没有为其提供指令时,会引发该问题。我不熟悉你正在使用的库,所以我不确定这是你应该做的(你没有正确地对他们的东西进行子分类)还是他们应该做的(这不应该在他们稳定的分支上)。天哪,阅读障碍。多谢了,老兄,耶稣花了好几天的时间试图弄明白这个该死的诵读困难症。多谢了,老兄,耶稣花了好几天的时间试图弄明白这一点