Skip to content

Commit

Permalink
Update Version 3.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
shinny-pack authored and shinny-mayanqiong committed Mar 9, 2022
1 parent 4b0fa90 commit a9497b2
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 11 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.2.4
Version: 3.2.5
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.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.
Expand Down
7 changes: 7 additions & 0 deletions doc/version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 后网页卡顿的问题
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[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.2.4'
__version__ = '3.2.5'
4 changes: 3 additions & 1 deletion tqsdk/algorithm/twap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tqsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 参数
Expand Down
4 changes: 3 additions & 1 deletion tqsdk/lib/target_pos_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 13 additions & 4 deletions tqsdk/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 中的这些字段应该有行情服务负责
Expand All @@ -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:
Expand All @@ -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()
Expand Down

0 comments on commit a9497b2

Please sign in to comment.