hyperquant 0.39__tar.gz → 0.42__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.39 → hyperquant-0.42}/PKG-INFO +1 -1
- {hyperquant-0.39 → hyperquant-0.42}/pyproject.toml +1 -1
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/broker/models/ourbit.py +6 -5
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/broker/ourbit.py +38 -16
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/core.py +1 -0
- hyperquant-0.42/test.py +8 -0
- hyperquant-0.42/tmp.py +139 -0
- {hyperquant-0.39 → hyperquant-0.42}/uv.lock +1 -1
- hyperquant-0.39/test.py +0 -120
- hyperquant-0.39/tmp.py +0 -115
- {hyperquant-0.39 → hyperquant-0.42}/.gitignore +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/.python-version +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/README.md +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/data/logs/notikit.log +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/pub.sh +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/requirements-dev.lock +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/requirements.lock +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/__init__.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/broker/auth.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/broker/hyperliquid.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/broker/lib/hpstore.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/broker/lib/hyper_types.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/broker/models/hyperliquid.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/broker/ws.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/datavison/_util.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/datavison/binance.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/datavison/coinglass.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/datavison/okx.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/db.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/draw.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/logkit.py +0 -0
- {hyperquant-0.39 → hyperquant-0.42}/src/hyperquant/notikit.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hyperquant
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.42
|
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
|
@@ -661,13 +661,13 @@ class SpotOrders(DataStore):
|
|
661
661
|
|
662
662
|
state = d.get("status")
|
663
663
|
|
664
|
-
if state ==
|
664
|
+
if state == 1:
|
665
665
|
item["state"] = "open"
|
666
666
|
self._insert([item])
|
667
667
|
|
668
|
-
elif state == 3:
|
668
|
+
elif state == 3 or state == 2:
|
669
669
|
item["state"] = "filled"
|
670
|
-
|
670
|
+
|
671
671
|
# 如果这三个字段存在追加
|
672
672
|
if d.get("singleDealId") and d.get("singleDealPrice") and d.get("singleDealQuantity"):
|
673
673
|
item.update({
|
@@ -743,7 +743,7 @@ class SpotBook(DataStore):
|
|
743
743
|
sort_data = self.sorted({'s': symbol}, self.limit)
|
744
744
|
asks = sort_data.get('a', [])
|
745
745
|
bids = sort_data.get('b', [])
|
746
|
-
self.
|
746
|
+
self._find_and_delete({'s': symbol})
|
747
747
|
self._update(asks + bids)
|
748
748
|
|
749
749
|
|
@@ -770,7 +770,7 @@ class SpotBook(DataStore):
|
|
770
770
|
sort_data = self.sorted({'s': symbol}, self.limit)
|
771
771
|
asks = sort_data.get('a', [])
|
772
772
|
bids = sort_data.get('b', [])
|
773
|
-
self.
|
773
|
+
self._find_and_delete({'s': symbol})
|
774
774
|
self._update(asks + bids)
|
775
775
|
|
776
776
|
# print(f'处理耗时: {time.time()*1000 - ts:.2f} ms')
|
@@ -1015,6 +1015,7 @@ class OurbitSpotDataStore(DataStoreCollection):
|
|
1015
1015
|
return self._get("order", SpotOrders)
|
1016
1016
|
|
1017
1017
|
def onmessage(self, msg: Item, ws: ClientWebSocketResponse | None = None) -> None:
|
1018
|
+
# print(msg, '\n')
|
1018
1019
|
channel = msg.get("c")
|
1019
1020
|
if 'msg' in msg:
|
1020
1021
|
if 'invalid' in msg['msg']:
|
@@ -65,7 +65,7 @@ class OurbitSwap:
|
|
65
65
|
hdlr_json=self.store.onmessage
|
66
66
|
)
|
67
67
|
|
68
|
-
async def
|
68
|
+
async def sub_orderbook(self, symbols: str | list[str]):
|
69
69
|
if isinstance(symbols, str):
|
70
70
|
symbols = [symbols]
|
71
71
|
|
@@ -366,7 +366,7 @@ class OurbitSpot:
|
|
366
366
|
token = res.data['data'].get("wsToken")
|
367
367
|
|
368
368
|
|
369
|
-
self.client.ws_connect(
|
369
|
+
app = self.client.ws_connect(
|
370
370
|
f"{self.ws_url}?wsToken={token}&platform=web",
|
371
371
|
send_json={
|
372
372
|
"method": "SUBSCRIPTION",
|
@@ -380,6 +380,9 @@ class OurbitSpot:
|
|
380
380
|
hdlr_json=self.store.onmessage
|
381
381
|
)
|
382
382
|
|
383
|
+
await app._event.wait()
|
384
|
+
|
385
|
+
|
383
386
|
async def sub_orderbook(self, symbols: str | list[str]):
|
384
387
|
"""订阅订单簿深度数据
|
385
388
|
|
@@ -407,16 +410,18 @@ class OurbitSpot:
|
|
407
410
|
for symbol in symbols:
|
408
411
|
subscription_params.append(f"spot@public.increase.aggre.depth@{symbol}")
|
409
412
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
413
|
+
|
414
|
+
# 一次sub20个,超过需要分开订阅
|
415
|
+
for i in range(0, len(subscription_params), 20):
|
416
|
+
self.client.ws_connect(
|
417
|
+
'wss://www.ourbit.com/ws?platform=web',
|
418
|
+
send_json={
|
419
|
+
"method": "SUBSCRIPTION",
|
420
|
+
"params": subscription_params[i:i + 20],
|
421
|
+
"id": 2
|
422
|
+
},
|
423
|
+
hdlr_json=self.store.onmessage
|
424
|
+
)
|
420
425
|
|
421
426
|
async def place_order(
|
422
427
|
self,
|
@@ -453,7 +458,8 @@ class OurbitSpot:
|
|
453
458
|
price_scale = detail.get('price_scale')
|
454
459
|
quantity_scale = detail.get('quantity_scale')
|
455
460
|
|
456
|
-
|
461
|
+
use_quantity = True if quantity is not None else False
|
462
|
+
|
457
463
|
# 如果指定了USDT金额,重新计算数量
|
458
464
|
if usdt_amount is not None:
|
459
465
|
if side == "buy":
|
@@ -482,11 +488,21 @@ class OurbitSpot:
|
|
482
488
|
data["price"] = str(price)
|
483
489
|
elif order_type == "market":
|
484
490
|
data["orderType"] = "MARKET_ORDER"
|
485
|
-
|
491
|
+
data["price"] = price
|
492
|
+
# 删除quantity, 市价只支持amount
|
493
|
+
if not use_quantity:
|
494
|
+
del data["quantity"]
|
495
|
+
data["amount"] = str(usdt_amount)
|
496
|
+
|
497
|
+
# print(data)
|
498
|
+
if order_type == 'market':
|
499
|
+
url = f'{self.api_url}/api/platform/spot/v4/order/place'
|
500
|
+
elif order_type == 'limit':
|
501
|
+
url = f'{self.api_url}/api/platform/spot/order/place'
|
486
502
|
|
487
503
|
res = await self.client.fetch(
|
488
504
|
"POST",
|
489
|
-
|
505
|
+
url,
|
490
506
|
json=data
|
491
507
|
)
|
492
508
|
|
@@ -495,4 +511,10 @@ class OurbitSpot:
|
|
495
511
|
case {"msg": 'success'}:
|
496
512
|
return res.data["data"]
|
497
513
|
case _:
|
498
|
-
raise Exception(f"Failed to place order: {res.data}")
|
514
|
+
raise Exception(f"Failed to place order: {res.data}")
|
515
|
+
|
516
|
+
async def cancel_orders(self, order_ids: list[str]):
|
517
|
+
|
518
|
+
for order_id in order_ids:
|
519
|
+
url = f'{self.api_url}/api/platform/spot/order/cancel/v2?orderId={order_id}'
|
520
|
+
await self.client.fetch("DELETE", url)
|
hyperquant-0.42/test.py
ADDED
hyperquant-0.42/tmp.py
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
import asyncio
|
2
|
+
import random
|
3
|
+
import time
|
4
|
+
import pybotters
|
5
|
+
import hyperquant
|
6
|
+
from hyperquant.broker.models.ourbit import OurbitSpotDataStore
|
7
|
+
from hyperquant.broker.ourbit import OurbitSpot
|
8
|
+
|
9
|
+
|
10
|
+
async def main():
|
11
|
+
store = OurbitSpotDataStore()
|
12
|
+
|
13
|
+
async with pybotters.Client(
|
14
|
+
apis={
|
15
|
+
"ourbit": [
|
16
|
+
"WEB3bf088f8b2f2fae07592fe1a6240e2d798100a9cb2a91f8fda1056b6865ab3ee"
|
17
|
+
]
|
18
|
+
}
|
19
|
+
) as client:
|
20
|
+
res = await client.fetch("POST", "https://www.ourbit.com/ucenter/api/user_info")
|
21
|
+
|
22
|
+
ob_spot = OurbitSpot(client)
|
23
|
+
await ob_spot.__aenter__()
|
24
|
+
# await ob_spot.sub_personal()
|
25
|
+
# await ob_spot.update('ticker')
|
26
|
+
# print(ob_spot.store.ticker.find())
|
27
|
+
|
28
|
+
# await ob_spot.sub_orderbook('DOLO_USDT')
|
29
|
+
# print(ob_spot.store.book.find())
|
30
|
+
await ob_spot.update('ticker')
|
31
|
+
symbols = [d['symbol'] for d in ob_spot.store.ticker.find()][:5]
|
32
|
+
|
33
|
+
await ob_spot.sub_orderbook(symbols)
|
34
|
+
|
35
|
+
# print(len(ob_spot.store.book.find()))
|
36
|
+
import pandas as pd
|
37
|
+
print(pd.DataFrame(ob_spot.store.book.find({'S': 'a'})))
|
38
|
+
|
39
|
+
|
40
|
+
while True:
|
41
|
+
await ob_spot.store.book.wait()
|
42
|
+
print(len(ob_spot.store.book.find()))
|
43
|
+
|
44
|
+
# while True:
|
45
|
+
# await ob_spot.store.balance.wait()
|
46
|
+
# print(ob_spot.store.balance.find())
|
47
|
+
return
|
48
|
+
|
49
|
+
await store.initialize(
|
50
|
+
client.get("https://www.ourbit.com/api/platform/spot/market/v2/tickers")
|
51
|
+
)
|
52
|
+
|
53
|
+
print(store.ticker.find())
|
54
|
+
|
55
|
+
return
|
56
|
+
|
57
|
+
await store.initialize(
|
58
|
+
client.get(
|
59
|
+
"https://www.ourbit.com/api/platform/spot/market/depth?symbol=XRP_USDT"
|
60
|
+
)
|
61
|
+
)
|
62
|
+
|
63
|
+
print(store.book.find())
|
64
|
+
|
65
|
+
client.ws_connect(
|
66
|
+
"wss://www.ourbit.com/ws?platform=web",
|
67
|
+
send_json={
|
68
|
+
"method": "SUBSCRIPTION",
|
69
|
+
"params": ["spot@public.increase.aggre.depth@XRP_USDT"],
|
70
|
+
"id": 3,
|
71
|
+
},
|
72
|
+
hdlr_json=store.onmessage,
|
73
|
+
)
|
74
|
+
while True:
|
75
|
+
await store.book.wait()
|
76
|
+
# await asyncio.sleep(1)
|
77
|
+
print(store.book.find())
|
78
|
+
# print(store.book.find({'s': 'XRP_USDT', 'S': 'a'}))
|
79
|
+
# print(store.book.find({'s': 'XRP_USDT', 'S': 'b' }))
|
80
|
+
# print(store.book.find())
|
81
|
+
# ts = time.time()*1000
|
82
|
+
# book = store.book.sorted({'s': 'XRP_USDT'}, 1)
|
83
|
+
# print(f'排序耗时: {time.time()*1000 - ts:.2f} ms')
|
84
|
+
|
85
|
+
async def test_watch_order():
|
86
|
+
|
87
|
+
|
88
|
+
async def watch_orders(ob_spot: OurbitSpot):
|
89
|
+
with ob_spot.store.orders.watch() as stream:
|
90
|
+
async for change in stream:
|
91
|
+
|
92
|
+
data = change.data
|
93
|
+
if change.operation == 'delete':
|
94
|
+
state = data['state']
|
95
|
+
if state == 'filled':
|
96
|
+
price = float(data['avg_price'])
|
97
|
+
quantity = float(data['deal_quantity'])
|
98
|
+
ts = time.time() * 1000
|
99
|
+
symbol = data['symbol']
|
100
|
+
print(price, quantity, ts, symbol, '@@@@')
|
101
|
+
|
102
|
+
async with pybotters.Client(apis={
|
103
|
+
"ourbit": [
|
104
|
+
"WEB3bf088f8b2f2fae07592fe1a6240e2d798100a9cb2a91f8fda1056b6865ab3ee"
|
105
|
+
]
|
106
|
+
}) as client:
|
107
|
+
ob_spot = OurbitSpot(client)
|
108
|
+
await ob_spot.__aenter__()
|
109
|
+
await ob_spot.sub_personal()
|
110
|
+
await watch_orders(ob_spot)
|
111
|
+
|
112
|
+
# with ob_spot.store.orders.watch() as stream:
|
113
|
+
# oid = await ob_spot.place_order('SOL_USDT', 'buy', order_type='market', price=205, quantity=0.03 )
|
114
|
+
# print(oid)
|
115
|
+
# async for change in stream:
|
116
|
+
# print(change)
|
117
|
+
|
118
|
+
|
119
|
+
# await asyncio.sleep(1)
|
120
|
+
# order = ob_spot.store.orders.get({'order_id': oid})
|
121
|
+
# print(order)
|
122
|
+
|
123
|
+
async def test_cancel_order():
|
124
|
+
async with pybotters.Client(apis={
|
125
|
+
"ourbit": [
|
126
|
+
"WEB3bf088f8b2f2fae07592fe1a6240e2d798100a9cb2a91f8fda1056b6865ab3ee"
|
127
|
+
]
|
128
|
+
}) as client:
|
129
|
+
ob_spot = OurbitSpot(client)
|
130
|
+
await ob_spot.__aenter__()
|
131
|
+
# await ob_spot.sub_personal()
|
132
|
+
# await ob_spot.update('all')
|
133
|
+
|
134
|
+
oid = await ob_spot.place_order('SOL_USDT', 'buy', order_type='limit', price=205, quantity=0.03 )
|
135
|
+
print(oid)
|
136
|
+
await ob_spot.cancel_orders([oid])
|
137
|
+
|
138
|
+
if __name__ == "__main__":
|
139
|
+
asyncio.run(test_watch_order())
|
hyperquant-0.39/test.py
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
# import asyncio
|
2
|
-
# import hyperquant
|
3
|
-
# from hyperquant.broker.models.ourbit import OurbitSwapDataStore
|
4
|
-
# import pybotters
|
5
|
-
|
6
|
-
# async def test():
|
7
|
-
# store = OurbitSwapDataStore()
|
8
|
-
# async with pybotters.Client(
|
9
|
-
# apis={
|
10
|
-
# "ourbit": [
|
11
|
-
# "WEB3bf088f8b2f2fae07592fe1a6240e2d798100a9cb2a91f8fda1056b6865ab3ee"
|
12
|
-
# ]
|
13
|
-
# }
|
14
|
-
# ) as client:
|
15
|
-
# await store.initialize( client.get( "https://futures.ourbit.com/api/v1/private/position/open_positions") )
|
16
|
-
# print(store.position.find())
|
17
|
-
|
18
|
-
# if __name__ == "__main__":
|
19
|
-
# asyncio.run(test())
|
20
|
-
|
21
|
-
import asyncio
|
22
|
-
from hyperquant.broker.ourbit import OurbitSwap
|
23
|
-
import pybotters
|
24
|
-
import hyperquant
|
25
|
-
|
26
|
-
async def test():
|
27
|
-
async with pybotters.Client(
|
28
|
-
apis={
|
29
|
-
"ourbit": [
|
30
|
-
"WEB3bf088f8b2f2fae07592fe1a6240e2d798100a9cb2a91f8fda1056b6865ab3ee"
|
31
|
-
]
|
32
|
-
}
|
33
|
-
) as client:
|
34
|
-
ourbit = OurbitSwap(client)
|
35
|
-
await ourbit.__aenter__()
|
36
|
-
res = await ourbit.place_order(
|
37
|
-
symbol="SOL_USDT",
|
38
|
-
size=1,
|
39
|
-
side="buy",
|
40
|
-
order_type="limit_GTC",
|
41
|
-
price=192
|
42
|
-
)
|
43
|
-
print(res)
|
44
|
-
|
45
|
-
|
46
|
-
# # await ourbit.update('orders')
|
47
|
-
# await ourbit.sub_personal()
|
48
|
-
|
49
|
-
# while True:
|
50
|
-
# await ourbit.store.position.wait()
|
51
|
-
# print(ourbit.store.position.find())
|
52
|
-
# # await ourbit.store.position.wait()
|
53
|
-
# # print(ourbit.store.position.find())
|
54
|
-
# await ourbit.store.orders.wait()
|
55
|
-
|
56
|
-
# with ourbit.store.orders.watch() as changes:
|
57
|
-
# async for change in changes:
|
58
|
-
# print(change.operation, change.data)
|
59
|
-
|
60
|
-
|
61
|
-
# print(res.data)
|
62
|
-
|
63
|
-
# print(ourbit.datastore.detail.find({"symbol": "SOL_USDT"}))
|
64
|
-
|
65
|
-
# print(ourbit.datastore.detail.find())
|
66
|
-
|
67
|
-
# await ourbit.update('balance')
|
68
|
-
# print(ourbit.store.balance.find())
|
69
|
-
|
70
|
-
# res = await client.fetch(
|
71
|
-
# 'GET',
|
72
|
-
# 'https://futures.ourbit.com//api/v1/private/order/list/history_orders?category=1&page_num=1&page_size=4&start_time=1755682343814&states=4&symbol=SOL_USDT'
|
73
|
-
# )
|
74
|
-
|
75
|
-
# print(res.data)
|
76
|
-
|
77
|
-
# print(await ourbit.query_order('219079365441409152'))
|
78
|
-
|
79
|
-
# await ourbit.place_order(
|
80
|
-
# symbol="SOL_USDT",
|
81
|
-
# side="sell",
|
82
|
-
# order_type="market",
|
83
|
-
# usdt_amount=3,
|
84
|
-
# price=206.44
|
85
|
-
# )
|
86
|
-
|
87
|
-
# print(ourbit.datastore.orders.find())
|
88
|
-
|
89
|
-
# await ourbit.cancel_orders(['219206341921656960'])
|
90
|
-
|
91
|
-
|
92
|
-
# print(ourbit.datastore.orders.find())
|
93
|
-
|
94
|
-
# ps = ourbit.datastore.position.find({
|
95
|
-
# "symbol": "SOL_USDT",
|
96
|
-
# "side": "long"
|
97
|
-
# })[0]
|
98
|
-
|
99
|
-
# position_id = ps.get("position_id")
|
100
|
-
|
101
|
-
# await ourbit.place_order(
|
102
|
-
# symbol="SOL_USDT",
|
103
|
-
# size=1,
|
104
|
-
# side="close",
|
105
|
-
# order_type="market",
|
106
|
-
# position_id=position_id
|
107
|
-
# )
|
108
|
-
|
109
|
-
# await ourbit.sub_order_book("SOL_USDT")
|
110
|
-
|
111
|
-
# while True:
|
112
|
-
# await ourbit.store.book.wait()
|
113
|
-
# asks = ourbit.store.book.find({'side': 'A'})
|
114
|
-
# bids = ourbit.store.book.find({'side': 'B'})
|
115
|
-
# print("Ask0:", asks[0]['px'])
|
116
|
-
# print("Bid0:", bids[0]['px'])
|
117
|
-
# print('-----\n')
|
118
|
-
|
119
|
-
if __name__ == "__main__":
|
120
|
-
asyncio.run(test())
|
hyperquant-0.39/tmp.py
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
import asyncio
|
2
|
-
import random
|
3
|
-
import time
|
4
|
-
import pybotters
|
5
|
-
import hyperquant
|
6
|
-
from hyperquant.broker.models.ourbit import OurbitSpotDataStore
|
7
|
-
from hyperquant.broker.ourbit import OurbitSpot
|
8
|
-
|
9
|
-
|
10
|
-
async def main():
|
11
|
-
store = OurbitSpotDataStore()
|
12
|
-
|
13
|
-
async with pybotters.Client(
|
14
|
-
apis={
|
15
|
-
"ourbit": [
|
16
|
-
"WEB3bf088f8b2f2fae07592fe1a6240e2d798100a9cb2a91f8fda1056b6865ab3ee"
|
17
|
-
]
|
18
|
-
}
|
19
|
-
) as client:
|
20
|
-
res = await client.fetch("POST", "https://www.ourbit.com/ucenter/api/user_info")
|
21
|
-
|
22
|
-
ob_spot = OurbitSpot(client)
|
23
|
-
await ob_spot.__aenter__()
|
24
|
-
await ob_spot.sub_personal()
|
25
|
-
await ob_spot.update('ticker')
|
26
|
-
print(ob_spot.store.ticker.find())
|
27
|
-
|
28
|
-
# while True:
|
29
|
-
# await ob_spot.store.balance.wait()
|
30
|
-
# print(ob_spot.store.balance.find())
|
31
|
-
return
|
32
|
-
|
33
|
-
await store.initialize(
|
34
|
-
client.get("https://www.ourbit.com/api/platform/spot/market/v2/tickers")
|
35
|
-
)
|
36
|
-
|
37
|
-
print(store.ticker.find())
|
38
|
-
|
39
|
-
return
|
40
|
-
|
41
|
-
await store.initialize(
|
42
|
-
client.get(
|
43
|
-
"https://www.ourbit.com/api/platform/spot/market/depth?symbol=XRP_USDT"
|
44
|
-
)
|
45
|
-
)
|
46
|
-
|
47
|
-
print(store.book.find())
|
48
|
-
|
49
|
-
client.ws_connect(
|
50
|
-
"wss://www.ourbit.com/ws?platform=web",
|
51
|
-
send_json={
|
52
|
-
"method": "SUBSCRIPTION",
|
53
|
-
"params": ["spot@public.increase.aggre.depth@XRP_USDT"],
|
54
|
-
"id": 3,
|
55
|
-
},
|
56
|
-
hdlr_json=store.onmessage,
|
57
|
-
)
|
58
|
-
while True:
|
59
|
-
await store.book.wait()
|
60
|
-
# await asyncio.sleep(1)
|
61
|
-
print(store.book.find())
|
62
|
-
# print(store.book.find({'s': 'XRP_USDT', 'S': 'a'}))
|
63
|
-
# print(store.book.find({'s': 'XRP_USDT', 'S': 'b' }))
|
64
|
-
# print(store.book.find())
|
65
|
-
# ts = time.time()*1000
|
66
|
-
# book = store.book.sorted({'s': 'XRP_USDT'}, 1)
|
67
|
-
# print(f'排序耗时: {time.time()*1000 - ts:.2f} ms')
|
68
|
-
|
69
|
-
|
70
|
-
if __name__ == "__main__":
|
71
|
-
asyncio.run(main())
|
72
|
-
|
73
|
-
# import aiohttp
|
74
|
-
# import asyncio
|
75
|
-
|
76
|
-
# async def fetch_orders():
|
77
|
-
# url = "https://www.ourbit.com/api/platform/spot/order/current/orders/v2"
|
78
|
-
# params = {
|
79
|
-
# "orderTypes": "1,2,3,4,5,100",
|
80
|
-
# "pageNum": "1",
|
81
|
-
# "pageSize": "100",
|
82
|
-
# "states": "0,1,3"
|
83
|
-
# }
|
84
|
-
# headers = {
|
85
|
-
# "accept": "*/*",
|
86
|
-
# "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
87
|
-
# "baggage": "sentry-environment=prd,sentry-release=production%20-%20v3.28.8%20-%20cc4977f,sentry-public_key=48c007e1b13c063127c3119a97a2dd0e,sentry-trace_id=20b4bba185e143428bce7e3aeb376b63,sentry-sample_rate=0.1,sentry-sampled=true",
|
88
|
-
# "cache-control": "no-cache",
|
89
|
-
# "language": "zh-CN",
|
90
|
-
# "luminex-trace-id": "0a4def65-f9ed-47df-8d72-7574abac2ae8-0100",
|
91
|
-
# "luminex-uid": "31204775",
|
92
|
-
# "pragma": "akamai-x-cache-on",
|
93
|
-
# "priority": "u=1, i",
|
94
|
-
# "referer": "https://www.ourbit.com/zh-CN/exchange/BTC_USDT",
|
95
|
-
# "sec-ch-ua": '"Not;A=Brand";v="99", "Microsoft Edge";v="139", "Chromium";v="139"',
|
96
|
-
# "sec-ch-ua-mobile": "?0",
|
97
|
-
# "sec-ch-ua-platform": '"macOS"',
|
98
|
-
# "sec-fetch-dest": "empty",
|
99
|
-
# "sec-fetch-mode": "cors",
|
100
|
-
# "sec-fetch-site": "same-origin",
|
101
|
-
# "sentry-trace": "20b4bba185e143428bce7e3aeb376b63-99fc208a301b8675-1",
|
102
|
-
# "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0"
|
103
|
-
# }
|
104
|
-
# cookies = {
|
105
|
-
# "uc_token": "WEB3bf088f8b2f2fae07592fe1a6240e2d798100a9cb2a91f8fda1056b6865ab3ee",
|
106
|
-
# "u_id": "WEB3bf088f8b2f2fae07592fe1a6240e2d798100a9cb2a91f8fda1056b6865ab3ee",
|
107
|
-
# }
|
108
|
-
|
109
|
-
# async with aiohttp.ClientSession(headers=headers, cookies=cookies) as session:
|
110
|
-
# async with session.get(url, params=params) as resp:
|
111
|
-
# data = await resp.json()
|
112
|
-
# print(data)
|
113
|
-
|
114
|
-
# if __name__ == "__main__":
|
115
|
-
# asyncio.run(fetch_orders())
|
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
|