qmt-rpyc 0.3.0rc3__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.
- qmt_rpyc-0.3.0rc3/LICENSE +21 -0
- qmt_rpyc-0.3.0rc3/PKG-INFO +230 -0
- qmt_rpyc-0.3.0rc3/README.md +192 -0
- qmt_rpyc-0.3.0rc3/pyproject.toml +62 -0
- qmt_rpyc-0.3.0rc3/setup.cfg +4 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/__init__.py +4 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/cli/__init__.py +1 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/cli/client.py +495 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/cli/server.py +599 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/client.py +328 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/config.py +164 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/exceptions.py +24 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/protocol.py +186 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/proxy.py +124 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/py.typed +1 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/self_test.py +508 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/__init__.py +1 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/api_surface.py +111 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/auth_limiter.py +45 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/connection.py +646 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/datetime_patch.py +129 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/download_manager.py +201 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/environment.py +170 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/event_bus.py +67 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/logging_config.py +44 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/main.py +279 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/serializer.py +98 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/server/service.py +541 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc/version.py +3 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc.egg-info/PKG-INFO +230 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc.egg-info/SOURCES.txt +51 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc.egg-info/dependency_links.txt +1 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc.egg-info/entry_points.txt +3 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc.egg-info/requires.txt +20 -0
- qmt_rpyc-0.3.0rc3/src/qmt_rpyc.egg-info/top_level.txt +1 -0
- qmt_rpyc-0.3.0rc3/tests/test_api_surface.py +83 -0
- qmt_rpyc-0.3.0rc3/tests/test_auth_limiter.py +36 -0
- qmt_rpyc-0.3.0rc3/tests/test_cli.py +134 -0
- qmt_rpyc-0.3.0rc3/tests/test_client.py +239 -0
- qmt_rpyc-0.3.0rc3/tests/test_client_exceptions.py +33 -0
- qmt_rpyc-0.3.0rc3/tests/test_config.py +55 -0
- qmt_rpyc-0.3.0rc3/tests/test_connection.py +271 -0
- qmt_rpyc-0.3.0rc3/tests/test_datetime_patch.py +21 -0
- qmt_rpyc-0.3.0rc3/tests/test_download_manager.py +117 -0
- qmt_rpyc-0.3.0rc3/tests/test_event_bus.py +92 -0
- qmt_rpyc-0.3.0rc3/tests/test_integration.py +111 -0
- qmt_rpyc-0.3.0rc3/tests/test_live_integration.py +943 -0
- qmt_rpyc-0.3.0rc3/tests/test_main.py +125 -0
- qmt_rpyc-0.3.0rc3/tests/test_protocol.py +60 -0
- qmt_rpyc-0.3.0rc3/tests/test_proxy.py +84 -0
- qmt_rpyc-0.3.0rc3/tests/test_serializer.py +121 -0
- qmt_rpyc-0.3.0rc3/tests/test_server_cli.py +51 -0
- qmt_rpyc-0.3.0rc3/tests/test_service.py +257 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 qmt-rpyc contributors
|
|
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,230 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qmt-rpyc
|
|
3
|
+
Version: 0.3.0rc3
|
|
4
|
+
Summary: Cross-platform RPyC bridge for QMT/MiniQMT xtquant
|
|
5
|
+
Author: qmt-rpyc contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/realqiyan/qmt-rpyc
|
|
8
|
+
Project-URL: Repository, https://github.com/realqiyan/qmt-rpyc
|
|
9
|
+
Project-URL: Issues, https://github.com/realqiyan/qmt-rpyc/issues
|
|
10
|
+
Keywords: qmt,miniqmt,xtquant,rpyc,trading
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: rpyc<7,>=6.0
|
|
24
|
+
Requires-Dist: platformdirs>=3.0
|
|
25
|
+
Requires-Dist: tomli>=2.0; python_version < "3.11"
|
|
26
|
+
Requires-Dist: tomli-w>=1.0
|
|
27
|
+
Requires-Dist: keyring>=25.6
|
|
28
|
+
Provides-Extra: server
|
|
29
|
+
Requires-Dist: python-dotenv>=1.0; (python_version >= "3.10" and python_version < "3.12") and extra == "server"
|
|
30
|
+
Requires-Dist: numpy<2,>=1.24; (python_version >= "3.10" and python_version < "3.12") and extra == "server"
|
|
31
|
+
Requires-Dist: pandas<3,>=2; (python_version >= "3.10" and python_version < "3.12") and extra == "server"
|
|
32
|
+
Requires-Dist: psutil>=5; (python_version >= "3.10" and python_version < "3.12") and extra == "server"
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
36
|
+
Requires-Dist: twine>=5; extra == "dev"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# qmt-rpyc
|
|
40
|
+
|
|
41
|
+
[English](README.en.md)
|
|
42
|
+
|
|
43
|
+
qmt-rpyc 通过 RPyC 将 Windows QMT/MiniQMT 中的 broker-customized
|
|
44
|
+
`xtquant` SDK 暴露给 Linux、macOS 和 Windows 客户端。
|
|
45
|
+
|
|
46
|
+
> 当前版本为 `0.3.0rc3`。请先在模拟或只读环境验证,再用于实盘。
|
|
47
|
+
|
|
48
|
+
## 安装
|
|
49
|
+
|
|
50
|
+
### 客户端
|
|
51
|
+
|
|
52
|
+
要求 Python 3.9 或更高版本。
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install qmt-rpyc
|
|
56
|
+
qmt-rpyc-client init --profile office
|
|
57
|
+
qmt-rpyc-client check --profile office
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Python SDK:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from qmt_rpyc import QmtClient
|
|
64
|
+
|
|
65
|
+
with QmtClient.connect(
|
|
66
|
+
"192.168.1.20",
|
|
67
|
+
port=18812,
|
|
68
|
+
auth_key="shared-secret-123456",
|
|
69
|
+
) as client:
|
|
70
|
+
print(client.health())
|
|
71
|
+
print(client.xtdata.get_instrument_detail("600000.SH"))
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
也可以使用初始化后的 profile:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from qmt_rpyc import QmtClient
|
|
78
|
+
|
|
79
|
+
with QmtClient.connect_profile("office") as client:
|
|
80
|
+
print(client.health())
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Windows 服务端
|
|
84
|
+
|
|
85
|
+
要求:
|
|
86
|
+
|
|
87
|
+
- MiniQMT 已安装、登录并运行。
|
|
88
|
+
- 64 位 Python 3.10 或 3.11,与券商 `xtquant` 扩展匹配。
|
|
89
|
+
- 安装期间能够访问 PyPI。
|
|
90
|
+
|
|
91
|
+
从 GitHub Release 解压 Windows 安装包后运行:
|
|
92
|
+
|
|
93
|
+
```bat
|
|
94
|
+
install-server.bat
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
安装器在 `%LOCALAPPDATA%\qmt-rpyc` 创建专用虚拟环境,然后进入配置
|
|
98
|
+
向导。也可手工安装:
|
|
99
|
+
|
|
100
|
+
```bat
|
|
101
|
+
py -3.11 -m venv %LOCALAPPDATA%\qmt-rpyc\venv
|
|
102
|
+
%LOCALAPPDATA%\qmt-rpyc\venv\Scripts\pip.exe install "qmt-rpyc[server]"
|
|
103
|
+
%LOCALAPPDATA%\qmt-rpyc\venv\Scripts\qmt-rpyc-server.exe init
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
日常操作:
|
|
107
|
+
|
|
108
|
+
```bat
|
|
109
|
+
qmt-rpyc-server check
|
|
110
|
+
qmt-rpyc-server start
|
|
111
|
+
qmt-rpyc-server status
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`start` 在前台运行,启动时如果无法连接 MiniQMT 或订阅配置账户会直接
|
|
115
|
+
失败。运行过程中断线仍会执行心跳检查和指数退避重连。
|
|
116
|
+
|
|
117
|
+
## 动态 CLI
|
|
118
|
+
|
|
119
|
+
API 列表和帮助来自实际 Windows 部署:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
qmt-rpyc-client api --profile office list xtdata
|
|
123
|
+
qmt-rpyc-client api --profile office describe trader query_stock_asset
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
调用只接受 JSON:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
qmt-rpyc-client call --profile office xtdata get_full_tick \
|
|
130
|
+
--args '[["600000.SH"]]'
|
|
131
|
+
|
|
132
|
+
qmt-rpyc-client call --profile office trader query_stock_asset \
|
|
133
|
+
--args '["YOUR_ACCOUNT_ID"]'
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
交易方法必须显式确认:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
qmt-rpyc-client call --profile office trader order_stock \
|
|
140
|
+
--args '["YOUR_ACCOUNT_ID","600000.SH",23,100,5,10.0]' \
|
|
141
|
+
--confirm-trading
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
未知写操作要求 `--confirm-write`。带 `callback` 参数的方法首版不支持
|
|
145
|
+
CLI 调用。
|
|
146
|
+
|
|
147
|
+
事件、下载和自检:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
qmt-rpyc-client events --profile office --types order,trade,disconnect
|
|
151
|
+
qmt-rpyc-client download --profile office start download_history_data \
|
|
152
|
+
--args '["600000.SH","1d","20240101","20241231"]'
|
|
153
|
+
qmt-rpyc-client download --profile office status TASK_ID
|
|
154
|
+
qmt-rpyc-client self-test --profile office
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 配置
|
|
158
|
+
|
|
159
|
+
服务端默认配置:
|
|
160
|
+
|
|
161
|
+
```text
|
|
162
|
+
%LOCALAPPDATA%\qmt-rpyc\config.env
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`qmt-rpyc-server init` 会:
|
|
166
|
+
|
|
167
|
+
- 尝试读取当前目录 `.env`,确认后导入。
|
|
168
|
+
- 探测运行中的 MiniQMT、`userdata_mini`、账户和 `xtquant`。
|
|
169
|
+
- 推荐私有 LAN 地址,不静默绑定所有网卡。
|
|
170
|
+
- 默认生成强认证密钥,也允许用户自定义。
|
|
171
|
+
- 经确认后在受管 venv 中建立指向券商 `xtquant` 的 junction。
|
|
172
|
+
|
|
173
|
+
客户端 profile 使用平台标准配置目录。认证密钥默认保存到 Windows
|
|
174
|
+
Credential Manager、macOS Keychain 或 Linux Secret Service。没有可用
|
|
175
|
+
keyring 时,可选择环境变量、每次隐藏输入或明确确认后的配置文件存储。
|
|
176
|
+
|
|
177
|
+
配置优先级:
|
|
178
|
+
|
|
179
|
+
```text
|
|
180
|
+
命令行 > 环境变量 > profile > 默认值
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 安全边界
|
|
184
|
+
|
|
185
|
+
- HMAC 在创建 RPyC Connection 之前完成,未认证连接无法进入
|
|
186
|
+
RPyC/pickle 协议层。
|
|
187
|
+
- 认证后保留 `rpyc.classic.obtain()`,响应一次性物化为本地对象。
|
|
188
|
+
- 共享密钥持有者对该服务实例拥有完整信任,可以访问全部账户数据和交易
|
|
189
|
+
API。
|
|
190
|
+
- HMAC 只认证,不加密流量。仅应部署在受信任私有网络;跨公网或不可信
|
|
191
|
+
网络必须使用 TLS 或 VPN。
|
|
192
|
+
- 防火墙规则只能通过显式的
|
|
193
|
+
`qmt-rpyc-server firewall add/remove` 管理。
|
|
194
|
+
- 安全问题请按 [SECURITY.md](SECURITY.md) 私密报告。
|
|
195
|
+
|
|
196
|
+
## 迁移
|
|
197
|
+
|
|
198
|
+
0.3.0 使用新的专用命名空间,不提供旧包兼容层:
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
# 旧
|
|
202
|
+
from client import QmtClient
|
|
203
|
+
|
|
204
|
+
# 新
|
|
205
|
+
from qmt_rpyc import QmtClient
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
完整说明见 [MIGRATION.md](MIGRATION.md)。
|
|
209
|
+
|
|
210
|
+
## 开发与测试
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
python -m venv .venv
|
|
214
|
+
.venv/bin/python -m pip install -e ".[dev]"
|
|
215
|
+
.venv/bin/python -m pytest tests/ -v -k "not live"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
真实 QMT 测试:
|
|
219
|
+
|
|
220
|
+
```bat
|
|
221
|
+
scripts\test_server.bat
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## 法律声明
|
|
225
|
+
|
|
226
|
+
本项目不包含、不分发 `xtquant`、QMT 或 MiniQMT。相关软件、商标、数据和
|
|
227
|
+
许可归其权利方所有。本项目不提供投资建议;实盘交易和部署风险由使用者
|
|
228
|
+
自行承担。
|
|
229
|
+
|
|
230
|
+
本项目采用 [MIT License](LICENSE)。
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# qmt-rpyc
|
|
2
|
+
|
|
3
|
+
[English](README.en.md)
|
|
4
|
+
|
|
5
|
+
qmt-rpyc 通过 RPyC 将 Windows QMT/MiniQMT 中的 broker-customized
|
|
6
|
+
`xtquant` SDK 暴露给 Linux、macOS 和 Windows 客户端。
|
|
7
|
+
|
|
8
|
+
> 当前版本为 `0.3.0rc3`。请先在模拟或只读环境验证,再用于实盘。
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
### 客户端
|
|
13
|
+
|
|
14
|
+
要求 Python 3.9 或更高版本。
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install qmt-rpyc
|
|
18
|
+
qmt-rpyc-client init --profile office
|
|
19
|
+
qmt-rpyc-client check --profile office
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Python SDK:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from qmt_rpyc import QmtClient
|
|
26
|
+
|
|
27
|
+
with QmtClient.connect(
|
|
28
|
+
"192.168.1.20",
|
|
29
|
+
port=18812,
|
|
30
|
+
auth_key="shared-secret-123456",
|
|
31
|
+
) as client:
|
|
32
|
+
print(client.health())
|
|
33
|
+
print(client.xtdata.get_instrument_detail("600000.SH"))
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
也可以使用初始化后的 profile:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from qmt_rpyc import QmtClient
|
|
40
|
+
|
|
41
|
+
with QmtClient.connect_profile("office") as client:
|
|
42
|
+
print(client.health())
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Windows 服务端
|
|
46
|
+
|
|
47
|
+
要求:
|
|
48
|
+
|
|
49
|
+
- MiniQMT 已安装、登录并运行。
|
|
50
|
+
- 64 位 Python 3.10 或 3.11,与券商 `xtquant` 扩展匹配。
|
|
51
|
+
- 安装期间能够访问 PyPI。
|
|
52
|
+
|
|
53
|
+
从 GitHub Release 解压 Windows 安装包后运行:
|
|
54
|
+
|
|
55
|
+
```bat
|
|
56
|
+
install-server.bat
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
安装器在 `%LOCALAPPDATA%\qmt-rpyc` 创建专用虚拟环境,然后进入配置
|
|
60
|
+
向导。也可手工安装:
|
|
61
|
+
|
|
62
|
+
```bat
|
|
63
|
+
py -3.11 -m venv %LOCALAPPDATA%\qmt-rpyc\venv
|
|
64
|
+
%LOCALAPPDATA%\qmt-rpyc\venv\Scripts\pip.exe install "qmt-rpyc[server]"
|
|
65
|
+
%LOCALAPPDATA%\qmt-rpyc\venv\Scripts\qmt-rpyc-server.exe init
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
日常操作:
|
|
69
|
+
|
|
70
|
+
```bat
|
|
71
|
+
qmt-rpyc-server check
|
|
72
|
+
qmt-rpyc-server start
|
|
73
|
+
qmt-rpyc-server status
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`start` 在前台运行,启动时如果无法连接 MiniQMT 或订阅配置账户会直接
|
|
77
|
+
失败。运行过程中断线仍会执行心跳检查和指数退避重连。
|
|
78
|
+
|
|
79
|
+
## 动态 CLI
|
|
80
|
+
|
|
81
|
+
API 列表和帮助来自实际 Windows 部署:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
qmt-rpyc-client api --profile office list xtdata
|
|
85
|
+
qmt-rpyc-client api --profile office describe trader query_stock_asset
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
调用只接受 JSON:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
qmt-rpyc-client call --profile office xtdata get_full_tick \
|
|
92
|
+
--args '[["600000.SH"]]'
|
|
93
|
+
|
|
94
|
+
qmt-rpyc-client call --profile office trader query_stock_asset \
|
|
95
|
+
--args '["YOUR_ACCOUNT_ID"]'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
交易方法必须显式确认:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
qmt-rpyc-client call --profile office trader order_stock \
|
|
102
|
+
--args '["YOUR_ACCOUNT_ID","600000.SH",23,100,5,10.0]' \
|
|
103
|
+
--confirm-trading
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
未知写操作要求 `--confirm-write`。带 `callback` 参数的方法首版不支持
|
|
107
|
+
CLI 调用。
|
|
108
|
+
|
|
109
|
+
事件、下载和自检:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
qmt-rpyc-client events --profile office --types order,trade,disconnect
|
|
113
|
+
qmt-rpyc-client download --profile office start download_history_data \
|
|
114
|
+
--args '["600000.SH","1d","20240101","20241231"]'
|
|
115
|
+
qmt-rpyc-client download --profile office status TASK_ID
|
|
116
|
+
qmt-rpyc-client self-test --profile office
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## 配置
|
|
120
|
+
|
|
121
|
+
服务端默认配置:
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
%LOCALAPPDATA%\qmt-rpyc\config.env
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`qmt-rpyc-server init` 会:
|
|
128
|
+
|
|
129
|
+
- 尝试读取当前目录 `.env`,确认后导入。
|
|
130
|
+
- 探测运行中的 MiniQMT、`userdata_mini`、账户和 `xtquant`。
|
|
131
|
+
- 推荐私有 LAN 地址,不静默绑定所有网卡。
|
|
132
|
+
- 默认生成强认证密钥,也允许用户自定义。
|
|
133
|
+
- 经确认后在受管 venv 中建立指向券商 `xtquant` 的 junction。
|
|
134
|
+
|
|
135
|
+
客户端 profile 使用平台标准配置目录。认证密钥默认保存到 Windows
|
|
136
|
+
Credential Manager、macOS Keychain 或 Linux Secret Service。没有可用
|
|
137
|
+
keyring 时,可选择环境变量、每次隐藏输入或明确确认后的配置文件存储。
|
|
138
|
+
|
|
139
|
+
配置优先级:
|
|
140
|
+
|
|
141
|
+
```text
|
|
142
|
+
命令行 > 环境变量 > profile > 默认值
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 安全边界
|
|
146
|
+
|
|
147
|
+
- HMAC 在创建 RPyC Connection 之前完成,未认证连接无法进入
|
|
148
|
+
RPyC/pickle 协议层。
|
|
149
|
+
- 认证后保留 `rpyc.classic.obtain()`,响应一次性物化为本地对象。
|
|
150
|
+
- 共享密钥持有者对该服务实例拥有完整信任,可以访问全部账户数据和交易
|
|
151
|
+
API。
|
|
152
|
+
- HMAC 只认证,不加密流量。仅应部署在受信任私有网络;跨公网或不可信
|
|
153
|
+
网络必须使用 TLS 或 VPN。
|
|
154
|
+
- 防火墙规则只能通过显式的
|
|
155
|
+
`qmt-rpyc-server firewall add/remove` 管理。
|
|
156
|
+
- 安全问题请按 [SECURITY.md](SECURITY.md) 私密报告。
|
|
157
|
+
|
|
158
|
+
## 迁移
|
|
159
|
+
|
|
160
|
+
0.3.0 使用新的专用命名空间,不提供旧包兼容层:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
# 旧
|
|
164
|
+
from client import QmtClient
|
|
165
|
+
|
|
166
|
+
# 新
|
|
167
|
+
from qmt_rpyc import QmtClient
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
完整说明见 [MIGRATION.md](MIGRATION.md)。
|
|
171
|
+
|
|
172
|
+
## 开发与测试
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
python -m venv .venv
|
|
176
|
+
.venv/bin/python -m pip install -e ".[dev]"
|
|
177
|
+
.venv/bin/python -m pytest tests/ -v -k "not live"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
真实 QMT 测试:
|
|
181
|
+
|
|
182
|
+
```bat
|
|
183
|
+
scripts\test_server.bat
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## 法律声明
|
|
187
|
+
|
|
188
|
+
本项目不包含、不分发 `xtquant`、QMT 或 MiniQMT。相关软件、商标、数据和
|
|
189
|
+
许可归其权利方所有。本项目不提供投资建议;实盘交易和部署风险由使用者
|
|
190
|
+
自行承担。
|
|
191
|
+
|
|
192
|
+
本项目采用 [MIT License](LICENSE)。
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "qmt-rpyc"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Cross-platform RPyC bridge for QMT/MiniQMT xtquant"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{name = "qmt-rpyc contributors"}]
|
|
13
|
+
keywords = ["qmt", "miniqmt", "xtquant", "rpyc", "trading"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.9",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"rpyc>=6.0,<7",
|
|
27
|
+
"platformdirs>=3.0",
|
|
28
|
+
"tomli>=2.0; python_version < '3.11'",
|
|
29
|
+
"tomli-w>=1.0",
|
|
30
|
+
"keyring>=25.6",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
server = [
|
|
35
|
+
"python-dotenv>=1.0; python_version >= '3.10' and python_version < '3.12'",
|
|
36
|
+
"numpy>=1.24,<2; python_version >= '3.10' and python_version < '3.12'",
|
|
37
|
+
"pandas>=2,<3; python_version >= '3.10' and python_version < '3.12'",
|
|
38
|
+
"psutil>=5; python_version >= '3.10' and python_version < '3.12'",
|
|
39
|
+
]
|
|
40
|
+
dev = [
|
|
41
|
+
"build>=1",
|
|
42
|
+
"pytest>=8",
|
|
43
|
+
"twine>=5",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.urls]
|
|
47
|
+
Homepage = "https://github.com/realqiyan/qmt-rpyc"
|
|
48
|
+
Repository = "https://github.com/realqiyan/qmt-rpyc"
|
|
49
|
+
Issues = "https://github.com/realqiyan/qmt-rpyc/issues"
|
|
50
|
+
|
|
51
|
+
[project.scripts]
|
|
52
|
+
qmt-rpyc-client = "qmt_rpyc.cli.client:main"
|
|
53
|
+
qmt-rpyc-server = "qmt_rpyc.cli.server:main"
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["src"]
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.dynamic]
|
|
59
|
+
version = {attr = "qmt_rpyc.version.__version__"}
|
|
60
|
+
|
|
61
|
+
[tool.setuptools.package-data]
|
|
62
|
+
qmt_rpyc = ["py.typed"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Command-line interfaces for qmt-rpyc."""
|