oxarchive 0.3.5__tar.gz → 0.3.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oxarchive
3
- Version: 0.3.5
3
+ Version: 0.3.7
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
@@ -57,7 +57,7 @@ except ImportError:
57
57
  OxArchiveWs = None # type: ignore
58
58
  WsOptions = None # type: ignore
59
59
 
60
- __version__ = "0.3.5"
60
+ __version__ = "0.3.7"
61
61
 
62
62
  __all__ = [
63
63
  # Client
@@ -124,9 +124,6 @@ class Trade(BaseModel):
124
124
  start_position: Optional[str] = None
125
125
  """Position size before this trade."""
126
126
 
127
- source: Optional[Literal["s3", "ws", "api", "live"]] = None
128
- """Data source: 's3' (historical), 'api' (REST backfill), 'ws' (websocket), 'live' (real-time ingestion)."""
129
-
130
127
  user_address: Optional[str] = None
131
128
  """User's wallet address (for fill-level data)."""
132
129
 
@@ -124,13 +124,36 @@ def _transform_trade(coin: str, raw: dict) -> Trade:
124
124
  """Transform raw Hyperliquid trade format to SDK Trade type.
125
125
 
126
126
  Raw WebSocket format: { coin, side, px, sz, time, hash, tid, users: [maker, taker] }
127
+ Historical replay format: { coin, side, price, size, time, hash, tradeId, userAddress, ... }
127
128
  SDK format: { coin, side, price, size, timestamp, tx_hash, trade_id, maker_address, taker_address }
128
129
  """
129
130
  from datetime import datetime
130
131
 
131
132
  # Check if already in SDK format (from REST API or historical replay)
132
133
  if "price" in raw and "size" in raw:
133
- return Trade(**raw)
134
+ # Map camelCase keys from WebSocket to snake_case for Pydantic
135
+ mapped = {
136
+ "coin": raw.get("coin", coin),
137
+ "side": raw.get("side", "B"),
138
+ "price": raw.get("price"),
139
+ "size": raw.get("size"),
140
+ "timestamp": raw.get("timestamp") or (datetime.utcfromtimestamp(raw.get("time", 0) / 1000).isoformat() + "Z" if raw.get("time") else None),
141
+ "tx_hash": raw.get("tx_hash") or raw.get("hash"),
142
+ "trade_id": raw.get("trade_id") or raw.get("tradeId"),
143
+ "order_id": raw.get("order_id") or raw.get("orderId"),
144
+ "crossed": raw.get("crossed"),
145
+ "fee": raw.get("fee"),
146
+ "fee_token": raw.get("fee_token") or raw.get("feeToken"),
147
+ "closed_pnl": raw.get("closed_pnl") or raw.get("closedPnl"),
148
+ "direction": raw.get("direction"),
149
+ "start_position": raw.get("start_position") or raw.get("startPosition"),
150
+ "user_address": raw.get("user_address") or raw.get("userAddress"),
151
+ "maker_address": raw.get("maker_address"),
152
+ "taker_address": raw.get("taker_address"),
153
+ }
154
+ # Remove None values to let Pydantic use defaults
155
+ mapped = {k: v for k, v in mapped.items() if v is not None}
156
+ return Trade(**mapped)
134
157
 
135
158
  # Transform from Hyperliquid raw format
136
159
  time_ms = raw.get("time")
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "oxarchive"
7
- version = "0.3.5"
7
+ version = "0.3.7"
8
8
  description = "Official Python SDK for 0xarchive - Hyperliquid Historical Data API"
9
9
  readme = "README.md"
10
10
  license = "MIT"
File without changes
File without changes
File without changes
File without changes