QAfinancial 的疑问
发布于 1 个月前 作者 nehcuh 120 次浏览 来自 报bug

从2019-09-30的财务字段,比之前的字段多了 308-315,是不是因为这个原因,导致获取从 2019-06-30 到 2019-09-30 的财务数据,报 KeyError

import QUANTAXIS as QA
df_finance = QA.QA_fetch_financial_report_adv(code=QA.QA_fetch_stock_list_adv().index.tolist(), start='2019-01-01', end='2019-09-30').data\

报错如下

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-34fd23b5419b> in <module>
----> 1 df_finance = QA.QA_fetch_financial_report_adv(code=QA.QA_fetch_stock_list_adv().index.tolist(), start='2019-01-01', end='2019-09-30').data

d:\documents\projects\quantaxis\QUANTAXIS\QAFetch\QAQuery_Advance.py in QA_fetch_financial_report_adv(code, start, end, ltype)
    618             data=month_data, index=pd.to_datetime(month_data), name='date')
    619         timerange = series.loc[start:end].tolist()
--> 620         return QA_DataStruct_Financial(QA_fetch_financial_report(code, timerange, ltype=ltype))
    621
    622

d:\documents\projects\quantaxis\QUANTAXIS\QAFetch\QAQuery.py in QA_fetch_financial_report(code, report_date, ltype, db)
    864             return None
    865     except Exception as e:
--> 866         raise e
    867
    868

d:\documents\projects\quantaxis\QUANTAXIS\QAFetch\QAQuery.py in QA_fetch_financial_report(code, report_date, ltype, db)
    852                 endict['code'] = 'code'
    853                 endict['report_date'] = 'report_date'
--> 854                 res_pd.columns = res_pd.columns.map(lambda x: endict[x])
    855
    856             if res_pd.report_date.dtype == numpy.int64:

~\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py in map(self, mapper, na_action)
   4516         from .multi import MultiIndex
   4517         new_values = super(Index, self)._map_values(
-> 4518             mapper, na_action=na_action)
   4519 
   4520         attributes = self._get_attributes_dict()

~\Continuum\anaconda3\lib\site-packages\pandas\core\base.py in _map_values(self, mapper, na_action)
   1216
   1217         # mapper is a function
-> 1218         new_values = map_f(values, mapper)
   1219
   1220         return new_values

pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()

d:\documents\projects\quantaxis\QUANTAXIS\QAFetch\QAQuery.py in <lambda>(x)
    852                 endict['code'] = 'code'
    853                 endict['report_date'] = 'report_date'
--> 854                 res_pd.columns = res_pd.columns.map(lambda x: endict[x])
    855
    856             if res_pd.report_date.dtype == numpy.int64:

KeyError: '312'
2 回复

git pull 我已经兼容了

回到顶部