funcat icon indicating copy to clipboard operation
funcat copied to clipboard

导入数据格式问题

Open Tipsyume opened this issue 4 years ago • 0 comments

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出错,这个是什么参数?是我传的数据有问题吗

Tipsyume avatar Dec 01 '19 07:12 Tipsyume