oxarchive 0.4.2__tar.gz → 0.4.3__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.4.2 → oxarchive-0.4.3}/PKG-INFO +45 -2
- {oxarchive-0.4.2 → oxarchive-0.4.3}/README.md +44 -1
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/__init__.py +3 -1
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/resources/orderbook.py +18 -1
- {oxarchive-0.4.2 → oxarchive-0.4.3}/pyproject.toml +1 -1
- {oxarchive-0.4.2 → oxarchive-0.4.3}/.gitignore +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/client.py +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/exchanges.py +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/http.py +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/resources/__init__.py +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/resources/funding.py +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/resources/instruments.py +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/resources/openinterest.py +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/resources/trades.py +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/types.py +0 -0
- {oxarchive-0.4.2 → oxarchive-0.4.3}/oxarchive/websocket.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oxarchive
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
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
|
|
@@ -153,6 +153,46 @@ orderbook = await client.hyperliquid.orderbook.aget("BTC")
|
|
|
153
153
|
history = await client.hyperliquid.orderbook.ahistory("BTC", start=..., end=...)
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
+
#### Lighter Orderbook Granularity
|
|
157
|
+
|
|
158
|
+
Lighter.xyz orderbook history supports a `granularity` parameter for different data resolutions. Tier restrictions apply.
|
|
159
|
+
|
|
160
|
+
| Granularity | Interval | Tier Required | Credit Multiplier |
|
|
161
|
+
|-------------|----------|---------------|-------------------|
|
|
162
|
+
| `checkpoint` | ~60s | Free+ | 1x |
|
|
163
|
+
| `30s` | 30s | Build+ | 2x |
|
|
164
|
+
| `10s` | 10s | Build+ | 3x |
|
|
165
|
+
| `1s` | 1s | Pro+ | 10x |
|
|
166
|
+
| `tick` | tick-level | Enterprise | 20x |
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
# Get Lighter orderbook history with 10s resolution (Build+ tier)
|
|
170
|
+
history = client.lighter.orderbook.history(
|
|
171
|
+
"BTC",
|
|
172
|
+
start="2024-01-01",
|
|
173
|
+
end="2024-01-02",
|
|
174
|
+
granularity="10s"
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
# Get 1-second resolution (Pro+ tier)
|
|
178
|
+
history = client.lighter.orderbook.history(
|
|
179
|
+
"BTC",
|
|
180
|
+
start="2024-01-01",
|
|
181
|
+
end="2024-01-02",
|
|
182
|
+
granularity="1s"
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
# Tick-level data (Enterprise tier) - returns checkpoint + raw deltas
|
|
186
|
+
history = client.lighter.orderbook.history(
|
|
187
|
+
"BTC",
|
|
188
|
+
start="2024-01-01",
|
|
189
|
+
end="2024-01-02",
|
|
190
|
+
granularity="tick"
|
|
191
|
+
)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Note:** The `granularity` parameter is ignored for Hyperliquid orderbook history.
|
|
195
|
+
|
|
156
196
|
### Trades
|
|
157
197
|
|
|
158
198
|
The trades API uses cursor-based pagination for efficient retrieval of large datasets.
|
|
@@ -479,7 +519,7 @@ except OxArchiveError as e:
|
|
|
479
519
|
Full type hint support with Pydantic models:
|
|
480
520
|
|
|
481
521
|
```python
|
|
482
|
-
from oxarchive import Client
|
|
522
|
+
from oxarchive import Client, LighterGranularity
|
|
483
523
|
from oxarchive.types import OrderBook, Trade, Instrument, LighterInstrument, FundingRate, OpenInterest
|
|
484
524
|
from oxarchive.resources.trades import CursorResponse
|
|
485
525
|
|
|
@@ -488,6 +528,9 @@ client = Client(api_key="ox_your_api_key")
|
|
|
488
528
|
orderbook: OrderBook = client.orderbook.get("BTC")
|
|
489
529
|
trades: list[Trade] = client.trades.recent("BTC")
|
|
490
530
|
result: CursorResponse = client.trades.list("BTC", start=..., end=...)
|
|
531
|
+
|
|
532
|
+
# Lighter granularity type hint
|
|
533
|
+
granularity: LighterGranularity = "10s"
|
|
491
534
|
```
|
|
492
535
|
|
|
493
536
|
## Requirements
|
|
@@ -116,6 +116,46 @@ orderbook = await client.hyperliquid.orderbook.aget("BTC")
|
|
|
116
116
|
history = await client.hyperliquid.orderbook.ahistory("BTC", start=..., end=...)
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
+
#### Lighter Orderbook Granularity
|
|
120
|
+
|
|
121
|
+
Lighter.xyz orderbook history supports a `granularity` parameter for different data resolutions. Tier restrictions apply.
|
|
122
|
+
|
|
123
|
+
| Granularity | Interval | Tier Required | Credit Multiplier |
|
|
124
|
+
|-------------|----------|---------------|-------------------|
|
|
125
|
+
| `checkpoint` | ~60s | Free+ | 1x |
|
|
126
|
+
| `30s` | 30s | Build+ | 2x |
|
|
127
|
+
| `10s` | 10s | Build+ | 3x |
|
|
128
|
+
| `1s` | 1s | Pro+ | 10x |
|
|
129
|
+
| `tick` | tick-level | Enterprise | 20x |
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
# Get Lighter orderbook history with 10s resolution (Build+ tier)
|
|
133
|
+
history = client.lighter.orderbook.history(
|
|
134
|
+
"BTC",
|
|
135
|
+
start="2024-01-01",
|
|
136
|
+
end="2024-01-02",
|
|
137
|
+
granularity="10s"
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# Get 1-second resolution (Pro+ tier)
|
|
141
|
+
history = client.lighter.orderbook.history(
|
|
142
|
+
"BTC",
|
|
143
|
+
start="2024-01-01",
|
|
144
|
+
end="2024-01-02",
|
|
145
|
+
granularity="1s"
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# Tick-level data (Enterprise tier) - returns checkpoint + raw deltas
|
|
149
|
+
history = client.lighter.orderbook.history(
|
|
150
|
+
"BTC",
|
|
151
|
+
start="2024-01-01",
|
|
152
|
+
end="2024-01-02",
|
|
153
|
+
granularity="tick"
|
|
154
|
+
)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Note:** The `granularity` parameter is ignored for Hyperliquid orderbook history.
|
|
158
|
+
|
|
119
159
|
### Trades
|
|
120
160
|
|
|
121
161
|
The trades API uses cursor-based pagination for efficient retrieval of large datasets.
|
|
@@ -442,7 +482,7 @@ except OxArchiveError as e:
|
|
|
442
482
|
Full type hint support with Pydantic models:
|
|
443
483
|
|
|
444
484
|
```python
|
|
445
|
-
from oxarchive import Client
|
|
485
|
+
from oxarchive import Client, LighterGranularity
|
|
446
486
|
from oxarchive.types import OrderBook, Trade, Instrument, LighterInstrument, FundingRate, OpenInterest
|
|
447
487
|
from oxarchive.resources.trades import CursorResponse
|
|
448
488
|
|
|
@@ -451,6 +491,9 @@ client = Client(api_key="ox_your_api_key")
|
|
|
451
491
|
orderbook: OrderBook = client.orderbook.get("BTC")
|
|
452
492
|
trades: list[Trade] = client.trades.recent("BTC")
|
|
453
493
|
result: CursorResponse = client.trades.list("BTC", start=..., end=...)
|
|
494
|
+
|
|
495
|
+
# Lighter granularity type hint
|
|
496
|
+
granularity: LighterGranularity = "10s"
|
|
454
497
|
```
|
|
455
498
|
|
|
456
499
|
## Requirements
|
|
@@ -23,6 +23,7 @@ Example:
|
|
|
23
23
|
|
|
24
24
|
from .client import Client
|
|
25
25
|
from .exchanges import HyperliquidClient, LighterClient
|
|
26
|
+
from .resources.orderbook import LighterGranularity
|
|
26
27
|
from .types import (
|
|
27
28
|
OrderBook,
|
|
28
29
|
Trade,
|
|
@@ -64,7 +65,7 @@ except ImportError:
|
|
|
64
65
|
OxArchiveWs = None # type: ignore
|
|
65
66
|
WsOptions = None # type: ignore
|
|
66
67
|
|
|
67
|
-
__version__ = "0.4.
|
|
68
|
+
__version__ = "0.4.3"
|
|
68
69
|
|
|
69
70
|
__all__ = [
|
|
70
71
|
# Client
|
|
@@ -80,6 +81,7 @@ __all__ = [
|
|
|
80
81
|
"Trade",
|
|
81
82
|
"Instrument",
|
|
82
83
|
"LighterInstrument",
|
|
84
|
+
"LighterGranularity",
|
|
83
85
|
"FundingRate",
|
|
84
86
|
"OpenInterest",
|
|
85
87
|
"OxArchiveError",
|
|
@@ -6,8 +6,13 @@ from datetime import datetime
|
|
|
6
6
|
from typing import Optional, Union
|
|
7
7
|
|
|
8
8
|
from ..http import HttpClient
|
|
9
|
+
from typing import Literal
|
|
10
|
+
|
|
9
11
|
from ..types import CursorResponse, OrderBook, Timestamp
|
|
10
12
|
|
|
13
|
+
# Lighter orderbook granularity levels (Lighter.xyz only)
|
|
14
|
+
LighterGranularity = Literal["checkpoint", "30s", "10s", "1s", "tick"]
|
|
15
|
+
|
|
11
16
|
|
|
12
17
|
class OrderBookResource:
|
|
13
18
|
"""
|
|
@@ -101,6 +106,7 @@ class OrderBookResource:
|
|
|
101
106
|
cursor: Optional[Timestamp] = None,
|
|
102
107
|
limit: Optional[int] = None,
|
|
103
108
|
depth: Optional[int] = None,
|
|
109
|
+
granularity: Optional[LighterGranularity] = None,
|
|
104
110
|
) -> CursorResponse[list[OrderBook]]:
|
|
105
111
|
"""
|
|
106
112
|
Get historical order book snapshots with cursor-based pagination.
|
|
@@ -112,6 +118,9 @@ class OrderBookResource:
|
|
|
112
118
|
cursor: Cursor from previous response's next_cursor (timestamp)
|
|
113
119
|
limit: Maximum number of results (default: 100, max: 1000)
|
|
114
120
|
depth: Number of price levels per side
|
|
121
|
+
granularity: Data resolution for Lighter orderbook (Lighter.xyz only, ignored for Hyperliquid).
|
|
122
|
+
Options: 'checkpoint' (1min, default), '30s', '10s', '1s', 'tick'.
|
|
123
|
+
Tier restrictions apply. Credit multipliers: checkpoint=1x, 30s=2x, 10s=3x, 1s=10x, tick=20x.
|
|
115
124
|
|
|
116
125
|
Returns:
|
|
117
126
|
CursorResponse with order book snapshots and next_cursor for pagination
|
|
@@ -124,6 +133,11 @@ class OrderBookResource:
|
|
|
124
133
|
... "BTC", start=start, end=end, cursor=result.next_cursor, limit=1000
|
|
125
134
|
... )
|
|
126
135
|
... snapshots.extend(result.data)
|
|
136
|
+
>>>
|
|
137
|
+
>>> # Lighter.xyz with 10s granularity (Build+ tier)
|
|
138
|
+
>>> result = client.lighter.orderbook.history(
|
|
139
|
+
... "BTC", start=start, end=end, granularity="10s"
|
|
140
|
+
... )
|
|
127
141
|
"""
|
|
128
142
|
data = self._http.get(
|
|
129
143
|
f"{self._base_path}/orderbook/{coin.upper()}/history",
|
|
@@ -133,6 +147,7 @@ class OrderBookResource:
|
|
|
133
147
|
"cursor": self._convert_timestamp(cursor),
|
|
134
148
|
"limit": limit,
|
|
135
149
|
"depth": depth,
|
|
150
|
+
"granularity": granularity,
|
|
136
151
|
},
|
|
137
152
|
)
|
|
138
153
|
return CursorResponse(
|
|
@@ -149,8 +164,9 @@ class OrderBookResource:
|
|
|
149
164
|
cursor: Optional[Timestamp] = None,
|
|
150
165
|
limit: Optional[int] = None,
|
|
151
166
|
depth: Optional[int] = None,
|
|
167
|
+
granularity: Optional[LighterGranularity] = None,
|
|
152
168
|
) -> CursorResponse[list[OrderBook]]:
|
|
153
|
-
"""Async version of history(). start and end are required."""
|
|
169
|
+
"""Async version of history(). start and end are required. See history() for granularity details."""
|
|
154
170
|
data = await self._http.aget(
|
|
155
171
|
f"{self._base_path}/orderbook/{coin.upper()}/history",
|
|
156
172
|
params={
|
|
@@ -159,6 +175,7 @@ class OrderBookResource:
|
|
|
159
175
|
"cursor": self._convert_timestamp(cursor),
|
|
160
176
|
"limit": limit,
|
|
161
177
|
"depth": depth,
|
|
178
|
+
"granularity": granularity,
|
|
162
179
|
},
|
|
163
180
|
)
|
|
164
181
|
return CursorResponse(
|
|
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
|