hyperquant 0.79__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.79 → hyperquant-0.81}/PKG-INFO +1 -1
- {hyperquant-0.79 → hyperquant-0.81}/apis.json +1 -1
- {hyperquant-0.79 → hyperquant-0.81}/pyproject.toml +1 -1
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/auth.py +1 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/lbank.py +90 -0
- {hyperquant-0.79 → hyperquant-0.81}/tests/test_bitget.py +3 -2
- {hyperquant-0.79 → hyperquant-0.81}/tests/test_lbank.py +11 -2
- {hyperquant-0.79 → hyperquant-0.81}/uv.lock +1 -1
- {hyperquant-0.79 → hyperquant-0.81}/.gitignore +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/.python-version +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/README.md +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/data/alpine_smoke.log +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/data/logs/notikit.log +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/data/logs/test_order_sync.log +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/data/records_swap.csv +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/data/records_swapc.csv +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/doc/lbank.md +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/pub.sh +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/requirements-dev.lock +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/requirements.lock +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/__init__.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/bitget.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/edgex.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/hyperliquid.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/lib/edgex_sign.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/lib/hpstore.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/lib/hyper_types.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/lib/util.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/models/bitget.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/models/edgex.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/models/hyperliquid.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/models/lbank.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/models/ourbit.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/ourbit.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/broker/ws.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/core.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/datavison/_util.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/datavison/binance.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/datavison/coinglass.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/datavison/okx.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/db.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/draw.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/logkit.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/src/hyperquant/notikit.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/tests/test_draw.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/tests/test_edgex.py +0 -0
- {hyperquant-0.79 → hyperquant-0.81}/tests/test_ourbit.py +0 -0
- {hyperquant-0.79 → 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
|
|
|
@@ -189,4 +190,4 @@ async def test_order_sync_polling():
|
|
|
189
190
|
|
|
190
191
|
|
|
191
192
|
if __name__ == "__main__":
|
|
192
|
-
asyncio.run(
|
|
193
|
+
asyncio.run(test_order())
|
|
@@ -124,7 +124,7 @@ async def test_place():
|
|
|
124
124
|
order = await lb.place_order(
|
|
125
125
|
"YGGUSDT",
|
|
126
126
|
direction="buy",
|
|
127
|
-
order_type='
|
|
127
|
+
order_type='market',
|
|
128
128
|
price=0.165,
|
|
129
129
|
volume=40,
|
|
130
130
|
)
|
|
@@ -132,6 +132,10 @@ async def test_place():
|
|
|
132
132
|
print(f'下单延迟 {int(time.time() * 1000) - start} ms')
|
|
133
133
|
|
|
134
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'))
|
|
135
139
|
|
|
136
140
|
async def test_cancel():
|
|
137
141
|
async with pybotters.Client(apis='./apis.json') as client:
|
|
@@ -139,6 +143,11 @@ async def test_cancel():
|
|
|
139
143
|
res = await lb.cancel_order("1000624020664540")
|
|
140
144
|
print(res)
|
|
141
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
|
+
|
|
142
151
|
|
|
143
152
|
async def order_sync_polling(
|
|
144
153
|
broker: Lbank,
|
|
@@ -285,4 +294,4 @@ async def test_query_order():
|
|
|
285
294
|
print(res)
|
|
286
295
|
|
|
287
296
|
if __name__ == "__main__":
|
|
288
|
-
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
|