hyperquant 1.58__tar.gz → 1.59__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.
- {hyperquant-1.58 → hyperquant-1.59}/PKG-INFO +1 -1
- {hyperquant-1.58 → hyperquant-1.59}/pyproject.toml +1 -1
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/polymarket.py +37 -0
- {hyperquant-1.58 → hyperquant-1.59}/uv.lock +1 -1
- {hyperquant-1.58 → hyperquant-1.59}/.gitignore +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/README.md +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/requirements-dev.lock +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/requirements.lock +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/__init__.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/auth.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/bitget.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/bitmart.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/coinw.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/deepcoin.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/edgex.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/hyperliquid.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/lbank.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/lib/edgex_sign.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/lib/hpstore.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/lib/hyper_types.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/lib/polymarket/ctfAbi.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/lib/polymarket/safeAbi.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/lib/util.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/lighter.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/apexpro.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/bitget.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/bitmart.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/coinw.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/deepcoin.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/edgex.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/hyperliquid.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/lbank.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/lighter.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/models/ourbit.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/ourbit.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/polymarket.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/broker/ws.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/core.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/datavison/_util.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/datavison/binance.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/datavison/coinglass.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/datavison/okx.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/db.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/draw.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/logkit.py +0 -0
- {hyperquant-1.58 → hyperquant-1.59}/src/hyperquant/notikit.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hyperquant
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.59
|
|
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
|
|
@@ -187,6 +187,13 @@ class Position(DataStore):
|
|
|
187
187
|
"no_qty": 0.0,
|
|
188
188
|
"yes_avg_cost": 0.0,
|
|
189
189
|
"no_avg_cost": 0.0,
|
|
190
|
+
"cash_flow": 0.0,
|
|
191
|
+
"open_cost": 0.0,
|
|
192
|
+
"realized_pnl": 0.0,
|
|
193
|
+
"pnl_if_yes_win": 0.0,
|
|
194
|
+
"pnl_if_no_win": 0.0,
|
|
195
|
+
"max_loss": 0.0,
|
|
196
|
+
"best_case_pnl": 0.0,
|
|
190
197
|
"net_diff": 0.0,
|
|
191
198
|
"portfolio_cost": 0.0,
|
|
192
199
|
"yes_asset": None,
|
|
@@ -200,9 +207,17 @@ class Position(DataStore):
|
|
|
200
207
|
no_qty = float(state.get("no_qty") or 0.0)
|
|
201
208
|
yes_avg = float(state.get("yes_avg_cost") or 0.0)
|
|
202
209
|
no_avg = float(state.get("no_avg_cost") or 0.0)
|
|
210
|
+
cash_flow = float(state.get("cash_flow") or 0.0)
|
|
211
|
+
open_cost = yes_qty * yes_avg + no_qty * no_avg
|
|
203
212
|
|
|
204
213
|
state["net_diff"] = yes_qty - no_qty
|
|
205
214
|
state["portfolio_cost"] = (yes_avg + no_avg) if (yes_qty > 0.0 and no_qty > 0.0) else 0.0
|
|
215
|
+
state["open_cost"] = open_cost
|
|
216
|
+
state["realized_pnl"] = cash_flow + open_cost
|
|
217
|
+
state["pnl_if_yes_win"] = cash_flow + yes_qty
|
|
218
|
+
state["pnl_if_no_win"] = cash_flow + no_qty
|
|
219
|
+
state["max_loss"] = min(state["pnl_if_yes_win"], state["pnl_if_no_win"])
|
|
220
|
+
state["best_case_pnl"] = max(state["pnl_if_yes_win"], state["pnl_if_no_win"])
|
|
206
221
|
|
|
207
222
|
def _upsert_row(self, row: dict[str, Any]) -> None:
|
|
208
223
|
existing = self.get({"asset": row["asset"]})
|
|
@@ -220,6 +235,13 @@ class Position(DataStore):
|
|
|
220
235
|
"no_qty": float(state.get("no_qty") or 0.0),
|
|
221
236
|
"yes_avg_cost": float(state.get("yes_avg_cost") or 0.0),
|
|
222
237
|
"no_avg_cost": float(state.get("no_avg_cost") or 0.0),
|
|
238
|
+
"cash_flow": float(state.get("cash_flow") or 0.0),
|
|
239
|
+
"open_cost": float(state.get("open_cost") or 0.0),
|
|
240
|
+
"realized_pnl": float(state.get("realized_pnl") or 0.0),
|
|
241
|
+
"pnl_if_yes_win": float(state.get("pnl_if_yes_win") or 0.0),
|
|
242
|
+
"pnl_if_no_win": float(state.get("pnl_if_no_win") or 0.0),
|
|
243
|
+
"max_loss": float(state.get("max_loss") or 0.0),
|
|
244
|
+
"best_case_pnl": float(state.get("best_case_pnl") or 0.0),
|
|
223
245
|
"net_diff": float(state.get("net_diff") or 0.0),
|
|
224
246
|
"portfolio_cost": float(state.get("portfolio_cost") or 0.0),
|
|
225
247
|
"ts": now_ms,
|
|
@@ -238,6 +260,8 @@ class Position(DataStore):
|
|
|
238
260
|
"size": yes_qty,
|
|
239
261
|
"avgPrice": yes_avg,
|
|
240
262
|
"totalAvgPrice": yes_avg,
|
|
263
|
+
"expected_pnl_if_win": common["pnl_if_yes_win"],
|
|
264
|
+
"expected_pnl_if_lose": common["pnl_if_no_win"],
|
|
241
265
|
**common,
|
|
242
266
|
}
|
|
243
267
|
)
|
|
@@ -251,6 +275,8 @@ class Position(DataStore):
|
|
|
251
275
|
"size": no_qty,
|
|
252
276
|
"avgPrice": no_avg,
|
|
253
277
|
"totalAvgPrice": no_avg,
|
|
278
|
+
"expected_pnl_if_win": common["pnl_if_no_win"],
|
|
279
|
+
"expected_pnl_if_lose": common["pnl_if_yes_win"],
|
|
254
280
|
**common,
|
|
255
281
|
}
|
|
256
282
|
)
|
|
@@ -298,6 +324,8 @@ class Position(DataStore):
|
|
|
298
324
|
delta = size * trade_sign * status_sign
|
|
299
325
|
if abs(delta) < 1e-12:
|
|
300
326
|
return
|
|
327
|
+
cash_delta = (-price * size if side == "BUY" else price * size) * status_sign
|
|
328
|
+
state["cash_flow"] = float(state.get("cash_flow") or 0.0) + cash_delta
|
|
301
329
|
|
|
302
330
|
qty_key = "yes_qty" if side_key == "YES" else "no_qty"
|
|
303
331
|
avg_key = "yes_avg_cost" if side_key == "YES" else "no_avg_cost"
|
|
@@ -1104,6 +1132,15 @@ class PolymarketDataStore(DataStoreCollection):
|
|
|
1104
1132
|
"no_qty": 3.0, // NO腿数量
|
|
1105
1133
|
"yes_avg_cost": 0.47, // YES腿VWAP成本
|
|
1106
1134
|
"no_avg_cost": 0.49, // NO腿VWAP成本
|
|
1135
|
+
"cash_flow": -0.88, // 交易净现金流(买入为负,卖出为正), FAILED会反向回滚
|
|
1136
|
+
"open_cost": 3.82, // 当前未平仓持仓成本 = yes_qty*yes_avg_cost + no_qty*no_avg_cost
|
|
1137
|
+
"realized_pnl": 2.94, // 已实现盈亏 = cash_flow + open_cost
|
|
1138
|
+
"pnl_if_yes_win": 4.12, // 若YES结算为1、NO归零时的最终盈亏
|
|
1139
|
+
"pnl_if_no_win": 2.12, // 若NO结算为1、YES归零时的最终盈亏
|
|
1140
|
+
"max_loss": 2.12, // 两种结算情景下的较差结果
|
|
1141
|
+
"best_case_pnl": 4.12, // 两种结算情景下的较优结果
|
|
1142
|
+
"expected_pnl_if_win": 4.12, // 对当前asset而言,该outcome获胜时的预期最终盈亏
|
|
1143
|
+
"expected_pnl_if_lose": 2.12,// 对当前asset而言,该outcome落败时的预期最终盈亏
|
|
1107
1144
|
"net_diff": 2.0, // 净敞口 = yes_qty - no_qty
|
|
1108
1145
|
"portfolio_cost": 0.96, // 组合成本 = yes_avg_cost + no_avg_cost(双腿都有仓时)
|
|
1109
1146
|
"ts": 1772269014393, // 本地更新时间戳(ms)
|
|
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
|
|
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
|
|
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
|
|
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
|