xtquant-share 1.4.0__tar.gz → 1.4.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.
Files changed (55) hide show
  1. {xtquant_share-1.4.0/xtquant_share.egg-info → xtquant_share-1.4.2}/PKG-INFO +70 -25
  2. xtquant_share-1.4.0/PKG-INFO → xtquant_share-1.4.2/README.md +66 -63
  3. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/pyproject.toml +5 -5
  4. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_client_permission.py +2 -2
  5. xtquant_share-1.4.2/tests/test_qmt_assetlog.py +226 -0
  6. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_server.py +8 -8
  7. xtquant_share-1.4.2/tests/test_server_dataframe_serialization.py +60 -0
  8. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/.env.example +8 -0
  9. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/__init__.py +3 -1
  10. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/auth.py +6 -0
  11. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/check_env.py +1 -1
  12. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/client.py +32 -2
  13. xtquant_share-1.4.2/xqshare/qmt_assetlog/__init__.py +26 -0
  14. xtquant_share-1.4.2/xqshare/qmt_assetlog/reader.py +275 -0
  15. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/server.py +166 -28
  16. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/tools/xtdata.py +2 -2
  17. xtquant_share-1.4.0/README.md → xtquant_share-1.4.2/xtquant_share.egg-info/PKG-INFO +108 -21
  18. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xtquant_share.egg-info/SOURCES.txt +4 -0
  19. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/LICENSE +0 -0
  20. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/setup.cfg +0 -0
  21. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_auth.py +0 -0
  22. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_channels_bigqmt.py +0 -0
  23. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_channels_health.py +0 -0
  24. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_channels_router.py +0 -0
  25. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_client.py +0 -0
  26. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_integration.py +0 -0
  27. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_qmt_datadir_factor.py +0 -0
  28. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_quote_events.py +0 -0
  29. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_remote_data.py +0 -0
  30. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_server_channel_routing.py +0 -0
  31. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_server_download_history_data2_compat.py +0 -0
  32. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_server_download_timeout.py +0 -0
  33. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_server_permission.py +0 -0
  34. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_tools_common.py +0 -0
  35. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/tests/test_trader_events.py +0 -0
  36. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/channels/__init__.py +0 -0
  37. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/channels/bigqmt.py +0 -0
  38. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/channels/health.py +0 -0
  39. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/channels/router.py +0 -0
  40. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/clients.yaml.example +0 -0
  41. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/qmt_datadir/__init__.py +0 -0
  42. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/qmt_datadir/divid.py +0 -0
  43. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/qmt_datadir/factor.py +0 -0
  44. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/qmt_datadir/kline.py +0 -0
  45. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/qmt_datadir/misc.py +0 -0
  46. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/qmt_datadir/reader.py +0 -0
  47. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/qmt_datadir/sector.py +0 -0
  48. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/qmt_watchdog.py +0 -0
  49. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/tools/__init__.py +0 -0
  50. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/tools/common.py +0 -0
  51. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xqshare/tools/xttrader.py +0 -0
  52. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xtquant_share.egg-info/dependency_links.txt +0 -0
  53. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xtquant_share.egg-info/entry_points.txt +0 -0
  54. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xtquant_share.egg-info/requires.txt +0 -0
  55. {xtquant_share-1.4.0 → xtquant_share-1.4.2}/xtquant_share.egg-info/top_level.txt +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xtquant-share
3
- Version: 1.4.0
3
+ Version: 1.4.2
4
4
  Summary: Xtreme Quant Share - eXtreme transparent sharing proxy for XtQuant on macOS/Linux
5
5
  Author-email: Jason Hu <63170682@qq.com>
6
6
  License-Expression: GPL-3.0-only
