enkeep-ctptest 6.7.7.9__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.
- enkeep_ctptest-6.7.7.9/.github/CODE_OF_CONDUCT.md +9 -0
- enkeep_ctptest-6.7.7.9/.github/ISSUE_TEMPLATE.md +19 -0
- enkeep_ctptest-6.7.7.9/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- enkeep_ctptest-6.7.7.9/.github/SUPPORT.md +8 -0
- enkeep_ctptest-6.7.7.9/.github/workflows/pythonapp.yml +32 -0
- enkeep_ctptest-6.7.7.9/.gitignore +38 -0
- enkeep_ctptest-6.7.7.9/CHANGELOG.md +58 -0
- enkeep_ctptest-6.7.7.9/LICENSE +21 -0
- enkeep_ctptest-6.7.7.9/PKG-INFO +112 -0
- enkeep_ctptest-6.7.7.9/README.md +87 -0
- enkeep_ctptest-6.7.7.9/meson.build +218 -0
- enkeep_ctptest-6.7.7.9/pyproject.toml +100 -0
- enkeep_ctptest-6.7.7.9/script/run.py +23 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/__init__.py +35 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/__init__.py +3 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/ctp_constant.py +1302 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_constant.py +1302 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_header_define.h +13 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_header_function.h +6 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_header_on.h +26 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_header_process.h +26 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_source_function.cpp +42 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_source_module.cpp +18 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_source_on.cpp +156 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_source_process.cpp +283 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_source_switch.cpp +78 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_md_source_task.cpp +211 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_struct.py +6414 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_header_define.h +154 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_header_function.h +222 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_header_on.h +308 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_header_process.h +308 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_source_function.cpp +1714 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_source_module.cpp +267 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_source_on.cpp +1848 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_source_process.cpp +6201 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_source_switch.cpp +924 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_td_source_task.cpp +2948 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/ctp_typedef.py +825 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/generate_api_functions.py +345 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/generate_data_type.py +76 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/generator/generate_struct.py +84 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/include/ctp/ThostFtdcMdApi.h +168 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/include/ctp/ThostFtdcTraderApi.h +914 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/include/ctp/ThostFtdcUserApiDataType.h +7068 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/include/ctp/ThostFtdcUserApiStruct.h +12386 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/libs/thostmduserapi_se.lib +0 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/libs/thosttraderapi_se.lib +0 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/libthostmduserapi_se.so +0 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/libthosttraderapi_se.so +0 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/thostmduserapi_se.dll +0 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/thosttraderapi_se.dll +0 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctp.h +146 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctp.sln +41 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctpmd/dllmain.cpp +19 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctpmd/stdafx.cpp +1 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctpmd/stdafx.h +17 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctpmd/targetver.h +8 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctpmd/vnctpmd.cpp +955 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctpmd/vnctpmd.h +209 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctpmd/vnctpmd.vcxproj +200 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctpmd/vnctpmd.vcxproj.filters +54 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctpmd/vnctpmd.vcxproj.user +4 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctptd/dllmain.cpp +19 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctptd/stdafx.cpp +1 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctptd/stdafx.h +16 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctptd/targetver.h +8 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctptd/vnctptd.cpp +14048 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctptd/vnctptd.h +1546 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctptd/vnctptd.vcxproj +198 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctptd/vnctptd.vcxproj.filters +54 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/api/vnctp/vnctptd/vnctptd.vcxproj.user +4 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/gateway/__init__.py +4 -0
- enkeep_ctptest-6.7.7.9/vnpy_ctptest/gateway/ctptest_gateway.py +891 -0
|
@@ -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_ctptest
|
|
29
|
+
- name: Build packages with uv
|
|
30
|
+
run: |
|
|
31
|
+
# Build source distribution and wheel distribution
|
|
32
|
+
uv build --sdist
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
|
|
22
|
+
# Executables
|
|
23
|
+
*.exe
|
|
24
|
+
*.out
|
|
25
|
+
*.app
|
|
26
|
+
|
|
27
|
+
# Python
|
|
28
|
+
*.pyc
|
|
29
|
+
dist/
|
|
30
|
+
build/
|
|
31
|
+
enkeep_ctptest.egg-info/
|
|
32
|
+
__pycache__/
|
|
33
|
+
|
|
34
|
+
# Visual Studio
|
|
35
|
+
.vs/
|
|
36
|
+
x64/
|
|
37
|
+
|
|
38
|
+
.DS_Store
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# 6.7.7.9版本
|
|
2
|
+
|
|
3
|
+
1. 适配enkeep_trade框架
|
|
4
|
+
2. 更新API版本到6.7.7
|
|
5
|
+
3. 修改包名为enkeep_ctptest
|
|
6
|
+
4. 使用Asset替代Product字段
|
|
7
|
+
5. 修改ContractData字段名(asset, price_tick, product_id)
|
|
8
|
+
|
|
9
|
+
# 6.7.7.0版本
|
|
10
|
+
|
|
11
|
+
1. 适配vnpy框架4.0版本
|
|
12
|
+
2. 更新API版本到6.7.7
|
|
13
|
+
|
|
14
|
+
# 6.7.2.1版本
|
|
15
|
+
|
|
16
|
+
1. 增加合约信息的最大和最小委托数量
|
|
17
|
+
|
|
18
|
+
# 6.7.2.0版本
|
|
19
|
+
|
|
20
|
+
1. 类型声明调整使用内置类型
|
|
21
|
+
2. 更新API版本到6.7.2
|
|
22
|
+
|
|
23
|
+
# 6.6.9.1版本
|
|
24
|
+
|
|
25
|
+
1. 增加对于不支持的委托状态过滤
|
|
26
|
+
2. 更新pybind11到2.11.1版本
|
|
27
|
+
|
|
28
|
+
# 6.6.9.0版本
|
|
29
|
+
|
|
30
|
+
1. API升级至6.6.9版本
|
|
31
|
+
2. 调整行情时间戳的处理方式,支持大商所的1毫秒级时间戳
|
|
32
|
+
|
|
33
|
+
# 6.6.7.3版本
|
|
34
|
+
|
|
35
|
+
1. 只有在授权码错误的情况下,才禁止再次发起认证
|
|
36
|
+
|
|
37
|
+
# 6.6.7.2版本
|
|
38
|
+
|
|
39
|
+
1. 补充Intel芯片的Mac系统安装时缺失.a静态库的问题
|
|
40
|
+
|
|
41
|
+
# 6.6.7.1版本
|
|
42
|
+
|
|
43
|
+
1. 增加苹果Mac系统支持
|
|
44
|
+
2. 增加收到不支持委托类型时的日志输出
|
|
45
|
+
|
|
46
|
+
# 6.6.7.0版本
|
|
47
|
+
|
|
48
|
+
1. API升级至6.6.7版本
|
|
49
|
+
2. 使用zoneinfo替换pytz库
|
|
50
|
+
3. 调整安装脚本setup.cfg,添加Python版本限制
|
|
51
|
+
|
|
52
|
+
# 6.5.1.12版本
|
|
53
|
+
|
|
54
|
+
1. 添加广州期货交易所枚举值字段支持
|
|
55
|
+
|
|
56
|
+
# 6.5.1.11版本
|
|
57
|
+
|
|
58
|
+
1. 增加对于委托函数返回值为非0(请求失败)状态的处理
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
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,112 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: enkeep_ctptest
|
|
3
|
+
Version: 6.7.7.9
|
|
4
|
+
Summary: CTP test gateway for enkeep_trade quant trading framework.
|
|
5
|
+
Keywords: quant,quantitative,investment,trading,algotrading,ctp
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
10
|
+
Classifier: Operating System :: MacOS
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Natural Language :: Chinese (Simplified)
|
|
20
|
+
Project-URL: Homepage, https://cnb.cool/enkeep/enkeep_ctptest
|
|
21
|
+
Project-URL: Source, https://cnb.cool/enkeep/enkeep_ctptest
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: pybind11>=2.9.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# enkeep框架的CTP测试环境底层接口
|
|
27
|
+
|
|
28
|
+
## 说明
|
|
29
|
+
|
|
30
|
+
基于CTP期货版的6.7.7接口封装开发,接口中自带的是【穿透式测试环境】的dll文件。
|
|
31
|
+
|
|
32
|
+
# tips:
|
|
33
|
+
|
|
34
|
+
## 打包
|
|
35
|
+
windows:
|
|
36
|
+
```
|
|
37
|
+
pip install build
|
|
38
|
+
|
|
39
|
+
python -m build .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
linux:
|
|
43
|
+
使用 cibuildwheel 自动化构建
|
|
44
|
+
如果你希望自动化整个流程,可以使用 cibuildwheel,它支持多平台自动构建和打包。
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
pip install cibuildwheel
|
|
48
|
+
|
|
49
|
+
cibuildwheel --output-dir dist
|
|
50
|
+
```
|
|
51
|
+
## 发布
|
|
52
|
+
|
|
53
|
+
先安装一下 twine:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
python -m pip install twine
|
|
57
|
+
twine upload dist/*
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# 推送到 coding-pypi
|
|
61
|
+
twine upload -r coding-pypi dist/*
|
|
62
|
+
```
|
|
63
|
+
没有账户去注册一个 https://pypi.org/
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## 使用
|
|
67
|
+
|
|
68
|
+
以脚本方式启动(script/run.py):
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
from enkeep_trade.event import EventEngine
|
|
72
|
+
from enkeep_trade.trader.engine import MainEngine
|
|
73
|
+
from enkeep_trade.trader.ui import MainWindow, create_qapp
|
|
74
|
+
|
|
75
|
+
from enkeep_ctptest import CtptestGateway
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def main():
|
|
79
|
+
"""主入口函数"""
|
|
80
|
+
qapp = create_qapp()
|
|
81
|
+
|
|
82
|
+
event_engine = EventEngine()
|
|
83
|
+
main_engine = MainEngine(event_engine)
|
|
84
|
+
main_engine.add_gateway(CtptestGateway)
|
|
85
|
+
|
|
86
|
+
main_window = MainWindow(main_engine, event_engine)
|
|
87
|
+
main_window.showMaximized()
|
|
88
|
+
|
|
89
|
+
qapp.exec()
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
if __name__ == "__main__":
|
|
93
|
+
main()
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Mac系统支持
|
|
97
|
+
|
|
98
|
+
由于新版本CTP的Mac系统API项目结构发生了较大变化,改为了使用framework目录的结构,因此无法再直接从PyPI下载预编译好的wheel二进制包进行安装。
|
|
99
|
+
|
|
100
|
+
用户需要克隆(或下载)本仓库的源代码到本地后自行编译安装,具体命令如下:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
git clone https://cnb.cool/enkeep/enkeep_ctptest.git
|
|
104
|
+
|
|
105
|
+
cd enkeep_ctptest
|
|
106
|
+
|
|
107
|
+
pip3 install .
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
相关注意事项如下:
|
|
111
|
+
|
|
112
|
+
源码编译需要依赖XCode开发工具中的C++编译器,请务必先安装好。
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# enkeep框架的CTP测试环境底层接口
|
|
2
|
+
|
|
3
|
+
## 说明
|
|
4
|
+
|
|
5
|
+
基于CTP期货版的6.7.7接口封装开发,接口中自带的是【穿透式测试环境】的dll文件。
|
|
6
|
+
|
|
7
|
+
# tips:
|
|
8
|
+
|
|
9
|
+
## 打包
|
|
10
|
+
windows:
|
|
11
|
+
```
|
|
12
|
+
pip install build
|
|
13
|
+
|
|
14
|
+
python -m build .
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
linux:
|
|
18
|
+
使用 cibuildwheel 自动化构建
|
|
19
|
+
如果你希望自动化整个流程,可以使用 cibuildwheel,它支持多平台自动构建和打包。
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
pip install cibuildwheel
|
|
23
|
+
|
|
24
|
+
cibuildwheel --output-dir dist
|
|
25
|
+
```
|
|
26
|
+
## 发布
|
|
27
|
+
|
|
28
|
+
先安装一下 twine:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
python -m pip install twine
|
|
32
|
+
twine upload dist/*
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# 推送到 coding-pypi
|
|
36
|
+
twine upload -r coding-pypi dist/*
|
|
37
|
+
```
|
|
38
|
+
没有账户去注册一个 https://pypi.org/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## 使用
|
|
42
|
+
|
|
43
|
+
以脚本方式启动(script/run.py):
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
from enkeep_trade.event import EventEngine
|
|
47
|
+
from enkeep_trade.trader.engine import MainEngine
|
|
48
|
+
from enkeep_trade.trader.ui import MainWindow, create_qapp
|
|
49
|
+
|
|
50
|
+
from enkeep_ctptest import CtptestGateway
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def main():
|
|
54
|
+
"""主入口函数"""
|
|
55
|
+
qapp = create_qapp()
|
|
56
|
+
|
|
57
|
+
event_engine = EventEngine()
|
|
58
|
+
main_engine = MainEngine(event_engine)
|
|
59
|
+
main_engine.add_gateway(CtptestGateway)
|
|
60
|
+
|
|
61
|
+
main_window = MainWindow(main_engine, event_engine)
|
|
62
|
+
main_window.showMaximized()
|
|
63
|
+
|
|
64
|
+
qapp.exec()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
main()
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Mac系统支持
|
|
72
|
+
|
|
73
|
+
由于新版本CTP的Mac系统API项目结构发生了较大变化,改为了使用framework目录的结构,因此无法再直接从PyPI下载预编译好的wheel二进制包进行安装。
|
|
74
|
+
|
|
75
|
+
用户需要克隆(或下载)本仓库的源代码到本地后自行编译安装,具体命令如下:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
git clone https://cnb.cool/enkeep/enkeep_ctptest.git
|
|
79
|
+
|
|
80
|
+
cd enkeep_ctptest
|
|
81
|
+
|
|
82
|
+
pip3 install .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
相关注意事项如下:
|
|
86
|
+
|
|
87
|
+
源码编译需要依赖XCode开发工具中的C++编译器,请务必先安装好。
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
project(
|
|
2
|
+
'enkeep_ctptest',
|
|
3
|
+
'cpp',
|
|
4
|
+
version: '6.7.7.9',
|
|
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() / 'enkeep_ctptest/api/libs'
|
|
52
|
+
api_dir = meson.current_source_dir() / 'enkeep_ctptest/api'
|
|
53
|
+
|
|
54
|
+
# 设置include目录
|
|
55
|
+
include_dirs = include_directories(
|
|
56
|
+
'enkeep_ctptest/api/include',
|
|
57
|
+
'enkeep_ctptest/api/vnctp',
|
|
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
|
+
# 设置Mac特定编译选项
|
|
70
|
+
elif host_machine.system() == 'darwin'
|
|
71
|
+
# Mac编译器设置
|
|
72
|
+
extra_cpp_args = [
|
|
73
|
+
'-std=c++11',
|
|
74
|
+
'-mmacosx-version-min=10.12',
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
# 设置链接参数,包括@rpath到@loader_path的修改
|
|
78
|
+
extra_link_args = [
|
|
79
|
+
'-mmacosx-version-min=10.12',
|
|
80
|
+
'-Wl,-rpath,@loader_path',
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
# 设置库目录
|
|
84
|
+
lib_dir = meson.current_source_dir() / 'enkeep_ctptest/api/libs'
|
|
85
|
+
api_dir = meson.current_source_dir() / 'enkeep_ctptest/api'
|
|
86
|
+
|
|
87
|
+
# 设置include目录
|
|
88
|
+
include_dirs = include_directories(
|
|
89
|
+
'enkeep_ctptest/api/include/mac',
|
|
90
|
+
'enkeep_ctptest/api/vnctp',
|
|
91
|
+
pybind11_include_dir,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# 定义Mac Framework依赖
|
|
95
|
+
thostmduserapi_lib = declare_dependency(
|
|
96
|
+
dependencies: [py_dep],
|
|
97
|
+
link_args: [
|
|
98
|
+
'-F', meson.current_source_dir() / 'enkeep_ctptest/api',
|
|
99
|
+
'-framework', 'thostmduserapi_se'
|
|
100
|
+
]
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
thosttraderapi_lib = declare_dependency(
|
|
104
|
+
dependencies: [py_dep],
|
|
105
|
+
link_args: [
|
|
106
|
+
'-F', meson.current_source_dir() / 'enkeep_ctptest/api',
|
|
107
|
+
'-framework', 'thosttraderapi_se'
|
|
108
|
+
]
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# 设置Linux特定编译选项
|
|
112
|
+
else # Linux
|
|
113
|
+
# Linux编译器设置
|
|
114
|
+
extra_cpp_args = [
|
|
115
|
+
'-std=c++17',
|
|
116
|
+
'-O3',
|
|
117
|
+
'-Wno-delete-incomplete',
|
|
118
|
+
'-Wno-sign-compare',
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
extra_link_args = [
|
|
122
|
+
'-lstdc++',
|
|
123
|
+
'-Wl,-rpath,$ORIGIN', # 添加rpath设置,使库能在运行时找到同目录下的动态库
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
# 设置库目录
|
|
127
|
+
lib_dir = meson.current_source_dir() / 'enkeep_ctptest/api'
|
|
128
|
+
|
|
129
|
+
# 设置include目录
|
|
130
|
+
include_dirs = include_directories(
|
|
131
|
+
'enkeep_ctptest/api/include',
|
|
132
|
+
'enkeep_ctptest/api/vnctp',
|
|
133
|
+
pybind11_include_dir,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
# 定义CTP库
|
|
137
|
+
thostmduserapi_lib = cpp.find_library('thostmduserapi_se',
|
|
138
|
+
dirs: [lib_dir],
|
|
139
|
+
required: true)
|
|
140
|
+
thosttraderapi_lib = cpp.find_library('thosttraderapi_se',
|
|
141
|
+
dirs: [lib_dir],
|
|
142
|
+
required: true)
|
|
143
|
+
endif
|
|
144
|
+
|
|
145
|
+
# 创建MD模块扩展
|
|
146
|
+
md_module = py.extension_module(
|
|
147
|
+
'vnctpmd',
|
|
148
|
+
sources: ['enkeep_ctptest/api/vnctp/vnctpmd/vnctpmd.cpp'],
|
|
149
|
+
include_directories: include_dirs,
|
|
150
|
+
dependencies: [py_dep, thostmduserapi_lib],
|
|
151
|
+
cpp_args: extra_cpp_args,
|
|
152
|
+
link_args: extra_link_args,
|
|
153
|
+
install: true,
|
|
154
|
+
subdir: 'enkeep_ctptest/api'
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# 创建TD模块扩展
|
|
158
|
+
td_module = py.extension_module(
|
|
159
|
+
'vnctptd',
|
|
160
|
+
sources: ['enkeep_ctptest/api/vnctp/vnctptd/vnctptd.cpp'],
|
|
161
|
+
include_directories: include_dirs,
|
|
162
|
+
dependencies: [py_dep, thosttraderapi_lib],
|
|
163
|
+
cpp_args: extra_cpp_args,
|
|
164
|
+
link_args: extra_link_args,
|
|
165
|
+
install: true,
|
|
166
|
+
subdir: 'enkeep_ctptest/api'
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
# 安装Python源代码
|
|
170
|
+
python_files = [
|
|
171
|
+
['enkeep_ctptest/__init__.py', 'enkeep_ctptest'],
|
|
172
|
+
['enkeep_ctptest/api/__init__.py', 'enkeep_ctptest/api'],
|
|
173
|
+
['enkeep_ctptest/api/ctp_constant.py', 'enkeep_ctptest/api'],
|
|
174
|
+
['enkeep_ctptest/gateway/__init__.py', 'enkeep_ctptest/gateway'],
|
|
175
|
+
['enkeep_ctptest/gateway/ctptest_gateway.py', 'enkeep_ctptest/gateway'],
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
foreach file : python_files
|
|
179
|
+
py.install_sources(
|
|
180
|
+
[file[0]],
|
|
181
|
+
pure: false,
|
|
182
|
+
subdir: file[1]
|
|
183
|
+
)
|
|
184
|
+
endforeach
|
|
185
|
+
|
|
186
|
+
# 安装API动态库文件
|
|
187
|
+
if host_machine.system() == 'windows'
|
|
188
|
+
api_libs = [
|
|
189
|
+
'enkeep_ctptest/api/thostmduserapi_se.dll',
|
|
190
|
+
'enkeep_ctptest/api/thosttraderapi_se.dll',
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
install_data(
|
|
194
|
+
api_libs,
|
|
195
|
+
install_dir: py.get_install_dir() / 'enkeep_ctptest/api'
|
|
196
|
+
)
|
|
197
|
+
elif host_machine.system() == 'darwin'
|
|
198
|
+
# 安装Mac Framework文件夹
|
|
199
|
+
install_subdir(
|
|
200
|
+
'enkeep_ctptest/api/thostmduserapi_se.framework',
|
|
201
|
+
install_dir: py.get_install_dir() / 'enkeep_ctptest/api'
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
install_subdir(
|
|
205
|
+
'enkeep_ctptest/api/thosttraderapi_se.framework',
|
|
206
|
+
install_dir: py.get_install_dir() / 'enkeep_ctptest/api'
|
|
207
|
+
)
|
|
208
|
+
else # Linux
|
|
209
|
+
api_libs = [
|
|
210
|
+
'enkeep_ctptest/api/libthostmduserapi_se.so',
|
|
211
|
+
'enkeep_ctptest/api/libthosttraderapi_se.so',
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
install_data(
|
|
215
|
+
api_libs,
|
|
216
|
+
install_dir: py.get_install_dir() / 'enkeep_ctptest/api'
|
|
217
|
+
)
|
|
218
|
+
endif
|