xtquant-share 1.3.1__tar.gz → 1.4.0__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 (51) hide show
  1. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/PKG-INFO +3 -1
  2. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/README.md +2 -0
  3. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/pyproject.toml +1 -1
  4. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_quote_events.py +48 -0
  5. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_server.py +21 -0
  6. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/__init__.py +1 -1
  7. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/server.py +104 -0
  8. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xtquant_share.egg-info/PKG-INFO +3 -1
  9. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/LICENSE +0 -0
  10. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/setup.cfg +0 -0
  11. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_auth.py +0 -0
  12. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_channels_bigqmt.py +0 -0
  13. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_channels_health.py +0 -0
  14. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_channels_router.py +0 -0
  15. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_client.py +0 -0
  16. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_client_permission.py +0 -0
  17. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_integration.py +0 -0
  18. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_qmt_datadir_factor.py +0 -0
  19. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_remote_data.py +0 -0
  20. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_server_channel_routing.py +0 -0
  21. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_server_download_history_data2_compat.py +0 -0
  22. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_server_download_timeout.py +0 -0
  23. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_server_permission.py +0 -0
  24. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_tools_common.py +0 -0
  25. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/tests/test_trader_events.py +0 -0
  26. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/.env.example +0 -0
  27. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/auth.py +0 -0
  28. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/channels/__init__.py +0 -0
  29. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/channels/bigqmt.py +0 -0
  30. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/channels/health.py +0 -0
  31. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/channels/router.py +0 -0
  32. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/check_env.py +0 -0
  33. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/client.py +0 -0
  34. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/clients.yaml.example +0 -0
  35. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/qmt_datadir/__init__.py +0 -0
  36. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/qmt_datadir/divid.py +0 -0
  37. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/qmt_datadir/factor.py +0 -0
  38. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/qmt_datadir/kline.py +0 -0
  39. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/qmt_datadir/misc.py +0 -0
  40. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/qmt_datadir/reader.py +0 -0
  41. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/qmt_datadir/sector.py +0 -0
  42. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/qmt_watchdog.py +0 -0
  43. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/tools/__init__.py +0 -0
  44. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/tools/common.py +0 -0
  45. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/tools/xtdata.py +0 -0
  46. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xqshare/tools/xttrader.py +0 -0
  47. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xtquant_share.egg-info/SOURCES.txt +0 -0
  48. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xtquant_share.egg-info/dependency_links.txt +0 -0
  49. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xtquant_share.egg-info/entry_points.txt +0 -0
  50. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xtquant_share.egg-info/requires.txt +0 -0
  51. {xtquant_share-1.3.1 → xtquant_share-1.4.0}/xtquant_share.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xtquant-share
3
- Version: 1.3.1
3
+ Version: 1.4.0
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
@@ -50,6 +50,7 @@ Dynamic: license-file
50
50
  - ✅ **认证加密** - 支持 HMAC token 认证,可选 SSL/TLS 加密
51
51
  - ✅ **断线重连** - 自动检测断线并重连,指数退避策略
52
52
  - ✅ **心跳保活** - 定期心跳检测,保持连接活跃
53
+ - ✅ **服务实例标识** - `get_instance_id()` 轻量感知 server 重启;行情订阅幂等自动去重,阻断底层 miniquote 订阅累积
53
54
  - ✅ **异步回调** - 支持交易事件(on_stock_*)与行情 tick 订阅回调(`xtdata.register_quote_callback` + `subscribe_whole_quote`)
54
55
  - ✅ **无感切换** - 大QMT ↔ miniQMT 无感切换(行情侧),自动探测 miniQMT 可用性,不可用自动切 bigqmt 通道(复用 xtquant_big_convert)
55
56
  - ✅ **完整日志** - API调用日志,记录函数名、参数、耗时
@@ -801,6 +802,7 @@ print(status)
801
802
 
802
803
  | 版本 | 日期 | 更新内容 |
803
804
  |------|------|----------|
805
+ | 1.4.0 | 2026-10-03 | 新增 `get_instance_id()` 服务实例标识(轻量感知 server 重启);行情订阅幂等(重复订阅自动释放旧 seq,阻断 miniquote 订阅累积泄漏) |
804
806
  | 1.1.1 | 2026-03-18 | 新增 xtview 模块支持(视图控制、调度任务管理),兼容不同 xtquant 版本 |
805
807
  | 1.1.0 | 2026-03-17 | 交易功能优化完善、`xqshare-server` 命令、`.env` 配置支持、远程对象传输性能优化 |
806
808
  | 1.0.4 | 2026-03-09 | JSON 输出优化:远程 DataFrame 高效序列化、`--compact` 参数、全局参数位置灵活、嵌套结构支持 |
@@ -8,6 +8,7 @@
8
8
  - ✅ **认证加密** - 支持 HMAC token 认证,可选 SSL/TLS 加密
9
9
  - ✅ **断线重连** - 自动检测断线并重连,指数退避策略
10
10
  - ✅ **心跳保活** - 定期心跳检测,保持连接活跃
11
+ - ✅ **服务实例标识** - `get_instance_id()` 轻量感知 server 重启;行情订阅幂等自动去重,阻断底层 miniquote 订阅累积
11
12
  - ✅ **异步回调** - 支持交易事件(on_stock_*)与行情 tick 订阅回调(`xtdata.register_quote_callback` + `subscribe_whole_quote`)
12
13
  - ✅ **无感切换** - 大QMT ↔ miniQMT 无感切换(行情侧),自动探测 miniQMT 可用性,不可用自动切 bigqmt 通道(复用 xtquant_big_convert)
13
14
  - ✅ **完整日志** - API调用日志,记录函数名、参数、耗时
@@ -759,6 +760,7 @@ print(status)
759
760
 
760
761
  | 版本 | 日期 | 更新内容 |
761
762
  |------|------|----------|
763
+ | 1.4.0 | 2026-10-03 | 新增 `get_instance_id()` 服务实例标识(轻量感知 server 重启);行情订阅幂等(重复订阅自动释放旧 seq,阻断 miniquote 订阅累积泄漏) |
762
764
  | 1.1.1 | 2026-03-18 | 新增 xtview 模块支持(视图控制、调度任务管理),兼容不同 xtquant 版本 |
763
765
  | 1.1.0 | 2026-03-17 | 交易功能优化完善、`xqshare-server` 命令、`.env` 配置支持、远程对象传输性能优化 |
764
766
  | 1.0.4 | 2026-03-09 | JSON 输出优化:远程 DataFrame 高效序列化、`--compact` 参数、全局参数位置灵活、嵌套结构支持 |
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "xtquant-share"
7
- version = "1.3.1"
7
+ version = "1.4.0"
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"
@@ -272,6 +272,54 @@ class TestLoggingProxyQuoteIntercept:
272
272
  finally:
273
273
  qec.stop()
274
274
 
275
+ def test_subscribe_idempotent_unsubscribe_old_seq(self):
276
+ """同一 client 重复订阅同一 code_list,应先 unsubscribe 旧 seq 再订阅(防 miniquote 累积)"""
277
+ mock = MagicMock()
278
+ mock.subscribe_whole_quote.side_effect = [1, 2]
279
+ mock.unsubscribe_quote = MagicMock()
280
+ qec = _QuoteEventCallback()
281
+ try:
282
+ proxy = self._proxy(mock, qec)
283
+ client_cb = MagicMock()
284
+ proxy.subscribe_whole_quote(["000001.SZ"], callback=client_cb) # seq=1
285
+ proxy.subscribe_whole_quote(["000001.SZ"], callback=client_cb) # seq=2,先 unsubscribe 1
286
+
287
+ mock.unsubscribe_quote.assert_called_once_with(1)
288
+ assert mock.subscribe_whole_quote.call_count == 2
289
+ finally:
290
+ qec.stop()
291
+
292
+ def test_subscribe_different_codes_no_unsubscribe(self):
293
+ """不同 code_list 的订阅互不影响,不应触发 unsubscribe"""
294
+ mock = MagicMock()
295
+ mock.subscribe_whole_quote.side_effect = [1, 2]
296
+ mock.unsubscribe_quote = MagicMock()
297
+ qec = _QuoteEventCallback()
298
+ try:
299
+ proxy = self._proxy(mock, qec)
300
+ proxy.subscribe_whole_quote(["000001.SZ"])
301
+ proxy.subscribe_whole_quote(["000002.SZ"])
302
+
303
+ mock.unsubscribe_quote.assert_not_called()
304
+ finally:
305
+ qec.stop()
306
+
307
+ def test_subscription_seq_record_and_clear(self):
308
+ """seq 管理:record → get 命中,clear 后 unsubscribe 所有 seq"""
309
+ qec = _QuoteEventCallback()
310
+ try:
311
+ key = ("subscribe_whole_quote", ("000001.SZ",))
312
+ qec.record_subscription("c1", key, 1)
313
+ assert qec.get_subscription_seq("c1", key) == 1
314
+ assert qec.get_subscription_seq("c1", ("subscribe_whole_quote", ("000002.SZ",))) is None
315
+
316
+ unsubscribed = []
317
+ qec.clear_client_subscriptions("c1", lambda seq: unsubscribed.append(seq))
318
+ assert unsubscribed == [1]
319
+ assert qec.get_subscription_seq("c1", key) is None
320
+ finally:
321
+ qec.stop()
322
+
275
323
 
276
324
  class TestRemoteQuoteCallback:
277
325
  """客户端行情回调接收器"""
@@ -477,5 +477,26 @@ class TestInitDatadirReader:
477
477
  XtQuantService._xtdata = original_xtdata
478
478
 
479
479
 
480
+ class TestInstanceId:
481
+ """服务实例标识(instance_id)与订阅幂等辅助函数"""
482
+
483
+ def test_instance_id_is_nonempty_str(self):
484
+ from xqshare import server as server_mod
485
+ assert isinstance(server_mod._INSTANCE_ID, str)
486
+ assert len(server_mod._INSTANCE_ID) > 0
487
+
488
+ def test_exposed_get_instance_id(self):
489
+ from xqshare import server as server_mod
490
+ svc = XtQuantService()
491
+ assert svc.exposed_get_instance_id() == server_mod._INSTANCE_ID
492
+
493
+ def test_normalize_code_key(self):
494
+ from xqshare.server import _normalize_code_key
495
+ assert _normalize_code_key(["000001.SZ"]) == ("000001.SZ",)
496
+ assert _normalize_code_key(["SZ", "SH"]) == ("SH", "SZ") # 排序去序
497
+ assert _normalize_code_key("000001.SZ") == ("000001.SZ",)
498
+ assert _normalize_code_key(("000001.SZ", "000002.SZ")) == ("000001.SZ", "000002.SZ")
499
+
500
+
480
501
  if __name__ == "__main__":
481
502
  pytest.main([__file__, "-v"])
@@ -4,7 +4,7 @@ XtQuant Share (xqshare) - Transparent remote proxy for xtquant library
4
4
  Allows using xtquant on macOS/Linux by proxying calls to a Windows server.
5
5
  """
6
6
 
7
- __version__ = "1.3.1"
7
+ __version__ = "1.4.0"
8
8
  __author__ = "Jason Hu"
9
9
 
10
10
  from .client import (
@@ -13,6 +13,7 @@ import logging
13
13
  import functools
14
14
  import json
15
15
  import threading
16
+ import uuid
16
17
  from datetime import datetime
17
18
  from typing import Any, Dict, Optional
18
19
 
@@ -565,6 +566,10 @@ class _QuoteEventCallback:
565
566
  # 该 RPC 会抛 EOFError,导致 dispatch 线程崩溃。id() 是纯本地操作。
566
567
  # value 记录 client_info,供 on_disconnect 按连接清理(修复 netref 累积泄漏)。
567
568
  self._subscribers = {} # id(client_callback_netref) -> {callback, client_info}
569
+ # 订阅幂等:client_info -> {code_key -> seq}。code_key = (方法名, 规范化code_list)。
570
+ # 同一 client 重复订阅同一 code_key 时先 unsubscribe 旧 seq 再订阅,
571
+ # 避免 miniquote 侧订阅累积(曾导致 miniquote 内存泄漏拖垮整机)。
572
+ self._subscriptions = {}
568
573
  self._running = True
569
574
  self._queue = []
570
575
  self._queue_lock = threading.Lock()
@@ -656,6 +661,38 @@ class _QuoteEventCallback:
656
661
  f"removed={len(stale)} total={len(self._subscribers)}"
657
662
  )
658
663
 
664
+ def get_subscription_seq(self, client_info: Optional[str], code_key):
665
+ """查该 client 是否已订阅过 code_key,返回旧 seq(未订阅返回 None)。"""
666
+ with self._lock:
667
+ subs = self._subscriptions.get(client_info)
668
+ if subs:
669
+ return subs.get(code_key)
670
+ return None
671
+
672
+ def record_subscription(self, client_info: Optional[str], code_key, seq):
673
+ """记录该 client 对 code_key 的最新订阅 seq(供下次重复订阅时先释放旧 seq)。"""
674
+ if client_info is None or seq is None:
675
+ return
676
+ with self._lock:
677
+ self._subscriptions.setdefault(client_info, {})[code_key] = seq
678
+
679
+ def clear_client_subscriptions(self, client_info: Optional[str], unsubscribe_func):
680
+ """清理该 client 的所有 miniquote 订阅(unsubscribe 所有 seq),on_disconnect 调用。"""
681
+ if client_info is None:
682
+ return
683
+ with self._lock:
684
+ subs = self._subscriptions.pop(client_info, None)
685
+ if not subs:
686
+ return
687
+ for seq in subs.values():
688
+ try:
689
+ unsubscribe_func(seq)
690
+ except Exception as exc:
691
+ logger.warning(f"[QuoteEvent] 清理订阅失败 seq={seq}: {exc}")
692
+ logger.info(
693
+ f"[QuoteEvent] 清理断开客户端的订阅: client={client_info} removed={len(subs)}"
694
+ )
695
+
659
696
  def _maybe_warn_subscriber_count(self):
660
697
  """订阅者数量超过水位时打 warning(回落时复位,便于反复告警)。"""
661
698
  n = len(self._subscribers)
@@ -681,6 +718,40 @@ _QUOTE_SUBSCRIBE_CALLBACK_POS = {
681
718
  }
682
719
 
683
720
 
721
+ # ==================== 服务实例标识 ====================
722
+
723
+ # server 进程启动时生成的唯一标识,用于让客户端轻量感知 server 重启:
724
+ # 客户端通过 get_instance_id() 对比该值,一旦变化说明 server 重启过,
725
+ # 内存态的订阅/回调状态已丢失,需要重新订阅。避免用「重复订阅 + seq 回退」
726
+ # 这种重且带副作用的方式探测重启(曾导致 miniquote 订阅累积泄漏)。
727
+ _INSTANCE_ID = uuid.uuid4().hex
728
+
729
+
730
+ def _normalize_code_key(code_list) -> tuple:
731
+ """把订阅的 code_list 规范化为可哈希的元组,用于订阅幂等去重。
732
+
733
+ subscribe_whole_quote 的 code_list 是 list(如 ['688523.SH'] / ['SH','SZ']),
734
+ subscribe_quote/quote2 的 stock_code 是单个 str。统一转成排序后的 tuple。
735
+ """
736
+ if isinstance(code_list, (list, tuple, set)):
737
+ return tuple(sorted(str(c) for c in code_list))
738
+ if isinstance(code_list, str):
739
+ return (code_list,)
740
+ return (str(code_list),)
741
+
742
+
743
+ def _unsubscribe_safely(target, seq):
744
+ """安全地取消一个 miniquote 订阅(unsubscribe_quote),失败不抛出。"""
745
+ if seq is None:
746
+ return
747
+ try:
748
+ unsubscribe = getattr(target, 'unsubscribe_quote', None)
749
+ if unsubscribe is not None:
750
+ unsubscribe(seq)
751
+ except Exception as exc:
752
+ logger.warning(f"[QuoteEvent] 取消旧订阅失败 seq={seq}: {exc}")
753
+
754
+
684
755
  # ==================== download 类调用超时隔离 ====================
685
756
 
686
757
  # 需要超时/线程隔离的 download 类方法名(盘后券商挂起会永久阻塞 worker 线程)
@@ -808,6 +879,7 @@ class LoggingProxy:
808
879
  if callable(attr):
809
880
  def wrapper(*args, **kwargs):
810
881
  full_name = f"{target_name}.{name}"
882
+ _sub_key = None # 订阅幂等:本次调用的 code_key,供 _log_call 后记录 seq
811
883
 
812
884
  # 权限检查
813
885
  if permission_checker and account_level:
@@ -844,6 +916,11 @@ class LoggingProxy:
844
916
  if target_name == 'xtdata' and quote_event_callback is not None:
845
917
  if name in _QUOTE_SUBSCRIBE_CALLBACK_POS:
846
918
  pos = _QUOTE_SUBSCRIBE_CALLBACK_POS[name]
919
+ # 订阅幂等:提取 code_key(方法名 + 规范化 code_list),
920
+ # 同一 client 重复订阅时先 unsubscribe 旧 seq,避免 miniquote 累积。
921
+ _code_list = _deliver(args[0]) if args else kwargs.get('stock_code')
922
+ if _code_list is not None:
923
+ _sub_key = (name, _normalize_code_key(_code_list))
847
924
  client_callback = kwargs.pop('callback', None)
848
925
  if client_callback is not None:
849
926
  # 客户端传了接收器(netref),注册到路由器(带 client_info 供断线清理)
@@ -858,6 +935,11 @@ class LoggingProxy:
858
935
  else:
859
936
  # 未传回调:仍用服务端路由器接管(此时无订阅者,数据被丢弃)
860
937
  kwargs['callback'] = quote_event_callback
938
+ # 幂等:重复订阅先释放旧 seq(失败不阻断本次订阅)
939
+ if _sub_key is not None:
940
+ old_seq = quote_event_callback.get_subscription_seq(get_client_info(), _sub_key)
941
+ if old_seq is not None:
942
+ _unsubscribe_safely(target, old_seq)
861
943
 
862
944
  # download 类调用统一加超时隔离:对直通底层 xtquant 的 download
863
945
  # 方法(无 exposed_* 封装的)包进 _call_download_with_timeout,
@@ -870,6 +952,12 @@ class LoggingProxy:
870
952
  else:
871
953
  result = _log_call(full_name, get_client_info(), attr, *args, **kwargs)
872
954
 
955
+ # 订阅幂等:记录本次订阅返回的 seq,供下次重复订阅时先释放旧 seq
956
+ if _sub_key is not None:
957
+ _seq = _deliver(result)
958
+ if isinstance(_seq, int):
959
+ quote_event_callback.record_subscription(get_client_info(), _sub_key, _seq)
960
+
873
961
  # 如果返回的是复杂对象(非基本类型),递归包装
874
962
  if result is not None and hasattr(result, '__class__'):
875
963
  if not isinstance(result, (int, float, str, bool, list, dict, tuple, type(None), bytes)):
@@ -975,6 +1063,12 @@ class XtQuantService(rpyc.Service):
975
1063
  qec = XtQuantService._quote_event_callback
976
1064
  if qec is not None:
977
1065
  qec.clear_client_callbacks(client_info)
1066
+ # 清理本连接向 miniquote 建立的所有订阅(unsubscribe 所有 seq),
1067
+ # 避免 miniquote 侧订阅累积泄漏(根因:反复订阅不取消)。
1068
+ qec.clear_client_subscriptions(
1069
+ client_info,
1070
+ lambda seq: _unsubscribe_safely(XtQuantService._xtdata, seq),
1071
+ )
978
1072
  # 自动清理本次连接创建的所有 trader 实例及其事件路由器,
979
1073
  # 含停止 _TraderEventCallback 的 dispatch daemon 线程(否则线程持
980
1074
  # 有回调对象与 netref,随断线累积泄漏)
@@ -1044,6 +1138,16 @@ class XtQuantService(rpyc.Service):
1044
1138
  def exposed_heartbeat(self):
1045
1139
  return "pong"
1046
1140
 
1141
+ @log_api_call("get_instance_id")
1142
+ def exposed_get_instance_id(self):
1143
+ """返回本 server 进程的实例标识。
1144
+
1145
+ 供客户端轻量感知 server 重启:该值在每次 server 进程启动时变化。
1146
+ 客户端可周期性对比(例如复用现有 heartbeat 流程或单独轮询),
1147
+ 一旦变化即说明订阅/回调等内存态已丢失,需要重新订阅。
1148
+ """
1149
+ return _INSTANCE_ID
1150
+
1047
1151
  # ==================== 模块代理接口 ====================
1048
1152
 
1049
1153
  @log_api_call("get_xtdata")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xtquant-share
3
- Version: 1.3.1
3
+ Version: 1.4.0
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
@@ -50,6 +50,7 @@ Dynamic: license-file
50
50
  - ✅ **认证加密** - 支持 HMAC token 认证,可选 SSL/TLS 加密
51
51
  - ✅ **断线重连** - 自动检测断线并重连,指数退避策略
52
52
  - ✅ **心跳保活** - 定期心跳检测,保持连接活跃
53
+ - ✅ **服务实例标识** - `get_instance_id()` 轻量感知 server 重启;行情订阅幂等自动去重,阻断底层 miniquote 订阅累积
53
54
  - ✅ **异步回调** - 支持交易事件(on_stock_*)与行情 tick 订阅回调(`xtdata.register_quote_callback` + `subscribe_whole_quote`)
54
55
  - ✅ **无感切换** - 大QMT ↔ miniQMT 无感切换(行情侧),自动探测 miniQMT 可用性,不可用自动切 bigqmt 通道(复用 xtquant_big_convert)
55
56
  - ✅ **完整日志** - API调用日志,记录函数名、参数、耗时
@@ -801,6 +802,7 @@ print(status)
801
802
 
802
803
  | 版本 | 日期 | 更新内容 |
803
804
  |------|------|----------|
805
+ | 1.4.0 | 2026-10-03 | 新增 `get_instance_id()` 服务实例标识(轻量感知 server 重启);行情订阅幂等(重复订阅自动释放旧 seq,阻断 miniquote 订阅累积泄漏) |
804
806
  | 1.1.1 | 2026-03-18 | 新增 xtview 模块支持(视图控制、调度任务管理),兼容不同 xtquant 版本 |
805
807
  | 1.1.0 | 2026-03-17 | 交易功能优化完善、`xqshare-server` 命令、`.env` 配置支持、远程对象传输性能优化 |
806
808
  | 1.0.4 | 2026-03-09 | JSON 输出优化:远程 DataFrame 高效序列化、`--compact` 参数、全局参数位置灵活、嵌套结构支持 |
File without changes
File without changes