hyperquant 0.63__py3-none-any.whl → 0.64__py3-none-any.whl

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.
@@ -69,6 +69,14 @@ class Lbank:
69
69
  """订阅指定交易对的订单簿(遵循 LBank 协议)。
70
70
  """
71
71
 
72
+ async def sub(payload):
73
+ wsapp = self.client.ws_connect(
74
+ self.ws_url,
75
+ hdlr_bytes=self.store.onmessage,
76
+ send_json=payload,
77
+ )
78
+ await wsapp._event.wait()
79
+
72
80
  send_jsons = []
73
81
  y = 3000000001
74
82
  if limit:
@@ -94,10 +102,4 @@ class Lbank:
94
102
  self.store.register_book_channel(str(y), symbol)
95
103
  y += 1
96
104
 
97
- wsapp = self.client.ws_connect(
98
- self.ws_url,
99
- send_json=send_jsons,
100
- hdlr_bytes=self.store.onmessage,
101
- )
102
-
103
- await wsapp._event.wait()
105
+ await asyncio.gather(*(sub(send_json) for send_json in send_jsons))
@@ -35,34 +35,7 @@ class Book(DataStore):
35
35
  self.symbol_map: dict[str, str] = {}
36
36
 
37
37
 
38
- def _format_levels(
39
- self,
40
- levels: list[list[Any]],
41
- channel_id: str | None,
42
- side: str,
43
- symbol: str | None,
44
- ) -> list[dict[str, Any]]:
45
- formatted: list[dict[str, Any]] = []
46
- for level in levels:
47
- if len(level) < 2:
48
- continue
49
- try:
50
- price = float(level[0])
51
- size = float(level[1])
52
- except (TypeError, ValueError): # pragma: no cover - defensive guard
53
- continue
54
- formatted.append(
55
- {
56
- "id": channel_id,
57
- "S": side,
58
- "p": price,
59
- "q": size,
60
- "s": symbol,
61
- }
62
- )
63
- if self.limit is not None:
64
- formatted = formatted[: self.limit]
65
- return formatted
38
+
66
39
 
67
40
  def _on_message(self, msg: Any) -> None:
68
41
 
@@ -81,11 +54,21 @@ class Book(DataStore):
81
54
  if symbol is None and data.get("i"):
82
55
  symbol = self.symbol_map.get(str(data["i"]))
83
56
 
84
- bids = self._format_levels(data.get("b", []), channel_id, "b", symbol)
85
- asks = self._format_levels(data.get("s", []), channel_id, "a", symbol)
86
-
57
+ bids = data.get("b", [])
58
+ asks = data.get("s", [])
87
59
  if not (bids or asks):
88
60
  return
61
+ bids = bids[: self.limit] if self.limit else bids
62
+ asks = asks[: self.limit] if self.limit else asks
63
+ bids = [
64
+ {"id": channel_id, "S": "b", "p": str(item[0]), "q": str(item[1]), "s": symbol}
65
+ for item in bids
66
+ ]
67
+ asks = [
68
+ {"id": channel_id, "S": "a", "p": str(item[0]), "q": str(item[1]), "s": symbol}
69
+ for item in asks
70
+ ]
71
+
89
72
 
90
73
  if channel_id is not None:
91
74
  self._find_and_delete({"id": channel_id})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperquant
3
- Version: 0.63
3
+ Version: 0.64
4
4
  Summary: A minimal yet hyper-efficient backtesting framework for quantitative trading
5
5
  Project-URL: Homepage, https://github.com/yourusername/hyperquant
6
6
  Project-URL: Issues, https://github.com/yourusername/hyperquant/issues
@@ -7,19 +7,19 @@ hyperquant/notikit.py,sha256=x5yAZ_tAvLQRXcRbcg-VabCaN45LUhvlTZnUqkIqfAA,3596
7
7
  hyperquant/broker/auth.py,sha256=oA9Yw1I59-u0Tnoj2e4wUup5q8V5T2qpga5RKbiAiZI,2614
8
8
  hyperquant/broker/edgex.py,sha256=qQtc8jZqB5ZODoGGVcG_aIVUlrJX_pRF9EyO927LiVM,6646
9
9
  hyperquant/broker/hyperliquid.py,sha256=7MxbI9OyIBcImDelPJu-8Nd53WXjxPB5TwE6gsjHbto,23252
10
- hyperquant/broker/lbank.py,sha256=e-DnZg-rBwpTV7FWmPpG89Y7kk7NZOzilvEn7V3LEI0,2978
10
+ hyperquant/broker/lbank.py,sha256=9waMiBfjsogewTwTOcaG5_5bJHLjXSrv56oqjEptgh4,3107
11
11
  hyperquant/broker/ourbit.py,sha256=NUcDSIttf-HGWzoW1uBTrGLPHlkuemMjYCm91MigTno,18228
12
12
  hyperquant/broker/ws.py,sha256=4Igi0zuwGHmU46BSz24sFURkYalrE5Z68qkZEFBfbJE,2147
13
13
  hyperquant/broker/lib/hpstore.py,sha256=LnLK2zmnwVvhEbLzYI-jz_SfYpO1Dv2u2cJaRAb84D8,8296
14
14
  hyperquant/broker/lib/hyper_types.py,sha256=HqjjzjUekldjEeVn6hxiWA8nevAViC2xHADOzDz9qyw,991
15
15
  hyperquant/broker/models/edgex.py,sha256=texNBwz_9r9CTl7dRNjvSm_toxV_og0TWnap3dqUk2s,15795
16
16
  hyperquant/broker/models/hyperliquid.py,sha256=c4r5739ibZfnk69RxPjQl902AVuUOwT8RNvKsMtwXBY,9459
17
- hyperquant/broker/models/lbank.py,sha256=_P0oRPID2Yd_cpElHa3QIT471YlfIzexXMrzm1WVnHI,7652
17
+ hyperquant/broker/models/lbank.py,sha256=ArYBHHF9p66rNXs9fn41W2asa5mK-mqgplajCHr51YA,7106
18
18
  hyperquant/broker/models/ourbit.py,sha256=xMcbuCEXd3XOpPBq0RYF2zpTFNnxPtuNJZCexMZVZ1k,41965
19
19
  hyperquant/datavison/_util.py,sha256=92qk4vO856RqycO0YqEIHJlEg-W9XKapDVqAMxe6rbw,533
20
20
  hyperquant/datavison/binance.py,sha256=3yNKTqvt_vUQcxzeX4ocMsI5k6Q6gLZrvgXxAEad6Kc,5001
21
21
  hyperquant/datavison/coinglass.py,sha256=PEjdjISP9QUKD_xzXNzhJ9WFDTlkBrRQlVL-5pxD5mo,10482
22
22
  hyperquant/datavison/okx.py,sha256=yg8WrdQ7wgWHNAInIgsWPM47N3Wkfr253169IPAycAY,6898
23
- hyperquant-0.63.dist-info/METADATA,sha256=yR1kCvRQayVfbHDAbBQAEC53n_-xTwyyDz7jsIgtwBM,4317
24
- hyperquant-0.63.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
- hyperquant-0.63.dist-info/RECORD,,
23
+ hyperquant-0.64.dist-info/METADATA,sha256=8O2BgrL-YzkxoAf0oqBhE9-hLdcwpvbBL6e_gpnOlAk,4317
24
+ hyperquant-0.64.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
+ hyperquant-0.64.dist-info/RECORD,,