Skip to content

Commit 685ed32

Browse files
committed
updated based on review comments
1 parent 1a34489 commit 685ed32

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

examples/basic_ws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main():
2020
info.subscribe({"type": "bbo", "coin": "ETH"}, print)
2121
info.subscribe({"type": "activeAssetCtx", "coin": "BTC"}, print) # Perp
2222
info.subscribe({"type": "activeAssetCtx", "coin": "@1"}, print) # Spot
23-
info.subscribe({"type": "activeAssetData", "user": address, "coin": "BTC"}, print) # Perp
23+
info.subscribe({"type": "activeAssetData", "user": address, "coin": "BTC"}, print) # Perp only
2424

2525

2626
if __name__ == "__main__":

hyperliquid/utils/types.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
{
8585
"type": Union[Literal["cross"], Literal["isolated"]],
8686
"value": int,
87-
"rawUsd": Optional[str],
87+
"rawUsd": NotRequired[str],
8888
},
8989
)
9090
TradesMsg = TypedDict("TradesMsg", {"channel": Literal["trades"], "data": List[Trade]})
@@ -115,8 +115,8 @@
115115
"user": str,
116116
"coin": str,
117117
"leverage": Leverage,
118-
"maxTradeSzs": List[str],
119-
"availableToTrade": List[str],
118+
"maxTradeSzs": Tuple[str, str],
119+
"availableToTrade": Tuple[str, str],
120120
"markPx": str,
121121
},
122122
)
@@ -170,6 +170,7 @@
170170
OtherWsMsg,
171171
ActiveAssetCtxMsg,
172172
ActiveSpotAssetCtxMsg,
173+
ActiveAssetDataMsg,
173174
]
174175

175176
# b is the public address of the builder, f is the amount of the fee in tenths of basis points. e.g. 10 means 1 basis point

hyperliquid/websocket_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def subscription_to_identifier(subscription: Subscription) -> str:
3636
elif subscription["type"] == "activeAssetCtx":
3737
return f'activeAssetCtx:{subscription["coin"].lower()}'
3838
elif subscription["type"] == "activeAssetData":
39-
return f'activeAssetData:{subscription["coin"].lower()}'
39+
return f'activeAssetData:{subscription["coin"].lower()},{subscription["user"]}'
4040

4141

4242
def ws_msg_to_identifier(ws_msg: WsMsg) -> Optional[str]:
@@ -71,7 +71,7 @@ def ws_msg_to_identifier(ws_msg: WsMsg) -> Optional[str]:
7171
elif ws_msg["channel"] == "activeAssetCtx" or ws_msg["channel"] == "activeSpotAssetCtx":
7272
return f'activeAssetCtx:{ws_msg["data"]["coin"].lower()}'
7373
elif ws_msg["channel"] == "activeAssetData":
74-
return f'activeAssetData:{ws_msg["data"]["coin"].lower()}'
74+
return f'activeAssetData:{ws_msg["data"]["coin"].lower()},{ws_msg["data"]["user"]}'
7575

7676

7777
class WebsocketManager(threading.Thread):

0 commit comments

Comments
 (0)