Skip to content

教程上的代码运行不起来 #32

@zhangshoug

Description

@zhangshoug

https://github.com/cedricporter/funcat/blob/master/notebooks/funcat-tutorial.ipynb
中的代码运行到计算均线就出错误了。

如果是 bug 反馈,烦请在 issue 中描述以下问题:

1. funcat 的版本

0.3.2

2. Python 的版本

Python 3.6.5 |Anaconda

3. 是 Windows / Linux / MacOS or others?

linux mint 18.3 amd64

4. 您出现问题对应的源码 / 或者能复现问题的简易代码

$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

from matplotlib import rcParams
import matplotlib.pyplot as plt
import numpy as np
np.seterr(all='ignore')
{'divide': 'warn', 'over': 'warn', 'under': 'ignore', 'invalid': 'warn'}
rcParams['figure.figsize'] = (14, 6)
from funcat import *
from funcat.data.tushare_backend import TushareDataBackend
from funcat.data.rqalpha_data_backend import RQAlphaDataBackend
backend = "rqalpha"
set_data_backend(RQAlphaDataBackend("~/.rqalpha/bundle"))
set_start_date("2015-01-01")
S("000001.XSHG") # 设置当前关注股票
T("2016-06-01") # 设置当前观察日期
print(O, H, L, C, V) # 打印 Open High Low Close
2917.15 2929.08 2909.51 2913.51 18838642100.0
C / C[1] - 1 # 当天涨幅
-0.0010663027751299792
MA(C, 60) # 打印60日均线
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.6/site-packages/talib/init.py", line 20, in wrapper
for arg in chain(args, kwargs.values())
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.6/site-packages/funcat/func.py", line 31, in init
series = self.func(series, arg)
File "/opt/anaconda3/lib/python3.6/site-packages/talib/init.py", line 24, in wrapper
return func(*args, **kwargs)
File "talib/_func.pxi", line 7863, in talib._ta_lib.MA
TypeError: only size-1 arrays can be converted to Python scalars

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/opt/anaconda3/lib/python3.6/site-packages/funcat/func.py", line 33, in init
raise FormulaException(e)
funcat.utils.FormulaException: only size-1 arrays can be converted to Python scalars

5. 您出现的错误堆栈日志信息

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions