From a9497b2883a8f10f51ca6b2271497d75924d6e71 Mon Sep 17 00:00:00 2001 From: shinny-pack Date: Wed, 9 Mar 2022 02:33:47 +0000 Subject: [PATCH] Update Version 3.2.5 --- PKG-INFO | 2 +- doc/conf.py | 4 ++-- doc/version.rst | 7 +++++++ setup.py | 2 +- tqsdk/__version__.py | 2 +- tqsdk/algorithm/twap.py | 4 +++- tqsdk/api.py | 2 ++ tqsdk/lib/target_pos_task.py | 4 +++- tqsdk/symbols.py | 17 +++++++++++++---- 9 files changed, 33 insertions(+), 11 deletions(-) diff --git a/PKG-INFO b/PKG-INFO index 24bbfd54..bd02afe3 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: tqsdk -Version: 3.2.4 +Version: 3.2.5 Summary: TianQin SDK Home-page: https://www.shinnytech.com/tqsdk Author: TianQin diff --git a/doc/conf.py b/doc/conf.py index 0b4e34f4..00f04df2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -48,9 +48,9 @@ # built documents. # # The short X.Y version. -version = u'3.2.4' +version = u'3.2.5' # The full version, including alpha/beta/rc tags. -release = u'3.2.4' +release = u'3.2.5' # 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 3271301e..c39ca2c6 100644 --- a/doc/version.rst +++ b/doc/version.rst @@ -2,6 +2,13 @@ 版本变更 ============================= +3.2.5 (2022/03/09) + +* 修复:修正上交所 ETF 期权的昨结算(pre_settlement)字段未正确显示的问题 +* 修复::py:class:`~tqsdk.TargetPosTask` 及 :py:class:`~tqsdk.algorithm.twap` 添加强麦期货暂不支持的提示 +* 修复:api.insert_order 没有检查 advanced 参数 + + 3.2.4 (2022/03/07) * 优化:某些情况下启用 web_gui 后网页卡顿的问题 diff --git a/setup.py b/setup.py index 892cf74a..a9d3c80e 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ def get_tag(self): setuptools.setup( name='tqsdk', - version="3.2.4", + version="3.2.5", description='TianQin SDK', author='TianQin', author_email='tianqincn@gmail.com', diff --git a/tqsdk/__version__.py b/tqsdk/__version__.py index cca48bd0..0223f2dc 100644 --- a/tqsdk/__version__.py +++ b/tqsdk/__version__.py @@ -1 +1 @@ -__version__ = '3.2.4' +__version__ = '3.2.5' diff --git a/tqsdk/algorithm/twap.py b/tqsdk/algorithm/twap.py index ba231fad..26c28031 100644 --- a/tqsdk/algorithm/twap.py +++ b/tqsdk/algorithm/twap.py @@ -120,7 +120,9 @@ def __init__(self, api: TqApi, symbol: str, direction: str, offset: str, volume: if symbol.startswith("CZCE.CJ"): raise Exception("红枣期货不支持创建 targetpostask、twap、vwap 任务,交易所规定该品种最小开仓手数为大于等于 4 手,这些函数还未支持该规则!") if symbol.startswith("CZCE.ZC"): - raise Exception("动力煤期货不支持创建 targetpostask、twap、vwap 任务,交易所规定该品种最小开仓手数为大于等于 2 手,这些函数还未支持该规则!") + raise Exception("动力煤期货不支持创建 targetpostask、twap、vwap 任务,交易所规定该品种最小开仓手数为大于等于 4 手,这些函数还未支持该规则!") + if symbol.startswith("CZCE.WH"): + raise Exception("强麦期货不支持创建 targetpostask、twap、vwap 任务,交易所规定该品种最小开仓手数为大于等于 10 手,这些函数还未支持该规则!") self._api = api self._account = api._account._check_valid(account) if self._account is None: diff --git a/tqsdk/api.py b/tqsdk/api.py index d012a95c..1c341db2 100644 --- a/tqsdk/api.py +++ b/tqsdk/api.py @@ -1246,6 +1246,8 @@ def insert_order(self, symbol: str, direction: str, offset: str = "", volume: in raise Exception(f"账户 {account._broker_id}, {account._account_id} 不支持交易合约 {symbol}。") if isinstance(account, TqKq) and exchange_id in ["SSE", "SZSE"]: # 快期模拟暂不支持,提前抛错 raise Exception(f"快期模拟暂不支持股票及 ETF 期权交易,股票交易请使用 TqKqStock。") + if not (advanced is None or advanced in ["FAK", "FOK"]): + raise Exception("advanced 参数错误,只支持以下选项之一 'FAK', 'FOK', None。") order_id = order_id if order_id else _generate_uuid("PYSDK_insert") # 股票下单时, 不支持 offset 参数 diff --git a/tqsdk/lib/target_pos_task.py b/tqsdk/lib/target_pos_task.py index ca730f90..b0c37695 100644 --- a/tqsdk/lib/target_pos_task.py +++ b/tqsdk/lib/target_pos_task.py @@ -198,7 +198,9 @@ def get_price(direction, quote): if symbol.startswith("CZCE.CJ"): raise Exception("红枣期货不支持创建 targetpostask、twap、vwap 任务,交易所规定该品种最小开仓手数为大于等于 4 手,这些函数还未支持该规则!") if symbol.startswith("CZCE.ZC"): - raise Exception("动力煤期货不支持创建 targetpostask、twap、vwap 任务,交易所规定该品种最小开仓手数为大于等于 2 手,这些函数还未支持该规则!") + raise Exception("动力煤期货不支持创建 targetpostask、twap、vwap 任务,交易所规定该品种最小开仓手数为大于等于 4 手,这些函数还未支持该规则!") + if symbol.startswith("CZCE.WH"): + raise Exception("强麦期货不支持创建 targetpostask、twap、vwap 任务,交易所规定该品种最小开仓手数为大于等于 10 手,这些函数还未支持该规则!") super(TargetPosTask, self).__init__() self._api = api self._account = api._account._check_valid(account) diff --git a/tqsdk/symbols.py b/tqsdk/symbols.py index 6f937dc3..1a1f16fa 100644 --- a/tqsdk/symbols.py +++ b/tqsdk/symbols.py @@ -19,6 +19,7 @@ async def _run(self, api, sim_send_chan, sim_recv_chan, md_send_chan, md_recv_ch self._sim_recv_chan = sim_recv_chan self._md_send_chan = md_send_chan self._md_recv_chan = md_recv_chan + self._sse_options = set() self._quotes_all_keys = set(Quote(None).keys()) self._quotes_all_keys = self._quotes_all_keys.union({'margin', 'commission'}) # 以下字段合约服务也会请求,但是不应该记在 quotes 中,quotes 中的这些字段应该有行情服务负责 @@ -30,6 +31,9 @@ async def _run(self, api, sim_send_chan, sim_recv_chan, md_send_chan, md_recv_ch data = pack.setdefault("data", []) # 对于收到的数据,全部转发给下游 # 对于合约服务信息,query_id 为 PYSDK_quote_xxx 开头的,一定是请求了合约的全部合约信息,需要转为 quotes 转发给下游 + updated_quotes = {} # 合约服务内容转为的 quotes 对象 + # 分两次循环,第一次循环找到所有的 SSE 期权,第二次循环将从行情收到的 SSE 期权的 pre_settlement 删掉 + # 最终将 updated_quotes 发送给下游 for d in data: for query_id, query_result in d.get("symbols", {}).items(): if query_result: @@ -38,17 +42,22 @@ async def _run(self, api, sim_send_chan, sim_recv_chan, md_send_chan, md_recv_ch elif query_id.startswith("PYSDK_quote"): quotes = self._api._symbols_to_quotes(query_result, self._quotes_all_keys) for quote in quotes.values(): - if not (quote["ins_class"] == "OPTION" and quote["exchange_id"] == "SSE"): + if quote["ins_class"] == "OPTION" and quote["exchange_id"] == "SSE": + self._sse_options.add(quote["instrument_id"]) + else: # quotes 中的 pre_settlement 字段应该由行情服务负责,行情没有上交所期权的 pre_settlement,需要从合约服务取,其他合约不变 quote.pop("pre_settlement", None) - data.append( - {"quotes": quotes} - ) + updated_quotes.update(quotes) self._md_send_chan.send_nowait({ "aid": "ins_query", "query_id": query_id, "query": "" }) + for d in data: + for symbol, quote in d.get("quotes", {}).items(): + if symbol in self._sse_options: + quote.pop("pre_settlement", None) + data.append({"quotes": updated_quotes}) await self._sim_recv_chan.send(pack) finally: sim_task.cancel()