From b88696fd31911da27f62c2e365930508a2c93bac Mon Sep 17 00:00:00 2001 From: sheep Date: Fri, 29 Jul 2022 17:47:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=20get=5Fquote=5Fhistory=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=9B=B4=E5=A4=9A=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 6 ++++++ efinance/__version__.py | 2 +- efinance/bond/getter.py | 6 ++---- efinance/common/config.py | 1 + efinance/common/getter.py | 2 ++ efinance/stock/getter.py | 6 ++---- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index fab2f33..a64f251 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## v0.4.9(2022-07-29) + +### Added + +- 为 `get_quote_history` 添加更多选项 + ## v0.4.8(2022-06-30) ### Fixed diff --git a/efinance/__version__.py b/efinance/__version__.py index 42ec998..ad0a2c2 100644 --- a/efinance/__version__.py +++ b/efinance/__version__.py @@ -1,5 +1,5 @@ __title__ = 'efinance' -__version__ = '0.4.8' +__version__ = '0.4.9' __author__ = 'micro sheep' __url__ = 'https://github.com/Micro-sheep/efinance' __author_email__ = 'micro-sheep@outlook.com' diff --git a/efinance/bond/getter.py b/efinance/bond/getter.py index db2e359..dc18d7c 100644 --- a/efinance/bond/getter.py +++ b/efinance/bond/getter.py @@ -292,7 +292,8 @@ def get_quote_history(bond_codes: Union[str, List[str]], beg=beg, end=end, klt=klt, - fqt=fqt + fqt=fqt, + **kwargs ) if isinstance(df, pd.DataFrame): @@ -307,9 +308,6 @@ def get_quote_history(bond_codes: Union[str, List[str]], '名称': '债券名称' }, inplace=True) - # NOTE 扩展接口 设定此关键词即返回 DataFrame 而不是 dict - if kwargs.get('return_df'): - df: pd.DataFrame = pd.concat(df, axis=0, ignore_index=True) return df diff --git a/efinance/common/config.py b/efinance/common/config.py index cebc3fc..8f32003 100644 --- a/efinance/common/config.py +++ b/efinance/common/config.py @@ -5,6 +5,7 @@ class MagicConfig: EXTRA_FIELDS = 'extra_fields' QUOTE_ID_MODE = 'quote_id_mode' + RETURN_DF = 'return_df' # 各个市场编号 diff --git a/efinance/common/getter.py b/efinance/common/getter.py index 0953ace..c959e92 100644 --- a/efinance/common/getter.py +++ b/efinance/common/getter.py @@ -149,6 +149,8 @@ def start(code: str): start(code) multitasking.wait_for_tasks() pbar.close() + if kwargs.get(MagicConfig.RETURN_DF): + return pd.concat(dfs, axis=0, ignore_index=True) return dfs diff --git a/efinance/stock/getter.py b/efinance/stock/getter.py index 0df3cbc..2202f40 100644 --- a/efinance/stock/getter.py +++ b/efinance/stock/getter.py @@ -235,7 +235,8 @@ def get_quote_history(stock_codes: Union[str, List[str]], beg=beg, end=end, klt=klt, - fqt=fqt + fqt=fqt, + **kwargs ) if isinstance(df, pd.DataFrame): @@ -250,9 +251,6 @@ def get_quote_history(stock_codes: Union[str, List[str]], '名称': '股票名称' }, inplace=True) - # NOTE 扩展接口 设定此关键词即返回 DataFrame 而不是 dict - if kwargs.get('return_df'): - df: pd.DataFrame = pd.concat(df, axis=0, ignore_index=True) return df