pybotters.HyperliquidDataStore

class pybotters.HyperliquidDataStore

DataStoreCollection for Hyperliquid.

https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions

Methods

__init__()

onmessage(msg[, ws])

WebSocket message handler.

wait()

DataStoreCollection の onmessage ハンドラが呼び出しされるまで待機します。

Attributes

active_asset_ctx

activeAssetCtx data stream.

active_asset_data

activeAssetData data stream.

all_mids

allMids data stream.

bbo

bbo data stream.

candle

candle data stream.

l2_book

l2Book data stream.

notification

notification data stream.

order_updates

orderUpdates data stream.

trades

trades data stream.

user_events

userEvents data stream.

user_fills

userFills data stream.

user_fundings

userFundings data stream.

user_non_funding_ledger_updates

userNonFundingLedgerUpdates data stream.

user_twap_history

userTwapHistory data stream.

user_twap_slice_fills

userTwapSliceFills data stream.

web_data2

webData2 data stream.

property active_asset_ctx: ActiveAssetCtx

activeAssetCtx data stream.

Data type: Mutable

Keys: ["coin"]

Data structure:

[
    {
        "coin": "BTC",
        "dayNtlVlm": "1169046.29406",
        "prevDayPx": "15.322",
        "markPx": "14.3161",
        "midPx": "14.314",
        "funding": "0.0000125",
        "openInterest": "688.11",
        "oraclePx": "14.32",
    },
    {
        "coin": "USDC",
        "dayNtlVlm": "8906.0",
        "prevDayPx": "0.20432",
        "markPx": "0.14",
        "midPx": "0.209265",
        "circulatingSupply": "851681534.05516005",
    },
]
property active_asset_data: ActiveAssetData

activeAssetData data stream.

Data type: Mutable

Keys: ["user", "coin"]

Data structure:

[
    {
        "user": "0x0000000000000000000000000000000000000001",
        "coin": "ETH",
        "leverage": {
            "type": "cross",
            "value": 20,
        },
        "maxTradeSzs": ["0.0", "0.0"],
        "availableToTrade": ["0.0", "0.0"],
    },
]
property all_mids: AllMids

allMids data stream.

Data type: Mutable

Keys: ["coin"]

Data structure:

[
    {"coin": "AVAX", "px": "18.435"},
    {"coin": "@107", "px": "18.62041381"},
]
property bbo: Bbo

bbo data stream.

Data type: Mutable

Keys: ["coin"]

Data structure:

[
    {
        "coin": "TEST",
        "time": 1708622398623,
        "bbo": [
            {"px": "19900", "sz": "1", "n": 1},
            {"px": "20100", "sz": "1", "n": 1},
        ],
    },
]
property candle: Candle

candle data stream.

Data type: Mutable

Keys: ["t", "T", "s", "i"]

Data structure:

[
    {
        "t": 1681923600000,
        "T": 1681924499999,
        "s": "BTC",
        "i": "1m",
        "o": "106640.0",
        "c": "106678.0",
        "h": "106678.0",
        "l": "106640.0",
        "v": "1.92753",
        "n": 80,
    },
]
property l2_book: L2Book

l2Book data stream.

Data type: Mutable

Keys: ["coin", "side", "px"]

Data structure:

[
    {
        "coin": "BTC",
        "side": "A",
        "px": "20300",
        "sz": "3",
        "n": 3,
    },
    {
        "coin": "BTC",
        "side": "A",
        "px": "20200",
        "sz": "2",
        "n": 2,
    },
    {
        "coin": "BTC",
        "side": "A",
        "px": "20100",
        "sz": "1",
        "n": 1,
    },
    {
        "coin": "BTC",
        "side": "B",
        "px": "19900",
        "sz": "1",
        "n": 1,
    },
    {
        "coin": "BTC",
        "side": "B",
        "px": "19800",
        "sz": "2",
        "n": 2,
    },
    {
        "coin": "BTC",
        "side": "B",
        "px": "19700",
        "sz": "3",
        "n": 3,
    },
]
property notification: Notification

notification data stream.

Data type: Append-only

Data structure:

[
    {"notification": "<notification>"},
]
property order_updates: OrderUpdates

orderUpdates data stream.

Data type: Mutable; active orders only

Keys: ["coin", "oid"]

Data structure:

[
    {
        "coin": "ETH",
        "side": "A",
        "limitPx": "2412.7",
        "sz": "0.0",
        "oid": 1,
        "timestamp": 1724361546645,
        "origSz": "0.0076",
        "cloid": None,
        "status": "<status>",
        "statusTimestamp": 1724361546645,
    },
]
property trades: Trades

trades data stream.

Data type: Append-only

Data structure:

[
    {
        "coin": "AVAX",
        "side": "B",
        "px": "18.435",
        "sz": "93.53",
        "time": 1681222254710,
        "hash": "0xa166e3fa63c25663024b03f2e0da011a00307e4017465df020210d3d432e7cb8",
        "tid": 118906512037719,
        "users": [
            "0x0000000000000000000000000000000000000000",
            "0x0000000000000000000000000000000000000000",
        ],
    },
]
property user_events: UserEvents

userEvents data stream.

Data type: Append-only

Data structure:

[
    # fills
    {
        "type": "fills",
        "coin": "AVAX",
        "px": "18.435",
        "sz": "93.53",
        "side": "B",
        "time": 1681222254710,
        "startPosition": "26.86",
        "dir": "Open Long",
        "closedPnl": "0.0",
        "hash": "0xa166e3fa63c25663024b03f2e0da011a00307e4017465df020210d3d432e7cb8",
        "oid": 90542681,
        "crossed": False,
        "fee": "0.01",
        "tid": 118906512037719,
        "liquidation": {
            "liquidatedUser": "0x0000000000000000000000000000000000000000",
            "markPx": "18.435",
            "method": "<method>",
        },
        "feeToken": "USDC",
        "builderFee": "0.01",
    },
    # funding
    {
        "type": "funding",
        "time": 1681222254710,
        "coin": "ETH",
        "usdc": "-3.625312",
        "szi": "49.1477",
        "fundingRate": "0.0000417",
    },
    # liquidation
    {
        "type": "liquidation",
        "lid": 0,
        "liquidator": "0x0000000000000000000000000000000000000000",
        "liquidated_user": "0x0000000000000000000000000000000000000000",
        "liquidated_ntl_pos": "0.0",
        "liquidated_account_value": "0.0",
    },
    # nonUserCancel
    {
        "type": "nonUserCancel",
        "coin": "AVAX",
        "oid": 90542681,
    },
]
property user_fills: UserFills

userFills data stream.

Data type: Append-only

Data structure:

[
    {
        "coin": "AVAX",
        "px": "18.435",
        "sz": "93.53",
        "side": "B",
        "time": 1681222254710,
        "startPosition": "26.86",
        "dir": "Open Long",
        "closedPnl": "0.0",
        "hash": "0xa166e3fa63c25663024b03f2e0da011a00307e4017465df020210d3d432e7cb8",
        "oid": 90542681,
        "crossed": False,
        "fee": "0.01",
        "tid": 118906512037719,
        "liquidation": {
            "liquidatedUser": "0x0000000000000000000000000000000000000000",
            "markPx": "18.435",
            "method": "<method>",
        },
        "feeToken": "USDC",
        "builderFee": "0.01",
    },
]
property user_fundings: UserFundings

userFundings data stream.

Data type: Append-only

Data structure:

[
    {
        "time": 1681222254710,
        "coin": "ETH",
        "usdc": "-3.625312",
        "szi": "49.1477",
        "fundingRate": "0.0000417",
    },
]
property user_non_funding_ledger_updates: UserNonFundingLedgerUpdates

userNonFundingLedgerUpdates data stream.

Data type: Append-only

Data structure:

[
    {
        "time": 1681222254710,
        "hash": "0xa166e3fa63c25663024b03f2e0da011a00307e4017465df020210d3d432e7cb8",
        "delta": {
            "type": "<type>",
            "usdc": "0.0",
        },
    },
]
property user_twap_history: UserTwapHistory

userTwapHistory data stream.

Data type: Append-only

Data structure:

[
    {
        "state": {},
        "status": {
            "status": "<status>",
            "description": "<description>",
        },
        "time": 1681222254710,
    },
]
property user_twap_slice_fills: UserTwapSliceFills

userTwapSliceFills data stream.

Data type: Append-only

Data structure:

[
    {
        "coin": "AVAX",
        "px": "18.435",
        "sz": "93.53",
        "side": "B",
        "time": 1681222254710,
        "startPosition": "26.86",
        "dir": "Open Long",
        "closedPnl": "0.0",
        "hash": "0xa166e3fa63c25663024b03f2e0da011a00307e4017465df020210d3d432e7cb8",
        "oid": 90542681,
        "crossed": False,
        "fee": "0.01",
        "tid": 118906512037719,
        "liquidation": {
            "liquidatedUser": "0x0000000000000000000000000000000000000000",
            "markPx": "18.435",
            "method": "<method>",
        },
        "feeToken": "USDC",
        "builderFee": "0.01",
        "twapId": 3156,
    },
]
property web_data2: WebData2

webData2 data stream.

Data type: Mutable

Keys: ["user"]

Data structure:

[
    {
        "clearinghouseState": {
            "marginSummary": {
                "accountValue": "29.78001",
                "totalNtlPos": "0.0",
                "totalRawUsd": "29.78001",
                "totalMarginUsed": "0.0",
            },
            "crossMarginSummary": {
                "accountValue": "29.78001",
                "totalNtlPos": "0.0",
                "totalRawUsd": "29.78001",
                "totalMarginUsed": "0.0",
            },
            "crossMaintenanceMarginUsed": "0.0",
            "withdrawable": "29.78001",
            "assetPositions": [],
            "time": 1733968369395,
        },
        "user": "0x0000000000000000000000000000000000000001",
    },
]