1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
%global _empty_manifest_terminate_build 0
Name: python-tqsdk
Version: 3.3.0
Release: 1
Summary: TianQin SDK
License: Apache Software License
URL: https://www.shinnytech.com/tqsdk
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/56/f7/422cea722db7f87778f0ed961faf60309e2409af14b1436d7c37bab883e9/tqsdk-3.3.0.tar.gz
Requires: python3-websockets
Requires: python3-requests
Requires: python3-numpy
Requires: python3-pandas
Requires: python3-scipy
Requires: python3-simplejson
Requires: python3-aiohttp
Requires: python3-certifi
Requires: python3-pyjwt
Requires: python3-psutil
Requires: python3-shinny-structlog
Requires: python3-sgqlc
Requires: python3-filelock
%description
TqSdk 是一个由[信易科技](https://www.shinnytech.com)发起并贡献主要代码的开源 python 库.
依托[快期多年积累成熟的交易及行情服务器体系](https://www.shinnytech.com/diff), TqSdk 支持用户使用极少的代码量构建各种类型的量化交易策略程序,
并提供包含期货、期权、股票的 历史数据-实时数据-开发调试-策略回测-模拟交易-实盘交易-运行监控-风险管理 全套解决方案.
``` {.sourceCode .python}
from tqsdk import TqApi, TqAuth, TqAccount, TargetPosTask
api = TqApi(TqAccount("H海通期货", "4003242", "123456"), auth=TqAuth("信易账户", "账户密码")) # 创建 TqApi 实例, 指定交易账户
q_1910 = api.get_quote("SHFE.rb1910") # 订阅近月合约行情
t_1910 = TargetPosTask(api, "SHFE.rb1910") # 创建近月合约调仓工具
q_2001 = api.get_quote("SHFE.rb2001") # 订阅远月合约行情
t_2001 = TargetPosTask(api, "SHFE.rb2001") # 创建远月合约调仓工具
while True:
api.wait_update() # 等待数据更新
spread = q_1910["last_price"] - q_2001["last_price"] # 计算近月合约-远月合约价差
print("当前价差:", spread)
if spread > 250:
print("价差过高: 空近月,多远月")
t_1910.set_target_volume(-1) # 要求把1910合约调整为空头1手
t_2001.set_target_volume(1) # 要求把2001合约调整为多头1手
elif spread < 200:
print("价差回复: 清空持仓") # 要求把 1910 和 2001合约都调整为不持仓
t_1910.set_target_volume(0)
t_2001.set_target_volume(0)
```
要快速了解如何使用TqSdk, 可以访问我们的 [十分钟快速入门指南](https://doc.shinnytech.com/tqsdk/latest/quickstart.html).
%package -n python3-tqsdk
Summary: TianQin SDK
Provides: python-tqsdk
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
BuildRequires: python3-cffi
BuildRequires: gcc
BuildRequires: gdb
%description -n python3-tqsdk
TqSdk 是一个由[信易科技](https://www.shinnytech.com)发起并贡献主要代码的开源 python 库.
依托[快期多年积累成熟的交易及行情服务器体系](https://www.shinnytech.com/diff), TqSdk 支持用户使用极少的代码量构建各种类型的量化交易策略程序,
并提供包含期货、期权、股票的 历史数据-实时数据-开发调试-策略回测-模拟交易-实盘交易-运行监控-风险管理 全套解决方案.
``` {.sourceCode .python}
from tqsdk import TqApi, TqAuth, TqAccount, TargetPosTask
api = TqApi(TqAccount("H海通期货", "4003242", "123456"), auth=TqAuth("信易账户", "账户密码")) # 创建 TqApi 实例, 指定交易账户
q_1910 = api.get_quote("SHFE.rb1910") # 订阅近月合约行情
t_1910 = TargetPosTask(api, "SHFE.rb1910") # 创建近月合约调仓工具
q_2001 = api.get_quote("SHFE.rb2001") # 订阅远月合约行情
t_2001 = TargetPosTask(api, "SHFE.rb2001") # 创建远月合约调仓工具
while True:
api.wait_update() # 等待数据更新
spread = q_1910["last_price"] - q_2001["last_price"] # 计算近月合约-远月合约价差
print("当前价差:", spread)
if spread > 250:
print("价差过高: 空近月,多远月")
t_1910.set_target_volume(-1) # 要求把1910合约调整为空头1手
t_2001.set_target_volume(1) # 要求把2001合约调整为多头1手
elif spread < 200:
print("价差回复: 清空持仓") # 要求把 1910 和 2001合约都调整为不持仓
t_1910.set_target_volume(0)
t_2001.set_target_volume(0)
```
要快速了解如何使用TqSdk, 可以访问我们的 [十分钟快速入门指南](https://doc.shinnytech.com/tqsdk/latest/quickstart.html).
%package help
Summary: Development documents and examples for tqsdk
Provides: python3-tqsdk-doc
%description help
TqSdk 是一个由[信易科技](https://www.shinnytech.com)发起并贡献主要代码的开源 python 库.
依托[快期多年积累成熟的交易及行情服务器体系](https://www.shinnytech.com/diff), TqSdk 支持用户使用极少的代码量构建各种类型的量化交易策略程序,
并提供包含期货、期权、股票的 历史数据-实时数据-开发调试-策略回测-模拟交易-实盘交易-运行监控-风险管理 全套解决方案.
``` {.sourceCode .python}
from tqsdk import TqApi, TqAuth, TqAccount, TargetPosTask
api = TqApi(TqAccount("H海通期货", "4003242", "123456"), auth=TqAuth("信易账户", "账户密码")) # 创建 TqApi 实例, 指定交易账户
q_1910 = api.get_quote("SHFE.rb1910") # 订阅近月合约行情
t_1910 = TargetPosTask(api, "SHFE.rb1910") # 创建近月合约调仓工具
q_2001 = api.get_quote("SHFE.rb2001") # 订阅远月合约行情
t_2001 = TargetPosTask(api, "SHFE.rb2001") # 创建远月合约调仓工具
while True:
api.wait_update() # 等待数据更新
spread = q_1910["last_price"] - q_2001["last_price"] # 计算近月合约-远月合约价差
print("当前价差:", spread)
if spread > 250:
print("价差过高: 空近月,多远月")
t_1910.set_target_volume(-1) # 要求把1910合约调整为空头1手
t_2001.set_target_volume(1) # 要求把2001合约调整为多头1手
elif spread < 200:
print("价差回复: 清空持仓") # 要求把 1910 和 2001合约都调整为不持仓
t_1910.set_target_volume(0)
t_2001.set_target_volume(0)
```
要快速了解如何使用TqSdk, 可以访问我们的 [十分钟快速入门指南](https://doc.shinnytech.com/tqsdk/latest/quickstart.html).
%prep
%autosetup -n tqsdk-3.3.0
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-tqsdk -f filelist.lst
%dir %{python3_sitearch}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 3.3.0-1
- Package Spec generated
|