Skip to content

Commit

Permalink
Update Version 3.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
shinny-pack authored and shinny-mayanqiong committed Apr 11, 2024
1 parent f8a5887 commit b72cb7c
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions doc/version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 判断某个对象是否更新,可能返回的结果不正确
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='tqsdk',
version="3.5.5",
version="3.5.6",
description='TianQin SDK',
author='TianQin',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion tqsdk/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.5.5'
__version__ = '3.5.6'
7 changes: 5 additions & 2 deletions tqsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down Expand Up @@ -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: 外盘主连
Expand Down Expand Up @@ -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 == "":
Expand All @@ -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:
Expand Down Expand Up @@ -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): [可选] 品种
Expand Down
13 changes: 7 additions & 6 deletions tqsdk/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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/")
13 changes: 13 additions & 0 deletions tqsdk/constants.py
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit b72cb7c

Please sign in to comment.