refraction-ray / xalpha

基金投资管理回测引擎
MIT License
2.04k stars 437 forks source link

xa.get_daily("SH600036",) does not work ! #187

Open e1-git opened 3 months ago

e1-git commented 3 months ago

{'data': {'items': [], 'items_size': 0}, 'error_code': 0, 'error_description': ''}

File ~/opt/anaconda3/lib/python3.10/site-packages/xalpha/universal.py:171, in get_historicalfromxq(code, count, type, full) --> 171 df = pd.DataFrame(data=r["data"]["item"], columns=r["data"]["column"]) 172 df["date"] = (df["timestamp"]).apply(ts2pdts) # reset hours to zero 173 return df

KeyError: 'item'

refraction-ray commented 3 months ago

works for me, need more info on the settings and environments to locate and reproduce the error

e1-git commented 3 months ago

os: Ubuntu 22.04 LTS python version: 3.10.9 (main, Mar 1 2023, 18:23:06) [GCC 11.2.0] xalpha version: 0.11.11

os: macos Ventura 13.0.1 python version: 3.10.13 (main, Sep 11 2023, 08:16:02) [Clang 14.0.6 ] xalpha version: 0.12.0

both have the same error.

KeyError Traceback (most recent call last) File ~/anaconda3/lib/python3.10/site-packages/xalpha/universal.py:1993, in cachedio..cached..wrapper(*args, **kws) 1992 elif backend == "memory": -> 1993 df0 = getattr(thismodule, "cached_dict")[key] 1994 else:

KeyError: 'SH600036'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last) Cell In[5], line 6 ----> 6 xa.get_daily("SH600036", prev=15)

File ~/anaconda3/lib/python3.10/site-packages/xalpha/universal.py:2051, in cachedio..cached..wrapper(*args, *kws) 2047 kws["end"] = ( 2048 today_obj() - dt.timedelta(days=1) 2049 ).strftime("%Y%m%d") 2050 is_changed = True -> 2051 df0 = f(args, **kws) 2053 if df0 is not None and len(df0) > 0 and is_changed: 2054 if backend == "csv":

File ~/anaconda3/lib/python3.10/site-packages/xalpha/universal.py:1128, in _get_daily(code, start, end, prev, _from, wrapper, handler, **kws) 1125 elif from in ["xueqiu", "xq", "snowball", "XQ"]: 1126 code, type = decouple_code(code) -> 1128 df = get_historicalfromxq(code, count, type=type_) 1129 df = prettify(df) 1130 elif _from in ["zhongjianjia", "zjj", "chinamoney", "ZJJ"]:

File ~/anaconda3/lib/python3.10/site-packages/xalpha/universal.py:168, in get_historicalfromxq(code, count, type, full) 160 # pe 是 TTM 数据 161 r = rget_json( 162 url.format( 163 code=code, tomorrow=int(tomorrowts() * 1000), count=count, type=type_ (...) 166 headers={"user-agent": "Mozilla/5.0"}, 167 ) --> 168 df = pd.DataFrame(data=r["data"]["item"], columns=r["data"]["column"]) 169 df["date"] = (df["timestamp"]).apply(ts2pdts) # reset hours to zero 170 return df

KeyError: 'item'

ohmyboy12 commented 1 month ago

I use xalpha 0.12.0, also the get_daily does not work

refraction-ray commented 4 weeks ago

refer to https://github.com/refraction-ray/xalpha/issues/190#issuecomment-2395048600

ohmyboy12 commented 4 weeks ago

邮件已收到~~我会查看之后回复您