hyperquant 0.63__tar.gz → 0.64__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 (44) hide show
  1. {hyperquant-0.63 → hyperquant-0.64}/PKG-INFO +1 -1
  2. {hyperquant-0.63 → hyperquant-0.64}/pyproject.toml +1 -1
  3. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/lbank.py +9 -7
  4. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/models/lbank.py +14 -31
  5. {hyperquant-0.63 → hyperquant-0.64}/tests/test_lbank.py +23 -7
  6. {hyperquant-0.63 → hyperquant-0.64}/uv.lock +1 -1
  7. {hyperquant-0.63 → hyperquant-0.64}/.gitignore +0 -0
  8. {hyperquant-0.63 → hyperquant-0.64}/.python-version +0 -0
  9. {hyperquant-0.63 → hyperquant-0.64}/README.md +0 -0
  10. {hyperquant-0.63 → hyperquant-0.64}/apis.json +0 -0
  11. {hyperquant-0.63 → hyperquant-0.64}/backtest_tmp.py +0 -0
  12. {hyperquant-0.63 → hyperquant-0.64}/data/alpine_smoke.log +0 -0
  13. {hyperquant-0.63 → hyperquant-0.64}/data/logs/notikit.log +0 -0
  14. {hyperquant-0.63 → hyperquant-0.64}/data/logs/test_order_sync.log +0 -0
  15. {hyperquant-0.63 → hyperquant-0.64}/data/records_swap.csv +0 -0
  16. {hyperquant-0.63 → hyperquant-0.64}/data/records_swapc.csv +0 -0
  17. {hyperquant-0.63 → hyperquant-0.64}/deals.json +0 -0
  18. {hyperquant-0.63 → hyperquant-0.64}/pub.sh +0 -0
  19. {hyperquant-0.63 → hyperquant-0.64}/requirements-dev.lock +0 -0
  20. {hyperquant-0.63 → hyperquant-0.64}/requirements.lock +0 -0
  21. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/__init__.py +0 -0
  22. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/auth.py +0 -0
  23. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/edgex.py +0 -0
  24. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/hyperliquid.py +0 -0
  25. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/lib/hpstore.py +0 -0
  26. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/lib/hyper_types.py +0 -0
  27. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/models/edgex.py +0 -0
  28. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/models/hyperliquid.py +0 -0
  29. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/models/ourbit.py +0 -0
  30. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/ourbit.py +0 -0
  31. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/broker/ws.py +0 -0
  32. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/core.py +0 -0
  33. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/datavison/_util.py +0 -0
  34. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/datavison/binance.py +0 -0
  35. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/datavison/coinglass.py +0 -0
  36. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/datavison/okx.py +0 -0
  37. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/db.py +0 -0
  38. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/draw.py +0 -0
  39. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/logkit.py +0 -0
  40. {hyperquant-0.63 → hyperquant-0.64}/src/hyperquant/notikit.py +0 -0
  41. {hyperquant-0.63 → hyperquant-0.64}/tests/test_draw.py +0 -0
  42. {hyperquant-0.63 → hyperquant-0.64}/tests/test_edgex.py +0 -0
  43. {hyperquant-0.63 → hyperquant-0.64}/tests/test_ourbit.py +0 -0
  44. {hyperquant-0.63 → hyperquant-0.64}/tests/tmp.py +0 -0
@@ -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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "hyperquant"
3
- version = "0.63"
3
+ version = "0.64"
4
4
  description = "A minimal yet hyper-efficient backtesting framework for quantitative trading"
5
5
  authors = [
6
6
  { name = "MissinA", email = "1421329142@qq.com" }
@@ -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,4 +1,5 @@
1
1
  import asyncio
2
+ import json
2
3
  import zlib
3
4
  from aiohttp import ClientWebSocketResponse
4
5
  import pybotters
@@ -12,7 +13,9 @@ def callback(msg, ws: ClientWebSocketResponse = None):
12
13
 
13
14
  def callback2(msg, ws: ClientWebSocketResponse = None):
14
15
  # print("Received message:", msg)
15
- print(str(msg))
16
+ # print(str(msg))
17
+ data = json.loads(msg)
18
+ print(data.get('y'))
16
19
 
17
20
 
18
21
  async def main():
@@ -41,11 +44,20 @@ async def main2():
41
44
  async with pybotters.Client() as client:
42
45
  # webData2
43
46
  # x 为chanel, y为唯一标识, a为参数, z为版本号
44
- client.ws_connect(
47
+ wsapp = client.ws_connect(
45
48
  "wss://uuws.rerrkvifj.com/ws/v3",
46
- send_json={"x": 3, "y": "3000000001", "a": {"i": "BTCUSDT_0.1_25"}, "z": 1},
49
+ send_json={'x': 3, 'y': '3000000001', 'a': {'i': 'SOLUSDT_0.01_25'}, 'z': 1},
47
50
  hdlr_bytes=callback2,
48
51
  )
52
+ await wsapp._event.wait()
53
+
54
+ async with pybotters.Client() as client2:
55
+ client2.ws_connect(
56
+ "wss://uuws.rerrkvifj.com/ws/v3",
57
+ send_json={'x': 3, 'y': '3000000002', 'a': {'i': 'XRPUSDT_0.0001_25'}, 'z': 1},
58
+ hdlr_bytes=callback2,
59
+ )
60
+ await wsapp.current_ws.send_json({'x': 3, 'y': '3000000002', 'a': {'i': 'XRPUSDT_0.0001_25'}, 'z': 1})
49
61
 
50
62
  while True:
51
63
  await asyncio.sleep(1)
@@ -73,13 +85,17 @@ async def test_broker_detail():
73
85
  async def test_broker_subbook():
74
86
  async with pybotters.Client() as client:
75
87
  async with Lbank(client) as lb:
76
- # 取20个symbol 尝试是否可以订阅成功
77
- symbols = [item["symbol"] for item in lb.store.detail.find()[:4]]
88
+ symbols = [item['symbol'] for item in lb.store.detail.find()]
89
+ symbols = symbols[10:30]
90
+ print(symbols)
91
+
78
92
  await lb.sub_orderbook(symbols, limit=1)
93
+
79
94
  while True:
95
+ print(lb.store.book.find({
96
+ "s": symbols[8]
97
+ }))
80
98
  await asyncio.sleep(1)
81
- print(len(lb.store.book.find()))
82
-
83
99
 
84
100
  if __name__ == "__main__":
85
101
  asyncio.run(test_broker_subbook())
@@ -530,7 +530,7 @@ wheels = [
530
530
 
531
531
  [[package]]
532
532
  name = "hyperquant"
533
- version = "0.62"
533
+ version = "0.63"
534
534
  source = { editable = "." }
535
535
  dependencies = [
536
536
  { name = "aiohttp" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes