spot

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Balances []struct {
		Coin     string `json:"coin"`
		Token    int64  `json:"token"`
		Hold     string `json:"hold"`
		Total    string `json:"total"`
		EntryNtl string `json:"entryNtl"`
	}
}

type CancelOrderRequest

type CancelOrderRequest struct {
	AssetID int
	OrderID int64
}

type Candle

type Candle struct {
	T      int64  `json:"t"` // Open time
	TClose int64  `json:"T"` // Close time
	S      string `json:"s"` // Symbol
	I      string `json:"i"` // Interval
	O      string `json:"o"` // Open
	C      string `json:"c"` // Close
	H      string `json:"h"` // High
	L      string `json:"l"` // Low
	V      string `json:"v"` // Volume
	N      int64  `json:"n"` // Number of trades
}

type CandleSnapshotRequest

type CandleSnapshotRequest struct {
	Coin      string `json:"coin"`
	Interval  string `json:"interval"`
	StartTime int64  `json:"startTime"`
	EndTime   int64  `json:"endTime"`
}

type Client

type Client struct {
	*hyperliquid.Client
}

func NewClient

func NewClient(base *hyperliquid.Client) *Client

func (*Client) AllMids

func (c *Client) AllMids(ctx context.Context) (map[string]string, error)

func (*Client) CandleSnapshot

func (c *Client) CandleSnapshot(ctx context.Context, coin string, interval string, startTime, endTime int64) ([]Candle, error)

func (*Client) GetBalance

func (c *Client) GetBalance() (*Balance, error)

func (*Client) GetSpotMeta

func (c *Client) GetSpotMeta(ctx context.Context) (*SpotMeta, error)

func (*Client) L2Book

func (c *Client) L2Book(ctx context.Context, coin string) (*L2BookResponse, error)

type L2BookResponse

type L2BookResponse struct {
	Coin   string      `json:"coin"`
	Levels [][]L2Level `json:"levels"`
	Time   int64       `json:"time"`
}

type L2Level

type L2Level struct {
	Px string `json:"px"`
	Sz string `json:"sz"`
	N  int    `json:"n"`
}

type ModifyOrderRequest

type ModifyOrderRequest struct {
	Oid   *int64
	Cloid *string
	Order PlaceOrderRequest
}

type OrderType

type OrderType struct {
	Limit   *OrderTypeLimit
	Trigger *OrderTypeTrigger
}

type OrderTypeLimit

type OrderTypeLimit struct {
	Tif hyperliquid.Tif
}

type OrderTypeTrigger

type OrderTypeTrigger struct {
	IsMarket  bool
	TriggerPx float64
	Tpsl      hyperliquid.Tpsl
}

type PlaceOrderRequest

type PlaceOrderRequest struct {
	AssetID       int
	IsBuy         bool
	Price         float64
	Size          float64
	OrderType     OrderType
	ClientOrderID *string
}

type SpotMeta

type SpotMeta struct {
	Tokens []struct {
		Name        string `json:"name"`
		SzDecimals  int    `json:"szDecimals"`
		WeiDecimals int    `json:"weiDecimals"`
		Index       int    `json:"index"`
		TokenId     string `json:"tokenId"`
		IsCanonical bool   `json:"isCanonical"`
		FullName    string `json:"fullName,omitempty"`
	}
	Universe []struct {
		Name        string `json:"name"`
		Index       int    `json:"index"`
		Tokens      []int  `json:"tokens"`
		IsCanonical bool   `json:"isCanonical"`
	}
}

type WebsocketClient

type WebsocketClient struct {
	*hyperliquid.WebsocketClient
}

func NewWebsocketClient

func NewWebsocketClient(base *hyperliquid.WebsocketClient) *WebsocketClient

func (*WebsocketClient) CancelOrder

func (c *WebsocketClient) CancelOrder(ctx context.Context, req CancelOrderRequest) (chan hyperliquid.PostResult, error)

CancelOrder via WS

func (*WebsocketClient) ModifyOrder

func (c *WebsocketClient) ModifyOrder(ctx context.Context, req ModifyOrderRequest) (chan hyperliquid.PostResult, error)

ModifyOrder via WS

func (*WebsocketClient) PlaceOrder

func (c *WebsocketClient) PlaceOrder(ctx context.Context, req PlaceOrderRequest) (chan hyperliquid.PostResult, error)

PlaceOrder via WS

func (*WebsocketClient) SubscribeBbo

func (c *WebsocketClient) SubscribeBbo(coin string, handler func(hyperliquid.WsBbo)) error

func (*WebsocketClient) SubscribeL2Book

func (c *WebsocketClient) SubscribeL2Book(coin string, handler func(hyperliquid.WsL2Book)) error

Helper to subscribe to L2Book

func (*WebsocketClient) SubscribeOrderUpdates

func (c *WebsocketClient) SubscribeOrderUpdates(user string, handler func([]hyperliquid.WsOrderUpdate)) error

SubscribeOrderUpdates

func (*WebsocketClient) SubscribeTrades

func (c *WebsocketClient) SubscribeTrades(coin string, handler func([]hyperliquid.WsTrade)) error

SubscribeTrades

func (*WebsocketClient) SubscribeUserEvents

func (c *WebsocketClient) SubscribeUserEvents(user string, handler func(hyperliquid.WsUserEvent)) error

SubscribeUserEvents

func (*WebsocketClient) SubscribeUserFills

func (c *WebsocketClient) SubscribeUserFills(user string, handler func(hyperliquid.WsUserFills)) error

SubscribeUserFills

func (*WebsocketClient) UnsubscribeBbo

func (c *WebsocketClient) UnsubscribeBbo(coin string) error

func (*WebsocketClient) UnsubscribeL2Book

func (c *WebsocketClient) UnsubscribeL2Book(coin string) error

func (*WebsocketClient) UnsubscribeTrades

func (c *WebsocketClient) UnsubscribeTrades(coin string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL