oxarchive 0.3.4__py3-none-any.whl → 0.3.6__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
oxarchive/websocket.py
CHANGED
|
@@ -124,13 +124,37 @@ 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
|
-
|
|
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
|
+
"source": raw.get("source"),
|
|
151
|
+
"user_address": raw.get("user_address") or raw.get("userAddress"),
|
|
152
|
+
"maker_address": raw.get("maker_address"),
|
|
153
|
+
"taker_address": raw.get("taker_address"),
|
|
154
|
+
}
|
|
155
|
+
# Remove None values to let Pydantic use defaults
|
|
156
|
+
mapped = {k: v for k, v in mapped.items() if v is not None}
|
|
157
|
+
return Trade(**mapped)
|
|
134
158
|
|
|
135
159
|
# Transform from Hyperliquid raw format
|
|
136
160
|
time_ms = raw.get("time")
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
oxarchive/__init__.py,sha256=
|
|
1
|
+
oxarchive/__init__.py,sha256=Q6hk0SMNM5HLYIuyFXrCPYrT261n90iPKoGakQL11vk,2181
|
|
2
2
|
oxarchive/client.py,sha256=3P0fvOcyM5BWppkVV4054NduDHKvRg-cWeluoGymmRk,3163
|
|
3
3
|
oxarchive/http.py,sha256=SY_o9Ag8ADo1HI3i3uAKW1xwkYjPE75gRAjnMsddAGs,4211
|
|
4
4
|
oxarchive/types.py,sha256=pQJt1ZilZaV6h4anPYHloVrB97Q9Y2v9B9iYTkMXFo0,11025
|
|
5
|
-
oxarchive/websocket.py,sha256=
|
|
5
|
+
oxarchive/websocket.py,sha256=f5MeqwWL0WRn1X4uRXaSir7izUPPpkG1R75JuvA_fqE,28383
|
|
6
6
|
oxarchive/resources/__init__.py,sha256=WQ4GYQ8p3L0D2Isk4IV4h1DRpvyZlt6tOF1t_CJr6ls,385
|
|
7
7
|
oxarchive/resources/funding.py,sha256=TXkZxodVQTVcVbzNG6SpMQAzf8AkLm2NYZJxnP4MNXw,3500
|
|
8
8
|
oxarchive/resources/instruments.py,sha256=flD1sH6x3P3CTqV1ZwkfwbranVacmhsHn5Dhr7lGQhM,1606
|
|
9
9
|
oxarchive/resources/openinterest.py,sha256=h13yLA72LpfryUf8IqF6W7uE4ObYY2Qbc-auv4LtPqc,3552
|
|
10
10
|
oxarchive/resources/orderbook.py,sha256=o_DTdpzKrZvHL9YXm8cGGUugPM8uUa6r9O_72r1ByV0,4557
|
|
11
11
|
oxarchive/resources/trades.py,sha256=XCi2rXA2hxaTt0KNlWw8f7W0hzAvNWyT7DaivMz_rHw,10012
|
|
12
|
-
oxarchive-0.3.
|
|
13
|
-
oxarchive-0.3.
|
|
14
|
-
oxarchive-0.3.
|
|
12
|
+
oxarchive-0.3.6.dist-info/METADATA,sha256=mAi4P9emfIG3_rlaFXyocwpRjxLEw9xo5sAwnMBUE5U,11070
|
|
13
|
+
oxarchive-0.3.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
14
|
+
oxarchive-0.3.6.dist-info/RECORD,,
|
|
File without changes
|