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

AKShare 接口问题报告 | AKShare Interface Issue Report #5325

Closed
xpwang0925 opened this issue Nov 12, 2024 · 2 comments · May be fixed by #5329
Closed

AKShare 接口问题报告 | AKShare Interface Issue Report #5325

xpwang0925 opened this issue Nov 12, 2024 · 2 comments · May be fixed by #5329
Labels
bug Something isn't working

Comments

@xpwang0925
Copy link

AKShare 已升级到最新版本 1.15.20
调用的接口: get_futures_daily
代码如下:
current_time = datetime.now()
formatted_now = current_time.strftime("%Y-%m-%d %H:%M:%S")
curret_date = current_time.strftime("%Y-%m-%d")
curret_date_f6 = current_time.strftime("%Y%m")
print(ak.version)

get_futures_daily_df = ak.get_futures_daily(start_date='20200101', end_date='20200101', market="DCE")
print(get_futures_daily_df)

报错信息:

KeyError Traceback (most recent call last)
Cell In[1], line 344
342 curret_date_f6 = current_time.strftime("%Y%m")
343 logger.info("开始获取: 交割统计-大连商品交易所")
--> 344 get_futures_daily_df = ak.get_futures_daily(start_date='20200101', end_date='20200101', market="DCE")
345 print(get_futures_daily_df)
346 # print(formatted_now)
347 # get_futures_daily_df['etl_time'] = formatted_now
348 # db_util.df_save_to_mysql(df=get_futures_daily_df, table_name='dce_futures_daily')
(...)
419 # print("start_date: " + str(start_date))
420 # print(futures_dce_wh_receipt_df)

File ~/miniconda3/lib/python3.11/site-packages/akshare/futures/futures_daily_bar.py:677, in get_futures_daily(start_date, end_date, market)
675 if len(df_list) > 0:
676 temp_df = pd.concat(df_list).reset_index(drop=True)
--> 677 temp_df = temp_df[~temp_df["symbol"].str.contains("efp")]
678 return temp_df

File ~/miniconda3/lib/python3.11/site-packages/pandas/core/frame.py:4102, in DataFrame.getitem(self, key)
4100 if self.columns.nlevels > 1:
4101 return self._getitem_multilevel(key)
-> 4102 indexer = self.columns.get_loc(key)
4103 if is_integer(indexer):
4104 indexer = [indexer]

File ~/miniconda3/lib/python3.11/site-packages/pandas/core/indexes/range.py:417, in RangeIndex.get_loc(self, key)
415 raise KeyError(key) from err
416 if isinstance(key, Hashable):
--> 417 raise KeyError(key)
418 self._check_indexing_error(key)
419 raise KeyError(key)

KeyError: 'symbol'

期望获得的结果: 之前在1.13.7 上执行是正常的。 升级版本后报错。期望执行结果不要报错,可以继续使用

@xpwang0925 xpwang0925 added the bug Something isn't working label Nov 12, 2024
@albertandking
Copy link
Collaborator

AKShare 已升级到最新版本 1.15.20 调用的接口: get_futures_daily 代码如下: current_time = datetime.now() formatted_now = current_time.strftime("%Y-%m-%d %H:%M:%S") curret_date = current_time.strftime("%Y-%m-%d") curret_date_f6 = current_time.strftime("%Y%m") print(ak.version)

get_futures_daily_df = ak.get_futures_daily(start_date='20200101', end_date='20200101', market="DCE") print(get_futures_daily_df)

报错信息:

KeyError Traceback (most recent call last) Cell In[1], line 344 342 curret_date_f6 = current_time.strftime("%Y%m") 343 logger.info("开始获取: 交割统计-大连商品交易所") --> 344 get_futures_daily_df = ak.get_futures_daily(start_date='20200101', end_date='20200101', market="DCE") 345 print(get_futures_daily_df) 346 # print(formatted_now) 347 # get_futures_daily_df['etl_time'] = formatted_now 348 # db_util.df_save_to_mysql(df=get_futures_daily_df, table_name='dce_futures_daily') (...) 419 # print("start_date: " + str(start_date)) 420 # print(futures_dce_wh_receipt_df)

File ~/miniconda3/lib/python3.11/site-packages/akshare/futures/futures_daily_bar.py:677, in get_futures_daily(start_date, end_date, market) 675 if len(df_list) > 0: 676 temp_df = pd.concat(df_list).reset_index(drop=True) --> 677 temp_df = temp_df[~temp_df["symbol"].str.contains("efp")] 678 return temp_df

File ~/miniconda3/lib/python3.11/site-packages/pandas/core/frame.py:4102, in DataFrame.getitem(self, key) 4100 if self.columns.nlevels > 1: 4101 return self._getitem_multilevel(key) -> 4102 indexer = self.columns.get_loc(key) 4103 if is_integer(indexer): 4104 indexer = [indexer]

File ~/miniconda3/lib/python3.11/site-packages/pandas/core/indexes/range.py:417, in RangeIndex.get_loc(self, key) 415 raise KeyError(key) from err 416 if isinstance(key, Hashable): --> 417 raise KeyError(key) 418 self._check_indexing_error(key) 419 raise KeyError(key)

KeyError: 'symbol'

期望获得的结果: 之前在1.13.7 上执行是正常的。 升级版本后报错。期望执行结果不要报错,可以继续使用

接口测试正常

@xpwang0925
Copy link
Author

xpwang0925 commented Nov 12, 2024

请问最新的版本是: 1.15.20 吗? 我这没有任何逻辑啊

get_futures_daily_df = ak.get_futures_daily(start_date='20200101', end_date='20200101', market="DCE") 就这调用,可以返回数据结果?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants