Skip to content

Commit 99e6aa2

Browse files
shinny-hongyanshinny-chenli
authored andcommitted
Update Version 3.7.9
1 parent 99411cd commit 99e6aa2

20 files changed

+358
-40
lines changed

PKG-INFO

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: tqsdk
3-
Version: 3.7.8
3+
Version: 3.7.9
44
Summary: TianQin SDK
55
Home-page: https://www.shinnytech.com/tqsdk
66
Author: TianQin

doc/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
# built documents.
4949
#
5050
# The short X.Y version.
51-
version = u'3.7.8'
51+
version = u'3.7.9'
5252
# The full version, including alpha/beta/rc tags.
53-
release = u'3.7.8'
53+
release = u'3.7.9'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.

doc/demo/base.rst

+90
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,96 @@ t41 - 开仓/平仓
5151
:language: python
5252

5353

54+
.. _tutorial-t50:
55+
56+
t50 - 查询交易所合约每日结算价
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
59+
.. literalinclude:: ../../tqsdk/demo/tutorial/t50.py
60+
:language: python
61+
62+
63+
.. _tutorial-t51:
64+
65+
t51 - 查询合约成交排名/持仓排名
66+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67+
68+
.. literalinclude:: ../../tqsdk/demo/tutorial/t51.py
69+
:language: python
70+
71+
72+
.. _tutorial-t52:
73+
74+
t52 - 根据合约类型、交易所、品种等条件查询合约
75+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76+
77+
.. literalinclude:: ../../tqsdk/demo/tutorial/t52.py
78+
:language: python
79+
80+
81+
.. _tutorial-t53:
82+
83+
t53 - 查询主连合约对应的标的合约列表
84+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85+
86+
.. literalinclude:: ../../tqsdk/demo/tutorial/t53.py
87+
:language: python
88+
89+
90+
.. _tutorial-t54:
91+
92+
t54 - 查询合约信息
93+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
94+
95+
.. literalinclude:: ../../tqsdk/demo/tutorial/t54.py
96+
:language: python
97+
98+
99+
.. _tutorial-t55:
100+
101+
t55 - 查询期权合约
102+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103+
104+
.. literalinclude:: ../../tqsdk/demo/tutorial/t55.py
105+
:language: python
106+
107+
108+
.. _tutorial-t56:
109+
110+
t56 - 根据条件查询期权
111+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112+
113+
.. literalinclude:: ../../tqsdk/demo/tutorial/t56.py
114+
:language: python
115+
116+
117+
.. _tutorial-t57:
118+
119+
t57 - 根据条件查询全部的实值、平值、虚值期权
120+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121+
122+
.. literalinclude:: ../../tqsdk/demo/tutorial/t57.py
123+
:language: python
124+
125+
126+
.. _tutorial-t58:
127+
128+
t58 - 针对ETF期权和股指期权查询全部的实值、平值、虚值期权
129+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130+
131+
.. literalinclude:: ../../tqsdk/demo/tutorial/t58.py
132+
:language: python
133+
134+
135+
.. _tutorial-t59:
136+
137+
t59 - 查询指定期权的希腊指标
138+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
139+
140+
.. literalinclude:: ../../tqsdk/demo/tutorial/t59.py
141+
:language: python
142+
143+
54144
.. _tutorial-t60:
55145

56146
t60 - 单均线策略

doc/quickstart.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ TqSdk AI 助手
281281
-------------------------------------------------
282282
TqSdk 基于先进的大语言模型和常见天勤问题资料库,提供了新一代的 AI 助手
283283

284-
解释函数,编写demo策略,分析代码报错原因,它都有不错的表现 `点击使用 <https://udify.app/chat/im02prcHNEOVbPAx/>`_
284+
解释函数,编写demo策略,分析代码报错原因,它都有不错的表现 `点击使用 <https://www.shinnytech.com/tianqin/>`_
285285

286286
.. figure:: images/llm_pic1.png
287287
.. figure:: images/llm_pic2.png

doc/tqsdk_llm.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
天勤量化 AI 助手
44
-----------------------------------------------
5+
点击使用 `使用天勤 AI 助手! <https://www.shinnytech.com/tianqin/>`_
56
在使用天勤的过程中,用户往往会遇到各种问题,尤其是初学者,他们可能会关心以下几点:
67

78
* 天勤量化可以实现哪些功能?
@@ -22,7 +23,7 @@
2223
* 根据具体需求或策略提供天勤实现的示例
2324
* 天勤或 Python 报错的可能解决方案
2425

25-
点击即刻尝试 `使用天勤 AI 助手! <https://udify.app/chat/im02prcHNEOVbPAx/>`_
26+
点击即刻尝试 `使用天勤 AI 助手! <https://www.shinnytech.com/tianqin/>`_
2627

2728
下图是具体的使用示例 demo
2829

doc/usage/mddatas.rst

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ GFEX 广州期货交易所
6363
SSE.000300 - 沪深300指数
6464
SSE.000905 - 中证500指数
6565
SSE.000852 - 中证1000指数
66+
SSE.588000 - 上交所华夏科创50
67+
SSE.588080 - 上交所易方达科创50
68+
SZSE.159915 - 深交所创业板
6669
SSE.510050 - 上交所上证50ETF
6770
SSE.510300 - 上交所沪深300ETF
6871
SZSE.159919 - 深交所沪深300ETF

doc/version.rst

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
版本变更
44
=============================
5+
3.7.9 (2025/03/07)
6+
7+
* docs: 修正天勤 AI 的指向地址
8+
* docs: 增加上交所深交所 ETF 标的合约代码示例
9+
10+
511
3.7.8 (2025/01/23)
612

713
* docs: 修正部分文档

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name='tqsdk',
11-
version="3.7.8",
11+
version="3.7.9",
1212
description='TianQin SDK',
1313
author='TianQin',
1414
author_email='tianqincn@gmail.com',

tqsdk/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.7.8'
1+
__version__ = '3.7.9'

tqsdk/api.py

+7-33
Original file line numberDiff line numberDiff line change
@@ -185,41 +185,15 @@ def __init__(self, account: Optional[Union[TqMultiAccount, UnionTradeable]] = No
185185
186186
Example2::
187187
188-
# 使用快期模拟帐号连接行情服务器
189-
from tqsdk import TqApi, TqAuth, TqKq
190-
api = TqApi(TqKq(), auth=TqAuth("快期账户", "账户密码")) # 根据填写的快期账户参数连接指定的快期模拟账户
188+
# 使用simnow帐号连接行情和交易服务器
189+
from tqsdk import TqApi, TqAuth, TqAccount
190+
api = TqApi(TqAccount("simnow", "simnow用户名", "simnow密码"), auth=TqAuth("快期账户", "账户密码"))
191191
192192
Example3::
193193
194-
# 使用模拟帐号直连行情服务器
195-
from tqsdk import TqApi, TqAuth, TqSim
196-
api = TqApi(TqSim(), auth=TqAuth("快期账户", "账户密码")) # 不填写参数则默认为 TqSim() 模拟账号
197-
198-
Example4::
199-
200-
# 进行策略回测
201-
from datetime import date
202-
from tqsdk import TqApi, TqAuth, TqBacktest
203-
api = TqApi(backtest=TqBacktest(start_dt=date(2018, 5, 1), end_dt=date(2018, 10, 1)), auth=TqAuth("快期账户", "账户密码"))
204-
205-
Example5::
206-
207-
# 进行策略复盘
208-
from datetime import date
209-
from tqsdk import TqApi, TqAuth, TqReplay
210-
api = TqApi(backtest=TqReplay(replay_dt=date(2019, 12, 16)), auth=TqAuth("快期账户", "账户密码"))
211-
212-
Example6::
213-
214-
# 开启 web_gui 功能,使用默认参数True
215-
from tqsdk import TqApi, TqAuth
216-
api = TqApi(web_gui=True, auth=TqAuth("快期账户", "账户密码"))
217-
218-
Example7::
219-
220-
# 开启 web_gui 功能,使用本机IP端口固定网址生成
221-
from tqsdk import TqApi, TqAuth
222-
api = TqApi(web_gui=":9876", auth=TqAuth("快期账户", "账户密码")) # 等价于 api = TqApi(web_gui="0.0.0.0:9876", auth=TqAuth("快期账户", "账户密码"))
194+
# 使用快期模拟帐号连接行情服务器
195+
from tqsdk import TqApi, TqAuth, TqKq
196+
api = TqApi(TqKq(), auth=TqAuth("快期账户", "账户密码")) # 根据填写的快期账户参数连接指定的快期模拟账户
223197
224198
"""
225199

@@ -2387,7 +2361,7 @@ def query_symbol_ranking(self, symbol: str, ranking_type: str, days: int = 1, st
23872361
23882362
ranking_type (str):[必填] 表示返回结果以哪一项为排名基准,VOLUME 成交量排名,LONG 多头持仓排名, SHORT 空头持仓排名
23892363
2390-
days (int): [必填] 返回结果中包含的天数,默认为 1
2364+
days (int): [可选] 返回结果中包含的天数,默认为 1
23912365
23922366
start_dt (date): [可选] 查询时间段开始日期,默认为 None
23932367
* 如果开始日期为 date 类型,则返回从开始日期之后 days 个交易日的有效数据

tqsdk/demo/tutorial/t50.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
__author__ = 'chaos'
4+
5+
from datetime import datetime
6+
from tqsdk import TqApi, TqAuth
7+
8+
api = TqApi(auth=TqAuth("快期账户", "账户密码"))
9+
# 注意:该函数返回的对象不会更新,不建议在循环内调用该方法
10+
11+
# 最近3天结算价信息
12+
df = api.query_symbol_settlement("SHFE.ag2504", days=3)
13+
print(df.to_string())
14+
15+
# 查询从2025年2月10日开始两天的结算价信息
16+
df = api.query_symbol_settlement("SHFE.ag2504", days=2, start_dt=datetime(2025,2,10).date())
17+
print(df.to_string())
18+
19+
# 关闭api,释放相应资源
20+
api.close()

tqsdk/demo/tutorial/t51.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
__author__ = 'chaos'
4+
5+
from tqsdk import TqApi, TqAuth
6+
7+
api = TqApi(auth=TqAuth("快期账户", "账户密码"))
8+
# 注意:该函数返回的对象不会更新,不建议在循环内调用该方法
9+
10+
# 最近 1 天持仓排名信息,以成交量排序
11+
df = api.query_symbol_ranking("SHFE.ag2504", ranking_type="VOLUME")
12+
print(df.to_string())
13+
14+
# 最近 3 天持仓排名信息,以多头持仓量排序
15+
df = api.query_symbol_ranking("SHFE.ag2504", ranking_type="LONG",days=3)
16+
print(df.to_string())
17+
18+
# 关闭api,释放相应资源
19+
api.close()

tqsdk/demo/tutorial/t52.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
__author__ = 'chaos'
4+
5+
from tqsdk import TqApi, TqAuth
6+
7+
api = TqApi(auth=TqAuth("快期账户", "账户密码"))
8+
9+
# 不推荐使用以下方式获取符合某种条件的合约列表,推荐使用接口来完成此功能。
10+
# ls = [k for k,v in api._data["quotes"].items() if k.startswith("KQ.m")]
11+
# print(ls)
12+
13+
# au 品种的全部合约,包括已下市以及未下市合约
14+
ls = api.query_quotes(ins_class="FUTURE", product_id="au")
15+
print(ls)
16+
17+
# au、cu 品种的全部未下市合约合约
18+
ls = api.query_quotes(ins_class=["FUTURE"], product_id=["au", "cu"], expired=False)
19+
print(ls)
20+
21+
# au 品种指数合约
22+
ls = api.query_quotes(ins_class="INDEX", product_id="au")
23+
print(ls)
24+
25+
# 全部主连合约
26+
ls = api.query_quotes(ins_class="CONT")
27+
print(ls)
28+
29+
# au 品种主连合约
30+
ls = api.query_quotes(ins_class="CONT", product_id="au")
31+
print(ls)
32+
33+
# 上期所带夜盘的期货合约列表
34+
ls = api.query_quotes(ins_class="FUTURE", exchange_id="SHFE", has_night=True)
35+
print(ls)
36+
37+
# au 品种的全部未下市合约、指数、主连
38+
ls = api.query_quotes(product_id="au", expired=False)
39+
print(ls)
40+
41+
# 上海交易所股票代码列表
42+
ls = api.query_quotes(ins_class="STOCK", exchange_id="SSE", expired=False)
43+
print(ls)
44+
45+
# 上海交易所基金代码列表
46+
ls = api.query_quotes(ins_class="FUND", exchange_id="SSE", expired=False)
47+
print(ls)
48+
49+
# 关闭api,释放相应资源
50+
api.close()

tqsdk/demo/tutorial/t53.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
__author__ = 'chaos'
4+
5+
from tqsdk import TqApi, TqAuth
6+
7+
api = TqApi(auth=TqAuth("快期账户", "账户密码"))
8+
9+
# 全部主连合约对应的标的合约
10+
ls = api.query_cont_quotes()
11+
print(ls)
12+
13+
# 大商所主连合约对应的标的合约
14+
ls = api.query_cont_quotes(exchange_id="DCE")
15+
print(ls)
16+
17+
# jd 品种主连合约对应的标的合约
18+
ls = api.query_cont_quotes(product_id="jd")
19+
print(ls)
20+
21+
# 关闭api,释放相应资源
22+
api.close()
23+
24+
# 预期输出如下
25+
# ['SHFE.cu2503', 'SHFE.ni2503', 'CFFEX.TS2503', 'SHFE.br2503', 'CZCE.OI505', 'DCE.c2505', 'GFEX.lc2505', 'INE.bc2503', 'CZCE.CJ505', 'CFFEX.TF2503', 'SHFE.hc2505', 'SHFE.ru2505', 'DCE.lg2507', 'DCE.a2505', 'DCE.b2505', 'GFEX.ps2506', 'SHFE.ss2505', 'CZCE.CF505', 'DCE.m2505', 'CFFEX.T2503', 'DCE.pg2503', 'CZCE.SR505', 'CZCE.PF504', 'SHFE.pb2503', 'CZCE.UR505', 'CZCE.MA505', 'CZCE.PX505', 'SHFE.sn2503', 'GFEX.si2505', 'CZCE.FG505', 'CFFEX.IM2503', 'CZCE.ZC505', 'CFFEX.IC2503', 'INE.nr2504', 'INE.lu2505', 'DCE.fb2505', 'CZCE.RM505', 'CFFEX.TL2503', 'CZCE.SA505', 'CZCE.AP505', 'CZCE.PK505', 'CZCE.SF505', 'SHFE.ao2505', 'CZCE.TA505', 'SHFE.bu2504', 'SHFE.zn2503', 'DCE.jm2505', 'DCE.jd2505', 'INE.sc2504', 'INE.ec2504', 'CZCE.PM505', 'DCE.lh2505', 'CZCE.WH505', 'CZCE.RI505', 'DCE.l2505', 'CZCE.PR503', 'CZCE.CY505', 'DCE.eg2505', 'DCE.pp2505', 'SHFE.fu2505', 'DCE.v2505', 'DCE.p2505', 'SHFE.rb2505', 'CZCE.JR505', 'SHFE.sp2505', 'CZCE.SM505', 'CFFEX.IF2503', 'DCE.rr2503', 'SHFE.au2504', 'DCE.bb2509', 'SHFE.ag2504', 'SHFE.al2504', 'DCE.j2505', 'CZCE.RS507', 'DCE.y2505', 'DCE.i2505', 'CZCE.SH505', 'CZCE.LR505', 'DCE.cs2503', 'SHFE.wr2505', 'CFFEX.IH2503', 'DCE.eb2503']
26+
# ['DCE.c2505', 'DCE.lg2507', 'DCE.a2505', 'DCE.b2505', 'DCE.m2505', 'DCE.pg2503', 'DCE.fb2505', 'DCE.jm2505', 'DCE.jd2505', 'DCE.lh2505', 'DCE.l2505', 'DCE.eg2505', 'DCE.pp2505', 'DCE.v2505', 'DCE.p2505', 'DCE.rr2503', 'DCE.bb2509', 'DCE.j2505', 'DCE.y2505', 'DCE.i2505', 'DCE.cs2503', 'DCE.eb2503']
27+
# ['DCE.jd2505']

tqsdk/demo/tutorial/t54.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
__author__ = 'chaos'
4+
5+
from tqsdk import TqApi, TqAuth
6+
7+
api = TqApi(auth=TqAuth("快期账户", "账户密码"))
8+
9+
ls = api.query_options("SSE.510050", option_class="CALL", expired=False) # 所有未下市上交所上证50etf期权
10+
df = api.query_symbol_info(ls)
11+
print(df.to_string())
12+
13+
# 关闭api,释放相应资源
14+
api.close()

0 commit comments

Comments
 (0)