7
- Project-URL: Homepage, https://gitee.com/jdragonhu/xqshare
8
- Project-URL: Documentation, https://gitee.com/jdragonhu/xqshare#readme
9
- Project-URL: Repository, https://gitee.com/jdragonhu/xqshare
10
- Project-URL: Issues, https://gitee.com/jdragonhu/xqshare/issues
7
+ Project-URL: Homepage, https://github.com/xiangy2020/xqshare
8
+ Project-URL: Documentation, https://github.com/xiangy2020/xqshare#readme
9
+ Project-URL: Repository, https://github.com/xiangy2020/xqshare
10
+ Project-URL: Issues, https://github.com/xiangy2020/xqshare/issues
11
11
  Keywords: xtquant,rpyc,remote,proxy,quant,stock,trading,qmt
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Developers
@@ -53,6 +53,7 @@ Dynamic: license-file
53
53
  - ✅ **服务实例标识** - `get_instance_id()` 轻量感知 server 重启;行情订阅幂等自动去重,阻断底层 miniquote 订阅累积
54
54
  - ✅ **异步回调** - 支持交易事件(on_stock_*)与行情 tick 订阅回调(`xtdata.register_quote_callback` + `subscribe_whole_quote`)
55
55
  - ✅ **无感切换** - 大QMT ↔ miniQMT 无感切换(行情侧),自动探测 miniQMT 可用性,不可用自动切 bigqmt 通道(复用 xtquant_big_convert)
56
+ - ✅ **资产兜底** - 大QMT 日志资金心跳 → 总资产/可用/市值/负债(miniQMT 独立交易不可用时仍能读资产)
56
57
  - ✅ **完整日志** - API调用日志,记录函数名、参数、耗时
57
58
  - ✅ **零学习成本** - 无需记忆新 API
58
59
 
@@ -80,11 +81,7 @@ pip install xqshare
80
81
  ### 从源码安装
81
82
 
82
83
  ```bash
83
- # Gitee(国内推荐)
84
- git clone https://gitee.com/jdragonhu/xqshare.git
85
-
86
- # GitHub(备用)
87
- git clone https://github.com/jasonhu/xqshare.git
84
+ git clone https://github.com/xiangy2020/xqshare.git
88
85
 
89
86
  cd xqshare
90
87
  pip install -e .
@@ -115,7 +112,7 @@ python -m xqshare.server
115
112
  ### 客户端快速测试
116
113
 
117
114
  ```bash
118
- export XQSHARE_REMOTE_HOST="21.214.136.216"
115
+ export XQSHARE_REMOTE_HOST="203.0.113.10"
119
116
  xtdata get_stock_list_in_sector --sector-name "沪深A股" --limit 10
120
117
  ```
121
118
 
@@ -205,7 +202,7 @@ xttrader order_cancel --order-id 1082130745
205
202
  **推荐:使用环境变量配置(避免敏感信息泄露)**
206
203
  ```bash
207
204
  # 设置环境变量
208
- export XQSHARE_REMOTE_HOST="21.214.136.216"
205
+ export XQSHARE_REMOTE_HOST="203.0.113.10"
209
206
  export XQSHARE_CLIENT_SECRET="your-secret"
210
207
 
211
208
  # 获取股票列表
@@ -237,10 +234,10 @@ python examples/query_positions.py
237
234
  **备选:命令行参数(覆盖环境变量):**
238
235
  ```bash
239
236
  # 显式指定服务端地址
240
- python examples/get_stock_list.py --host 21.214.136.216 --sector "沪深300"
237
+ python examples/get_stock_list.py --host 203.0.113.10 --sector "沪深300"
241
238
 
242
239
  # 显式指定认证密钥
243
- python examples/get_tick_data.py --host 21.214.136.216 --secret "your-secret" --codes "000001.SZ"
240
+ python examples/get_tick_data.py --host 203.0.113.10 --secret "your-secret" --codes "000001.SZ"
244
241
 
245
242
  # 查看帮助
246
243
  python examples/get_stock_list.py --help
@@ -254,11 +251,11 @@ python examples/get_stock_list.py --help
254
251
  from xqshare import XtQuantRemote, connect, disconnect, xtdata, xttrader, xttype
255
252
 
256
253
  # 方式1:类实例(推荐)
257
- with XtQuantRemote("21.214.136.216", client_secret="xxx") as xt:
254
+ with XtQuantRemote("203.0.113.10", client_secret="xxx") as xt:
258
255
  stocks = xt.xtdata.get_stock_list_in_sector("沪深A股")
259
256
 
260
257
  # 方式2:全局便捷函数
261
- connect(host="21.214.136.216", client_secret="xxx")
258
+ connect(host="203.0.113.10", client_secret="xxx")
262
259
  stocks = xtdata.get_stock_list_in_sector("沪深A股")
263
260
  disconnect()
264
261
  ```
