vnpy_tts 6.7.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vnpy_tts-6.7.2.2/.flake8 +5 -0
- vnpy_tts-6.7.2.2/.github/CODE_OF_CONDUCT.md +9 -0
- vnpy_tts-6.7.2.2/.github/ISSUE_TEMPLATE.md +19 -0
- vnpy_tts-6.7.2.2/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- vnpy_tts-6.7.2.2/.github/SUPPORT.md +8 -0
- vnpy_tts-6.7.2.2/.github/workflows/pythonapp.yml +32 -0
- vnpy_tts-6.7.2.2/.gitignore +42 -0
- vnpy_tts-6.7.2.2/CHANGELOG.md +49 -0
- vnpy_tts-6.7.2.2/LICENSE +21 -0
- vnpy_tts-6.7.2.2/PKG-INFO +137 -0
- vnpy_tts-6.7.2.2/README.md +108 -0
- vnpy_tts-6.7.2.2/meson.build +165 -0
- vnpy_tts-6.7.2.2/pyproject.toml +85 -0
- vnpy_tts-6.7.2.2/script/run.py +23 -0
- vnpy_tts-6.7.2.2/vnpy_tts/__init__.py +34 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/__init__.py +3 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/generator/generate_api_functions.py +345 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/generator/generate_data_type.py +76 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/generator/generate_struct.py +84 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/include/tts/ThostFtdcMdApi.h +168 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/include/tts/ThostFtdcTraderApi.h +770 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/include/tts/ThostFtdcUserApiDataType.h +6878 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/include/tts/ThostFtdcUserApiStruct.h +10915 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/libs/thostmduserapi_se.lib +0 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/libs/thosttraderapi_se.lib +0 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/libthostmduserapi_se.so +0 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/libthosttraderapi_se.so +0 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/thostmduserapi_se.dll +0 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/thosttraderapi_se.dll +0 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/tts_constant.py +1253 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vntts.h +146 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vntts.sln +43 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttsmd/dllmain.cpp +19 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttsmd/framework.h +5 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttsmd/pch.cpp +5 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttsmd/pch.h +13 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttsmd/vnttsmd.cpp +953 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttsmd/vnttsmd.h +209 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttsmd/vnttsmd.vcxproj +187 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttsmd/vnttsmd.vcxproj.filters +54 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttsmd/vnttsmd.vcxproj.user +4 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttstd/dllmain.cpp +19 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttstd/framework.h +5 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttstd/pch.cpp +5 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttstd/pch.h +13 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttstd/vnttstd.cpp +12075 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttstd/vnttstd.h +1306 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttstd/vnttstd.vcxproj +187 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttstd/vnttstd.vcxproj.filters +54 -0
- vnpy_tts-6.7.2.2/vnpy_tts/api/vntts/vnttstd/vnttstd.vcxproj.user +4 -0
- vnpy_tts-6.7.2.2/vnpy_tts/gateway/__init__.py +4 -0
- vnpy_tts-6.7.2.2/vnpy_tts/gateway/tts_gateway.py +926 -0
vnpy_tts-6.7.2.2/.flake8
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# 行为准则
|
|
2
|
+
|
|
3
|
+
这是一份VeighNa项目社区的行为准则,也是项目作者自己在刚入行量化金融行业时对于理想中的社区的期望:
|
|
4
|
+
|
|
5
|
+
* 为交易员而生:作为一款从金融机构量化业务中诞生的交易系统开发框架,设计上都优先满足机构专业交易员的使用习惯,而不是其他用户(散户、爱好者、技术人员等)
|
|
6
|
+
|
|
7
|
+
* 对新用户友好,保持耐心:大部分人在接触新东西的时候都是磕磕碰碰、有很多的问题,请记住此时别人对你伸出的援助之手,并把它传递给未来需要的人
|
|
8
|
+
|
|
9
|
+
* 尊重他人,慎重言行:礼貌文明的交流方式除了能得到别人同样的回应,更能减少不必要的摩擦,保证高效的交流
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## 环境
|
|
2
|
+
|
|
3
|
+
* 操作系统: 如Windows 11或者Ubuntu 22.04
|
|
4
|
+
* Python版本: 如VeighNa Studio-4.0.0
|
|
5
|
+
* VeighNa版本: 如v4.0.0发行版或者dev branch 20250320(下载日期)
|
|
6
|
+
|
|
7
|
+
## Issue类型
|
|
8
|
+
三选一:Bug/Enhancement/Question
|
|
9
|
+
|
|
10
|
+
## 预期程序行为
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## 实际程序行为
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## 重现步骤
|
|
17
|
+
|
|
18
|
+
针对Bug类型Issue,请提供具体重现步骤以及报错截图
|
|
19
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Python application
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
|
|
8
|
+
runs-on: windows-latest
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v1
|
|
12
|
+
- name: Set up Python 3.13
|
|
13
|
+
uses: actions/setup-python@v1
|
|
14
|
+
with:
|
|
15
|
+
python-version: '3.13'
|
|
16
|
+
- name: Install dependencies
|
|
17
|
+
run: |
|
|
18
|
+
python -m pip install --upgrade pip
|
|
19
|
+
pip install ta-lib==0.6.3 --index=https://pypi.vnpy.com
|
|
20
|
+
pip install vnpy ruff mypy uv
|
|
21
|
+
- name: Lint with ruff
|
|
22
|
+
run: |
|
|
23
|
+
# Run ruff linter based on pyproject.toml configuration
|
|
24
|
+
ruff check .
|
|
25
|
+
- name: Type check with mypy
|
|
26
|
+
run: |
|
|
27
|
+
# Run mypy type checking based on pyproject.toml configuration
|
|
28
|
+
mypy vnpy_tts
|
|
29
|
+
- name: Build packages with uv
|
|
30
|
+
run: |
|
|
31
|
+
# Build source distribution and wheel distribution
|
|
32
|
+
uv build --sdist
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Prerequisites
|
|
2
|
+
*.d
|
|
3
|
+
|
|
4
|
+
# Compiled Object files
|
|
5
|
+
*.slo
|
|
6
|
+
*.lo
|
|
7
|
+
*.o
|
|
8
|
+
*.obj
|
|
9
|
+
|
|
10
|
+
# Precompiled Headers
|
|
11
|
+
*.gch
|
|
12
|
+
*.pch
|
|
13
|
+
|
|
14
|
+
# Fortran module files
|
|
15
|
+
*.mod
|
|
16
|
+
*.smod
|
|
17
|
+
|
|
18
|
+
# Compiled Static libraries
|
|
19
|
+
*.lai
|
|
20
|
+
*.la
|
|
21
|
+
*.a
|
|
22
|
+
|
|
23
|
+
# Executables
|
|
24
|
+
*.exe
|
|
25
|
+
*.out
|
|
26
|
+
*.app
|
|
27
|
+
|
|
28
|
+
# Python
|
|
29
|
+
*.pyc
|
|
30
|
+
dist/
|
|
31
|
+
build/
|
|
32
|
+
vnpy_tts.egg-info/
|
|
33
|
+
__pycache__/
|
|
34
|
+
|
|
35
|
+
# Visual Studio
|
|
36
|
+
.vs/
|
|
37
|
+
x64/
|
|
38
|
+
|
|
39
|
+
dist/
|
|
40
|
+
build/
|
|
41
|
+
*.egg-info/
|
|
42
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# 6.7.2.2版本
|
|
2
|
+
|
|
3
|
+
1. 适配vnpy框架4.0版本
|
|
4
|
+
|
|
5
|
+
# 6.7.2.1版本
|
|
6
|
+
|
|
7
|
+
1. 升级pybind11封装工具库版本,支持Python 3.11/3.12
|
|
8
|
+
|
|
9
|
+
# 6.7.2.0版本
|
|
10
|
+
|
|
11
|
+
1. 替换最新版本dll和so,升级到6.7.2
|
|
12
|
+
2. 类型声明使用内置数据类型
|
|
13
|
+
|
|
14
|
+
# 6.6.9.1版本
|
|
15
|
+
|
|
16
|
+
1. 替换最新版本dll和so,升级到6.6.9
|
|
17
|
+
|
|
18
|
+
# 6.6.7.3版本
|
|
19
|
+
|
|
20
|
+
1. 替换最新版本dll,修复openctp升级导致的资金不显示的问题
|
|
21
|
+
|
|
22
|
+
# 6.6.7.2版本
|
|
23
|
+
|
|
24
|
+
1. 添加广州期货交易所枚举值字段支持
|
|
25
|
+
2. 替换最新版本dll和so,修复openctp升级导致的资金不显示的问题
|
|
26
|
+
|
|
27
|
+
# 6.6.7.1版本
|
|
28
|
+
|
|
29
|
+
1. 替换dll,增加平昨支持
|
|
30
|
+
|
|
31
|
+
# 6.6.7.0版本
|
|
32
|
+
|
|
33
|
+
1. 使用zoneinfo替换pytz库
|
|
34
|
+
2. 调整安装脚本setup.cfg,添加Python版本限制
|
|
35
|
+
|
|
36
|
+
# 6.5.1.3版本
|
|
37
|
+
|
|
38
|
+
1. 修复sdist打包缺失lib文件的问题
|
|
39
|
+
2. 完善函数和变量的类型声明
|
|
40
|
+
|
|
41
|
+
# 6.5.1.2版本
|
|
42
|
+
|
|
43
|
+
1. 调整安装脚本setup.py,支持Windows下安装时根据Python版本进行编译
|
|
44
|
+
2. 调整接口初始化时,接口名称的赋值方式
|
|
45
|
+
|
|
46
|
+
# 6.5.1.1版本
|
|
47
|
+
|
|
48
|
+
1. 增加行情TickData的成交额turnover字段
|
|
49
|
+
2. 增加对上交所和深交所股票模拟交易的支持
|
vnpy_tts-6.7.2.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present, Xiaoyou Chen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: vnpy_tts
|
|
3
|
+
Version: 6.7.2.2
|
|
4
|
+
Summary: TTS gateway for vn.py quant trading framework.
|
|
5
|
+
Keywords: quant,quantitative,investment,trading,algotrading,ctp
|
|
6
|
+
Author-Email: Xiaoyou Chen <xiaoyou.chen@mail.vnpy.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Operating System :: MacOS
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
20
|
+
Classifier: Natural Language :: Chinese (Simplified)
|
|
21
|
+
Project-URL: Homepage, https://www.vnpy.com
|
|
22
|
+
Project-URL: Documentation, https://www.vnpy.com/docs
|
|
23
|
+
Project-URL: Changes, https://github.com/vnpy/vnpy_tts/blob/master/CHANGELOG.md
|
|
24
|
+
Project-URL: Source, https://github.com/vnpy/vnpy_tts/
|
|
25
|
+
Project-URL: Forum, https://www.vnpy.com/forum
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: vnpy>=4.0.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# VeighNa框架的TTS仿真系统交易接口
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img src ="https://vnpy.oss-cn-shanghai.aliyuncs.com/vnpy-logo.png"/>
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<img src ="https://img.shields.io/badge/version-6.7.2.2-blueviolet.svg"/>
|
|
38
|
+
<img src ="https://img.shields.io/badge/platform-windows|linux-yellow.svg"/>
|
|
39
|
+
<img src ="https://img.shields.io/badge/python-3.10|3.11|3.12|3.13-blue.svg"/>
|
|
40
|
+
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
## 说明
|
|
44
|
+
|
|
45
|
+
基于TTS的6.7.2接口封装开发,对接类CTP的仿真交易环境。
|
|
46
|
+
|
|
47
|
+
目前TTS支持的仿真交易包括:
|
|
48
|
+
|
|
49
|
+
- 期货
|
|
50
|
+
- 中金所
|
|
51
|
+
- 上期所
|
|
52
|
+
- 大商所
|
|
53
|
+
- 郑商所
|
|
54
|
+
- 广期所
|
|
55
|
+
- 能交所
|
|
56
|
+
- 股票
|
|
57
|
+
- 上交所
|
|
58
|
+
- 深交所
|
|
59
|
+
|
|
60
|
+
## 安装
|
|
61
|
+
|
|
62
|
+
安装环境推荐基于3.9.0版本以上的【[**VeighNa Studio**](https://www.vnpy.com)】。
|
|
63
|
+
|
|
64
|
+
直接使用pip命令:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
pip install vnpy_tts
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
或者下载源代码后,解压后在cmd中运行:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
pip install .
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
使用源代码安装时需要进行C++编译,因此在执行上述命令之前请确保已经安装了【Visual Studio(Windows)】或者【GCC(Linux)】编译器。
|
|
78
|
+
|
|
79
|
+
如果需要以**开发模式**安装到当前Python环境,可以使用下述命令:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
pip install -e . --no-build-isolation --config-settings=build-dir=.\vnpy_tts\api
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## 使用
|
|
87
|
+
|
|
88
|
+
以脚本方式启动(script/run.py):
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
from vnpy.event import EventEngine
|
|
92
|
+
from vnpy.trader.engine import MainEngine
|
|
93
|
+
from vnpy.trader.ui import MainWindow, create_qapp
|
|
94
|
+
|
|
95
|
+
from vnpy_tts import TtsGateway
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def main():
|
|
99
|
+
"""主入口函数"""
|
|
100
|
+
qapp = create_qapp()
|
|
101
|
+
|
|
102
|
+
event_engine = EventEngine()
|
|
103
|
+
main_engine = MainEngine(event_engine)
|
|
104
|
+
main_engine.add_gateway(TtsGateway)
|
|
105
|
+
|
|
106
|
+
main_window = MainWindow(main_engine, event_engine)
|
|
107
|
+
main_window.showMaximized()
|
|
108
|
+
|
|
109
|
+
qapp.exec()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
main()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 连接
|
|
117
|
+
|
|
118
|
+
模拟账号可通过https://github.com/krenx1983/openctp 获取。
|
|
119
|
+
|
|
120
|
+
连接信息如下:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
{
|
|
124
|
+
"用户名": "xxxxxx",
|
|
125
|
+
"密码": "xxxxxx",
|
|
126
|
+
"经纪商代码": "",
|
|
127
|
+
"交易服务器": "121.36.146.182:20002",
|
|
128
|
+
"行情服务器": "121.36.146.182:20004",
|
|
129
|
+
"产品名称": "",
|
|
130
|
+
"授权编码": ""
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
7x24小时环境:
|
|
134
|
+
交易服务器 - 122.37.80.177:20002
|
|
135
|
+
行情服务器 - 122.37.80.177:20004
|
|
136
|
+
|
|
137
|
+
经纪商代码、产品名称、授权编码三项可以不填。
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# VeighNa框架的TTS仿真系统交易接口
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src ="https://vnpy.oss-cn-shanghai.aliyuncs.com/vnpy-logo.png"/>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src ="https://img.shields.io/badge/version-6.7.2.2-blueviolet.svg"/>
|
|
9
|
+
<img src ="https://img.shields.io/badge/platform-windows|linux-yellow.svg"/>
|
|
10
|
+
<img src ="https://img.shields.io/badge/python-3.10|3.11|3.12|3.13-blue.svg"/>
|
|
11
|
+
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
## 说明
|
|
15
|
+
|
|
16
|
+
基于TTS的6.7.2接口封装开发,对接类CTP的仿真交易环境。
|
|
17
|
+
|
|
18
|
+
目前TTS支持的仿真交易包括:
|
|
19
|
+
|
|
20
|
+
- 期货
|
|
21
|
+
- 中金所
|
|
22
|
+
- 上期所
|
|
23
|
+
- 大商所
|
|
24
|
+
- 郑商所
|
|
25
|
+
- 广期所
|
|
26
|
+
- 能交所
|
|
27
|
+
- 股票
|
|
28
|
+
- 上交所
|
|
29
|
+
- 深交所
|
|
30
|
+
|
|
31
|
+
## 安装
|
|
32
|
+
|
|
33
|
+
安装环境推荐基于3.9.0版本以上的【[**VeighNa Studio**](https://www.vnpy.com)】。
|
|
34
|
+
|
|
35
|
+
直接使用pip命令:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
pip install vnpy_tts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
或者下载源代码后,解压后在cmd中运行:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
pip install .
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
使用源代码安装时需要进行C++编译,因此在执行上述命令之前请确保已经安装了【Visual Studio(Windows)】或者【GCC(Linux)】编译器。
|
|
49
|
+
|
|
50
|
+
如果需要以**开发模式**安装到当前Python环境,可以使用下述命令:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install -e . --no-build-isolation --config-settings=build-dir=.\vnpy_tts\api
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## 使用
|
|
58
|
+
|
|
59
|
+
以脚本方式启动(script/run.py):
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
from vnpy.event import EventEngine
|
|
63
|
+
from vnpy.trader.engine import MainEngine
|
|
64
|
+
from vnpy.trader.ui import MainWindow, create_qapp
|
|
65
|
+
|
|
66
|
+
from vnpy_tts import TtsGateway
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def main():
|
|
70
|
+
"""主入口函数"""
|
|
71
|
+
qapp = create_qapp()
|
|
72
|
+
|
|
73
|
+
event_engine = EventEngine()
|
|
74
|
+
main_engine = MainEngine(event_engine)
|
|
75
|
+
main_engine.add_gateway(TtsGateway)
|
|
76
|
+
|
|
77
|
+
main_window = MainWindow(main_engine, event_engine)
|
|
78
|
+
main_window.showMaximized()
|
|
79
|
+
|
|
80
|
+
qapp.exec()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if __name__ == "__main__":
|
|
84
|
+
main()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 连接
|
|
88
|
+
|
|
89
|
+
模拟账号可通过https://github.com/krenx1983/openctp 获取。
|
|
90
|
+
|
|
91
|
+
连接信息如下:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
{
|
|
95
|
+
"用户名": "xxxxxx",
|
|
96
|
+
"密码": "xxxxxx",
|
|
97
|
+
"经纪商代码": "",
|
|
98
|
+
"交易服务器": "121.36.146.182:20002",
|
|
99
|
+
"行情服务器": "121.36.146.182:20004",
|
|
100
|
+
"产品名称": "",
|
|
101
|
+
"授权编码": ""
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
7x24小时环境:
|
|
105
|
+
交易服务器 - 122.37.80.177:20002
|
|
106
|
+
行情服务器 - 122.37.80.177:20004
|
|
107
|
+
|
|
108
|
+
经纪商代码、产品名称、授权编码三项可以不填。
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
project(
|
|
2
|
+
'vnpy_tts',
|
|
3
|
+
'cpp',
|
|
4
|
+
version: '6.7.2.2',
|
|
5
|
+
license: 'MIT',
|
|
6
|
+
meson_version: '>=1.7.0',
|
|
7
|
+
default_options: [
|
|
8
|
+
'buildtype=release',
|
|
9
|
+
'cpp_std=c++17',
|
|
10
|
+
'warning_level=2',
|
|
11
|
+
],
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# 导入文件系统和Python模块
|
|
15
|
+
fs = import('fs')
|
|
16
|
+
py = import('python').find_installation(pure: false)
|
|
17
|
+
py_dep = py.dependency()
|
|
18
|
+
|
|
19
|
+
# 获取pybind11路径
|
|
20
|
+
python_cmd = host_machine.system() == 'windows' ? 'python' : 'python3'
|
|
21
|
+
pybind11_include_dir = run_command(python_cmd, '-c', 'import pybind11; print(pybind11.get_include())', check: true).stdout().strip()
|
|
22
|
+
message('使用pybind11路径: ' + pybind11_include_dir)
|
|
23
|
+
|
|
24
|
+
# 获取编译器信息
|
|
25
|
+
cpp = meson.get_compiler('cpp')
|
|
26
|
+
compiler_id = cpp.get_id()
|
|
27
|
+
|
|
28
|
+
# 输出构建目标系统信息
|
|
29
|
+
message('构建目标系统: ' + host_machine.system())
|
|
30
|
+
|
|
31
|
+
# 初始化变量
|
|
32
|
+
thostmduserapi_lib = []
|
|
33
|
+
thosttraderapi_lib = []
|
|
34
|
+
extra_cpp_args = []
|
|
35
|
+
extra_link_args = []
|
|
36
|
+
|
|
37
|
+
# 初始化库变量
|
|
38
|
+
thostmduserapi_lib = []
|
|
39
|
+
thosttraderapi_lib = []
|
|
40
|
+
|
|
41
|
+
# 初始化其他编译选项
|
|
42
|
+
extra_link_args = []
|
|
43
|
+
install_rpath_value = ''
|
|
44
|
+
|
|
45
|
+
# 设置Windows特定编译选项
|
|
46
|
+
if host_machine.system() == 'windows'
|
|
47
|
+
# Windows编译器设置
|
|
48
|
+
add_project_arguments('/MT', language : 'cpp')
|
|
49
|
+
|
|
50
|
+
# 设置库目录
|
|
51
|
+
lib_dir = meson.current_source_dir() / 'vnpy_tts/api/libs'
|
|
52
|
+
api_dir = meson.current_source_dir() / 'vnpy_tts/api'
|
|
53
|
+
|
|
54
|
+
# 设置include目录
|
|
55
|
+
include_dirs = include_directories(
|
|
56
|
+
'vnpy_tts/api/include',
|
|
57
|
+
'vnpy_tts/api/vntts',
|
|
58
|
+
pybind11_include_dir,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# 定义CTP库
|
|
62
|
+
thostmduserapi_lib = cpp.find_library('thostmduserapi_se',
|
|
63
|
+
dirs: [lib_dir, api_dir],
|
|
64
|
+
required: true)
|
|
65
|
+
thosttraderapi_lib = cpp.find_library('thosttraderapi_se',
|
|
66
|
+
dirs: [lib_dir, api_dir],
|
|
67
|
+
required: true)
|
|
68
|
+
|
|
69
|
+
# 设置Linux特定编译选项
|
|
70
|
+
else # Linux
|
|
71
|
+
# Linux编译器设置
|
|
72
|
+
extra_cpp_args = [
|
|
73
|
+
'-std=c++17',
|
|
74
|
+
'-O3',
|
|
75
|
+
'-Wno-delete-incomplete',
|
|
76
|
+
'-Wno-sign-compare',
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
extra_link_args = [
|
|
80
|
+
'-lstdc++',
|
|
81
|
+
'-Wl,-rpath,$ORIGIN', # 添加rpath设置,使库能在运行时找到同目录下的动态库
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
# 设置库目录
|
|
85
|
+
lib_dir = meson.current_source_dir() / 'vnpy_tts/api'
|
|
86
|
+
|
|
87
|
+
# 设置include目录
|
|
88
|
+
include_dirs = include_directories(
|
|
89
|
+
'vnpy_tts/api/include',
|
|
90
|
+
'vnpy_tts/api/vntts',
|
|
91
|
+
pybind11_include_dir,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# 定义CTP库
|
|
95
|
+
thostmduserapi_lib = cpp.find_library('thostmduserapi_se',
|
|
96
|
+
dirs: [lib_dir],
|
|
97
|
+
required: true)
|
|
98
|
+
thosttraderapi_lib = cpp.find_library('thosttraderapi_se',
|
|
99
|
+
dirs: [lib_dir],
|
|
100
|
+
required: true)
|
|
101
|
+
endif
|
|
102
|
+
|
|
103
|
+
# 创建MD模块扩展
|
|
104
|
+
md_module = py.extension_module(
|
|
105
|
+
'vnttsmd',
|
|
106
|
+
sources: ['vnpy_tts/api/vntts/vnttsmd/vnttsmd.cpp'],
|
|
107
|
+
include_directories: include_dirs,
|
|
108
|
+
dependencies: [py_dep, thostmduserapi_lib],
|
|
109
|
+
cpp_args: extra_cpp_args,
|
|
110
|
+
link_args: extra_link_args,
|
|
111
|
+
install: true,
|
|
112
|
+
subdir: 'vnpy_tts/api'
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# 创建TD模块扩展
|
|
116
|
+
td_module = py.extension_module(
|
|
117
|
+
'vnttstd',
|
|
118
|
+
sources: ['vnpy_tts/api/vntts/vnttstd/vnttstd.cpp'],
|
|
119
|
+
include_directories: include_dirs,
|
|
120
|
+
dependencies: [py_dep, thosttraderapi_lib],
|
|
121
|
+
cpp_args: extra_cpp_args,
|
|
122
|
+
link_args: extra_link_args,
|
|
123
|
+
install: true,
|
|
124
|
+
subdir: 'vnpy_tts/api'
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# 安装Python源代码
|
|
128
|
+
python_files = [
|
|
129
|
+
['vnpy_tts/__init__.py', 'vnpy_tts'],
|
|
130
|
+
['vnpy_tts/api/__init__.py', 'vnpy_tts/api'],
|
|
131
|
+
['vnpy_tts/api/tts_constant.py', 'vnpy_tts/api'],
|
|
132
|
+
['vnpy_tts/gateway/__init__.py', 'vnpy_tts/gateway'],
|
|
133
|
+
['vnpy_tts/gateway/tts_gateway.py', 'vnpy_tts/gateway'],
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
foreach file : python_files
|
|
137
|
+
py.install_sources(
|
|
138
|
+
[file[0]],
|
|
139
|
+
pure: false,
|
|
140
|
+
subdir: file[1]
|
|
141
|
+
)
|
|
142
|
+
endforeach
|
|
143
|
+
|
|
144
|
+
# 安装API动态库文件
|
|
145
|
+
if host_machine.system() == 'windows'
|
|
146
|
+
api_libs = [
|
|
147
|
+
'vnpy_tts/api/thostmduserapi_se.dll',
|
|
148
|
+
'vnpy_tts/api/thosttraderapi_se.dll',
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
install_data(
|
|
152
|
+
api_libs,
|
|
153
|
+
install_dir: py.get_install_dir() / 'vnpy_tts/api'
|
|
154
|
+
)
|
|
155
|
+
else # Linux
|
|
156
|
+
api_libs = [
|
|
157
|
+
'vnpy_tts/api/libthostmduserapi_se.so',
|
|
158
|
+
'vnpy_tts/api/libthosttraderapi_se.so',
|
|
159
|
+
]
|
|
160
|
+
|
|
161
|
+
install_data(
|
|
162
|
+
api_libs,
|
|
163
|
+
install_dir: py.get_install_dir() / 'vnpy_tts/api'
|
|
164
|
+
)
|
|
165
|
+
endif
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "vnpy_tts"
|
|
3
|
+
version = "6.7.2.2"
|
|
4
|
+
description = "TTS gateway for vn.py quant trading framework."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = {text = "MIT"}
|
|
7
|
+
authors = [{name = "Xiaoyou Chen", email = "xiaoyou.chen@mail.vnpy.com"}]
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Development Status :: 5 - Production/Stable",
|
|
10
|
+
"Operating System :: Microsoft :: Windows",
|
|
11
|
+
"Operating System :: POSIX :: Linux",
|
|
12
|
+
"Operating System :: MacOS",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.10",
|
|
15
|
+
"Programming Language :: Python :: 3.11",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
19
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Natural Language :: Chinese (Simplified)",
|
|
22
|
+
]
|
|
23
|
+
requires-python = ">=3.10"
|
|
24
|
+
dependencies = ["vnpy>=4.0.0"]
|
|
25
|
+
keywords = ["quant", "quantitative", "investment", "trading", "algotrading", "ctp"]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
"Homepage" = "https://www.vnpy.com"
|
|
29
|
+
"Documentation" = "https://www.vnpy.com/docs"
|
|
30
|
+
"Changes" = "https://github.com/vnpy/vnpy_tts/blob/master/CHANGELOG.md"
|
|
31
|
+
"Source" = "https://github.com/vnpy/vnpy_tts/"
|
|
32
|
+
"Forum" = "https://www.vnpy.com/forum"
|
|
33
|
+
|
|
34
|
+
[build-system]
|
|
35
|
+
requires = [
|
|
36
|
+
"meson-python>=0.17.1",
|
|
37
|
+
"meson>=1.7.0",
|
|
38
|
+
"pybind11>=2.13.6",
|
|
39
|
+
]
|
|
40
|
+
build-backend = "mesonpy"
|
|
41
|
+
|
|
42
|
+
[tool.mesonpy]
|
|
43
|
+
args = ['--vsenv']
|
|
44
|
+
|
|
45
|
+
[tool.mesonpy.distribution]
|
|
46
|
+
include = [
|
|
47
|
+
"**/*.dll",
|
|
48
|
+
"**/*.so",
|
|
49
|
+
"**/*.pyd",
|
|
50
|
+
"**/*.h",
|
|
51
|
+
"**/*.cpp",
|
|
52
|
+
"**/*.lib",
|
|
53
|
+
"**/*.a",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
preserve-path = true
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
target-version = "py310"
|
|
60
|
+
output-format = "full"
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = [
|
|
64
|
+
"B", # flake8-bugbear
|
|
65
|
+
"E", # pycodestyle error
|
|
66
|
+
"F", # pyflakes
|
|
67
|
+
"UP", # pyupgrade
|
|
68
|
+
"W", # pycodestyle warning
|
|
69
|
+
]
|
|
70
|
+
ignore = ["E501"]
|
|
71
|
+
|
|
72
|
+
[tool.mypy]
|
|
73
|
+
python_version = "3.10"
|
|
74
|
+
warn_return_any = true
|
|
75
|
+
warn_unused_configs = true
|
|
76
|
+
disallow_untyped_defs = true
|
|
77
|
+
disallow_incomplete_defs = true
|
|
78
|
+
check_untyped_defs = true
|
|
79
|
+
disallow_untyped_decorators = true
|
|
80
|
+
no_implicit_optional = true
|
|
81
|
+
strict_optional = true
|
|
82
|
+
warn_redundant_casts = true
|
|
83
|
+
warn_unused_ignores = true
|
|
84
|
+
warn_no_return = true
|
|
85
|
+
ignore_missing_imports = true
|