hyperquant 1.38__tar.gz → 1.39__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-1.38 → hyperquant-1.39}/PKG-INFO +1 -1
  2. {hyperquant-1.38 → hyperquant-1.39}/pyproject.toml +1 -1
  3. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/polymarket.py +20 -0
  4. {hyperquant-1.38 → hyperquant-1.39}/uv.lock +1 -1
  5. {hyperquant-1.38 → hyperquant-1.39}/.gitignore +0 -0
  6. {hyperquant-1.38 → hyperquant-1.39}/README.md +0 -0
  7. {hyperquant-1.38 → hyperquant-1.39}/requirements-dev.lock +0 -0
  8. {hyperquant-1.38 → hyperquant-1.39}/requirements.lock +0 -0
  9. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/__init__.py +0 -0
  10. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/auth.py +0 -0
  11. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/bitget.py +0 -0
  12. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/bitmart.py +0 -0
  13. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/coinw.py +0 -0
  14. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/deepcoin.py +0 -0
  15. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/edgex.py +0 -0
  16. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/hyperliquid.py +0 -0
  17. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/lbank.py +0 -0
  18. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/lib/edgex_sign.py +0 -0
  19. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/lib/hpstore.py +0 -0
  20. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/lib/hyper_types.py +0 -0
  21. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/lib/util.py +0 -0
  22. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/lighter.py +0 -0
  23. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/apexpro.py +0 -0
  24. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/bitget.py +0 -0
  25. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/bitmart.py +0 -0
  26. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/coinw.py +0 -0
  27. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/deepcoin.py +0 -0
  28. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/edgex.py +0 -0
  29. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/hyperliquid.py +0 -0
  30. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/lbank.py +0 -0
  31. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/lighter.py +0 -0
  32. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/models/ourbit.py +0 -0
  33. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/ourbit.py +0 -0
  34. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/polymarket.py +0 -0
  35. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/broker/ws.py +0 -0
  36. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/core.py +0 -0
  37. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/datavison/_util.py +0 -0
  38. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/datavison/binance.py +0 -0
  39. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/datavison/coinglass.py +0 -0
  40. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/datavison/okx.py +0 -0
  41. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/db.py +0 -0
  42. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/draw.py +0 -0
  43. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/logkit.py +0 -0
  44. {hyperquant-1.38 → hyperquant-1.39}/src/hyperquant/notikit.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperquant
3
- Version: 1.38
3
+ Version: 1.39
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 = "1.38"
3
+ version = "1.39"
4
4
  description = "A minimal yet hyper-efficient backtesting framework for quantitative trading"
5
5
  authors = [
6
6
  { name = "MissinA", email = "1421329142@qq.com" }
@@ -29,6 +29,7 @@ class Position(DataStore):
29
29
  outcome = trade.get("outcome")
30
30
  side = str(trade.get("side") or "").upper()
31
31
  size_raw = trade.get("size")
32
+ price_raw = trade.get("price")
32
33
 
33
34
  if not asset_id or not outcome or side not in {"BUY", "SELL"}:
34
35
  return
@@ -37,19 +38,37 @@ class Position(DataStore):
37
38
  size = float(size_raw)
38
39
  except (TypeError, ValueError):
39
40
  return
41
+ try:
42
+ price = float(price_raw)
43
+ except (TypeError, ValueError):
44
+ price = None
40
45
 
41
46
  key = {"asset": asset_id, "outcome": outcome}
42
47
  existing = self.get(key) or {}
43
48
 
44
49
  cur_size = float(existing.get("size") or 0.0)
45
50
  cur_total_bought = float(existing.get("totalBought") or 0.0)
51
+ cur_avg_price = float(existing.get("avgPrice") or 0.0)
52
+ cur_cost = cur_size * cur_avg_price
46
53
 
47
54
  if side == "BUY":
48
55
  new_size = cur_size + size
49
56
  total_bought = cur_total_bought + size
57
+ # 未拿到成交价时使用当前均价兜底,避免均价被拉低
58
+ effective_price = price if price is not None else cur_avg_price
59
+ new_cost = cur_cost + size * effective_price
50
60
  else: # SELL
51
61
  new_size = cur_size - size
52
62
  total_bought = cur_total_bought
63
+ # 卖出按照当前均价释放成本
64
+ new_cost = cur_cost - min(size, cur_size) * cur_avg_price
65
+
66
+ if new_size <= 0:
67
+ new_size = 0.0
68
+ avg_price = 0.0
69
+ new_cost = 0.0
70
+ else:
71
+ avg_price = max(new_cost, 0.0) / new_size
53
72
 
54
73
  rec: dict[str, Any] = {
55
74
  "asset": asset_id,
@@ -57,6 +76,7 @@ class Position(DataStore):
57
76
  "side": side,
58
77
  "size": new_size,
59
78
  "totalBought": total_bought,
79
+ "avgPrice": avg_price,
60
80
  }
61
81
 
62
82
  if existing:
@@ -945,7 +945,7 @@ wheels = [
945
945
 
946
946
  [[package]]
947
947
  name = "hyperquant"
948
- version = "1.37"
948
+ version = "1.38"
949
949
  source = { editable = "." }
950
950
  dependencies = [
951
951
  { name = "aiohttp" },
File without changes
File without changes
File without changes