@@ -267,6 +264,7 @@ disconnect()
267
264
  - `xt.xtdata` - 行情数据模块
268
265
  - `xt.xttype` - 类型定义模块(StockAccount 等)
269
266
  - `xt.datadir` - QMT datadir 文件解析模块(无需 miniQMT 进程)
267
+ - `xt.assetlog` / `xt.get_asset()` - 大QMT 日志资金心跳 → 资产快照(trader 不可用时的兜底)
270
268
  - `xt.create_trader()` - 创建交易实例(需自行 connect)
271
269
  - `xt.create_trader_and_connect()` - 创建交易实例并等待真实连接建立(推荐用于下单)
272
270
 
@@ -306,7 +304,7 @@ QMT_DATADIR_PATH=D:\国金证券QMT交易端\datadir
306
304
  ```python
307
305
  from xqshare import XtQuantRemote
308
306
 
309
- with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
307
+ with XtQuantRemote("203.0.113.10", client_secret="my-secret") as xt:
310
308
  # 读取 K 线数据(直接解析 .DAT 文件,无需 miniQMT 进程)
311
309
  df = xt.datadir.kline("600000.SH", "1d")
312
310
  print(df.tail())
@@ -342,7 +340,7 @@ with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
342
340
  ```python
343
341
  import xqshare
344
342
 
345
- xqshare.connect(host="21.214.136.216", client_secret="my-secret")
343
+ xqshare.connect(host="203.0.113.10", client_secret="my-secret")
346
344
 
347
345
  # 与 xqshare.xtdata 用法完全对称
348
346
  df = xqshare.datadir.kline("600000.SH", "1d")
@@ -372,12 +370,58 @@ RuntimeError: datadir 不可用:未配置 QMT_DATADIR_PATH 且无法自动推
372
370
 
373
371
  ---
374
372
 
373
+ ## assetlog:日志资金心跳 → 资产
374
+
375
+ miniQMT / 独立交易模式被券商关闭后,`xttrader.query_stock_asset` 会报「交易服务端未启动」。但大QMT 客户端登录后,每 3~12 秒会往 `<QMT>/userdata/log/XtClient_YYYYMMDD.log` 写一条资金心跳:
376
+
377
+ ```
378
+ 2026-11-09 17:12:11,309 [INFO] ... [calc] update fund [2_10039_1000_<ACCOUNT>] bal 138879.92 avai 55757.92 debt 0.00 mv 83122.00
379
+ ```
380
+
381
+ `xqshare.assetlog` 增量 tail 这个文件,给出总资产 / 可用资金 / 市值 / 负债。
382
+
383
+ ### Server 端配置(Windows)
384
+
385
+ ```ini
386
+ # 日志目录(可选):不配则按 QMT_USERDATA_PATH 推断为 <QMT安装>/userdata/log
387
+ QMT_LOG_DIR=C:\Install\pazq_qmt\pazq_qmt_2.0.8.0\userdata\log
388
+
389
+ # 判为过期的阈值(秒),默认 60
390
+ QMT_ASSETLOG_STALE_S=60
391
+ ```
392
+
393
+ ### Client 端使用
394
+
395
+ ```python
396
+ from xqshare import XtQuantRemote
397
+
398
+ with XtQuantRemote("203.0.113.10", client_secret="my-secret") as xt:
399
+ snap = xt.get_asset("<ACCOUNT_ID>") # 或 xt.assetlog.get_asset(...)
400
+ print(snap["total_asset"], snap["cash"], snap["market_value"], snap["stale"])
401
+ # 138879.92 55757.92 83122.0 False
402
+ ```
403
+
404
+ > ⚠️ 这是**推送快照**,不是查询接口:断线就停,返回值带 `as_of` / `age_s` / `stale`,用之前先看新鲜度。
405
+
406
+ ### 能力边界
407
+
408
+ | 项 | 是否支持 | 说明 |
409
+ |----|---------|------|
410
+ | 总资产 / 可用 / 市值 / 负债 | ✅ | 心跳里直接有 |
411
+ | 持仓明细 | ❌ | 日志没有逐票数量与成本 |
412
+ | 冻结资金 | ❌ | `accountdetail` 行的 marketvalue 是 DBL_MAX,整行不可信 |
413
+ | 即时查询 | ❌ | 只有 3~12 秒的推送节拍 |
414
+
415
+ 详细字段与异常说明见 [doc/xqshare-api.md](doc/xqshare-api.md#8-assetlog-模块-api)。
416
+
417
+ ---
418
+
375
419
  ## 使用示例
376
420
 
377
421
  ```python
378
422
  from xqshare import XtQuantRemote
379
423
 
380
- with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
424
+ with XtQuantRemote("203.0.113.10", client_secret="my-secret") as xt:
381
425
  # 获取股票列表
382
426
  stocks = xt.xtdata.get_stock_list_in_sector("沪深A股")
383
427
  print(f"股票数量: {len(stocks)}")
@@ -400,7 +444,7 @@ with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
400
444
  ```python
401
445
  from xqshare import XtQuantRemote
402
446
 
403
- with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
447
+ with XtQuantRemote("203.0.113.10", client_secret="my-secret") as xt:
404
448
  # 创建交易实例并等待真实连接建立(推荐)
405
449
  # userdata_path 可通过环境变量 QMT_USERDATA_PATH 配置
406
450
  trader = xt.create_trader_and_connect("C:\\QMT\\userdata_mini")
@@ -482,7 +526,7 @@ logs/client_20260228.log
482
526
  **客户端也会记录调用:**
483
527
  ```python
484
528
  # 设置日志级别
485
- xt = XtQuantRemote("21.214.136.216", log_level="DEBUG")
529
+ xt = XtQuantRemote("203.0.113.10", log_level="DEBUG")
486
530
  ```
487
531
 
488
532
  客户端日志示例:
@@ -594,7 +638,7 @@ python -m xqshare.server --ssl --cert server.crt --key server.key
594
638
 
595
639
  ```python
596
640
  xt = XtQuantRemote(
597
- host="21.214.136.216",
641
+ host="203.0.113.10",
598
642
  use_ssl=True,
599
643
  ssl_verify=False # 自签名证书需禁用验证
600
644
  )
@@ -612,7 +656,7 @@ xt = XtQuantRemote(
612
656
 
613
657
  ```python
614
658
  xt = XtQuantRemote(
615
- host="21.214.136.216",
659
+ host="203.0.113.10",
616
660
  auto_reconnect=True,
617
661
  max_retries=10,
618
662
  heartbeat_interval=15,
@@ -783,8 +827,8 @@ tail -f logs/client_*.log
783
827
 
784
828
  ```bash
785
829
  # 检查网络
786
- ping 21.214.136.216
787
- telnet 21.214.136.216 18812
830
+ ping 203.0.113.10
831
+ telnet 203.0.113.10 18812
788
832
  ```
789
833
 
790
834
  ### 查看服务状态
@@ -802,6 +846,7 @@ print(status)
802
846
 
803
847
  | 版本 | 日期 | 更新内容 |
804
848
  |------|------|----------|
849
+ | 1.4.1 | 2026-10-06 | 修复 `create_trader_and_connect` 连接等待:不触发 `on_connected` 回调的 xtquant 版本(平安 QMT)不再空耗 10 秒,改为短间隔轮询 `query_stock_asset` 探活,秒级返回 |
805
850
  | 1.4.0 | 2026-10-03 | 新增 `get_instance_id()` 服务实例标识(轻量感知 server 重启);行情订阅幂等(重复订阅自动释放旧 seq,阻断 miniquote 订阅累积泄漏) |
806
851
  | 1.1.1 | 2026-03-18 | 新增 xtview 模块支持(视图控制、调度任务管理),兼容不同 xtquant 版本 |
807
852
  | 1.1.0 | 2026-03-17 | 交易功能优化完善、`xqshare-server` 命令、`.env` 配置支持、远程对象传输性能优化 |
@@ -1,45 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: xtquant-share
3
- Version: 1.4.0
4
- Summary: Xtreme Quant Share - eXtreme transparent sharing proxy for XtQuant on macOS/Linux
5
- Author-email: Jason Hu <63170682@qq.com>
6
- License-Expression: GPL-3.0-only
7
- Project-URL: Homepage, https://gitee.com/jdragonhu/xqshare
8
- Project-URL: Documentation, https://gitee.com/jdragonhu/xqshare#readme
9
- Project-URL: Repository, https://gitee.com/jdragonhu/xqshare
10
- Project-URL: Issues, https://gitee.com/jdragonhu/xqshare/issues
11
- Keywords: xtquant,rpyc,remote,proxy,quant,stock,trading,qmt
12
- Classifier: Development Status :: 4 - Beta
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Intended Audience :: Financial and Insurance Industry
15
- Classifier: Operating System :: OS Independent
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.8
18
- Classifier: Programming Language :: Python :: 3.9
19
- Classifier: Programming Language :: Python :: 3.10
20
- Classifier: Programming Language :: Python :: 3.11
21
- Classifier: Programming Language :: Python :: 3.12
22
- Classifier: Topic :: Office/Business :: Financial :: Investment
23
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
- Classifier: Topic :: System :: Networking
25
- Requires-Python: >=3.8
26
- Description-Content-Type: text/markdown
27
- License-File: LICENSE
28
- Requires-Dist: rpyc>=6.0
29
- Requires-Dist: python-dotenv>=1.0
30
- Requires-Dist: pyyaml>=6.0
31
- Requires-Dist: psutil>=5.9
32
- Provides-Extra: dev
33
- Requires-Dist: pytest>=7.0; extra == "dev"
34
- Requires-Dist: black>=23.0; extra == "dev"
35
- Requires-Dist: flake8>=6.0; extra == "dev"
36
- Provides-Extra: datadir
37
- Requires-Dist: pandas>=1.0; extra == "datadir"
38
- Requires-Dist: pyarrow>=6.0; extra == "datadir"
39
- Provides-Extra: bigqmt
40
- Requires-Dist: xtquant-big-convert[redis]; extra == "bigqmt"
41
- Dynamic: license-file
42
-
43
1
  # 极限量化 (xqshare)
44
2
 
45
3
  完全透明的 XtQuant 远程调用方案,让 macOS/Linux 可以像本地一样调用 Windows 上的 xtquant 库。
@@ -53,6 +11,7 @@ Dynamic: license-file
53
11
  - ✅ **服务实例标识** - `get_instance_id()` 轻量感知 server 重启;行情订阅幂等自动去重,阻断底层 miniquote 订阅累积
54
12
  - ✅ **异步回调** - 支持交易事件(on_stock_*)与行情 tick 订阅回调(`xtdata.register_quote_callback` + `subscribe_whole_quote`)
55
13
  - ✅ **无感切换** - 大QMT ↔ miniQMT 无感切换(行情侧),自动探测 miniQMT 可用性,不可用自动切 bigqmt 通道(复用 xtquant_big_convert)
14
+ - ✅ **资产兜底** - 大QMT 日志资金心跳 → 总资产/可用/市值/负债(miniQMT 独立交易不可用时仍能读资产)
56
15
  - ✅ **完整日志** - API调用日志,记录函数名、参数、耗时
57
16
  - ✅ **零学习成本** - 无需记忆新 API
58
17
 
@@ -80,11 +39,7 @@ pip install xqshare
80
39
  ### 从源码安装
81
40
 
82
41
  ```bash
83
- # Gitee(国内推荐)
84
- git clone https://gitee.com/jdragonhu/xqshare.git
85
-
86
- # GitHub(备用)
87
- git clone https://github.com/jasonhu/xqshare.git
42
+ git clone https://github.com/xiangy2020/xqshare.git
88
43
 
89
44
  cd xqshare
90
45
  pip install -e .
@@ -115,7 +70,7 @@ python -m xqshare.server
115
70
  ### 客户端快速测试
116
71
 
117
72
  ```bash
118
- export XQSHARE_REMOTE_HOST="21.214.136.216"
73
+ export XQSHARE_REMOTE_HOST="203.0.113.10"
119
74
  xtdata get_stock_list_in_sector --sector-name "沪深A股" --limit 10
120
75
  ```
121
76
 
@@ -205,7 +160,7 @@ xttrader order_cancel --order-id 1082130745
205
160
  **推荐:使用环境变量配置(避免敏感信息泄露)**
206
161
  ```bash
207
162
  # 设置环境变量
208
- export XQSHARE_REMOTE_HOST="21.214.136.216"
163
+ export XQSHARE_REMOTE_HOST="203.0.113.10"
209
164
  export XQSHARE_CLIENT_SECRET="your-secret"
210
165
 
211
166
  # 获取股票列表
@@ -237,10 +192,10 @@ python examples/query_positions.py
237
192
  **备选:命令行参数(覆盖环境变量):**
238
193
  ```bash
239
194
  # 显式指定服务端地址
240
- python examples/get_stock_list.py --host 21.214.136.216 --sector "沪深300"
195
+ python examples/get_stock_list.py --host 203.0.113.10 --sector "沪深300"
241
196
 
242
197
  # 显式指定认证密钥
243
- python examples/get_tick_data.py --host 21.214.136.216 --secret "your-secret" --codes "000001.SZ"
198
+ python examples/get_tick_data.py --host 203.0.113.10 --secret "your-secret" --codes "000001.SZ"
244
199
 
245
200
  # 查看帮助
246
201
  python examples/get_stock_list.py --help
@@ -254,11 +209,11 @@ python examples/get_stock_list.py --help
254
209
  from xqshare import XtQuantRemote, connect, disconnect, xtdata, xttrader, xttype
255
210
 
256
211
  # 方式1:类实例(推荐)
257
- with XtQuantRemote("21.214.136.216", client_secret="xxx") as xt:
212
+ with XtQuantRemote("203.0.113.10", client_secret="xxx") as xt:
258
213
  stocks = xt.xtdata.get_stock_list_in_sector("沪深A股")
259
214
 
260
215
  # 方式2:全局便捷函数
261
- connect(host="21.214.136.216", client_secret="xxx")
216
+ connect(host="203.0.113.10", client_secret="xxx")
262
217
  stocks = xtdata.get_stock_list_in_sector("沪深A股")
263
218
  disconnect()
264
219
  ```
@@ -267,6 +222,7 @@ disconnect()
267
222
  - `xt.xtdata` - 行情数据模块
268
223
  - `xt.xttype` - 类型定义模块(StockAccount 等)
269
224
  - `xt.datadir` - QMT datadir 文件解析模块(无需 miniQMT 进程)
225
+ - `xt.assetlog` / `xt.get_asset()` - 大QMT 日志资金心跳 → 资产快照(trader 不可用时的兜底)
270
226
  - `xt.create_trader()` - 创建交易实例(需自行 connect)
271
227
  - `xt.create_trader_and_connect()` - 创建交易实例并等待真实连接建立(推荐用于下单)
272
228
 
@@ -306,7 +262,7 @@ QMT_DATADIR_PATH=D:\国金证券QMT交易端\datadir
306
262
  ```python
307
263
  from xqshare import XtQuantRemote
308
264
 
309
- with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
265
+ with XtQuantRemote("203.0.113.10", client_secret="my-secret") as xt:
310
266
  # 读取 K 线数据(直接解析 .DAT 文件,无需 miniQMT 进程)
311
267
  df = xt.datadir.kline("600000.SH", "1d")
312
268
  print(df.tail())
@@ -342,7 +298,7 @@ with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
342
298
  ```python
343
299
  import xqshare
344
300
 
345
- xqshare.connect(host="21.214.136.216", client_secret="my-secret")
301
+ xqshare.connect(host="203.0.113.10", client_secret="my-secret")
346
302
 
347
303
  # 与 xqshare.xtdata 用法完全对称
348
304
  df = xqshare.datadir.kline("600000.SH", "1d")
@@ -372,12 +328,58 @@ RuntimeError: datadir 不可用:未配置 QMT_DATADIR_PATH 且无法自动推
372
328
 
373
329
  ---
374
330
 
331
+ ## assetlog:日志资金心跳 → 资产
332
+
333
+ miniQMT / 独立交易模式被券商关闭后,`xttrader.query_stock_asset` 会报「交易服务端未启动」。但大QMT 客户端登录后,每 3~12 秒会往 `<QMT>/userdata/log/XtClient_YYYYMMDD.log` 写一条资金心跳:
334
+
335
+ ```
336
+ 2026-11-09 17:12:11,309 [INFO] ... [calc] update fund [2_10039_1000_<ACCOUNT>] bal 138879.92 avai 55757.92 debt 0.00 mv 83122.00
337
+ ```
338
+
339
+ `xqshare.assetlog` 增量 tail 这个文件,给出总资产 / 可用资金 / 市值 / 负债。
340
+
341
+ ### Server 端配置(Windows)
342
+
343
+ ```ini
344
+ # 日志目录(可选):不配则按 QMT_USERDATA_PATH 推断为 <QMT安装>/userdata/log
345
+ QMT_LOG_DIR=C:\Install\pazq_qmt\pazq_qmt_2.0.8.0\userdata\log
346
+
347
+ # 判为过期的阈值(秒),默认 60
348
+ QMT_ASSETLOG_STALE_S=60
349
+ ```
350
+
351
+ ### Client 端使用
352
+
353
+ ```python
354
+ from xqshare import XtQuantRemote
355
+
356
+ with XtQuantRemote("203.0.113.10", client_secret="my-secret") as xt:
357
+ snap = xt.get_asset("<ACCOUNT_ID>") # 或 xt.assetlog.get_asset(...)
358
+ print(snap["total_asset"], snap["cash"], snap["market_value"], snap["stale"])
359
+ # 138879.92 55757.92 83122.0 False
360
+ ```
361
+
362
+ > ⚠️ 这是**推送快照**,不是查询接口:断线就停,返回值带 `as_of` / `age_s` / `stale`,用之前先看新鲜度。
363
+
364
+ ### 能力边界
365
+
366
+ | 项 | 是否支持 | 说明 |
367
+ |----|---------|------|
368
+ | 总资产 / 可用 / 市值 / 负债 | ✅ | 心跳里直接有 |
369
+ | 持仓明细 | ❌ | 日志没有逐票数量与成本 |
370
+ | 冻结资金 | ❌ | `accountdetail` 行的 marketvalue 是 DBL_MAX,整行不可信 |
371
+ | 即时查询 | ❌ | 只有 3~12 秒的推送节拍 |
372
+
373
+ 详细字段与异常说明见 [doc/xqshare-api.md](doc/xqshare-api.md#8-assetlog-模块-api)。
374
+
375
+ ---
376
+
375
377
  ## 使用示例
376
378
 
377
379
  ```python
378
380
  from xqshare import XtQuantRemote
379
381
 
380
- with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
382
+ with XtQuantRemote("203.0.113.10", client_secret="my-secret") as xt:
381
383
  # 获取股票列表
382
384
  stocks = xt.xtdata.get_stock_list_in_sector("沪深A股")
383
385
  print(f"股票数量: {len(stocks)}")
@@ -400,7 +402,7 @@ with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
400
402
  ```python
401
403
  from xqshare import XtQuantRemote
402
404
 
403
- with XtQuantRemote("21.214.136.216", client_secret="my-secret") as xt:
405
+ with XtQuantRemote("203.0.113.10", client_secret="my-secret") as xt:
404
406
  # 创建交易实例并等待真实连接建立(推荐)
405
407
  # userdata_path 可通过环境变量 QMT_USERDATA_PATH 配置
406
408
  trader = xt.create_trader_and_connect("C:\\QMT\\userdata_mini")
@@ -482,7 +484,7 @@ logs/client_20260228.log
482
484
  **客户端也会记录调用:**
483
485
  ```python
484
486
  # 设置日志级别
485
- xt = XtQuantRemote("21.214.136.216", log_level="DEBUG")
487
+ xt = XtQuantRemote("203.0.113.10", log_level="DEBUG")
486
488
  ```
487
489
 
488
490
  客户端日志示例:
@@ -594,7 +596,7 @@ python -m xqshare.server --ssl --cert server.crt --key server.key
594
596
 
595
597
  ```python
596
598
  xt = XtQuantRemote(
597
- host="21.214.136.216",
599
+ host="203.0.113.10",
598
600
  use_ssl=True,
599
601
  ssl_verify=False # 自签名证书需禁用验证
600
602
  )
@@ -612,7 +614,7 @@ xt = XtQuantRemote(
612
614
 
613
615
  ```python
614
616
  xt = XtQuantRemote(
615
- host="21.214.136.216",
617
+ host="203.0.113.10",
616
618
  auto_reconnect=True,
617
619
  max_retries=10,
618
620
  heartbeat_interval=15,
@@ -783,8 +785,8 @@ tail -f logs/client_*.log
783
785
 
784
786
  ```bash
785
787
  # 检查网络
786
- ping 21.214.136.216
787
- telnet 21.214.136.216 18812
788
+ ping 203.0.113.10
789
+ telnet 203.0.113.10 18812
788
790
  ```
789
791
 
790
792
  ### 查看服务状态
@@ -802,6 +804,7 @@ print(status)
802
804
 
803
805
  | 版本 | 日期 | 更新内容 |
804
806
  |------|------|----------|
807
+ | 1.4.1 | 2026-10-06 | 修复 `create_trader_and_connect` 连接等待:不触发 `on_connected` 回调的 xtquant 版本(平安 QMT)不再空耗 10 秒,改为短间隔轮询 `query_stock_asset` 探活,秒级返回 |
805
808
  | 1.4.0 | 2026-10-03 | 新增 `get_instance_id()` 服务实例标识(轻量感知 server 重启);行情订阅幂等(重复订阅自动释放旧 seq,阻断 miniquote 订阅累积泄漏) |
806
809
  | 1.1.1 | 2026-03-18 | 新增 xtview 模块支持(视图控制、调度任务管理),兼容不同 xtquant 版本 |
807
810
  | 1.1.0 | 2026-03-17 | 交易功能优化完善、`xqshare-server` 命令、`.env` 配置支持、远程对象传输性能优化 |
@@ -815,4 +818,4 @@ print(status)
815
818
 
816
819
  ## License
817
820
 
818
- GNU General Public License v3.0
821
+ GNU General Public License v3.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "xtquant-share"
7
- version = "1.4.0"
7
+ version = "1.4.2"
8
8
  description = "Xtreme Quant Share - eXtreme transparent sharing proxy for XtQuant on macOS/Linux"
9
9
  readme = "README.md"
10
10
  license = "GPL-3.0-only"
@@ -65,10 +65,10 @@ xtdata = "xqshare.tools.xtdata:main"
65
65
  xttrader = "xqshare.tools.xttrader:main"
66
66
 
67
67
  [project.urls]
68
- Homepage = "https://gitee.com/jdragonhu/xqshare"
69
- Documentation = "https://gitee.com/jdragonhu/xqshare#readme"
70
- Repository = "https://gitee.com/jdragonhu/xqshare"
71
- Issues = "https://gitee.com/jdragonhu/xqshare/issues"
68
+ Homepage = "https://github.com/xiangy2020/xqshare"
69
+ Documentation = "https://github.com/xiangy2020/xqshare#readme"
70
+ Repository = "https://github.com/xiangy2020/xqshare"
71
+ Issues = "https://github.com/xiangy2020/xqshare/issues"
72
72
 
73
73
  [tool.setuptools.packages.find]
74
74
  where = ["."]
@@ -184,14 +184,14 @@ class TestClientEnvConfig:
184
184
  with patch('xqshare.client.rpyc.connect', return_value=mock_conn):
185
185
  with patch('xqshare.client.BgServingThread'):
186
186
  with patch.dict(os.environ, {
187
- "XQSHARE_REMOTE_HOST": "21.214.136.216",
187
+ "XQSHARE_REMOTE_HOST": "203.0.113.10",
188
188
  "XQSHARE_REMOTE_PORT": "18888",
189
189
  "XQSHARE_CLIENT_ID": "env-client",
190
190
  "XQSHARE_CLIENT_SECRET": "env-secret"
191
191
  }):
192
192
  client = XtQuantRemote(heartbeat_interval=0)
193
193
 
194
- assert client._host == "21.214.136.216"
194
+ assert client._host == "203.0.113.10"
195
195
  assert client._port == 18888
196
196
  assert client._client_id == "env-client"
197
197
  assert client._client_secret == "env-secret"