在pyalgotrade-python-3库中运行CSV支持示例

时间:2018-07-04 10:58:27

标签: pyalgotrade

我正在尝试运行PyAlgoTrade 0.18文档(http://gbeced.github.io/pyalgotrade/docs/v0.18/html/feed.html#csv-support-example)中的代码:

from pyalgotrade.feed import csvfeed  

feed = csvfeed.Feed("Date", "%Y-%m-%d")  
feed.addValuesFromCSV("quandl_gold_2.csv")  
for dateTime, value in feed:  
    print (dateTime, value) 

但出现错误:

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information.

================== RESTART: D:\New\Pyalgotrade\csvfeed_1.py ==================
Traceback (most recent call last): 
File "D:\New\Pyalgotrade\csvfeed_1.py", line 6, in for dateTime, value in feed: 
File "C:\Users\Ivanitskii\AppData\Local\Programs\Python\Python36\lib\site-  packages\pyalgotrade\feed_init_.py", line 28, in feed_iterator    feed.start() 
File "C:\Users\Ivanitskii\AppData\Local\Programs\Python\Python36\lib\site-packages\pyalgotrade\feed\memfeed.py", line 40, in start    self.__values.sort(cmpFun) 
TypeError: must use keyword argument for key function  
# line 40 - self.__values.sort(cmpFun) in this function^
    def start(self):
        super(MemFeed, self).start()
       # Now that all the data is in place, sort it to dispatch it in order.
        cmpFun = lambda x, y: list(cmp(x[0], y[0]))
        self.__values.sort(cmpFun)

在将Python 2适配到3时似乎是一个错误。

0 个答案:

没有答案