31 lines
1.5 KiB
Python
31 lines
1.5 KiB
Python
import os
|
|
import sys
|
|
import time
|
|
import json
|
|
from datetime import datetime, timezone
|
|
from hyperliquid.info import Info
|
|
from hyperliquid.utils import constants
|
|
from collections import deque
|
|
|
|
def main():
|
|
address, info, _ = example_utils.setup(constants.MAINNET_API_URL)
|
|
# An example showing how to subscribe to the different subscription types and prints the returned messages
|
|
# Some subscriptions do not return snapshots, so you will not receive a message until something happens
|
|
info.subscribe({"type": "allMids"}, print)
|
|
info.subscribe({"type": "l2Book", "coin": "ETH"}, print)
|
|
info.subscribe({"type": "trades", "coin": "PURR/USDC"}, print)
|
|
info.subscribe({"type": "userEvents", "user": address}, print)
|
|
info.subscribe({"type": "userFills", "user": address}, print)
|
|
info.subscribe({"type": "candle", "coin": "ETH", "interval": "1m"}, print)
|
|
info.subscribe({"type": "orderUpdates", "user": address}, print)
|
|
info.subscribe({"type": "userFundings", "user": address}, print)
|
|
info.subscribe({"type": "userNonFundingLedgerUpdates", "user": address}, print)
|
|
info.subscribe({"type": "webData2", "user": address}, print)
|
|
info.subscribe({"type": "bbo", "coin": "ETH"}, print)
|
|
info.subscribe({"type": "activeAssetCtx", "coin": "BTC"}, print) # Perp
|
|
info.subscribe({"type": "activeAssetCtx", "coin": "@1"}, print) # Spot
|
|
info.subscribe({"type": "activeAssetData", "user": address, "coin": "BTC"}, print) # Perp only
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |