hyperquant 0.78__tar.gz → 0.81__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.78 → hyperquant-0.81}/PKG-INFO +1 -1
- {hyperquant-0.78 → hyperquant-0.81}/apis.json +1 -1
- {hyperquant-0.78 → hyperquant-0.81}/pyproject.toml +1 -1
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/auth.py +1 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/lbank.py +90 -0
- {hyperquant-0.78 → hyperquant-0.81}/tests/test_bitget.py +5 -5
- {hyperquant-0.78 → hyperquant-0.81}/tests/test_lbank.py +18 -7
- {hyperquant-0.78 → hyperquant-0.81}/uv.lock +1 -1
- {hyperquant-0.78 → hyperquant-0.81}/.gitignore +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/.python-version +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/README.md +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/data/alpine_smoke.log +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/data/logs/notikit.log +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/data/logs/test_order_sync.log +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/data/records_swap.csv +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/data/records_swapc.csv +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/doc/lbank.md +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/pub.sh +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/requirements-dev.lock +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/requirements.lock +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/__init__.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/bitget.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/edgex.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/hyperliquid.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/lib/edgex_sign.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/lib/hpstore.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/lib/hyper_types.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/lib/util.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/models/bitget.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/models/edgex.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/models/hyperliquid.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/models/lbank.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/models/ourbit.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/ourbit.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/broker/ws.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/core.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/datavison/_util.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/datavison/binance.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/datavison/coinglass.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/datavison/okx.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/db.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/draw.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/logkit.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/src/hyperquant/notikit.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/tests/test_draw.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/tests/test_edgex.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/tests/test_ourbit.py +0 -0
- {hyperquant-0.78 → hyperquant-0.81}/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.81
|
|
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
|
|
@@ -192,6 +192,7 @@ class Auth:
|
|
|
192
192
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
|
|
193
193
|
}
|
|
194
194
|
)
|
|
195
|
+
print(headers)
|
|
195
196
|
|
|
196
197
|
# 更新 kwargs.body,保证发出去的与签名一致
|
|
197
198
|
# kwargs.update({"data": raw_body_for_sign})
|
|
@@ -495,6 +495,96 @@ class Lbank:
|
|
|
495
495
|
if not isinstance(data, dict) or data.get("code") != 200:
|
|
496
496
|
raise RuntimeError(f"{operation} failed: {data}")
|
|
497
497
|
return data.get("data") or {}
|
|
498
|
+
|
|
499
|
+
# https://uuapi.rerrkvifj.com/cfd/agg/v1/sendQryAll
|
|
500
|
+
# {
|
|
501
|
+
# "productGroup": "SwapU",
|
|
502
|
+
# "instrumentID": "BTCUSDT",
|
|
503
|
+
# "asset": "USDT"
|
|
504
|
+
# }
|
|
505
|
+
|
|
506
|
+
async def query_all(self, symbol:str):
|
|
507
|
+
"""查询资产信息
|
|
508
|
+
|
|
509
|
+
.. code:: json
|
|
510
|
+
|
|
511
|
+
{
|
|
512
|
+
"fundingRateTimestamp": 28800,
|
|
513
|
+
"isMarketAcount": 0,
|
|
514
|
+
"longMaxVolume": 10000000000000000,
|
|
515
|
+
"role": 2,
|
|
516
|
+
"openingTime": 1609545600000,
|
|
517
|
+
"isCrossMargin": 1,
|
|
518
|
+
"longLeverage": 25,
|
|
519
|
+
"shortLastVolume": 10000000000000000,
|
|
520
|
+
"longLastVolume": 10000000000000000,
|
|
521
|
+
"onTime": 1609459200000,
|
|
522
|
+
"shortMaintenanceMarginRate": "0.0025",
|
|
523
|
+
"state": 3,
|
|
524
|
+
"markedPrice": "111031.3",
|
|
525
|
+
"assetBalance": {
|
|
526
|
+
"reserveAvailable": "0.0",
|
|
527
|
+
"balance": "22.79163408",
|
|
528
|
+
"frozenMargin": "0.0",
|
|
529
|
+
"reserveMode": "0",
|
|
530
|
+
"totalCloseProfit": "-15.982736",
|
|
531
|
+
"available": "22.79163408",
|
|
532
|
+
"crossMargin": "0.0",
|
|
533
|
+
"reserve": "0.0",
|
|
534
|
+
"frozenFee": "0.0",
|
|
535
|
+
"marginAble": "0.0",
|
|
536
|
+
"realAvailable": "22.79163408"
|
|
537
|
+
},
|
|
538
|
+
"longMaxLeverage": 200,
|
|
539
|
+
"shortMaintenanceMarginQuickAmount": "0",
|
|
540
|
+
"shortLastAmount": "10798590",
|
|
541
|
+
"unrealProfitCalType": "2",
|
|
542
|
+
"longLastAmount": "10798590",
|
|
543
|
+
"shortMaxVolume": 10000000000000000,
|
|
544
|
+
"shortLeverage": 25,
|
|
545
|
+
"calMarkedPrice": "111031.3",
|
|
546
|
+
"longMaintenanceMarginRate": "0.0025",
|
|
547
|
+
"wsToken": "fa1d5e0ad94ede6efab6ced66ea5367cfe68c81173863424dc6e8d846d7e723b",
|
|
548
|
+
"shortMaxLeverage": 200,
|
|
549
|
+
"nextFundingRateTimestamp": 1760976000000,
|
|
550
|
+
"longMaintenanceMarginQuickAmount": "0",
|
|
551
|
+
"forbidTrade": false,
|
|
552
|
+
"defaultPositionType": "2",
|
|
553
|
+
"lastPrice": "111027.9",
|
|
554
|
+
"fundingRate": "0.00003598"
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
"""
|
|
558
|
+
|
|
559
|
+
payload = {
|
|
560
|
+
"productGroup": "SwapU",
|
|
561
|
+
"instrumentID": symbol,
|
|
562
|
+
"asset": "USDT"
|
|
563
|
+
}
|
|
564
|
+
res = await self.client.post(
|
|
565
|
+
f"{self.front_api}/cfd/agg/v1/sendQryAll",
|
|
566
|
+
json=payload,
|
|
567
|
+
headers=self._rest_headers,
|
|
568
|
+
)
|
|
569
|
+
data = await res.json()
|
|
570
|
+
print(data)
|
|
571
|
+
return self._ensure_ok("query_all", data)
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
async def set_position_mode(self, mode: Literal["hedge", "oneway"] = "oneway") -> dict[str, Any]:
|
|
575
|
+
"""设置持仓模式到单向持仓或对冲持仓"""
|
|
576
|
+
|
|
577
|
+
mode_code = "2" if mode == "oneway" else "1"
|
|
578
|
+
payload = {
|
|
579
|
+
"PositionType": mode_code,
|
|
580
|
+
}
|
|
581
|
+
res = await self.client.post(
|
|
582
|
+
f"{self.front_api}/cfd/action/v1.0/SendMemberAction",
|
|
583
|
+
json=payload,
|
|
584
|
+
headers=self._rest_headers,
|
|
585
|
+
)
|
|
586
|
+
data = await res.json()
|
|
587
|
+
return self._ensure_ok("set_position_mode", data)
|
|
498
588
|
|
|
499
589
|
@staticmethod
|
|
500
590
|
def _normalize_direction(direction: str) -> str:
|
|
@@ -65,12 +65,13 @@ async def test_order():
|
|
|
65
65
|
await bg.__aenter__()
|
|
66
66
|
ts = time.time() * 1000
|
|
67
67
|
res = await bg.place_order(
|
|
68
|
-
'
|
|
68
|
+
'LIGHTUSDT',
|
|
69
69
|
direction='long',
|
|
70
70
|
order_type='limit_gtc',
|
|
71
71
|
volume=0.1,
|
|
72
72
|
price=185
|
|
73
73
|
)
|
|
74
|
+
|
|
74
75
|
# print(res)
|
|
75
76
|
print(f'订单延迟: {time.time() * 1000 - ts} ms')
|
|
76
77
|
|
|
@@ -154,9 +155,8 @@ async def order_sync_polling(
|
|
|
154
155
|
|
|
155
156
|
if change.data.get("orderId") == order_id:
|
|
156
157
|
order = change.data
|
|
157
|
-
print(change.operation)
|
|
158
158
|
if change.operation == "delete":
|
|
159
|
-
return change.
|
|
159
|
+
return change.source
|
|
160
160
|
except TimeoutError:
|
|
161
161
|
pass
|
|
162
162
|
|
|
@@ -180,7 +180,7 @@ async def test_order_sync_polling():
|
|
|
180
180
|
bg,
|
|
181
181
|
symbol="SOLUSDT",
|
|
182
182
|
direction="long",
|
|
183
|
-
order_type="
|
|
183
|
+
order_type="market",
|
|
184
184
|
price=185,
|
|
185
185
|
volume=0.1,
|
|
186
186
|
window_sec=5.0,
|
|
@@ -190,4 +190,4 @@ async def test_order_sync_polling():
|
|
|
190
190
|
|
|
191
191
|
|
|
192
192
|
if __name__ == "__main__":
|
|
193
|
-
asyncio.run(
|
|
193
|
+
asyncio.run(test_order())
|
|
@@ -120,16 +120,22 @@ async def test_update():
|
|
|
120
120
|
async def test_place():
|
|
121
121
|
async with pybotters.Client(apis='./apis.json') as client:
|
|
122
122
|
async with Lbank(client) as lb:
|
|
123
|
+
start = int(time.time() * 1000)
|
|
123
124
|
order = await lb.place_order(
|
|
124
|
-
"
|
|
125
|
+
"YGGUSDT",
|
|
125
126
|
direction="buy",
|
|
126
|
-
order_type='
|
|
127
|
-
price=
|
|
128
|
-
volume=
|
|
127
|
+
order_type='market',
|
|
128
|
+
price=0.165,
|
|
129
|
+
volume=40,
|
|
129
130
|
)
|
|
130
|
-
print(order)
|
|
131
|
+
# print(order)
|
|
132
|
+
print(f'下单延迟 {int(time.time() * 1000) - start} ms')
|
|
131
133
|
|
|
132
134
|
|
|
135
|
+
async def test_query_all():
|
|
136
|
+
async with pybotters.Client(apis='./apis.json') as client:
|
|
137
|
+
async with Lbank(client) as lb:
|
|
138
|
+
print(await lb.query_all('BTCUSDT'))
|
|
133
139
|
|
|
134
140
|
async def test_cancel():
|
|
135
141
|
async with pybotters.Client(apis='./apis.json') as client:
|
|
@@ -137,6 +143,11 @@ async def test_cancel():
|
|
|
137
143
|
res = await lb.cancel_order("1000624020664540")
|
|
138
144
|
print(res)
|
|
139
145
|
|
|
146
|
+
async def test_oneway_mode():
|
|
147
|
+
async with pybotters.Client(apis='./apis.json') as client:
|
|
148
|
+
async with Lbank(client) as lb:
|
|
149
|
+
await lb.set_position_mode('oneway')
|
|
150
|
+
|
|
140
151
|
|
|
141
152
|
async def order_sync_polling(
|
|
142
153
|
broker: Lbank,
|
|
@@ -277,10 +288,10 @@ async def test_order_sync_polling():
|
|
|
277
288
|
# print(position)
|
|
278
289
|
|
|
279
290
|
async def test_query_order():
|
|
280
|
-
async with pybotters.Client(
|
|
291
|
+
async with pybotters.Client() as client:
|
|
281
292
|
async with Lbank(client) as lb:
|
|
282
293
|
res = await lb.query_order("1000633355403954")
|
|
283
294
|
print(res)
|
|
284
295
|
|
|
285
296
|
if __name__ == "__main__":
|
|
286
|
-
asyncio.run(
|
|
297
|
+
asyncio.run(test_query_all())
|
|
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
|