Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

导入数据格式问题 #37

Open
Tipsyume opened this issue Dec 1, 2019 · 0 comments
Open

导入数据格式问题 #37

Tipsyume opened this issue Dec 1, 2019 · 0 comments

Comments

@Tipsyume
Copy link

Tipsyume commented Dec 1, 2019

refuncat:版本0.3.3
python:版本3.7.4
Mac:
相关代码:

`backend = "tushare"

if backend == "rqalpha":
set_data_backend(RQAlphaDataBackend("~/.rqalpha/bundle"))
elif backend == "tushare":
set_data_backend(TushareDataBackend())

set_start_date("2019-01-01")

S("600009.SH") # 设置当前关注股票

T("2019-10-10") # 设置当前观察日期

no_str = "600009.SH"
df = ts.pro_bar(ts_code=no_str, asset='E', freq='D', start_date='20190101', end_date='20191201', ma=[5, 10, 20, 60], factors=['tor', 'vr'])

M1, M2 = 14, 6
OPEN = df['open']
HIGH = df['high']
LOW = df['low']
CLOSE = df['close']

OPEN = np.array(OPEN)
HIGH = np.array(HIGH)
LOW = np.array(LOW)
CLOSE = np.array(CLOSE)

TR = SUM(MAX(MAX(HIGH - LOW, ABS(HIGH - REF(CLOSE, 1))), ABS(LOW - REF(CLOSE, 1))), M1)
HD = HIGH - REF(HIGH, 1)
LD = REF(LOW, 1) - LOW

DMP = SUM(IF((HD > 0) & (HD > LD), HD, 0), M1)
DMM = SUM(IF((LD > 0) & (LD > HD), LD, 0), M1)
DI1 = DMP * 100 / TR
DI2 = DMM * 100 / TR
ADX = MA(ABS(DI2 - DI1) / (DI1 + DI2) * 100, M2)
ADXR = (ADX + REF(ADX, M2)) / 2

print(str(DI1),str(DI2), str(ADX), str(ADXR))`

异常日志:

Traceback (most recent call last): File "/Users/apple/PycharmProjects/h_Python/example/strategy/stock_formula.py", line 42, in <module> DMP = SUM(IF((HD > 0) & (HD > LD), HD, 0), M1) File "/Users/apple/PycharmProjects/h_Python/venv/lib/python3.7/site-packages/funcat/utils.py", line 92, in wrapper return func(*args, **kwargs) File "/Users/apple/PycharmProjects/h_Python/venv/lib/python3.7/site-packages/funcat/func.py", line 268, in iif cond_series, series1, series2 = fit_series(condition.series, series1, series2) AttributeError: 'numpy.ndarray' object has no attribute 'series'

IF 与 HHV , LLV 这3个方法都会用series,
日志中也提示series出错,这个是什么参数?是我传的数据有问题吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant