Documentation
¶
Index ¶
- Constants
- Variables
- func GetEIP712Domain(chainID string) apitypes.TypedDataDomain
- func SignOrder(order *OrderRequest, privateKeyHex string, chainID string, ...) error
- type AccountSummary
- type AccountSummaryResponse
- type CancelAllOrderRequest
- type CancelAllOrderResponse
- type CancelOrderRequest
- type CancelOrderResponse
- type Client
- func (c *Client) CancelAllOrders(ctx context.Context) error
- func (c *Client) CancelOrder(ctx context.Context, orderID string) error
- func (c *Client) CreateOrder(ctx context.Context, req *CreateOrderRequest, ...) (*CreateOrderResponse, error)
- func (c *Client) GetAccountSummary(ctx context.Context) (*GetAccountSummaryResponse, error)
- func (c *Client) GetAllFundingRates(ctx context.Context) ([]FundingRateData, error)
- func (c *Client) GetAllInitialLeverage(ctx context.Context) (*GetAllInitialLeverageResponse, error)
- func (c *Client) GetFundingAccountSummary(ctx context.Context) (*GetFundingAccountSummaryResponse, error)
- func (c *Client) GetFundingRate(ctx context.Context, instrument string) (*FundingRateData, error)
- func (c *Client) GetHistoricalFundingRate(ctx context.Context, instrument string, startTime *string, endTime *string, ...) (*GetFundingRateResponse, error)
- func (c *Client) GetInstruments(ctx context.Context) ([]Instrument, error)
- func (c *Client) GetKLine(ctx context.Context, instrument string, interval string, klineType string, ...) (*GetKLineResponse, error)
- func (c *Client) GetMiniTicker(ctx context.Context, instrument string) (*GetMiniTickerResponse, error)
- func (c *Client) GetOpenOrders(ctx context.Context, symbol string) ([]Order, error)
- func (c *Client) GetOrderBook(ctx context.Context, instrument string, limit int) (*GetOrderBookResponse, error)
- func (c *Client) GetTicker(ctx context.Context, instrument string) (*GetTickerResponse, error)
- func (c *Client) GetTrade(ctx context.Context, instrument string, limit int) (*GetTradeResponse, error)
- func (c *Client) Login(ctx context.Context) error
- func (c *Client) Post(ctx context.Context, url string, payload interface{}, signed bool) ([]byte, error)
- func (c *Client) SetLeverage(ctx context.Context, instrument string, leverage int) (*SetLeverageResponse, error)
- func (c *Client) WithCredentials(apiKey, subAccountID, privateKey string) *Client
- type CreateOrderRequest
- type CreateOrderResponse
- type FundingAccountSummary
- type FundingRate
- type FundingRateData
- type GetAccountSummaryRequest
- type GetAccountSummaryResponse
- type GetAllInitialLeverageRequest
- type GetAllInitialLeverageResponse
- type GetFundingAccountSummaryResponse
- type GetFundingRateRequest
- type GetFundingRateResponse
- type GetInstrumentsResponse
- type GetKLineRequest
- type GetKLineResponse
- type GetMiniTickerRequest
- type GetMiniTickerResponse
- type GetOpenOrdersRequest
- type GetOpenOrdersResponse
- type GetOrderBookRequest
- type GetOrderBookResponse
- type GetPositionsResponse
- type GetTickerRequest
- type GetTickerResponse
- type GetTradeRequest
- type GetTradeResponse
- type GrvtError
- type Instrument
- type KLine
- type KlineInterval
- type KlineType
- type Leverage
- type LoginRequest
- type MiniTicker
- type MiniTickerDeltaRate
- type MiniTickerSnapRate
- type Order
- type OrderBook
- type OrderBookDeltaRate
- type OrderBookLevel
- type OrderBookSnapDepth
- type OrderBookSnapRate
- type OrderLeg
- type OrderMetadata
- type OrderRequest
- type OrderSignature
- type OrderState
- type OrderStatus
- type OrderTpsl
- type OrderTrigger
- type Position
- type SetLeverageRequest
- type SetLeverageResponse
- type SpotBalance
- type Ticker
- type TickerDeltaRate
- type TickerSnapRate
- type Tier
- type TimeInForce
- type Trade
- type TradeLimit
- type VaultInvestment
- type WebsocketClient
- func (c *WebsocketClient) CancelAllOrders(ctx context.Context, req *CancelAllOrderRequest) (*CancelAllOrderResponse, error)
- func (c *WebsocketClient) CancelOrder(ctx context.Context, req *CancelOrderRequest) (*CancelOrderResponse, error)
- func (c *WebsocketClient) Close()
- func (c *WebsocketClient) Connect() error
- func (c *WebsocketClient) PlaceOrder(ctx context.Context, req *OrderRequest) (*CreateOrderResponse, error)
- func (c *WebsocketClient) SendRPC(method string, params interface{}) (*WsRpcResponse, error)
- func (c *WebsocketClient) Subscribe(stream, selector string, callback func([]byte) error) error
- func (c *WebsocketClient) SubscribeDeposit(callback func(WsFeeData[WsDeposit]) error) error
- func (c *WebsocketClient) SubscribeFill(instrument string, callback func(WsFeeData[WsFill]) error) error
- func (c *WebsocketClient) SubscribeKline(instrument string, interval KlineInterval, typ KlineType, ...) error
- func (c *WebsocketClient) SubscribeMiniTickerDelta(instrument string, interval MiniTickerDeltaRate, ...) error
- func (c *WebsocketClient) SubscribeMiniTickerSnap(instrument string, interval MiniTickerSnapRate, ...) error
- func (c *WebsocketClient) SubscribeOrderCancel(instrument string, callback func(WsFeeData[WsCancelOrderStatus]) error) error
- func (c *WebsocketClient) SubscribeOrderState(instrument string, callback func(WsFeeData[WsOrderState]) error) error
- func (c *WebsocketClient) SubscribeOrderUpdate(instrument string, callback func(WsFeeData[Order]) error) error
- func (c *WebsocketClient) SubscribeOrderbookDelta(instrument string, interval OrderBookDeltaRate, ...) error
- func (c *WebsocketClient) SubscribeOrderbookSnap(instrument string, interval OrderBookSnapRate, depth OrderBookSnapDepth, ...) error
- func (c *WebsocketClient) SubscribePositions(instrument string, callback func(WsFeeData[Position]) error) error
- func (c *WebsocketClient) SubscribeTickerDelta(instrument string, interval TickerDeltaRate, ...) error
- func (c *WebsocketClient) SubscribeTickerSnap(instrument string, interval TickerSnapRate, ...) error
- func (c *WebsocketClient) SubscribeTrade(instrument string, limit TradeLimit, callback func(WsFeeData[Trade]) error) error
- func (c *WebsocketClient) SubscribeTransfer(callback func(WsFeeData[WsTransfer]) error) error
- func (c *WebsocketClient) SubscribeWithdrawal(callback func(WsFeeData[WsWithdrawal]) error) error
- func (c *WebsocketClient) Unsubscribe(stream, selector string) error
- func (c *WebsocketClient) UnsubscribeKline(instrument string, interval KlineInterval, typ KlineType) error
- func (c *WebsocketClient) UnsubscribeMiniTickerDelta(instrument string, interval MiniTickerDeltaRate) error
- func (c *WebsocketClient) UnsubscribeMiniTickerSnap(instrument string, interval MiniTickerSnapRate) error
- func (c *WebsocketClient) UnsubscribeOrderbookDelta(instrument string, interval OrderBookDeltaRate) error
- func (c *WebsocketClient) UnsubscribeOrderbookSnap(instrument string, interval OrderBookSnapRate, depth OrderBookSnapDepth) error
- func (c *WebsocketClient) UnsubscribeTickerDelta(instrument string, interval TickerDeltaRate) error
- func (c *WebsocketClient) UnsubscribeTickerSnap(instrument string, interval TickerSnapRate) error
- func (c *WebsocketClient) UnsubscribeTrade(instrument string, limit TradeLimit) error
- type WsCancelOrderStatus
- type WsCreateOrderParams
- type WsDeposit
- type WsFeeData
- type WsFill
- type WsLiteRpcRequest
- type WsOrderBody
- type WsOrderLeg
- type WsOrderMetadata
- type WsOrderSignature
- type WsOrderState
- type WsRequest
- type WsRequestParams
- type WsRequestResponse
- type WsRpcError
- type WsRpcRequest
- type WsRpcResponse
- type WsTransfer
- type WsWithdrawal
Constants ¶
View Source
const ( EdgeURL = "https://edge.grvt.io" TradeDataURL = "https://trades.grvt.io" MarketDataURL = "https://market-data.grvt.io" ChainID = "325" )
Environment constants
View Source
const ( OrderStatusPending = "PENDING" OrderStatusOpen = "OPEN" OrderStatusFilled = "FILLED" OrderStatusRejected = "REJECTED" OrderStatusCancelled = "CANCELLED" )
View Source
const ( // Time allowed to write a message to the peer. WriteWait = 10 * time.Second // Time allowed to read the next pong message from the peer. PongWait = 60 * time.Second // Send pings to peer with this period. Must be less than PongWait. PingPeriod = (PongWait * 9) / 10 ReconnectWait = 5 * time.Second )
View Source
const ( WssMarketURL = "wss://market-data.grvt.io/ws/lite" WssTradeURL = "wss://trades.grvt.io/ws/lite" WssTradeRpcURL = "wss://trades.grvt.io/ws/lite" // market streams StreamMiniTickerSnap = "v1.mini.s" StreamMiniTickerDelta = "v1.mini.d" StreamTickerSnap = "v1.ticker.s" StreamTickerDelta = "v1.ticker.d" StreamOrderbookSnap = "v1.book.s" StreamOrderbookDelta = "v1.book.d" StreamTrade = "v1.trade" StreamKline = "v1.candle" // account stream StreamOrderUpdate = "v1.order" StreamOrderState = "v1.state" StreamOrderCancel = "v1.cancel" // fill StreamFill = "v1.fill" StreamPositions = "v1.position" // transfer StreamDeposit = "v1.deposit" StreamTransfer = "v1.transfer" StreamWithdrawal = "v1.withdrawal" )
View Source
const (
PriceMultiplier = 1_000_000_000
)
Variables ¶
View Source
var OrderTypes = apitypes.Types{
"EIP712Domain": {
{Name: "name", Type: "string"},
{Name: "version", Type: "string"},
{Name: "chainId", Type: "uint256"},
},
"Order": {
{Name: "subAccountID", Type: "uint64"},
{Name: "isMarket", Type: "bool"},
{Name: "timeInForce", Type: "uint8"},
{Name: "postOnly", Type: "bool"},
{Name: "reduceOnly", Type: "bool"},
{Name: "legs", Type: "OrderLeg[]"},
{Name: "nonce", Type: "uint32"},
{Name: "expiration", Type: "int64"},
},
"OrderLeg": {
{Name: "assetID", Type: "uint256"},
{Name: "contractSize", Type: "uint64"},
{Name: "limitPrice", Type: "uint64"},
{Name: "isBuyingContract", Type: "bool"},
},
}
Order Types Definition
View Source
var SignTimeInForceMap = map[TimeInForce]int{ GTT: 1, AON: 2, IOC: 3, FOK: 4, }
SignTimeInForce maps string TIF to integer for signing
Functions ¶
func SignOrder ¶
func SignOrder(order *OrderRequest, privateKeyHex string, chainID string, instruments map[string]Instrument) error
Types ¶
type AccountSummary ¶
type AccountSummary struct {
EventTime string `json:"et"`
SubAccountID string `json:"sa"`
MarginType string `json:"mt"`
SettleCurrency string `json:"sc"`
UnrealizedPnl string `json:"up"`
TotalEquity string `json:"te"`
InitialMargin string `json:"im"`
MaintenanceMargin string `json:"mm"`
AvailableBalance string `json:"ab"`
SpotBalance []struct {
Currency string `json:"c"`
Balance string `json:"b"`
IndexPrice string `json:"ip"`
} `json:"sb"`
Position []Position `json:"p"`
SettleIndexPrice string `json:"si"`
IsValue *bool `json:"iv"`
VaultImAdditions string `json:"vi"`
DeriskMargin string `json:"dm"`
DeriskToMaintenanceMarginRatio string `json:"dt"`
}
type AccountSummaryResponse ¶
type CancelAllOrderRequest ¶
type CancelAllOrderResponse ¶
type CancelAllOrderResponse struct {
Result struct {
Ack bool `json:"a"` // GRVT returns bool, not string
} `json:"r"`
}
type CancelOrderRequest ¶
type CancelOrderResponse ¶
type CancelOrderResponse struct {
Result struct {
Ack bool `json:"a"` // GRVT returns bool, not string
} `json:"r"`
}
type Client ¶
type Client struct {
ApiKey string
SubAccountID string
PrivateKey string
ChainID string
EdgeURL string
TradeDataURL string
MarketDataURL string
HttpClient *http.Client
// contains filtered or unexported fields
}
func (*Client) CancelOrder ¶
func (*Client) CreateOrder ¶
func (c *Client) CreateOrder(ctx context.Context, req *CreateOrderRequest, instruments map[string]Instrument) (*CreateOrderResponse, error)
func (*Client) GetAccountSummary ¶
func (c *Client) GetAccountSummary(ctx context.Context) (*GetAccountSummaryResponse, error)
func (*Client) GetAllFundingRates ¶
func (c *Client) GetAllFundingRates(ctx context.Context) ([]FundingRateData, error)
GetAllFundingRates retrieves real-time funding rates for all instruments Returns per-hour funding rates (converted from settlement interval rates)
func (*Client) GetAllInitialLeverage ¶
func (c *Client) GetAllInitialLeverage(ctx context.Context) (*GetAllInitialLeverageResponse, error)
func (*Client) GetFundingAccountSummary ¶
func (c *Client) GetFundingAccountSummary(ctx context.Context) (*GetFundingAccountSummaryResponse, error)
func (*Client) GetFundingRate ¶
GetFundingRate retrieves the current real-time funding rate for a specific instrument Returns per-hour funding rate (converted from the settlement interval rate)
func (*Client) GetHistoricalFundingRate ¶
func (c *Client) GetHistoricalFundingRate(ctx context.Context, instrument string, startTime *string, endTime *string, limit *int64, cursor *string, aggType *string) (*GetFundingRateResponse, error)
GetHistoricalFundingRate retrieves historical funding rate data Renamed from GetFundingRate to clarify it queries historical data
func (*Client) GetInstruments ¶
func (c *Client) GetInstruments(ctx context.Context) ([]Instrument, error)
func (*Client) GetMiniTicker ¶
func (*Client) GetOpenOrders ¶
func (*Client) GetOrderBook ¶
func (*Client) SetLeverage ¶
func (*Client) WithCredentials ¶
type CreateOrderRequest ¶
type CreateOrderRequest struct {
Order OrderRequest `json:"o"`
}
type CreateOrderResponse ¶
type CreateOrderResponse struct {
Result Order `json:"r"`
}
type FundingAccountSummary ¶
type FundingAccountSummary struct {
MainAccountId string `json:"ma"`
TotalEquity string `json:"te"`
SpotBalances []SpotBalance `json:"sb"`
VaultInvestments []VaultInvestment `json:"vi"`
}
type FundingRate ¶
type FundingRateData ¶
type FundingRateData struct {
Instrument string `json:"instrument"`
FundingRate string `json:"fundingRate"` // Per-hour funding rate (standardized)
FundingIntervalHours int64 `json:"fundingIntervalHours"` // Actual settlement interval in hours
FundingTime string `json:"fundingTime"` // Current funding time (calculated)
NextFundingTime string `json:"nextFundingTime"`
}
FundingRateData contains real-time funding rate information from ticker endpoint
type GetAccountSummaryRequest ¶
type GetAccountSummaryRequest struct {
SubAccountID string `json:"sa"`
}
type GetAccountSummaryResponse ¶
type GetAccountSummaryResponse struct {
Result AccountSummary `json:"r"`
}
type GetAllInitialLeverageRequest ¶
type GetAllInitialLeverageRequest struct {
SubAccountID string `json:"sa"`
}
type GetAllInitialLeverageResponse ¶
type GetAllInitialLeverageResponse struct {
Results []Leverage `json:"r"`
}
type GetFundingAccountSummaryResponse ¶
type GetFundingAccountSummaryResponse struct {
Result FundingAccountSummary `json:"r"`
Tier Tier `json:"t"`
}
type GetFundingRateRequest ¶
type GetFundingRateResponse ¶
type GetFundingRateResponse struct {
Result []FundingRate `json:"r"`
Next string `json:"n"`
}
type GetInstrumentsResponse ¶
type GetInstrumentsResponse struct {
Result []Instrument `json:"r"`
}
type GetKLineRequest ¶
type GetKLineResponse ¶
type GetMiniTickerRequest ¶
type GetMiniTickerRequest struct {
Instrument string `json:"i"`
}
type GetMiniTickerResponse ¶
type GetMiniTickerResponse struct {
Result MiniTicker `json:"r"`
}
type GetOpenOrdersRequest ¶
type GetOpenOrdersRequest struct {
SubAccountID string `json:"sa"`
Kind *[]string `json:"k,omitempty"`
Base *[]string `json:"b,omitempty"`
Quote *[]string `json:"q,omitempty"`
}
get open orders
type GetOpenOrdersResponse ¶
type GetOpenOrdersResponse struct {
Result []Order `json:"r"`
}
type GetOrderBookRequest ¶
type GetOrderBookResponse ¶
type GetOrderBookResponse struct {
Result OrderBook `json:"r"`
}
type GetPositionsResponse ¶
type GetPositionsResponse struct {
Result []Position `json:"result"`
}
type GetTickerRequest ¶
type GetTickerRequest struct {
Instrument string `json:"i"`
}
type GetTickerResponse ¶
type GetTickerResponse struct {
Result Ticker `json:"r"`
}
type GetTradeRequest ¶
type GetTradeResponse ¶
type GetTradeResponse struct {
Result []Trade `json:"r"`
}
type GrvtError ¶
type Instrument ¶
type Instrument struct {
Instrument string `json:"i"`
InstrumentHash string `json:"ih"`
Base string `json:"b"`
Quote string `json:"q"`
Kind string `json:"k"`
Venues []string `json:"v"`
SettlementPeriod string `json:"sp1"`
BaseDecimals int `json:"bd"`
QuoteDecimals int `json:"qd"`
TickSize string `json:"ts"`
MinSize string `json:"ms"`
CreateTime string `json:"ct"`
MaxPositionSize string `json:"mp"`
FundingIntervalHours int64 `json:"fi"`
AdjustedFundingRateCap string `json:"af"`
AdjustedFundingRateFloor string `json:"af1"`
}
type KlineInterval ¶
type KlineInterval string
const ( KlineInterval1m KlineInterval = "CI_1_M" KlineInterval3m KlineInterval = "CI_3_M" KlineInterval5m KlineInterval = "CI_5_M" KlineInterval15m KlineInterval = "CI_15_M" KlineInterval30m KlineInterval = "CI_30_M" KlineInterval1h KlineInterval = "CI_1_H" KlineInterval2h KlineInterval = "CI_2_H" KlineInterval4h KlineInterval = "CI_4_H" KlineInterval8h KlineInterval = "CI_8_H" KlineInterval12h KlineInterval = "CI_12_H" KlineInterval1d KlineInterval = "CI_1_D" KlineInterval3d KlineInterval = "CI_3_D" KlineInterval5d KlineInterval = "CI_5_D" KlineInterval1w KlineInterval = "CI_1_W" KlineInterval2w KlineInterval = "CI_2_W" KlineInterval3w KlineInterval = "CI_3_W" KlineInterval4w KlineInterval = "CI_4_W" )
type LoginRequest ¶
type LoginRequest struct {
ApiKey string `json:"api_key"`
}
type MiniTicker ¶
type MiniTicker struct {
EventTime string `json:"et"`
Instrument string `json:"i"`
MarkPrice string `json:"mp"`
IndexPrice string `json:"ip"`
LastPrice string `json:"lp"`
MidPrice string `json:"mp1"`
BestBidPrice string `json:"bb"`
BestBidSize string `json:"bb1"`
BestAskPrice string `json:"ba"`
BestAskSize string `json:"ba1"`
}
type MiniTickerDeltaRate ¶
type MiniTickerDeltaRate int
const ( MiniTickerDeltaRate0 MiniTickerDeltaRate = 0 MiniTickerDeltaRate50 MiniTickerDeltaRate = 50 MiniTickerDeltaRate100 MiniTickerDeltaRate = 100 MiniTickerDeltaRate200 MiniTickerDeltaRate = 200 MiniTickerDeltaRate500 MiniTickerDeltaRate = 500 MiniTickerDeltaRate1000 MiniTickerDeltaRate = 1000 MiniTickerDeltaRate5000 MiniTickerDeltaRate = 5000 )
type MiniTickerSnapRate ¶
type MiniTickerSnapRate int
const ( MiniTickerSnapRate200 MiniTickerSnapRate = 200 MiniTickerSnapRate500 MiniTickerSnapRate = 500 MiniTickerSnapRate1000 MiniTickerSnapRate = 1000 MiniTickerSnapRate5000 MiniTickerSnapRate = 5000 )
type Order ¶
type Order struct {
OrderID string `json:"oi"`
SubAccountID string `json:"sa"`
IsMarket bool `json:"im"`
TimeInForce TimeInForce `json:"tif"`
PostOnly bool `json:"po"`
ReduceOnly bool `json:"ro"`
Legs []OrderLeg `json:"l"`
Signature OrderSignature `json:"s"`
Metadata OrderMetadata `json:"m"`
State OrderState `json:"s1"`
}
type OrderBook ¶
type OrderBook struct {
Instrument string `json:"i"`
Bids []OrderBookLevel `json:"b"`
Asks []OrderBookLevel `json:"a"`
EventTime string `json:"et"`
}
type OrderBookDeltaRate ¶
type OrderBookDeltaRate int
const ( OrderBookDeltaRate50 OrderBookDeltaRate = 50 OrderBookDeltaRate100 OrderBookDeltaRate = 100 OrderBookDeltaRate500 OrderBookDeltaRate = 500 OrderBookDeltaRate1000 OrderBookDeltaRate = 1000 )
type OrderBookLevel ¶
type OrderBookSnapDepth ¶
type OrderBookSnapDepth int
const ( OrderBookSnapDepth10 OrderBookSnapDepth = 10 OrderBookSnapDepth50 OrderBookSnapDepth = 50 OrderBookSnapDepth100 OrderBookSnapDepth = 100 OrderBookSnapDepth500 OrderBookSnapDepth = 500 )
type OrderBookSnapRate ¶
type OrderBookSnapRate int
const ( OrderBookSnapRate500 OrderBookSnapRate = 500 OrderBookSnapRate1000 OrderBookSnapRate = 1000 )
type OrderMetadata ¶
type OrderMetadata struct {
ClientOrderID string `json:"co"`
CreatedTime string `json:"ct"`
Tigger OrderTrigger `json:"t"`
Broker string `json:"b"`
}
type OrderRequest ¶
type OrderRequest struct {
SubAccountID uint64 `json:"sa"`
IsMarket bool `json:"im"`
TimeInForce TimeInForce `json:"tif"`
PostOnly bool `json:"po"`
ReduceOnly bool `json:"ro"`
Legs []OrderLeg `json:"l"`
Signature OrderSignature `json:"s"`
Metadata OrderMetadata `json:"m"`
}
type OrderSignature ¶
type OrderState ¶
type OrderStatus ¶
type OrderStatus string
type OrderTrigger ¶
type Position ¶
type Position struct {
EventTime string `json:"et"`
SubAccountID string `json:"sa"`
Instrument string `json:"i"`
Size string `json:"s"`
Notional string `json:"n"`
EntryPrice string `json:"ep"`
ExitPrice string `json:"ep1"`
MarkPrice string `json:"mp"`
UnrealizedPnl string `json:"up"`
RealizedPnl string `json:"rp"`
TotalPnl string `json:"tp"`
Roi string `json:"r"`
QuoteIndexPrice string `json:"qi"`
EstLiquidationPrice string `json:"el"`
Leverage string `json:"l"`
CumulativeFee string `json:"cf"`
CumulativeRealizedFundingPayment string `json:"cr"`
}
type SetLeverageRequest ¶
type SetLeverageResponse ¶
type SetLeverageResponse struct {
Success string `json:"s"`
}
type SpotBalance ¶
type Ticker ¶
type Ticker struct {
EventTime string `json:"et"`
Instrument string `json:"i"`
MarkPrice string `json:"mp"`
IndexPrice string `json:"ip"`
LastPrice string `json:"lp"`
MidPrice string `json:"mp1"`
BestBidPrice string `json:"bb"`
BestBidSize string `json:"bb1"`
BestAskPrice string `json:"ba"`
BestAskSize string `json:"ba1"`
// more mini ticker
// DEPRECATED: Use FundingRate instead
FundingRate8hCurr string `json:"fr"`
// DEPRECATED: Use FundingRate instead
FundingRate8hAvg string `json:"fr1"`
InterestRate string `json:"ir"`
ForwardPrice string `json:"fp"`
BuyVolume24hB string `json:"bv"`
SellVolume24hB string `json:"sv"`
BuyVolume24hQ string `json:"bv1"`
SellVolume24hQ string `json:"sv1"`
HighPrice string `json:"hp"`
LowPrice string `json:"lp1"`
OpenPrice string `json:"op"`
OpenInterest string `json:"oi"`
LongShortRatio string `json:"ls"`
// FundingRate is the funding rate applied over funding_interval_hours
// (interval ending at next_funding_time), NOT per hour
FundingRate string `json:"fr2"`
NextFundingTime string `json:"nf"`
}
type TickerDeltaRate ¶
type TickerDeltaRate int
const ( TickerDeltaRate100 TickerDeltaRate = 100 TickerDeltaRate200 TickerDeltaRate = 200 TickerDeltaRate500 TickerDeltaRate = 500 TickerDeltaRate1000 TickerDeltaRate = 1000 TickerDeltaRate5000 TickerDeltaRate = 5000 )
type TickerSnapRate ¶
type TickerSnapRate int
const ( TickerSnapRate500 TickerSnapRate = 500 TickerSnapRate1000 TickerSnapRate = 1000 TickerSnapRate5000 TickerSnapRate = 5000 )
type TimeInForce ¶
type TimeInForce string
const ( GTT TimeInForce = "GOOD_TILL_TIME" AON TimeInForce = "ALL_OR_NONE" IOC TimeInForce = "IMMEDIATE_OR_CANCEL" FOK TimeInForce = "FILL_OR_KILL" )
type Trade ¶
type Trade struct {
EventTime string `json:"et"`
Instrument string `json:"i"`
IsTakerBuyer bool `json:"it"`
Size string `json:"s"`
Price string `json:"p"`
MarkPrice string `json:"mp"`
IndexPrice string `json:"ip"`
InterestRate float64 `json:"ir"`
ForwardPrice string `json:"fp"`
TradeId string `json:"ti"`
Venue string `json:"v"`
IsRpi bool `json:"ip1"`
}
type TradeLimit ¶
type TradeLimit int
const ( TradeLimit50 TradeLimit = 50 TradeLimit200 TradeLimit = 200 TradeLimit500 TradeLimit = 500 TradeLimit1000 TradeLimit = 1000 )
type VaultInvestment ¶
type WebsocketClient ¶
type WebsocketClient struct {
URL string
Conn *websocket.Conn
Mu sync.RWMutex
WriteMu sync.Mutex
Logger *zap.SugaredLogger
Debug bool
// contains filtered or unexported fields
}
func NewAccountRpcWebsocketClient ¶
func NewAccountRpcWebsocketClient(ctx context.Context, client *Client) *WebsocketClient
func NewAccountWebsocketClient ¶
func NewAccountWebsocketClient(ctx context.Context, client *Client) *WebsocketClient
func NewMarketWebsocketClient ¶
func NewMarketWebsocketClient(ctx context.Context, client *Client) *WebsocketClient
func (*WebsocketClient) CancelAllOrders ¶
func (c *WebsocketClient) CancelAllOrders(ctx context.Context, req *CancelAllOrderRequest) (*CancelAllOrderResponse, error)
func (*WebsocketClient) CancelOrder ¶
func (c *WebsocketClient) CancelOrder(ctx context.Context, req *CancelOrderRequest) (*CancelOrderResponse, error)
func (*WebsocketClient) Close ¶
func (c *WebsocketClient) Close()
func (*WebsocketClient) Connect ¶
func (c *WebsocketClient) Connect() error
func (*WebsocketClient) PlaceOrder ¶
func (c *WebsocketClient) PlaceOrder(ctx context.Context, req *OrderRequest) (*CreateOrderResponse, error)
func (*WebsocketClient) SendRPC ¶
func (c *WebsocketClient) SendRPC(method string, params interface{}) (*WsRpcResponse, error)
func (*WebsocketClient) Subscribe ¶
func (c *WebsocketClient) Subscribe(stream, selector string, callback func([]byte) error) error
func (*WebsocketClient) SubscribeDeposit ¶
func (c *WebsocketClient) SubscribeDeposit(callback func(WsFeeData[WsDeposit]) error) error
func (*WebsocketClient) SubscribeFill ¶
func (*WebsocketClient) SubscribeKline ¶
func (c *WebsocketClient) SubscribeKline(instrument string, interval KlineInterval, typ KlineType, callback func(WsFeeData[KLine]) error) error
func (*WebsocketClient) SubscribeMiniTickerDelta ¶
func (c *WebsocketClient) SubscribeMiniTickerDelta(instrument string, interval MiniTickerDeltaRate, callback func(WsFeeData[MiniTicker]) error) error
func (*WebsocketClient) SubscribeMiniTickerSnap ¶
func (c *WebsocketClient) SubscribeMiniTickerSnap(instrument string, interval MiniTickerSnapRate, callback func(WsFeeData[MiniTicker]) error) error
func (*WebsocketClient) SubscribeOrderCancel ¶
func (c *WebsocketClient) SubscribeOrderCancel(instrument string, callback func(WsFeeData[WsCancelOrderStatus]) error) error
func (*WebsocketClient) SubscribeOrderState ¶
func (c *WebsocketClient) SubscribeOrderState(instrument string, callback func(WsFeeData[WsOrderState]) error) error
func (*WebsocketClient) SubscribeOrderUpdate ¶
func (*WebsocketClient) SubscribeOrderbookDelta ¶
func (c *WebsocketClient) SubscribeOrderbookDelta(instrument string, interval OrderBookDeltaRate, callback func(WsFeeData[OrderBook]) error) error
func (*WebsocketClient) SubscribeOrderbookSnap ¶
func (c *WebsocketClient) SubscribeOrderbookSnap(instrument string, interval OrderBookSnapRate, depth OrderBookSnapDepth, callback func(WsFeeData[OrderBook]) error) error
func (*WebsocketClient) SubscribePositions ¶
func (*WebsocketClient) SubscribeTickerDelta ¶
func (c *WebsocketClient) SubscribeTickerDelta(instrument string, interval TickerDeltaRate, callback func(WsFeeData[Ticker]) error) error
func (*WebsocketClient) SubscribeTickerSnap ¶
func (c *WebsocketClient) SubscribeTickerSnap(instrument string, interval TickerSnapRate, callback func(WsFeeData[Ticker]) error) error
func (*WebsocketClient) SubscribeTrade ¶
func (c *WebsocketClient) SubscribeTrade(instrument string, limit TradeLimit, callback func(WsFeeData[Trade]) error) error
func (*WebsocketClient) SubscribeTransfer ¶
func (c *WebsocketClient) SubscribeTransfer(callback func(WsFeeData[WsTransfer]) error) error
func (*WebsocketClient) SubscribeWithdrawal ¶
func (c *WebsocketClient) SubscribeWithdrawal(callback func(WsFeeData[WsWithdrawal]) error) error
func (*WebsocketClient) Unsubscribe ¶
func (c *WebsocketClient) Unsubscribe(stream, selector string) error
func (*WebsocketClient) UnsubscribeKline ¶
func (c *WebsocketClient) UnsubscribeKline(instrument string, interval KlineInterval, typ KlineType) error
func (*WebsocketClient) UnsubscribeMiniTickerDelta ¶
func (c *WebsocketClient) UnsubscribeMiniTickerDelta(instrument string, interval MiniTickerDeltaRate) error
func (*WebsocketClient) UnsubscribeMiniTickerSnap ¶
func (c *WebsocketClient) UnsubscribeMiniTickerSnap(instrument string, interval MiniTickerSnapRate) error
func (*WebsocketClient) UnsubscribeOrderbookDelta ¶
func (c *WebsocketClient) UnsubscribeOrderbookDelta(instrument string, interval OrderBookDeltaRate) error
func (*WebsocketClient) UnsubscribeOrderbookSnap ¶
func (c *WebsocketClient) UnsubscribeOrderbookSnap(instrument string, interval OrderBookSnapRate, depth OrderBookSnapDepth) error
func (*WebsocketClient) UnsubscribeTickerDelta ¶
func (c *WebsocketClient) UnsubscribeTickerDelta(instrument string, interval TickerDeltaRate) error
func (*WebsocketClient) UnsubscribeTickerSnap ¶
func (c *WebsocketClient) UnsubscribeTickerSnap(instrument string, interval TickerSnapRate) error
func (*WebsocketClient) UnsubscribeTrade ¶
func (c *WebsocketClient) UnsubscribeTrade(instrument string, limit TradeLimit) error
type WsCancelOrderStatus ¶
type WsCreateOrderParams ¶
type WsCreateOrderParams struct {
Order WsOrderBody `json:"o"`
}
type WsFill ¶
type WsFill struct {
EventTime string `json:"et"`
SubAccountID string `json:"sa"`
Instrument string `json:"i"`
IsBuyer bool `json:"ib"`
IsTaker bool `json:"it"`
Size string `json:"s"`
Price string `json:"p"`
MarkPrice string `json:"mp"`
IndexPrice string `json:"ip"`
InterestRate float64 `json:"ir"`
ForwardPrice string `json:"fp"`
RealizedPnl string `json:"rp"`
Fee string `json:"f"`
FeeRate string `json:"fr"`
TradeID string `json:"ti"`
OrderID string `json:"oi"`
Venue string `json:"v"`
ClientOrderID string `json:"co"`
Signer string `json:"s1"`
Broker string `json:"b"`
IsRpi bool `json:"ir1"`
}
type WsLiteRpcRequest ¶
type WsOrderBody ¶
type WsOrderBody struct {
SubAccountID string `json:"sa"`
IsMarket bool `json:"im"`
TimeInForce TimeInForce `json:"ti"`
PostOnly bool `json:"po"`
ReduceOnly bool `json:"ro"`
Legs []WsOrderLeg `json:"l"`
Signature WsOrderSignature `json:"s"`
Metadata WsOrderMetadata `json:"m"`
}
type WsOrderLeg ¶
type WsOrderMetadata ¶
type WsOrderSignature ¶
type WsOrderState ¶
type WsOrderState struct {
OrderID string `json:"oi"`
ClientOrderID string `json:"co"`
OrderState OrderState `json:"os"`
}
type WsRequest ¶
type WsRequest struct {
JsonRpc string `json:"j"`
Method string `json:"m"`
Params *WsRequestParams `json:"p"`
Id int64 `json:"i"`
}
type WsRequestParams ¶
type WsRequestResponse ¶
type WsRequestResponse struct {
JsonRpc string `json:"j"`
Method string `json:"m"`
Result struct {
Stream string `json:"s"`
Subs []string `json:"subs"`
Unsubs []string `json:"unsubs"`
NumSnapshots []int64 `json:"num_snapshots"`
FirstSequenceNumber []int64 `json:"first_sequence_number"`
} `json:"r"`
Id int64 `json:"i"`
}
type WsRpcError ¶
type WsRpcRequest ¶
type WsRpcResponse ¶
type WsRpcResponse struct {
JsonRpc string `json:"j"`
Id uint32 `json:"i"` // Use uint32 to match Request
Result json.RawMessage `json:"r,omitempty"`
Error *WsRpcError `json:"e,omitempty"`
}
type WsTransfer ¶
type WsTransfer struct {
TxId string `json:"ti"`
FromAccountID string `json:"fa"`
FromSubAccountID string `json:"fs"`
ToAccountID string `json:"ta"`
ToSubAccountID string `json:"ts"`
Currency string `json:"c"`
NumTokens string `json:"nt"`
Signature OrderSignature `json:"s"`
EventTime string `json:"et"`
TransferType string `json:"tt"`
}
type WsWithdrawal ¶
type WsWithdrawal struct {
FromAccountID string `json:"fa"`
ToEthAddress string `json:"te"`
Currency string `json:"c"`
NumTokens string `json:"nt"`
Signature OrderSignature `json:"s"`
}
Click to show internal directories.
Click to hide internal directories.