hyperquant 0.87__py3-none-any.whl → 0.88__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.
@@ -292,7 +292,7 @@ class Coinw:
292
292
  ws_app = await self._ensure_private_ws()
293
293
  payloads = [
294
294
  {"event": "sub", "params": {"biz": "futures", "type": "order"}},
295
- {"event": "sub", "params": {"biz": "futures", "type": "position"}},
295
+ # {"event": "sub", "params": {"biz": "futures", "type": "position"}},
296
296
  {"event": "sub", "params": {"biz": "futures", "type": "position_change"}},
297
297
  {"event": "sub", "params": {"biz": "futures", "type": "assets"}},
298
298
  ]
@@ -280,15 +280,21 @@ class Orders(DataStore):
280
280
  class Position(DataStore):
281
281
  """CoinW 当前持仓数据存储。"""
282
282
 
283
- _KEYS = ["id"]
283
+ _KEYS = ["openId"]
284
284
 
285
285
  @staticmethod
286
286
  def _normalize(entry: dict[str, Any]) -> dict[str, Any] | None:
287
- position_id = entry.get("id")
288
- if position_id is None:
287
+ open_id = entry.get("openId")
288
+ if open_id is None:
289
289
  return None
290
290
  normalized = dict(entry)
291
- normalized["id"] = str(position_id)
291
+ normalized["openId"] = str(open_id)
292
+ normalized["status"] = str(entry.get("status") or entry.get("orderStatus") or "").lower()
293
+ normalized["is_closed"] = normalized["status"] in {"close", "closed", "finish"}
294
+ normalized["currentPiece"] = str(entry.get("currentPiece")) if entry.get("currentPiece") is not None else None
295
+ normalized["closedPiece"] = str(entry.get("closedPiece")) if entry.get("closedPiece") is not None else None
296
+ normalized["quantity"] = str(entry.get("quantity")) if entry.get("quantity") is not None else None
297
+ normalized["updatedDate"] = entry.get("updatedDate")
292
298
  return normalized
293
299
 
294
300
  def _onresponse(self, data: Any) -> None:
@@ -325,6 +331,7 @@ class Position(DataStore):
325
331
  return
326
332
 
327
333
  to_insert: list[dict[str, Any]] = []
334
+ to_update: list[dict[str, Any]] = []
328
335
  to_delete: list[dict[str, Any]] = []
329
336
 
330
337
  for entry in entries:
@@ -334,17 +341,21 @@ class Position(DataStore):
334
341
  if not normalized:
335
342
  continue
336
343
 
337
- status = normalized.get("status")
338
- normalized_status = str(status).lower() if status is not None else ""
339
- remove = normalized_status in {"close", "closed", "1", "2"}
344
+ criteria = {"openId": normalized["openId"]}
340
345
 
341
- query = {"id": normalized["id"]}
342
- to_delete.append(query)
343
- if not remove:
346
+ if normalized.get("is_closed"):
347
+ to_delete.append(criteria)
348
+ continue
349
+
350
+ if self.find(criteria):
351
+ to_update.append(normalized)
352
+ else:
344
353
  to_insert.append(normalized)
345
354
 
346
355
  if to_delete:
347
356
  self._delete(to_delete)
357
+ if to_update:
358
+ self._update(to_update)
348
359
  if to_insert:
349
360
  self._insert(to_insert)
350
361
 
@@ -453,7 +464,7 @@ class CoinwFuturesDataStore(DataStoreCollection):
453
464
  self.book._on_message(msg)
454
465
  elif msg_type == "order":
455
466
  self.orders._on_message(msg)
456
- elif msg_type == "position":
467
+ elif msg_type == "position" or msg_type == "position_change":
457
468
  self.position._on_message(msg)
458
469
  elif msg_type == "assets":
459
470
  self.balance._on_message(msg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperquant
3
- Version: 0.87
3
+ Version: 0.88
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
@@ -6,7 +6,7 @@ hyperquant/logkit.py,sha256=nUo7nx5eONvK39GOhWwS41zNRL756P2J7-5xGzwXnTY,8462
6
6
  hyperquant/notikit.py,sha256=x5yAZ_tAvLQRXcRbcg-VabCaN45LUhvlTZnUqkIqfAA,3596
7
7
  hyperquant/broker/auth.py,sha256=xNZEQP0LRRV9BkT2uXBJ-vFfeahUnRVq1bjIT6YbQu8,10089
8
8
  hyperquant/broker/bitget.py,sha256=X_S0LKZ7FZAEb6oEMr1vdGP1fondzK74BhmNTpRDSEA,9488
9
- hyperquant/broker/coinw.py,sha256=lRbxthAmIncTDcYm0VxZ-753HAj5_d5slwX-8EOHXyY,15854
9
+ hyperquant/broker/coinw.py,sha256=hSUdMfezWn2jJ9LGTLMFx6waSTE5kuypINDY1q8us5I,15856
10
10
  hyperquant/broker/edgex.py,sha256=TqUO2KRPLN_UaxvtLL6HnA9dAQXC1sGxOfqTHd6W5k8,18378
11
11
  hyperquant/broker/hyperliquid.py,sha256=7MxbI9OyIBcImDelPJu-8Nd53WXjxPB5TwE6gsjHbto,23252
12
12
  hyperquant/broker/lbank.py,sha256=98M5wmSoeHwbBYMA3rh25zqLb6fQKVaEmwqALF5nOvY,22181
@@ -17,7 +17,7 @@ hyperquant/broker/lib/hpstore.py,sha256=LnLK2zmnwVvhEbLzYI-jz_SfYpO1Dv2u2cJaRAb8
17
17
  hyperquant/broker/lib/hyper_types.py,sha256=HqjjzjUekldjEeVn6hxiWA8nevAViC2xHADOzDz9qyw,991
18
18
  hyperquant/broker/lib/util.py,sha256=iMU1qF0CHj5zzlIMEQGwjz-qtEVosEe7slXOCuB7Rcw,566
19
19
  hyperquant/broker/models/bitget.py,sha256=0RwDY75KrJb-c-oYoMxbqxWfsILe-n_Npojz4UFUq7c,11389
20
- hyperquant/broker/models/coinw.py,sha256=p86bzwBf-9GsRPMrtY7hWXkJphfSm7kN-_FRwEF9ZQ8,21264
20
+ hyperquant/broker/models/coinw.py,sha256=XLrARTyT4ClF1SEhaZ9uZHVo7ntAvE7nKxaU_mzVmqU,21949
21
21
  hyperquant/broker/models/edgex.py,sha256=vPAkceal44cjTYKQ_0BoNAskOpmkno_Yo1KxgMLPc6Y,33954
22
22
  hyperquant/broker/models/hyperliquid.py,sha256=c4r5739ibZfnk69RxPjQl902AVuUOwT8RNvKsMtwXBY,9459
23
23
  hyperquant/broker/models/lbank.py,sha256=vHkNKxIMzpoC_EwcZnEOPOupizF92yGWi9GKxvYYFUQ,19181
@@ -26,6 +26,6 @@ hyperquant/datavison/_util.py,sha256=92qk4vO856RqycO0YqEIHJlEg-W9XKapDVqAMxe6rbw
26
26
  hyperquant/datavison/binance.py,sha256=3yNKTqvt_vUQcxzeX4ocMsI5k6Q6gLZrvgXxAEad6Kc,5001
27
27
  hyperquant/datavison/coinglass.py,sha256=PEjdjISP9QUKD_xzXNzhJ9WFDTlkBrRQlVL-5pxD5mo,10482
28
28
  hyperquant/datavison/okx.py,sha256=yg8WrdQ7wgWHNAInIgsWPM47N3Wkfr253169IPAycAY,6898
29
- hyperquant-0.87.dist-info/METADATA,sha256=kKBv8ig72O_aDeRHobCeo3MJOKIxClr5UQwQOOO1x38,4317
30
- hyperquant-0.87.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
- hyperquant-0.87.dist-info/RECORD,,
29
+ hyperquant-0.88.dist-info/METADATA,sha256=JGkF-AvAkw1MGD_XnNSS5wR4x9g1etWbmw5ifc36AdI,4317
30
+ hyperquant-0.88.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
+ hyperquant-0.88.dist-info/RECORD,,