oxarchive 0.4.2__py3-none-any.whl → 0.4.4__py3-none-any.whl

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/__init__.py CHANGED
@@ -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.2"
68
+ __version__ = "0.4.4"
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(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oxarchive
3
- Version: 0.4.2
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
@@ -153,6 +153,59 @@ orderbook = await client.hyperliquid.orderbook.aget("BTC")
153
153
  history = await client.hyperliquid.orderbook.ahistory("BTC", start=..., end=...)
154
154
  ```
155
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
+ )
205
+ ```
206
+
207
+ **Note:** The `granularity` parameter is ignored for Hyperliquid orderbook history.
208
+
156
209
  ### Trades
157
210
 
158
211
  The trades API uses cursor-based pagination for efficient retrieval of large datasets.
@@ -479,7 +532,7 @@ except OxArchiveError as e:
479
532
  Full type hint support with Pydantic models:
480
533
 
481
534
  ```python
482
- from oxarchive import Client
535
+ from oxarchive import Client, LighterGranularity
483
536
  from oxarchive.types import OrderBook, Trade, Instrument, LighterInstrument, FundingRate, OpenInterest
484
537
  from oxarchive.resources.trades import CursorResponse
485
538
 
@@ -488,6 +541,9 @@ client = Client(api_key="ox_your_api_key")
488
541
  orderbook: OrderBook = client.orderbook.get("BTC")
489
542
  trades: list[Trade] = client.trades.recent("BTC")
490
543
  result: CursorResponse = client.trades.list("BTC", start=..., end=...)
544
+
545
+ # Lighter granularity type hint
546
+ granularity: LighterGranularity = "10s"
491
547
  ```
492
548
 
493
549
  ## Requirements
@@ -1,4 +1,4 @@
1
- oxarchive/__init__.py,sha256=6yC9nqGCEj0sxWPUpZaf1XR4ux7Iry3K2rZ0Z1jw3qg,2586
1
+ oxarchive/__init__.py,sha256=MFsShbQ6sAPBaf_Vn9azR-CydWUSK6w8S92on1oNl7Q,2666
2
2
  oxarchive/client.py,sha256=XWQ_VEBQy3UIAnmZQ-Z_FyzXnvMA3FITwtinBOf3o-Y,4453
3
3
  oxarchive/exchanges.py,sha256=kk--Uh4g1U_tPfhJhYtZD_1zR6tJS5D-iaPnOGwWa9c,2425
4
4
  oxarchive/http.py,sha256=SY_o9Ag8ADo1HI3i3uAKW1xwkYjPE75gRAjnMsddAGs,4211
@@ -8,8 +8,8 @@ oxarchive/resources/__init__.py,sha256=ZGS3rLOfQFD665oJYMia_MxfTWlal7MXtx874DLG5
8
8
  oxarchive/resources/funding.py,sha256=ybMWkpoccrkdwnd6W3oHgsaor7cBcA2nkYy4CbjmHUg,4485
9
9
  oxarchive/resources/instruments.py,sha256=6q7rMdIaixXgFVXgwQsVd-YuO7RIXr1oGPT5jBsqI9A,3733
10
10
  oxarchive/resources/openinterest.py,sha256=whwo60KFNLGwvVrDmDYYc-rMZr35Fcizb5Iil-DSvD8,4553
11
- oxarchive/resources/orderbook.py,sha256=-paXBdGYBCMX-LK-MeXIKlcFz97iW2UWn9Am2XCgg2U,5717
11
+ oxarchive/resources/orderbook.py,sha256=NzgKH45MBb2oAHyPmy6BSikaYyq0nM-8GFjur9LIRN8,6661
12
12
  oxarchive/resources/trades.py,sha256=t4iicyi1waaHzC7Q_cC-c7O4yVx1vqS4eMH8F8_5hxk,5503
13
- oxarchive-0.4.2.dist-info/METADATA,sha256=7WMhogTWSSHLw5wleZTw1ZCpM04Qe0OfXUIxcAJAJXg,13620
14
- oxarchive-0.4.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
15
- oxarchive-0.4.2.dist-info/RECORD,,
13
+ oxarchive-0.4.4.dist-info/METADATA,sha256=wcgN_17HlgSwtcayWuMLoDTfzU_ofwbgr0uWivhfDEo,15163
14
+ oxarchive-0.4.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
15
+ oxarchive-0.4.4.dist-info/RECORD,,