hyperquant 0.2__tar.gz → 0.4__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 (31) hide show
  1. {hyperquant-0.2 → hyperquant-0.4}/.gitignore +0 -1
  2. {hyperquant-0.2 → hyperquant-0.4}/PKG-INFO +2 -1
  3. hyperquant-0.4/data/logs/notikit.log +0 -0
  4. {hyperquant-0.2 → hyperquant-0.4}/pyproject.toml +2 -1
  5. {hyperquant-0.2 → hyperquant-0.4}/src/hyperquant/__init__.py +4 -1
  6. hyperquant-0.4/src/hyperquant/broker/auth.py +88 -0
  7. hyperquant-0.4/src/hyperquant/broker/hyperliquid.py +570 -0
  8. hyperquant-0.4/src/hyperquant/broker/lib/hpstore.py +252 -0
  9. hyperquant-0.4/src/hyperquant/broker/lib/hyper_types.py +48 -0
  10. hyperquant-0.4/src/hyperquant/broker/models/hyperliquid.py +284 -0
  11. hyperquant-0.4/src/hyperquant/broker/models/ourbit.py +1054 -0
  12. hyperquant-0.4/src/hyperquant/broker/ourbit.py +500 -0
  13. hyperquant-0.4/src/hyperquant/broker/ws.py +48 -0
  14. {hyperquant-0.2 → hyperquant-0.4}/src/hyperquant/core.py +77 -26
  15. hyperquant-0.4/src/hyperquant/datavison/okx.py +177 -0
  16. hyperquant-0.4/src/hyperquant/notikit.py +124 -0
  17. hyperquant-0.4/test.py +120 -0
  18. hyperquant-0.4/tmp.py +131 -0
  19. {hyperquant-0.2 → hyperquant-0.4}/uv.lock +16 -1
  20. hyperquant-0.2/test.py +0 -44
  21. {hyperquant-0.2 → hyperquant-0.4}/.python-version +0 -0
  22. {hyperquant-0.2 → hyperquant-0.4}/README.md +0 -0
  23. {hyperquant-0.2 → hyperquant-0.4}/pub.sh +0 -0
  24. {hyperquant-0.2 → hyperquant-0.4}/requirements-dev.lock +0 -0
  25. {hyperquant-0.2 → hyperquant-0.4}/requirements.lock +0 -0
  26. {hyperquant-0.2 → hyperquant-0.4}/src/hyperquant/datavison/_util.py +0 -0
  27. {hyperquant-0.2 → hyperquant-0.4}/src/hyperquant/datavison/binance.py +0 -0
  28. {hyperquant-0.2 → hyperquant-0.4}/src/hyperquant/datavison/coinglass.py +0 -0
  29. {hyperquant-0.2 → hyperquant-0.4}/src/hyperquant/db.py +0 -0
  30. {hyperquant-0.2 → hyperquant-0.4}/src/hyperquant/draw.py +0 -0
  31. {hyperquant-0.2 → hyperquant-0.4}/src/hyperquant/logkit.py +0 -0
@@ -10,7 +10,6 @@ dist/
10
10
  downloads/
11
11
  eggs/
12
12
  .eggs/
13
- lib/
14
13
  lib64/
15
14
  parts/
16
15
  sdist/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperquant
3
- Version: 0.2
3
+ Version: 0.4
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
@@ -19,6 +19,7 @@ Requires-Dist: cryptography>=44.0.2
19
19
  Requires-Dist: duckdb>=1.2.2
20
20
  Requires-Dist: numpy>=1.21.0
21
21
  Requires-Dist: pandas>=2.2.3
22
+ Requires-Dist: pybotters>=1.9.1
22
23
  Requires-Dist: pyecharts>=2.0.8
23
24
  Description-Content-Type: text/markdown
24
25
 
File without changes
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "hyperquant"
3
- version = "0.2"
3
+ version = "0.4"
4
4
  description = "A minimal yet hyper-efficient backtesting framework for quantitative trading"
5
5
  authors = [
6
6
  { name = "MissinA", email = "1421329142@qq.com" }
@@ -13,6 +13,7 @@ dependencies = [
13
13
  "cryptography>=44.0.2",
14
14
  "numpy>=1.21.0", # Added numpy as a new dependency
15
15
  "duckdb>=1.2.2",
16
+ "pybotters>=1.9.1",
16
17
  ]
17
18
  readme = "README.md"
18
19
  requires-python = ">=3.9"
@@ -2,4 +2,7 @@ from .core import *
2
2
  from .draw import *
3
3
  from .logkit import *
4
4
  from .datavison import *
5
- __version__ = "0.1.0"
5
+ from .notikit import *
6
+ __version__ = "0.1.0"
7
+
8
+ from .broker import auth, ws
@@ -0,0 +1,88 @@
1
+ import time
2
+ import hashlib
3
+ from typing import Any
4
+ from aiohttp import ClientWebSocketResponse
5
+ from multidict import CIMultiDict
6
+ from yarl import URL
7
+ import pybotters
8
+ import json as pyjson
9
+ from urllib.parse import urlencode
10
+
11
+
12
+ def md5_hex(s: str) -> str:
13
+ return hashlib.md5(s.encode("utf-8")).hexdigest()
14
+
15
+
16
+ # 🔑 Ourbit 的鉴权函数
17
+ class Auth:
18
+ @staticmethod
19
+ def ourbit(args: tuple[str, URL], kwargs: dict[str, Any]) -> tuple[str, URL]:
20
+ method: str = args[0]
21
+ url: URL = args[1]
22
+ data = kwargs.get("data") or {}
23
+ headers: CIMultiDict = kwargs["headers"]
24
+
25
+ # 从 session 里取 token
26
+ session = kwargs["session"]
27
+ token = session.__dict__["_apis"][pybotters.auth.Hosts.items[url.host].name][0]
28
+
29
+ # 时间戳 & body
30
+ now_ms = int(time.time() * 1000)
31
+ raw_body_for_sign = (
32
+ data
33
+ if isinstance(data, str)
34
+ else pyjson.dumps(data, separators=(",", ":"), ensure_ascii=False)
35
+ )
36
+
37
+ # 签名
38
+ mid_hash = md5_hex(f"{token}{now_ms}")[7:]
39
+ final_hash = md5_hex(f"{now_ms}{raw_body_for_sign}{mid_hash}")
40
+
41
+ # 设置 headers
42
+ headers.update(
43
+ {
44
+ "Authorization": token,
45
+ "Language": "Chinese",
46
+ "language": "Chinese",
47
+ "Content-Type": "application/json",
48
+ "x-ourbit-sign": final_hash,
49
+ "x-ourbit-nonce": str(now_ms),
50
+ }
51
+ )
52
+
53
+ # 更新 kwargs.body,保证发出去的与签名一致
54
+ kwargs.update({"data": raw_body_for_sign})
55
+
56
+ return args
57
+
58
+ @staticmethod
59
+ def ourbit_spot(args: tuple[str, URL], kwargs: dict[str, Any]) -> tuple[str, URL]:
60
+ method: str = args[0]
61
+ url: URL = args[1]
62
+ data = kwargs.get("data") or {}
63
+ headers: CIMultiDict = kwargs["headers"]
64
+
65
+ # 从 session 里取 token
66
+ session = kwargs["session"]
67
+ token = session.__dict__["_apis"][pybotters.auth.Hosts.items[url.host].name][0]
68
+ cookie = f"uc_token={token}; u_id={token}; "
69
+ headers.update({"cookie": cookie})
70
+
71
+ # wss消息增加参数
72
+ # if headers.get("Upgrade") == "websocket":
73
+ # args = (method, url)
74
+ # # 拼接 token
75
+ # q = dict(url.query)
76
+ # q["token"] = token
77
+ # url = url.with_query(q)
78
+
79
+
80
+ return args
81
+
82
+
83
+ pybotters.auth.Hosts.items["futures.ourbit.com"] = pybotters.auth.Item(
84
+ "ourbit", Auth.ourbit
85
+ )
86
+ pybotters.auth.Hosts.items["www.ourbit.com"] = pybotters.auth.Item(
87
+ "ourbit", Auth.ourbit_spot
88
+ )