Skip to content

Trade TypedDict does not match live trades payload #327

Open

Description

@koriyoshi2041

Summary

The Trade TypedDict in hyperliquid/utils/types.py does not match the payload currently emitted by the public trades WebSocket subscription.

Current declaration:

Trade = TypedDict("Trade", {"coin": str, "side": Side, "px": str, "sz": int, "hash": str, "time": int})

Observed live payload keys:

coin, side, px, sz, time, hash, tid, users

In the live payload, sz is a string, while the TypedDict declares it as int. The payload also includes tid and users, which are absent from the type.

Reproduction

I opened a read-only connection to wss://api.hyperliquid.xyz/ws and subscribed with:

{"method":"subscribe","subscription":{"type":"trades","coin":"BTC"}}

A representative item had the following runtime types:

coin: str
side: str
px: str
sz: str
time: int
hash: str
tid: int
users: list[str]

This used only the public market-data WebSocket: no wallet, signing, or order flow.

Expected

Trade should describe the wire payload, for example with sz: str, tid: int, and users: List[str] (or document any reason these fields are intentionally excluded).

I searched the current issues and pull requests for Trade, TypedDict, tid, and users and did not find an existing report for this mismatch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions