hyperquant 0.55__tar.gz → 0.56__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-0.55 → hyperquant-0.56}/PKG-INFO +1 -1
- {hyperquant-0.55 → hyperquant-0.56}/pyproject.toml +1 -1
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/broker/models/ourbit.py +1 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/broker/ourbit.py +1 -0
- {hyperquant-0.55 → hyperquant-0.56}/tests/test_ourbit.py +1 -1
- {hyperquant-0.55 → hyperquant-0.56}/uv.lock +1 -1
- hyperquant-0.55/tests/test_order_sync.py +0 -82
- {hyperquant-0.55 → hyperquant-0.56}/.gitignore +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/.python-version +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/README.md +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/apis.json +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/backtest_tmp.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/data/alpine_smoke.log +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/data/logs/notikit.log +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/data/logs/test_order_sync.log +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/deals.json +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/pnl_chart.html +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/pub.sh +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/requirements-dev.lock +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/requirements.lock +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/__init__.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/broker/auth.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/broker/hyperliquid.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/broker/lib/hpstore.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/broker/lib/hyper_types.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/broker/models/hyperliquid.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/broker/ws.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/core.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/datavison/_util.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/datavison/binance.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/datavison/coinglass.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/datavison/okx.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/db.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/draw.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/logkit.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/src/hyperquant/notikit.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/tests/test.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/tests/test_draw.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/tests/test_lbank.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/tests/test_store.py +0 -0
- {hyperquant-0.55 → hyperquant-0.56}/tests/tmp.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hyperquant
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.56
|
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
|
@@ -173,7 +173,7 @@ async def test_order_sync_swap():
|
|
173
173
|
# await ob.sub_orderbook(["SOL_USDT"]) # 订单簿频道
|
174
174
|
# # 示例:市价
|
175
175
|
# now= time.time()
|
176
|
-
result = await order_sync( ob, symbol="SOL_USDT", side="buy", order_type="
|
176
|
+
result = await order_sync( ob, symbol="SOL_USDT", side="buy", order_type="market", usdt_amount=8, price=200, window_sec=3)
|
177
177
|
print(result)
|
178
178
|
|
179
179
|
|
@@ -1,82 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
import time
|
3
|
-
from hyperquant.broker.ourbit import OurbitSpot
|
4
|
-
import pybotters
|
5
|
-
from hyperquant.logkit import get_logger
|
6
|
-
|
7
|
-
logger = get_logger('test_order_sync', './data/logs/test_order_sync.log', show_time=True)
|
8
|
-
|
9
|
-
|
10
|
-
# 等待指定 oid 的最终 delete,超时抛 TimeoutError
|
11
|
-
async def wait_delete(stream: pybotters.StoreStream, oid: str, seconds: float):
|
12
|
-
async with asyncio.timeout(seconds):
|
13
|
-
while True:
|
14
|
-
change = await stream.__anext__()
|
15
|
-
if change.operation == "delete" and change.data.get("order_id") == oid:
|
16
|
-
return change.data # 内含 state / avg_price / deal_quantity 等累计字段
|
17
|
-
|
18
|
-
|
19
|
-
async def order_sync(
|
20
|
-
ob: OurbitSpot,
|
21
|
-
symbol: str = "SOL_USDT",
|
22
|
-
side: str = "buy",
|
23
|
-
order_type: str = "market", # "market" / "limit"
|
24
|
-
usdt_amount: float | None = None, # 市价可填
|
25
|
-
quantity: float | None = None, # 市价可填
|
26
|
-
price: float | None = None, # 限价必填
|
27
|
-
window_sec: float = 2.0, # 主等待窗口(限价可设为 5.0)
|
28
|
-
grace_sec: float = 2, # 撤单后宽限
|
29
|
-
):
|
30
|
-
with ob.store.orders.watch() as stream:
|
31
|
-
# 下单(只保留最简两种入参形态)
|
32
|
-
try:
|
33
|
-
oid = await ob.place_order(
|
34
|
-
symbol,
|
35
|
-
side,
|
36
|
-
order_type=order_type,
|
37
|
-
usdt_amount=usdt_amount,
|
38
|
-
quantity=quantity,
|
39
|
-
price=price,
|
40
|
-
)
|
41
|
-
except Exception as e:
|
42
|
-
return {"symbol": symbol, "state": "error", "error": str(e)}
|
43
|
-
|
44
|
-
# 步骤1:主窗口内等待这单的最终 delete
|
45
|
-
try:
|
46
|
-
return await wait_delete(stream, oid, window_sec)
|
47
|
-
except TimeoutError:
|
48
|
-
# 步骤2:到点撤单(市价通常用不到;限价才有意义)
|
49
|
-
for i in range(3):
|
50
|
-
try:
|
51
|
-
await ob.cancel_order(oid)
|
52
|
-
break
|
53
|
-
except Exception:
|
54
|
-
pass
|
55
|
-
await asyncio.sleep(0.1)
|
56
|
-
# 固定宽限内再等“迟到”的最终 delete
|
57
|
-
try:
|
58
|
-
return await wait_delete(stream, oid, grace_sec)
|
59
|
-
except TimeoutError:
|
60
|
-
return {"order_id": oid, "symbol": symbol, "state": "timeout"}
|
61
|
-
|
62
|
-
|
63
|
-
async def test_order_sync():
|
64
|
-
async with pybotters.Client(
|
65
|
-
apis={
|
66
|
-
"ourbit": [
|
67
|
-
"WEB3bf088f8b2f2fae07592fe1a6240e2d798100a9cb2a91f8fda1056b6865ab3ee"
|
68
|
-
]
|
69
|
-
}
|
70
|
-
) as client:
|
71
|
-
ob = OurbitSpot(client)
|
72
|
-
await ob.__aenter__()
|
73
|
-
await ob.sub_personal() # 私有频道
|
74
|
-
ob.store.book.limit = 3
|
75
|
-
await ob.sub_orderbook(["SOL_USDT"]) # 订单簿频道
|
76
|
-
# # 示例:市价
|
77
|
-
# now= time.time()
|
78
|
-
result = await order_sync( ob, symbol="SOL_USDT", side="buy", order_type="market", usdt_amount=8, price=200, window_sec=2)
|
79
|
-
print(result)
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|