From b72cb7c706f106131b10e432decf5fabc52f39d8 Mon Sep 17 00:00:00 2001 From: shinny-pack Date: Thu, 11 Apr 2024 03:13:59 +0000 Subject: [PATCH] Update Version 3.5.6 --- PKG-INFO | 2 +- doc/conf.py | 4 ++-- doc/version.rst | 5 +++++ setup.py | 2 +- tqsdk/__version__.py | 2 +- tqsdk/api.py | 7 +++++-- tqsdk/auth.py | 13 +++++++------ tqsdk/constants.py | 13 +++++++++++++ 8 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 tqsdk/constants.py diff --git a/PKG-INFO b/PKG-INFO index e2f6b936..e8bf6532 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: tqsdk -Version: 3.5.5 +Version: 3.5.6 Summary: TianQin SDK Home-page: https://www.shinnytech.com/tqsdk Author: TianQin diff --git a/doc/conf.py b/doc/conf.py index 399675f5..82c82d90 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -48,9 +48,9 @@ # built documents. # # The short X.Y version. -version = u'3.5.5' +version = u'3.5.6' # The full version, including alpha/beta/rc tags. -release = u'3.5.5' +release = u'3.5.6' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/version.rst b/doc/version.rst index 59d2e53b..fab24a34 100644 --- a/doc/version.rst +++ b/doc/version.rst @@ -2,6 +2,11 @@ 版本变更 ============================= +3.5.6 (2024/04/11) + +* 修复::py:meth:`~tqsdk.TqApi.query_quotes` 函数无法查询广州期货交易所 GFEX 的主连合约和主力合约 + + 3.5.5 (2024/03/27) * 修复:TqSim 在调用 set_margin 之后,使用 is_changing 判断某个对象是否更新,可能返回的结果不正确 diff --git a/setup.py b/setup.py index 643d785e..ce414532 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='tqsdk', - version="3.5.5", + version="3.5.6", description='TianQin SDK', author='TianQin', author_email='tianqincn@gmail.com', diff --git a/tqsdk/__version__.py b/tqsdk/__version__.py index b363ca01..f59ba749 100644 --- a/tqsdk/__version__.py +++ b/tqsdk/__version__.py @@ -1 +1 @@ -__version__ = '3.5.5' +__version__ = '3.5.6' diff --git a/tqsdk/api.py b/tqsdk/api.py index 62db77a7..cb1c7d7b 100644 --- a/tqsdk/api.py +++ b/tqsdk/api.py @@ -54,6 +54,7 @@ from tqsdk.channel import TqChan from tqsdk.connect import TqConnect, MdReconnectHandler, ReconnectTimer from tqsdk.calendar import _get_trading_calendar, TqContCalendar, _init_chinese_rest_days +from tqsdk.constants import FUTURE_EXCHANGES from tqsdk.data_extension import DataExtension from tqsdk.data_series import DataSeries from tqsdk.datetime import _get_trading_day_from_timestamp, _datetime_to_timestamp_nano, _timestamp_nano_to_datetime, \ @@ -2371,6 +2372,7 @@ def query_quotes(self, ins_class: Union[str, List[str]] = None, exchange_id: Uni * DCE: 大商所 * CZCE: 郑商所 * INE: 能源交易所(原油) + * GFEX: 广州期货交易所 * SSE: 上交所 * SZSE: 深交所 * KQD: 外盘主连 @@ -2435,7 +2437,7 @@ def query_quotes(self, ins_class: Union[str, List[str]] = None, exchange_id: Uni if exchange_id == "": raise Exception("exchange_id 参数不能为空字符串。") # 如果是主连和指数,请求全部,在客户端区分交易所 - if ins_class not in ["INDEX", "CONT"] or exchange_id not in ["CFFEX", "SHFE", "DCE", "CZCE", "INE"]: + if ins_class not in ["INDEX", "CONT"] or exchange_id not in FUTURE_EXCHANGES: variables["exchange_id"] = [exchange_id] if isinstance(exchange_id, str) else exchange_id if product_id is not None: if product_id == "": @@ -2454,7 +2456,7 @@ def query_quotes(self, ins_class: Union[str, List[str]] = None, exchange_id: Uni def filter(query_result): result = [] for quote in query_result.get("result", {}).get("multi_symbol_info", []): - if ins_class in ["INDEX", "CONT"] and exchange_id in ["CFFEX", "SHFE", "DCE", "CZCE", "INE"]: + if ins_class in ["INDEX", "CONT"] and exchange_id in FUTURE_EXCHANGES: if exchange_id in quote["instrument_id"]: result.append(quote["instrument_id"]) else: @@ -2483,6 +2485,7 @@ def query_cont_quotes(self, exchange_id: str = None, product_id: str = None, has * DCE: 大商所 * CZCE: 郑商所 * INE: 能源交易所(原油) + * GFEX: 广州期货交易所 product_id (str): [可选] 品种 diff --git a/tqsdk/auth.py b/tqsdk/auth.py index cd7963a6..cd8c4681 100644 --- a/tqsdk/auth.py +++ b/tqsdk/auth.py @@ -10,7 +10,8 @@ import requests from shinny_structlog import ShinnyLoggerAdapter -import tqsdk +from tqsdk.constants import FUTURE_EXCHANGES, SPOT_EXCHANGES, KQ_EXCHANGES, KQD_EXCHANGES, STOCK_EXCHANGES +from tqsdk.__version__ import __version__ class TqAuth(object): @@ -49,7 +50,7 @@ def __init__(self, user_name: str = "", password: str = ""): @property def _base_headers(self): return { - "User-Agent": "tqsdk-python %s" % tqsdk.__version__, + "User-Agent": "tqsdk-python %s" % __version__, "Accept": "application/json", "Authorization": "Bearer %s" % self._access_token } @@ -148,9 +149,9 @@ def _has_account(self, account): def _has_md_grants(self, symbol): symbol_list = symbol if isinstance(symbol, list) else [symbol] for symbol in symbol_list: - if symbol.split('.', 1)[0] in ["SHFE", "DCE", "CZCE", "INE", "CFFEX", "KQ", "KQD", "SSWE", "GFEX"] and self._has_feature("futr"): + if symbol.split('.', 1)[0] in (FUTURE_EXCHANGES + SPOT_EXCHANGES + KQ_EXCHANGES + KQD_EXCHANGES) and self._has_feature("futr"): continue - elif symbol.split('.', 1)[0] in ["CSI", "SSE", "SZSE"] and self._has_feature("sec"): + elif symbol.split('.', 1)[0] in (["CSI"] + STOCK_EXCHANGES) and self._has_feature("sec"): continue elif symbol in ["SSE.000016", "SSE.000300", "SSE.000905", "SSE.000852"] and self._has_feature("lmt_idx"): continue @@ -160,8 +161,8 @@ def _has_md_grants(self, symbol): def _has_td_grants(self, symbol): # 对于 opt / cmb / adv 权限的检查由 OTG 做 - if symbol.split('.', 1)[0] in ["SSE", "SZSE"] and self._has_feature("sec"): + if symbol.split('.', 1)[0] in STOCK_EXCHANGES and self._has_feature("sec"): return True - if symbol.split('.', 1)[0] in ["SHFE", "DCE", "CZCE", "INE", "CFFEX", "KQ", "GFEX"] and self._has_feature("futr"): + if symbol.split('.', 1)[0] in (FUTURE_EXCHANGES + KQ_EXCHANGES) and self._has_feature("futr"): return True raise Exception(f"您的账户不支持交易 {symbol},需要购买后才能使用。升级网址:https://www.shinnytech.com/tqsdk_professional/") diff --git a/tqsdk/constants.py b/tqsdk/constants.py new file mode 100644 index 00000000..81ebcdba --- /dev/null +++ b/tqsdk/constants.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +__author__ = 'mayanqiong' + +""" +定义常量 +""" + +FUTURE_EXCHANGES = ["CFFEX", "SHFE", "DCE", "CZCE", "INE", "GFEX"] +STOCK_EXCHANGES = ["SSE", "SZSE"] +SPOT_EXCHANGES = ["SSWE"] +KQ_EXCHANGES = ["KQ"] +KQD_EXCHANGES = ["KQD"]