oxarchive 0.3.8__tar.gz → 0.4.4__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.
- {oxarchive-0.3.8 → oxarchive-0.4.4}/PKG-INFO +153 -39
- {oxarchive-0.3.8 → oxarchive-0.4.4}/README.md +150 -36
- {oxarchive-0.3.8 → oxarchive-0.4.4}/oxarchive/__init__.py +19 -6
- oxarchive-0.4.4/oxarchive/client.py +132 -0
- oxarchive-0.4.4/oxarchive/exchanges.py +79 -0
- {oxarchive-0.3.8 → oxarchive-0.4.4}/oxarchive/resources/__init__.py +2 -1
- {oxarchive-0.3.8 → oxarchive-0.4.4}/oxarchive/resources/funding.py +34 -18
- oxarchive-0.4.4/oxarchive/resources/instruments.py +110 -0
- {oxarchive-0.3.8 → oxarchive-0.4.4}/oxarchive/resources/openinterest.py +34 -18
- {oxarchive-0.3.8 → oxarchive-0.4.4}/oxarchive/resources/orderbook.py +59 -23
- oxarchive-0.4.4/oxarchive/resources/trades.py +157 -0
- {oxarchive-0.3.8 → oxarchive-0.4.4}/oxarchive/types.py +63 -1
- {oxarchive-0.3.8 → oxarchive-0.4.4}/oxarchive/websocket.py +6 -6
- {oxarchive-0.3.8 → oxarchive-0.4.4}/pyproject.toml +3 -3
- oxarchive-0.3.8/oxarchive/client.py +0 -110
- oxarchive-0.3.8/oxarchive/resources/instruments.py +0 -55
- oxarchive-0.3.8/oxarchive/resources/trades.py +0 -299
- {oxarchive-0.3.8 → oxarchive-0.4.4}/.gitignore +0 -0
- {oxarchive-0.3.8 → oxarchive-0.4.4}/oxarchive/http.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oxarchive
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.4
|
|
4
4
|
Summary: Official Python SDK for 0xarchive - Hyperliquid Historical Data API
|
|
5
5
|
Project-URL: Homepage, https://0xarchive.io
|
|
6
6
|
Project-URL: Documentation, https://0xarchive.io/docs/sdks
|
|
@@ -24,7 +24,7 @@ Requires-Python: >=3.9
|
|
|
24
24
|
Requires-Dist: httpx>=0.25.0
|
|
25
25
|
Requires-Dist: pydantic>=2.0.0
|
|
26
26
|
Provides-Extra: all
|
|
27
|
-
Requires-Dist: websockets>=
|
|
27
|
+
Requires-Dist: websockets>=14.0; extra == 'all'
|
|
28
28
|
Provides-Extra: dev
|
|
29
29
|
Requires-Dist: mypy>=1.9.0; extra == 'dev'
|
|
30
30
|
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
@@ -32,12 +32,16 @@ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
|
32
32
|
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
33
33
|
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
34
34
|
Provides-Extra: websocket
|
|
35
|
-
Requires-Dist: websockets>=
|
|
35
|
+
Requires-Dist: websockets>=14.0; extra == 'websocket'
|
|
36
36
|
Description-Content-Type: text/markdown
|
|
37
37
|
|
|
38
38
|
# oxarchive
|
|
39
39
|
|
|
40
|
-
Official Python SDK for [0xarchive](https://0xarchive.io) -
|
|
40
|
+
Official Python SDK for [0xarchive](https://0xarchive.io) - Historical Market Data API.
|
|
41
|
+
|
|
42
|
+
Supports multiple exchanges:
|
|
43
|
+
- **Hyperliquid** - Perpetuals data from April 2023
|
|
44
|
+
- **Lighter.xyz** - Perpetuals data (August 2025+ for fills, Jan 2026+ for OB, OI, Funding Rate)
|
|
41
45
|
|
|
42
46
|
## Installation
|
|
43
47
|
|
|
@@ -58,12 +62,16 @@ from oxarchive import Client
|
|
|
58
62
|
|
|
59
63
|
client = Client(api_key="ox_your_api_key")
|
|
60
64
|
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
print(f"BTC mid price: {
|
|
65
|
+
# Hyperliquid data
|
|
66
|
+
hl_orderbook = client.hyperliquid.orderbook.get("BTC")
|
|
67
|
+
print(f"Hyperliquid BTC mid price: {hl_orderbook.mid_price}")
|
|
68
|
+
|
|
69
|
+
# Lighter.xyz data
|
|
70
|
+
lighter_orderbook = client.lighter.orderbook.get("BTC")
|
|
71
|
+
print(f"Lighter BTC mid price: {lighter_orderbook.mid_price}")
|
|
64
72
|
|
|
65
73
|
# Get historical order book snapshots
|
|
66
|
-
history = client.orderbook.history(
|
|
74
|
+
history = client.hyperliquid.orderbook.history(
|
|
67
75
|
"ETH",
|
|
68
76
|
start="2024-01-01",
|
|
69
77
|
end="2024-01-02",
|
|
@@ -82,10 +90,13 @@ from oxarchive import Client
|
|
|
82
90
|
async def main():
|
|
83
91
|
client = Client(api_key="ox_your_api_key")
|
|
84
92
|
|
|
85
|
-
# Async get
|
|
86
|
-
orderbook = await client.orderbook.aget("BTC")
|
|
93
|
+
# Async get (Hyperliquid)
|
|
94
|
+
orderbook = await client.hyperliquid.orderbook.aget("BTC")
|
|
87
95
|
print(f"BTC mid price: {orderbook.mid_price}")
|
|
88
96
|
|
|
97
|
+
# Async get (Lighter.xyz)
|
|
98
|
+
lighter_ob = await client.lighter.orderbook.aget("BTC")
|
|
99
|
+
|
|
89
100
|
# Don't forget to close the client
|
|
90
101
|
await client.aclose()
|
|
91
102
|
|
|
@@ -96,7 +107,7 @@ Or use as async context manager:
|
|
|
96
107
|
|
|
97
108
|
```python
|
|
98
109
|
async with Client(api_key="ox_your_api_key") as client:
|
|
99
|
-
orderbook = await client.orderbook.aget("BTC")
|
|
110
|
+
orderbook = await client.hyperliquid.orderbook.aget("BTC")
|
|
100
111
|
```
|
|
101
112
|
|
|
102
113
|
## Configuration
|
|
@@ -111,20 +122,25 @@ client = Client(
|
|
|
111
122
|
|
|
112
123
|
## REST API Reference
|
|
113
124
|
|
|
125
|
+
All examples use `client.hyperliquid.*` but the same methods are available on `client.lighter.*` for Lighter.xyz data.
|
|
126
|
+
|
|
114
127
|
### Order Book
|
|
115
128
|
|
|
116
129
|
```python
|
|
117
|
-
# Get current order book
|
|
118
|
-
orderbook = client.orderbook.get("BTC")
|
|
130
|
+
# Get current order book (Hyperliquid)
|
|
131
|
+
orderbook = client.hyperliquid.orderbook.get("BTC")
|
|
132
|
+
|
|
133
|
+
# Get current order book (Lighter.xyz)
|
|
134
|
+
orderbook = client.lighter.orderbook.get("BTC")
|
|
119
135
|
|
|
120
136
|
# Get order book at specific timestamp
|
|
121
|
-
historical = client.orderbook.get("BTC", timestamp=1704067200000)
|
|
137
|
+
historical = client.hyperliquid.orderbook.get("BTC", timestamp=1704067200000)
|
|
122
138
|
|
|
123
139
|
# Get with limited depth
|
|
124
|
-
shallow = client.orderbook.get("BTC", depth=10)
|
|
140
|
+
shallow = client.hyperliquid.orderbook.get("BTC", depth=10)
|
|
125
141
|
|
|
126
142
|
# Get historical snapshots (start and end are required)
|
|
127
|
-
history = client.orderbook.history(
|
|
143
|
+
history = client.hyperliquid.orderbook.history(
|
|
128
144
|
"BTC",
|
|
129
145
|
start="2024-01-01",
|
|
130
146
|
end="2024-01-02",
|
|
@@ -133,25 +149,78 @@ history = client.orderbook.history(
|
|
|
133
149
|
)
|
|
134
150
|
|
|
135
151
|
# Async versions
|
|
136
|
-
orderbook = await client.orderbook.aget("BTC")
|
|
137
|
-
history = await client.orderbook.ahistory("BTC", start=..., end=...)
|
|
152
|
+
orderbook = await client.hyperliquid.orderbook.aget("BTC")
|
|
153
|
+
history = await client.hyperliquid.orderbook.ahistory("BTC", start=..., end=...)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### Orderbook Depth Limits
|
|
157
|
+
|
|
158
|
+
The `depth` parameter controls how many price levels are returned per side. Tier-based limits apply:
|
|
159
|
+
|
|
160
|
+
| Tier | Max Depth |
|
|
161
|
+
|------|-----------|
|
|
162
|
+
| Free | 20 |
|
|
163
|
+
| Build | 50 |
|
|
164
|
+
| Pro | 100 |
|
|
165
|
+
| Enterprise | Full Depth |
|
|
166
|
+
|
|
167
|
+
**Note:** Hyperliquid source data only contains 20 levels. Higher limits apply to Lighter.xyz data.
|
|
168
|
+
|
|
169
|
+
#### Lighter Orderbook Granularity
|
|
170
|
+
|
|
171
|
+
Lighter.xyz orderbook history supports a `granularity` parameter for different data resolutions. Tier restrictions apply.
|
|
172
|
+
|
|
173
|
+
| Granularity | Interval | Tier Required | Credit Multiplier |
|
|
174
|
+
|-------------|----------|---------------|-------------------|
|
|
175
|
+
| `checkpoint` | ~60s | Free+ | 1x |
|
|
176
|
+
| `30s` | 30s | Build+ | 2x |
|
|
177
|
+
| `10s` | 10s | Build+ | 3x |
|
|
178
|
+
| `1s` | 1s | Pro+ | 10x |
|
|
179
|
+
| `tick` | tick-level | Enterprise | 20x |
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
# Get Lighter orderbook history with 10s resolution (Build+ tier)
|
|
183
|
+
history = client.lighter.orderbook.history(
|
|
184
|
+
"BTC",
|
|
185
|
+
start="2024-01-01",
|
|
186
|
+
end="2024-01-02",
|
|
187
|
+
granularity="10s"
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# Get 1-second resolution (Pro+ tier)
|
|
191
|
+
history = client.lighter.orderbook.history(
|
|
192
|
+
"BTC",
|
|
193
|
+
start="2024-01-01",
|
|
194
|
+
end="2024-01-02",
|
|
195
|
+
granularity="1s"
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# Tick-level data (Enterprise tier) - returns checkpoint + raw deltas
|
|
199
|
+
history = client.lighter.orderbook.history(
|
|
200
|
+
"BTC",
|
|
201
|
+
start="2024-01-01",
|
|
202
|
+
end="2024-01-02",
|
|
203
|
+
granularity="tick"
|
|
204
|
+
)
|
|
138
205
|
```
|
|
139
206
|
|
|
207
|
+
**Note:** The `granularity` parameter is ignored for Hyperliquid orderbook history.
|
|
208
|
+
|
|
140
209
|
### Trades
|
|
141
210
|
|
|
142
211
|
The trades API uses cursor-based pagination for efficient retrieval of large datasets.
|
|
143
212
|
|
|
144
213
|
```python
|
|
145
214
|
# Get recent trades
|
|
146
|
-
recent = client.trades.recent("BTC", limit=100)
|
|
215
|
+
recent = client.hyperliquid.trades.recent("BTC", limit=100)
|
|
147
216
|
|
|
148
217
|
# Get trade history with cursor-based pagination
|
|
149
|
-
result = client.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
|
|
218
|
+
result = client.hyperliquid.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
|
|
150
219
|
trades = result.data
|
|
151
220
|
|
|
152
221
|
# Paginate through all results
|
|
153
222
|
while result.next_cursor:
|
|
154
|
-
result = client.trades.list(
|
|
223
|
+
result = client.hyperliquid.trades.list(
|
|
155
224
|
"ETH",
|
|
156
225
|
start="2024-01-01",
|
|
157
226
|
end="2024-01-02",
|
|
@@ -161,61 +230,103 @@ while result.next_cursor:
|
|
|
161
230
|
trades.extend(result.data)
|
|
162
231
|
|
|
163
232
|
# Filter by side
|
|
164
|
-
buys = client.trades.list("BTC", start=..., end=..., side="buy")
|
|
233
|
+
buys = client.hyperliquid.trades.list("BTC", start=..., end=..., side="buy")
|
|
165
234
|
|
|
166
235
|
# Async versions
|
|
167
|
-
recent = await client.trades.arecent("BTC")
|
|
168
|
-
result = await client.trades.alist("ETH", start=..., end=...)
|
|
236
|
+
recent = await client.hyperliquid.trades.arecent("BTC")
|
|
237
|
+
result = await client.hyperliquid.trades.alist("ETH", start=..., end=...)
|
|
169
238
|
```
|
|
170
239
|
|
|
171
240
|
### Instruments
|
|
172
241
|
|
|
173
242
|
```python
|
|
174
|
-
# List all trading instruments
|
|
175
|
-
instruments = client.instruments.list()
|
|
243
|
+
# List all trading instruments (Hyperliquid)
|
|
244
|
+
instruments = client.hyperliquid.instruments.list()
|
|
176
245
|
|
|
177
246
|
# Get specific instrument details
|
|
178
|
-
btc = client.instruments.get("BTC")
|
|
247
|
+
btc = client.hyperliquid.instruments.get("BTC")
|
|
248
|
+
print(f"BTC size decimals: {btc.sz_decimals}")
|
|
179
249
|
|
|
180
250
|
# Async versions
|
|
181
|
-
instruments = await client.instruments.alist()
|
|
182
|
-
btc = await client.instruments.aget("BTC")
|
|
251
|
+
instruments = await client.hyperliquid.instruments.alist()
|
|
252
|
+
btc = await client.hyperliquid.instruments.aget("BTC")
|
|
183
253
|
```
|
|
184
254
|
|
|
255
|
+
#### Lighter.xyz Instruments
|
|
256
|
+
|
|
257
|
+
Lighter instruments have a different schema with additional fields for fees, market IDs, and minimum order amounts:
|
|
258
|
+
|
|
259
|
+
```python
|
|
260
|
+
# List Lighter instruments (returns LighterInstrument, not Instrument)
|
|
261
|
+
lighter_instruments = client.lighter.instruments.list()
|
|
262
|
+
|
|
263
|
+
# Get specific Lighter instrument
|
|
264
|
+
eth = client.lighter.instruments.get("ETH")
|
|
265
|
+
print(f"ETH taker fee: {eth.taker_fee}")
|
|
266
|
+
print(f"ETH maker fee: {eth.maker_fee}")
|
|
267
|
+
print(f"ETH market ID: {eth.market_id}")
|
|
268
|
+
print(f"ETH min base amount: {eth.min_base_amount}")
|
|
269
|
+
|
|
270
|
+
# Async versions
|
|
271
|
+
lighter_instruments = await client.lighter.instruments.alist()
|
|
272
|
+
eth = await client.lighter.instruments.aget("ETH")
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**Key differences:**
|
|
276
|
+
| Field | Hyperliquid (`Instrument`) | Lighter (`LighterInstrument`) |
|
|
277
|
+
|-------|---------------------------|------------------------------|
|
|
278
|
+
| Symbol | `name` | `symbol` |
|
|
279
|
+
| Size decimals | `sz_decimals` | `size_decimals` |
|
|
280
|
+
| Fee info | Not available | `taker_fee`, `maker_fee`, `liquidation_fee` |
|
|
281
|
+
| Market ID | Not available | `market_id` |
|
|
282
|
+
| Min amounts | Not available | `min_base_amount`, `min_quote_amount` |
|
|
283
|
+
|
|
185
284
|
### Funding Rates
|
|
186
285
|
|
|
187
286
|
```python
|
|
188
287
|
# Get current funding rate
|
|
189
|
-
current = client.funding.current("BTC")
|
|
288
|
+
current = client.hyperliquid.funding.current("BTC")
|
|
190
289
|
|
|
191
290
|
# Get funding rate history (start is required)
|
|
192
|
-
history = client.funding.history(
|
|
291
|
+
history = client.hyperliquid.funding.history(
|
|
193
292
|
"ETH",
|
|
194
293
|
start="2024-01-01",
|
|
195
294
|
end="2024-01-07"
|
|
196
295
|
)
|
|
197
296
|
|
|
198
297
|
# Async versions
|
|
199
|
-
current = await client.funding.acurrent("BTC")
|
|
200
|
-
history = await client.funding.ahistory("ETH", start=..., end=...)
|
|
298
|
+
current = await client.hyperliquid.funding.acurrent("BTC")
|
|
299
|
+
history = await client.hyperliquid.funding.ahistory("ETH", start=..., end=...)
|
|
201
300
|
```
|
|
202
301
|
|
|
203
302
|
### Open Interest
|
|
204
303
|
|
|
205
304
|
```python
|
|
206
305
|
# Get current open interest
|
|
207
|
-
current = client.open_interest.current("BTC")
|
|
306
|
+
current = client.hyperliquid.open_interest.current("BTC")
|
|
208
307
|
|
|
209
308
|
# Get open interest history (start is required)
|
|
210
|
-
history = client.open_interest.history(
|
|
309
|
+
history = client.hyperliquid.open_interest.history(
|
|
211
310
|
"ETH",
|
|
212
311
|
start="2024-01-01",
|
|
213
312
|
end="2024-01-07"
|
|
214
313
|
)
|
|
215
314
|
|
|
216
315
|
# Async versions
|
|
217
|
-
current = await client.open_interest.acurrent("BTC")
|
|
218
|
-
history = await client.open_interest.ahistory("ETH", start=..., end=...)
|
|
316
|
+
current = await client.hyperliquid.open_interest.acurrent("BTC")
|
|
317
|
+
history = await client.hyperliquid.open_interest.ahistory("ETH", start=..., end=...)
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Legacy API (Deprecated)
|
|
321
|
+
|
|
322
|
+
The following legacy methods are deprecated and will be removed in v2.0. They default to Hyperliquid data:
|
|
323
|
+
|
|
324
|
+
```python
|
|
325
|
+
# Deprecated - use client.hyperliquid.orderbook.get() instead
|
|
326
|
+
orderbook = client.orderbook.get("BTC")
|
|
327
|
+
|
|
328
|
+
# Deprecated - use client.hyperliquid.trades.list() instead
|
|
329
|
+
trades = client.trades.list("BTC", start=..., end=...)
|
|
219
330
|
```
|
|
220
331
|
|
|
221
332
|
## WebSocket Client
|
|
@@ -421,8 +532,8 @@ except OxArchiveError as e:
|
|
|
421
532
|
Full type hint support with Pydantic models:
|
|
422
533
|
|
|
423
534
|
```python
|
|
424
|
-
from oxarchive import Client
|
|
425
|
-
from oxarchive.types import OrderBook, Trade, Instrument, FundingRate, OpenInterest
|
|
535
|
+
from oxarchive import Client, LighterGranularity
|
|
536
|
+
from oxarchive.types import OrderBook, Trade, Instrument, LighterInstrument, FundingRate, OpenInterest
|
|
426
537
|
from oxarchive.resources.trades import CursorResponse
|
|
427
538
|
|
|
428
539
|
client = Client(api_key="ox_your_api_key")
|
|
@@ -430,6 +541,9 @@ client = Client(api_key="ox_your_api_key")
|
|
|
430
541
|
orderbook: OrderBook = client.orderbook.get("BTC")
|
|
431
542
|
trades: list[Trade] = client.trades.recent("BTC")
|
|
432
543
|
result: CursorResponse = client.trades.list("BTC", start=..., end=...)
|
|
544
|
+
|
|
545
|
+
# Lighter granularity type hint
|
|
546
|
+
granularity: LighterGranularity = "10s"
|
|
433
547
|
```
|
|
434
548
|
|
|
435
549
|
## Requirements
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# oxarchive
|
|
2
2
|
|
|
3
|
-
Official Python SDK for [0xarchive](https://0xarchive.io) -
|
|
3
|
+
Official Python SDK for [0xarchive](https://0xarchive.io) - Historical Market Data API.
|
|
4
|
+
|
|
5
|
+
Supports multiple exchanges:
|
|
6
|
+
- **Hyperliquid** - Perpetuals data from April 2023
|
|
7
|
+
- **Lighter.xyz** - Perpetuals data (August 2025+ for fills, Jan 2026+ for OB, OI, Funding Rate)
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
@@ -21,12 +25,16 @@ from oxarchive import Client
|
|
|
21
25
|
|
|
22
26
|
client = Client(api_key="ox_your_api_key")
|
|
23
27
|
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
print(f"BTC mid price: {
|
|
28
|
+
# Hyperliquid data
|
|
29
|
+
hl_orderbook = client.hyperliquid.orderbook.get("BTC")
|
|
30
|
+
print(f"Hyperliquid BTC mid price: {hl_orderbook.mid_price}")
|
|
31
|
+
|
|
32
|
+
# Lighter.xyz data
|
|
33
|
+
lighter_orderbook = client.lighter.orderbook.get("BTC")
|
|
34
|
+
print(f"Lighter BTC mid price: {lighter_orderbook.mid_price}")
|
|
27
35
|
|
|
28
36
|
# Get historical order book snapshots
|
|
29
|
-
history = client.orderbook.history(
|
|
37
|
+
history = client.hyperliquid.orderbook.history(
|
|
30
38
|
"ETH",
|
|
31
39
|
start="2024-01-01",
|
|
32
40
|
end="2024-01-02",
|
|
@@ -45,10 +53,13 @@ from oxarchive import Client
|
|
|
45
53
|
async def main():
|
|
46
54
|
client = Client(api_key="ox_your_api_key")
|
|
47
55
|
|
|
48
|
-
# Async get
|
|
49
|
-
orderbook = await client.orderbook.aget("BTC")
|
|
56
|
+
# Async get (Hyperliquid)
|
|
57
|
+
orderbook = await client.hyperliquid.orderbook.aget("BTC")
|
|
50
58
|
print(f"BTC mid price: {orderbook.mid_price}")
|
|
51
59
|
|
|
60
|
+
# Async get (Lighter.xyz)
|
|
61
|
+
lighter_ob = await client.lighter.orderbook.aget("BTC")
|
|
62
|
+
|
|
52
63
|
# Don't forget to close the client
|
|
53
64
|
await client.aclose()
|
|
54
65
|
|
|
@@ -59,7 +70,7 @@ Or use as async context manager:
|
|
|
59
70
|
|
|
60
71
|
```python
|
|
61
72
|
async with Client(api_key="ox_your_api_key") as client:
|
|
62
|
-
orderbook = await client.orderbook.aget("BTC")
|
|
73
|
+
orderbook = await client.hyperliquid.orderbook.aget("BTC")
|
|
63
74
|
```
|
|
64
75
|
|
|
65
76
|
## Configuration
|
|
@@ -74,20 +85,25 @@ client = Client(
|
|
|
74
85
|
|
|
75
86
|
## REST API Reference
|
|
76
87
|
|
|
88
|
+
All examples use `client.hyperliquid.*` but the same methods are available on `client.lighter.*` for Lighter.xyz data.
|
|
89
|
+
|
|
77
90
|
### Order Book
|
|
78
91
|
|
|
79
92
|
```python
|
|
80
|
-
# Get current order book
|
|
81
|
-
orderbook = client.orderbook.get("BTC")
|
|
93
|
+
# Get current order book (Hyperliquid)
|
|
94
|
+
orderbook = client.hyperliquid.orderbook.get("BTC")
|
|
95
|
+
|
|
96
|
+
# Get current order book (Lighter.xyz)
|
|
97
|
+
orderbook = client.lighter.orderbook.get("BTC")
|
|
82
98
|
|
|
83
99
|
# Get order book at specific timestamp
|
|
84
|
-
historical = client.orderbook.get("BTC", timestamp=1704067200000)
|
|
100
|
+
historical = client.hyperliquid.orderbook.get("BTC", timestamp=1704067200000)
|
|
85
101
|
|
|
86
102
|
# Get with limited depth
|
|
87
|
-
shallow = client.orderbook.get("BTC", depth=10)
|
|
103
|
+
shallow = client.hyperliquid.orderbook.get("BTC", depth=10)
|
|
88
104
|
|
|
89
105
|
# Get historical snapshots (start and end are required)
|
|
90
|
-
history = client.orderbook.history(
|
|
106
|
+
history = client.hyperliquid.orderbook.history(
|
|
91
107
|
"BTC",
|
|
92
108
|
start="2024-01-01",
|
|
93
109
|
end="2024-01-02",
|
|
@@ -96,25 +112,78 @@ history = client.orderbook.history(
|
|
|
96
112
|
)
|
|
97
113
|
|
|
98
114
|
# Async versions
|
|
99
|
-
orderbook = await client.orderbook.aget("BTC")
|
|
100
|
-
history = await client.orderbook.ahistory("BTC", start=..., end=...)
|
|
115
|
+
orderbook = await client.hyperliquid.orderbook.aget("BTC")
|
|
116
|
+
history = await client.hyperliquid.orderbook.ahistory("BTC", start=..., end=...)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Orderbook Depth Limits
|
|
120
|
+
|
|
121
|
+
The `depth` parameter controls how many price levels are returned per side. Tier-based limits apply:
|
|
122
|
+
|
|
123
|
+
| Tier | Max Depth |
|
|
124
|
+
|------|-----------|
|
|
125
|
+
| Free | 20 |
|
|
126
|
+
| Build | 50 |
|
|
127
|
+
| Pro | 100 |
|
|
128
|
+
| Enterprise | Full Depth |
|
|
129
|
+
|
|
130
|
+
**Note:** Hyperliquid source data only contains 20 levels. Higher limits apply to Lighter.xyz data.
|
|
131
|
+
|
|
132
|
+
#### Lighter Orderbook Granularity
|
|
133
|
+
|
|
134
|
+
Lighter.xyz orderbook history supports a `granularity` parameter for different data resolutions. Tier restrictions apply.
|
|
135
|
+
|
|
136
|
+
| Granularity | Interval | Tier Required | Credit Multiplier |
|
|
137
|
+
|-------------|----------|---------------|-------------------|
|
|
138
|
+
| `checkpoint` | ~60s | Free+ | 1x |
|
|
139
|
+
| `30s` | 30s | Build+ | 2x |
|
|
140
|
+
| `10s` | 10s | Build+ | 3x |
|
|
141
|
+
| `1s` | 1s | Pro+ | 10x |
|
|
142
|
+
| `tick` | tick-level | Enterprise | 20x |
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
# Get Lighter orderbook history with 10s resolution (Build+ tier)
|
|
146
|
+
history = client.lighter.orderbook.history(
|
|
147
|
+
"BTC",
|
|
148
|
+
start="2024-01-01",
|
|
149
|
+
end="2024-01-02",
|
|
150
|
+
granularity="10s"
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
# Get 1-second resolution (Pro+ tier)
|
|
154
|
+
history = client.lighter.orderbook.history(
|
|
155
|
+
"BTC",
|
|
156
|
+
start="2024-01-01",
|
|
157
|
+
end="2024-01-02",
|
|
158
|
+
granularity="1s"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
# Tick-level data (Enterprise tier) - returns checkpoint + raw deltas
|
|
162
|
+
history = client.lighter.orderbook.history(
|
|
163
|
+
"BTC",
|
|
164
|
+
start="2024-01-01",
|
|
165
|
+
end="2024-01-02",
|
|
166
|
+
granularity="tick"
|
|
167
|
+
)
|
|
101
168
|
```
|
|
102
169
|
|
|
170
|
+
**Note:** The `granularity` parameter is ignored for Hyperliquid orderbook history.
|
|
171
|
+
|
|
103
172
|
### Trades
|
|
104
173
|
|
|
105
174
|
The trades API uses cursor-based pagination for efficient retrieval of large datasets.
|
|
106
175
|
|
|
107
176
|
```python
|
|
108
177
|
# Get recent trades
|
|
109
|
-
recent = client.trades.recent("BTC", limit=100)
|
|
178
|
+
recent = client.hyperliquid.trades.recent("BTC", limit=100)
|
|
110
179
|
|
|
111
180
|
# Get trade history with cursor-based pagination
|
|
112
|
-
result = client.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
|
|
181
|
+
result = client.hyperliquid.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
|
|
113
182
|
trades = result.data
|
|
114
183
|
|
|
115
184
|
# Paginate through all results
|
|
116
185
|
while result.next_cursor:
|
|
117
|
-
result = client.trades.list(
|
|
186
|
+
result = client.hyperliquid.trades.list(
|
|
118
187
|
"ETH",
|
|
119
188
|
start="2024-01-01",
|
|
120
189
|
end="2024-01-02",
|
|
@@ -124,61 +193,103 @@ while result.next_cursor:
|
|
|
124
193
|
trades.extend(result.data)
|
|
125
194
|
|
|
126
195
|
# Filter by side
|
|
127
|
-
buys = client.trades.list("BTC", start=..., end=..., side="buy")
|
|
196
|
+
buys = client.hyperliquid.trades.list("BTC", start=..., end=..., side="buy")
|
|
128
197
|
|
|
129
198
|
# Async versions
|
|
130
|
-
recent = await client.trades.arecent("BTC")
|
|
131
|
-
result = await client.trades.alist("ETH", start=..., end=...)
|
|
199
|
+
recent = await client.hyperliquid.trades.arecent("BTC")
|
|
200
|
+
result = await client.hyperliquid.trades.alist("ETH", start=..., end=...)
|
|
132
201
|
```
|
|
133
202
|
|
|
134
203
|
### Instruments
|
|
135
204
|
|
|
136
205
|
```python
|
|
137
|
-
# List all trading instruments
|
|
138
|
-
instruments = client.instruments.list()
|
|
206
|
+
# List all trading instruments (Hyperliquid)
|
|
207
|
+
instruments = client.hyperliquid.instruments.list()
|
|
139
208
|
|
|
140
209
|
# Get specific instrument details
|
|
141
|
-
btc = client.instruments.get("BTC")
|
|
210
|
+
btc = client.hyperliquid.instruments.get("BTC")
|
|
211
|
+
print(f"BTC size decimals: {btc.sz_decimals}")
|
|
142
212
|
|
|
143
213
|
# Async versions
|
|
144
|
-
instruments = await client.instruments.alist()
|
|
145
|
-
btc = await client.instruments.aget("BTC")
|
|
214
|
+
instruments = await client.hyperliquid.instruments.alist()
|
|
215
|
+
btc = await client.hyperliquid.instruments.aget("BTC")
|
|
146
216
|
```
|
|
147
217
|
|
|
218
|
+
#### Lighter.xyz Instruments
|
|
219
|
+
|
|
220
|
+
Lighter instruments have a different schema with additional fields for fees, market IDs, and minimum order amounts:
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
# List Lighter instruments (returns LighterInstrument, not Instrument)
|
|
224
|
+
lighter_instruments = client.lighter.instruments.list()
|
|
225
|
+
|
|
226
|
+
# Get specific Lighter instrument
|
|
227
|
+
eth = client.lighter.instruments.get("ETH")
|
|
228
|
+
print(f"ETH taker fee: {eth.taker_fee}")
|
|
229
|
+
print(f"ETH maker fee: {eth.maker_fee}")
|
|
230
|
+
print(f"ETH market ID: {eth.market_id}")
|
|
231
|
+
print(f"ETH min base amount: {eth.min_base_amount}")
|
|
232
|
+
|
|
233
|
+
# Async versions
|
|
234
|
+
lighter_instruments = await client.lighter.instruments.alist()
|
|
235
|
+
eth = await client.lighter.instruments.aget("ETH")
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Key differences:**
|
|
239
|
+
| Field | Hyperliquid (`Instrument`) | Lighter (`LighterInstrument`) |
|
|
240
|
+
|-------|---------------------------|------------------------------|
|
|
241
|
+
| Symbol | `name` | `symbol` |
|
|
242
|
+
| Size decimals | `sz_decimals` | `size_decimals` |
|
|
243
|
+
| Fee info | Not available | `taker_fee`, `maker_fee`, `liquidation_fee` |
|
|
244
|
+
| Market ID | Not available | `market_id` |
|
|
245
|
+
| Min amounts | Not available | `min_base_amount`, `min_quote_amount` |
|
|
246
|
+
|
|
148
247
|
### Funding Rates
|
|
149
248
|
|
|
150
249
|
```python
|
|
151
250
|
# Get current funding rate
|
|
152
|
-
current = client.funding.current("BTC")
|
|
251
|
+
current = client.hyperliquid.funding.current("BTC")
|
|
153
252
|
|
|
154
253
|
# Get funding rate history (start is required)
|
|
155
|
-
history = client.funding.history(
|
|
254
|
+
history = client.hyperliquid.funding.history(
|
|
156
255
|
"ETH",
|
|
157
256
|
start="2024-01-01",
|
|
158
257
|
end="2024-01-07"
|
|
159
258
|
)
|
|
160
259
|
|
|
161
260
|
# Async versions
|
|
162
|
-
current = await client.funding.acurrent("BTC")
|
|
163
|
-
history = await client.funding.ahistory("ETH", start=..., end=...)
|
|
261
|
+
current = await client.hyperliquid.funding.acurrent("BTC")
|
|
262
|
+
history = await client.hyperliquid.funding.ahistory("ETH", start=..., end=...)
|
|
164
263
|
```
|
|
165
264
|
|
|
166
265
|
### Open Interest
|
|
167
266
|
|
|
168
267
|
```python
|
|
169
268
|
# Get current open interest
|
|
170
|
-
current = client.open_interest.current("BTC")
|
|
269
|
+
current = client.hyperliquid.open_interest.current("BTC")
|
|
171
270
|
|
|
172
271
|
# Get open interest history (start is required)
|
|
173
|
-
history = client.open_interest.history(
|
|
272
|
+
history = client.hyperliquid.open_interest.history(
|
|
174
273
|
"ETH",
|
|
175
274
|
start="2024-01-01",
|
|
176
275
|
end="2024-01-07"
|
|
177
276
|
)
|
|
178
277
|
|
|
179
278
|
# Async versions
|
|
180
|
-
current = await client.open_interest.acurrent("BTC")
|
|
181
|
-
history = await client.open_interest.ahistory("ETH", start=..., end=...)
|
|
279
|
+
current = await client.hyperliquid.open_interest.acurrent("BTC")
|
|
280
|
+
history = await client.hyperliquid.open_interest.ahistory("ETH", start=..., end=...)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Legacy API (Deprecated)
|
|
284
|
+
|
|
285
|
+
The following legacy methods are deprecated and will be removed in v2.0. They default to Hyperliquid data:
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
# Deprecated - use client.hyperliquid.orderbook.get() instead
|
|
289
|
+
orderbook = client.orderbook.get("BTC")
|
|
290
|
+
|
|
291
|
+
# Deprecated - use client.hyperliquid.trades.list() instead
|
|
292
|
+
trades = client.trades.list("BTC", start=..., end=...)
|
|
182
293
|
```
|
|
183
294
|
|
|
184
295
|
## WebSocket Client
|
|
@@ -384,8 +495,8 @@ except OxArchiveError as e:
|
|
|
384
495
|
Full type hint support with Pydantic models:
|
|
385
496
|
|
|
386
497
|
```python
|
|
387
|
-
from oxarchive import Client
|
|
388
|
-
from oxarchive.types import OrderBook, Trade, Instrument, FundingRate, OpenInterest
|
|
498
|
+
from oxarchive import Client, LighterGranularity
|
|
499
|
+
from oxarchive.types import OrderBook, Trade, Instrument, LighterInstrument, FundingRate, OpenInterest
|
|
389
500
|
from oxarchive.resources.trades import CursorResponse
|
|
390
501
|
|
|
391
502
|
client = Client(api_key="ox_your_api_key")
|
|
@@ -393,6 +504,9 @@ client = Client(api_key="ox_your_api_key")
|
|
|
393
504
|
orderbook: OrderBook = client.orderbook.get("BTC")
|
|
394
505
|
trades: list[Trade] = client.trades.recent("BTC")
|
|
395
506
|
result: CursorResponse = client.trades.list("BTC", start=..., end=...)
|
|
507
|
+
|
|
508
|
+
# Lighter granularity type hint
|
|
509
|
+
granularity: LighterGranularity = "10s"
|
|
396
510
|
```
|
|
397
511
|
|
|
398
512
|
## Requirements
|