hyperquant 0.3__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 (34) hide show
  1. {hyperquant-0.3 → hyperquant-0.4}/PKG-INFO +1 -1
  2. {hyperquant-0.3 → hyperquant-0.4}/pyproject.toml +1 -1
  3. hyperquant-0.4/src/hyperquant/broker/auth.py +88 -0
  4. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/broker/hyperliquid.py +0 -2
  5. hyperquant-0.4/src/hyperquant/broker/models/ourbit.py +1054 -0
  6. hyperquant-0.4/src/hyperquant/broker/ourbit.py +500 -0
  7. hyperquant-0.4/src/hyperquant/broker/ws.py +48 -0
  8. {hyperquant-0.3 → hyperquant-0.4}/test.py +16 -2
  9. hyperquant-0.4/tmp.py +131 -0
  10. {hyperquant-0.3 → hyperquant-0.4}/uv.lock +1 -1
  11. hyperquant-0.3/src/hyperquant/broker/auth.py +0 -51
  12. hyperquant-0.3/src/hyperquant/broker/models/ourbit.py +0 -502
  13. hyperquant-0.3/src/hyperquant/broker/ourbit.py +0 -234
  14. hyperquant-0.3/src/hyperquant/broker/ws.py +0 -12
  15. {hyperquant-0.3 → hyperquant-0.4}/.gitignore +0 -0
  16. {hyperquant-0.3 → hyperquant-0.4}/.python-version +0 -0
  17. {hyperquant-0.3 → hyperquant-0.4}/README.md +0 -0
  18. {hyperquant-0.3 → hyperquant-0.4}/data/logs/notikit.log +0 -0
  19. {hyperquant-0.3 → hyperquant-0.4}/pub.sh +0 -0
  20. {hyperquant-0.3 → hyperquant-0.4}/requirements-dev.lock +0 -0
  21. {hyperquant-0.3 → hyperquant-0.4}/requirements.lock +0 -0
  22. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/__init__.py +0 -0
  23. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/broker/lib/hpstore.py +0 -0
  24. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/broker/lib/hyper_types.py +0 -0
  25. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/broker/models/hyperliquid.py +0 -0
  26. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/core.py +0 -0
  27. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/datavison/_util.py +0 -0
  28. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/datavison/binance.py +0 -0
  29. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/datavison/coinglass.py +0 -0
  30. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/datavison/okx.py +0 -0
  31. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/db.py +0 -0
  32. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/draw.py +0 -0
  33. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/logkit.py +0 -0
  34. {hyperquant-0.3 → hyperquant-0.4}/src/hyperquant/notikit.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperquant
3
- Version: 0.3
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "hyperquant"
3
- version = "0.3"
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" }
@@ -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
+ )
@@ -27,8 +27,6 @@ import pybotters
27
27
  from yarl import URL
28
28
 
29
29
  from .models.hyperliquid import MyHyperStore
30
- import uuid
31
-
32
30
 
33
31
  def to_cloid(s: str) -> str:
34
32
  """