Documentation
¶
Index ¶
- type AssetContext
- type CancelOrderRequest
- type CancelOrderResponse
- type Candle
- type CandleSnapshotRequest
- type Client
- func (c *Client) AllMids(ctx context.Context) (map[string]string, error)
- func (c *Client) CancelOrder(ctx context.Context, req CancelOrderRequest) (*string, error)
- func (c *Client) CandleSnapshot(ctx context.Context, coin string, interval string, startTime, endTime int64) ([]Candle, error)
- func (c *Client) GetAllFundingRates(ctx context.Context) (map[string]string, error)
- func (c *Client) GetBalance(ctx context.Context) (*PerpPosition, error)
- func (c *Client) GetFundingRate(ctx context.Context, coin string) (*FundingRate, error)
- func (c *Client) GetPerpPosition(ctx context.Context) (*PerpPosition, error)
- func (c *Client) GetPrepMeta(ctx context.Context) (*PrepMeta, error)
- func (c *Client) L2Book(ctx context.Context, coin string) (*L2BookResponse, error)
- func (c *Client) ModifyOrder(ctx context.Context, req ModifyOrderRequest) (*OrderStatus, error)
- func (c *Client) OrderStatus(ctx context.Context, user string, oid int64) (*OrderStatusInfo, error)
- func (c *Client) PlaceOrder(ctx context.Context, req PlaceOrderRequest) (*OrderStatus, error)
- func (c *Client) UpdateIsolatedMargin(ctx context.Context, req UpdateIsolatedMarginRequest) error
- func (c *Client) UpdateLeverage(ctx context.Context, req UpdateLeverageRequest) error
- func (c *Client) UserFills(ctx context.Context, user string) ([]UserFill, error)
- func (c *Client) UserOpenOrders(ctx context.Context, user string) ([]Order, error)
- type FundingRate
- type L2BookResponse
- type L2Level
- type MetaAndAssetCtxsResponse
- type ModifyOrderRequest
- type ModifyOrderResponse
- type Order
- type OrderFilled
- type OrderResting
- type OrderStatus
- type OrderStatusInfo
- type OrderStatusQueryResponse
- type OrderType
- type OrderTypeLimit
- type OrderTypeTrigger
- type PerpPosition
- type PlaceOrderRequest
- type PlaceOrderResponse
- type PrepMeta
- type UpdateIsolatedMarginRequest
- type UpdateIsolatedMarginResponse
- type UpdateLeverageRequest
- type UpdateLeverageResponse
- type UserFill
- type WebsocketClient
- func (c *WebsocketClient) CancelOrder(ctx context.Context, req CancelOrderRequest) (chan hyperliquid.PostResult, error)
- func (c *WebsocketClient) ModifyOrder(ctx context.Context, req ModifyOrderRequest) (chan hyperliquid.PostResult, error)
- func (c *WebsocketClient) PlaceOrder(ctx context.Context, req PlaceOrderRequest) (chan hyperliquid.PostResult, error)
- func (c *WebsocketClient) SubscribeBbo(coin string, handler func(hyperliquid.WsBbo)) error
- func (c *WebsocketClient) SubscribeL2Book(coin string, handler func(hyperliquid.WsL2Book)) error
- func (c *WebsocketClient) SubscribeOrderUpdates(user string, handler func([]hyperliquid.WsOrderUpdate)) error
- func (c *WebsocketClient) SubscribeTrades(coin string, handler func([]hyperliquid.WsTrade)) error
- func (c *WebsocketClient) SubscribeUserEvents(user string, handler func(hyperliquid.WsUserEvent)) error
- func (c *WebsocketClient) SubscribeUserFills(user string, handler func(hyperliquid.WsUserFills)) error
- func (c *WebsocketClient) SubscribeWebData2(user string, handler func(PerpPosition)) error
- func (c *WebsocketClient) UnsubscribeBbo(coin string) error
- func (c *WebsocketClient) UnsubscribeL2Book(coin string) error
- func (c *WebsocketClient) UnsubscribeTrades(coin string) error
- func (c *WebsocketClient) WithCredentials(privateKey, accountAddr string) *WebsocketClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetContext ¶
type AssetContext struct {
Funding string `json:"funding"` // Current funding rate (hourly)
MarkPx string `json:"markPx"` // Mark price
OpenInterest string `json:"openInterest"`
PrevDayPx string `json:"prevDayPx"`
DayNtlVlm string `json:"dayNtlVlm"` // Daily notional volume
Premium string `json:"premium"`
OraclePx string `json:"oraclePx"`
MidPx string `json:"midPx"`
ImpactPxs []string `json:"impactPxs,omitempty"`
DayBaseVlm string `json:"dayBaseVlm,omitempty"` // Daily base volume
}
type CancelOrderRequest ¶
type CancelOrderResponse ¶
type CancelOrderResponse struct {
Statuses hyperliquid.MixedArray `json:"statuses"`
}
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 Client ¶
type Client struct {
*hyperliquid.Client
}
func (*Client) CancelOrder ¶
func (*Client) CandleSnapshot ¶
func (*Client) GetAllFundingRates ¶
GetAllFundingRates retrieves funding rates for all available coins. Returns a map where keys are coin names (e.g., "BTC", "ETH") and values are funding rates.
func (*Client) GetBalance ¶
func (c *Client) GetBalance(ctx context.Context) (*PerpPosition, error)
GetBalance (Alias for GetPerpPosition)
func (*Client) GetFundingRate ¶
GetFundingRate retrieves the current funding rate for a specific coin. It uses the metaAndAssetCtxs endpoint which provides real-time asset contexts including mark price, funding rate, open interest, etc.
func (*Client) GetPerpPosition ¶
func (c *Client) GetPerpPosition(ctx context.Context) (*PerpPosition, error)
func (*Client) ModifyOrder ¶
func (c *Client) ModifyOrder(ctx context.Context, req ModifyOrderRequest) (*OrderStatus, error)
func (*Client) OrderStatus ¶
OrderStatus
func (*Client) PlaceOrder ¶
func (c *Client) PlaceOrder(ctx context.Context, req PlaceOrderRequest) (*OrderStatus, error)
func (*Client) UpdateIsolatedMargin ¶
func (c *Client) UpdateIsolatedMargin(ctx context.Context, req UpdateIsolatedMarginRequest) error
func (*Client) UpdateLeverage ¶
func (c *Client) UpdateLeverage(ctx context.Context, req UpdateLeverageRequest) error
type FundingRate ¶
type FundingRate struct {
Coin string `json:"coin"`
FundingRate string `json:"fundingRate"` // Per-hour funding rate
FundingIntervalHours int64 `json:"fundingIntervalHours"` // Always 1 for Hyperliquid
FundingTime int64 `json:"fundingTime"` // Current hour start (calculated)
NextFundingTime int64 `json:"nextFundingTime"` // Next hour start (calculated)
}
FundingRate - Simplified funding rate response
type L2BookResponse ¶
type MetaAndAssetCtxsResponse ¶
type MetaAndAssetCtxsResponse []AssetContext
MetaAndAssetCtxs - Response for metaAndAssetCtxs endpoint
type ModifyOrderRequest ¶
type ModifyOrderRequest struct {
Oid *int64
Cloid *string
Order PlaceOrderRequest
}
type ModifyOrderResponse ¶
type ModifyOrderResponse struct {
Statuses []OrderStatus `json:"statuses"`
}
type OrderFilled ¶
type OrderResting ¶
type OrderStatus ¶
type OrderStatus struct {
Resting *OrderResting `json:"resting,omitempty"`
Filled *OrderFilled `json:"filled,omitempty"`
Error *string `json:"error,omitempty"`
}
type OrderStatusInfo ¶
type OrderStatusInfo struct {
Coin string `json:"coin"`
Side string `json:"side"`
LimitPx string `json:"limitPx"`
Sz string `json:"sz"`
Oid int64 `json:"oid"`
Timestamp int64 `json:"timestamp"`
OrigSz string `json:"origSz"`
Status string `json:"status"`
FilledSz string `json:"filledSz"`
AvgPx string `json:"avgPx"`
CancelReason string `json:"cancelReason"`
}
type OrderStatusQueryResponse ¶
type OrderStatusQueryResponse struct {
OrderStatus OrderStatusInfo `json:"order"`
}
OrderStatusQueryResponse
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 PerpPosition ¶
type PerpPosition struct {
AssetPositions []struct {
Position struct {
Coin string `json:"coin"`
CumFunding struct {
AllTime string `json:"allTime"`
SinceOpen string `json:"sinceOpen"`
SinceChange string `json:"sinceChange"`
} `json:"cumFunding"`
EntryPx string `json:"entryPx"`
Leverage struct {
RawUsd string `json:"rawUsd"`
Type string `json:"type"`
Value int `json:"value"`
} `json:"leverage"`
LiquidationPx string `json:"liquidationPx"`
MarginUsed string `json:"marginUsed"`
MaxLeverage int `json:"maxLeverage"`
PositionValue string `json:"positionValue"`
ReturnOnEquity string `json:"returnOnEquity"`
Szi string `json:"szi"`
UnrealizedPnl string `json:"unrealizedPnl"`
} `json:"position"`
Type string `json:"type"`
} `json:"assetPositions"`
CrossMaintenanceMarginUsed string `json:"crossMaintenanceMarginUsed"`
CrossMarginSummary struct {
AccountValue string `json:"accountValue"`
TotalMarginUsed string `json:"totalMarginUsed"`
TotalNtlPos string `json:"totalNtlPos"`
TotalRawUsd string `json:"totalRawUsd"`
} `json:"crossMarginSummary"`
MarginSummary struct {
AccountValue string `json:"accountValue"`
TotalMarginUsed string `json:"totalMarginUsed"`
TotalNtlPos string `json:"totalNtlPos"`
TotalRawUsd string `json:"totalRawUsd"`
} `json:"marginSummary"`
Time int64 `json:"time"`
Withdrawable string `json:"withdrawable"`
}
PerpPosition
type PlaceOrderRequest ¶
type PlaceOrderResponse ¶
type PlaceOrderResponse struct {
Statuses []OrderStatus `json:"statuses"`
}
type PrepMeta ¶
type PrepMeta struct {
Universe []struct {
Name string `json:"name"`
SzDecimals int `json:"szDecimals"`
MaxLeverage int `json:"maxLeverage"`
} `json:"universe"`
}
PrepMeta
type UpdateIsolatedMarginRequest ¶
UpdateIsolatedMargin
type UpdateIsolatedMarginResponse ¶
type UpdateIsolatedMarginResponse struct {
Type string `json:"type"`
}
type UpdateLeverageRequest ¶
UpdateLeverage
type UpdateLeverageResponse ¶
type UpdateLeverageResponse struct {
Type string `json:"type"`
}
type UserFill ¶
type UserFill struct {
Coin string `json:"coin"`
Px string `json:"px"`
Sz string `json:"sz"`
Side string `json:"side"`
Time int64 `json:"time"`
StartPosition string `json:"startPosition"`
Dir string `json:"dir"`
ClosedPnl string `json:"closedPnl"`
Hash string `json:"hash"`
Oid int64 `json:"oid"`
Crossed bool `json:"crossed"`
Fee string `json:"fee"`
FeeToken string `json:"feeToken"`
Tid int64 `json:"tid"`
}
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 Notice: Snapshot update
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) SubscribeWebData2 ¶
func (c *WebsocketClient) SubscribeWebData2(user string, handler func(PerpPosition)) error
SubscribeWebData2
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
func (*WebsocketClient) WithCredentials ¶
func (c *WebsocketClient) WithCredentials(privateKey, accountAddr string) *WebsocketClient