Documentation
¶
Index ¶
- Variables
- func Request(api *BackpackREST, method, path string, params map[string]any, ...) (*resty.Response, error)
- func RequestWithAuth(api *BackpackREST, method, url string, instruction string, ...) (resp *resty.Response, err error)
- func Response[T any](response *resty.Response, e error) (result T, err error)
- func SubscribePrivateStream[T any](client *BackpackWebsocket, stream string, newable models.Newable, ...) error
- func SubscribePublicStream[T any](client *BackpackWebsocket, stream string, newable models.Newable, ...) error
- type BackpackError
- type BackpackREST
- func (b *BackpackREST) CancelOrderByClientID(symbol string, clientID uint32) (*models.Order, error)
- func (b *BackpackREST) CancelOrderByOrderID(symbol string, orderID string) (*models.Order, error)
- func (b *BackpackREST) CancelOrders(symbol string, marketType ...options.OrderType) ([]*models.Order, error)
- func (b *BackpackREST) ExecuteBorrowLend(asset string, side options.BorrowLendSide, quantity float64) error
- func (b *BackpackREST) ExecuteConditionalLimitOrder(symbol string, side options.Side, triggerPrice float64, price float64, ...) (*models.Order, error)
- func (b *BackpackREST) ExecuteLimitOrder(symbol string, side options.Side, price float64, quantity float64, ...) (*models.Order, error)
- func (b *BackpackREST) ExecuteMarketOrder(symbol string, side options.Side, quantity float64, ...) (*models.Order, error)
- func (b *BackpackREST) GetAccount() (*models.Account, error)
- func (b *BackpackREST) GetAccountCollateral() (*models.Collateral, error)
- func (b *BackpackREST) GetAccountMaxBorrow(asset string) (*models.AccountBorrowLimit, error)
- func (b *BackpackREST) GetAccountMaxOrder(symbol string, side options.Side, args ...options.AccountOrderLimitOptions) (*models.AccountOrderLimit, error)
- func (b *BackpackREST) GetAccountMaxWithdrawal(asset string, args ...options.AccountWithdrawalLimitOptions) (*models.AccountWithdrawalLimit, error)
- func (b *BackpackREST) GetBalance() (map[string]*models.AssetBalance, error)
- func (b *BackpackREST) GetBorrowLendHistory(options ...options.BorrowHistoryOptions) ([]*models.BorrowLendHistory, error)
- func (b *BackpackREST) GetBorrowLendMarkets() ([]*models.BorrowLendMarket, error)
- func (b *BackpackREST) GetBorrowLendMarketsHistory(interval options.BorrowLendMarketHistoryInterval, symbol ...string) ([]*models.BorrowLendMarketHistory, error)
- func (b *BackpackREST) GetBorrowLendPositions() ([]*models.BorrowLend, error)
- func (b *BackpackREST) GetBorrowPositionsHistory(options ...options.BorrowPostionHistoryOptions) ([]*models.BorrowPositionHistory, error)
- func (b *BackpackREST) GetDepositAddress(blockchain string) (*models.DepositAddress, error)
- func (b *BackpackREST) GetDeposits(filter ...options.DateFilter) ([]*models.Deposit, error)
- func (b *BackpackREST) GetDepth(symbol string) (*models.Depth, error)
- func (b *BackpackREST) GetFillHistory(options ...options.FillHistoryOptions) ([]*models.FillHistory, error)
- func (b *BackpackREST) GetFundingHistory(options ...options.FundingHistoryOptions) ([]*models.FundingHistory, error)
- func (b *BackpackREST) GetFundingRates(symbol string) (*models.PageHeaders, []*models.FundingRate, error)
- func (b *BackpackREST) GetInterestHistory(options ...options.InterestHistoryOptions) ([]*models.InterestHistory, error)
- func (b *BackpackREST) GetKlines(symbol string, interval options.KLineInterval, startTime time.Time, ...) ([]*models.Kline, error)
- func (b *BackpackREST) GetMarkPrices(symbol ...string) ([]*models.MarkPrice, error)
- func (b *BackpackREST) GetMarket(symbol string) (*models.Market, error)
- func (b *BackpackREST) GetMarketAssets() ([]*models.MarketAssets, error)
- func (b *BackpackREST) GetMarketCollateral() ([]*models.MarketCollateral, error)
- func (b *BackpackREST) GetMarkets() ([]*models.Market, error)
- func (b *BackpackREST) GetOpenInterest(symbol ...string) ([]*models.OpenInterest, error)
- func (b *BackpackREST) GetOrderByClientID(symbol string, clientID int) (*models.Order, error)
- func (b *BackpackREST) GetOrderByOrderID(symbol, orderID string) (*models.Order, error)
- func (b *BackpackREST) GetOrders(symbol *string, marketType *options.MarketType) ([]*models.Order, error)
- func (b *BackpackREST) GetOrdersHistory(options ...options.OrderHistoryOptions) ([]*models.OrderHistory, error)
- func (b *BackpackREST) GetPnlHistory(options ...options.PnlHistoryOptions) ([]*models.PnlHistory, error)
- func (b *BackpackREST) GetPositions() ([]*models.Position, error)
- func (b *BackpackREST) GetSettlementHistory(options ...options.SettlementHistoryOptions) ([]*models.SettlementHistory, error)
- func (b *BackpackREST) GetStatus() (*models.Status, error)
- func (b *BackpackREST) GetTicker(symbol string, interval ...options.TickerInterval) (*models.Ticker, error)
- func (b *BackpackREST) GetTickers(interval ...options.TickerInterval) ([]*models.Ticker, error)
- func (b *BackpackREST) GetTime() (*time.Time, error)
- func (b *BackpackREST) GetTrades(symbol string, limitoffset ...options.LimitOffset) ([]*models.Trade, error)
- func (b *BackpackREST) GetTradesHistory(symbol string, limit ...int) ([]*models.Trade, error)
- func (b *BackpackREST) GetWithdrawals(filter ...options.DateFilter) ([]*models.Withdrawal, error)
- func (b *BackpackREST) Ping() error
- func (b *BackpackREST) RequestForQuote(rfqId string, bidPrice, askPrice float64, clientID *int) (*models.Quote, error)
- func (b *BackpackREST) RequestWithdrawal(asset string, quantity float64, address, blockchain string, ...) (*models.Withdrawal, error)
- func (b *BackpackREST) UpdateAccount(account *models.AccountUpdateble) error
- type BackpackWebsocket
- func (client *BackpackWebsocket) Subscribe200msDepth(symbol string, handler func(*models.DepthUpdate)) error
- func (client *BackpackWebsocket) SubscribeBookTicker(symbol string, handler func(*models.BookTickerUpdate)) error
- func (client *BackpackWebsocket) SubscribeDepth(symbol string, handler func(*models.DepthUpdate)) error
- func (client *BackpackWebsocket) SubscribeKLine(interval options.KLineInterval, symbol string, ...) error
- func (client *BackpackWebsocket) SubscribeLiquidation(symbol string, handler func(*models.LiquidationUpdate)) error
- func (client *BackpackWebsocket) SubscribeMarkPrice(symbol string, handler func(*models.MarkPriceUpdate)) error
- func (client *BackpackWebsocket) SubscribeOpenInterest(symbol string, handler func(*models.OpenInterestUpdate)) error
- func (client *BackpackWebsocket) SubscribeOrderUpdate(handler func(*models.OrderUpdate)) error
- func (client *BackpackWebsocket) SubscribeOrderUpdateWithSymbol(symbol string, handler func(*models.OrderUpdate)) error
- func (client *BackpackWebsocket) SubscribePositionUpdate(handler func(*models.PositionUpdate)) error
- func (client *BackpackWebsocket) SubscribePositionUpdateWithSymbol(symbol string, handler func(*models.PositionUpdate)) error
- func (client *BackpackWebsocket) SubscribeRFQUpdate(handler func(*models.RFQUpdate)) error
- func (client *BackpackWebsocket) SubscribeRFQUpdateWithSymbol(symbol string, handler func(*models.RFQUpdate)) error
- func (client *BackpackWebsocket) SubscribeTicker(symbol string, handler func(*models.TickerUpdate)) error
- func (client *BackpackWebsocket) SubscribeTrade(symbol string, handler func(*models.TradeUpdate)) error
- func (client *BackpackWebsocket) Unsubscribe(stream string) error
- type Message
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidAPIKeyOrSecret = errors.New("invalid API key or secret")
)
Functions ¶
func RequestWithAuth ¶
func SubscribePrivateStream ¶
func SubscribePublicStream ¶
Types ¶
type BackpackError ¶
func (*BackpackError) Error ¶
func (e *BackpackError) Error() string
type BackpackREST ¶
type BackpackREST struct {
BaseURL string
APIKey string
APISecret string
Windows time.Duration
// contains filtered or unexported fields
}
func NewRESTClient ¶
func NewRESTClient(options ...rest.Options) *BackpackREST
func (*BackpackREST) CancelOrderByClientID ¶
func (*BackpackREST) CancelOrderByOrderID ¶
func (*BackpackREST) CancelOrders ¶
func (*BackpackREST) ExecuteBorrowLend ¶
func (b *BackpackREST) ExecuteBorrowLend(asset string, side options.BorrowLendSide, quantity float64) error
func (*BackpackREST) ExecuteConditionalLimitOrder ¶
func (b *BackpackREST) ExecuteConditionalLimitOrder(symbol string, side options.Side, triggerPrice float64, price float64, quantity float64, opts ...options.OrderOptionFn) (*models.Order, error)
ExecuteConditionalLimitOrder executes a conditional limit order (stop limit order) symbol: Trading pair (e.g. "BTC_USDC") side: Bid/Buy or Ask/Sell triggerPrice: The price at which the limit order will be triggered price: The limit price after trigger quantity: The amount to trade opts: Optional parameters like clientId, timeInForce etc.
func (*BackpackREST) ExecuteLimitOrder ¶
func (b *BackpackREST) ExecuteLimitOrder(symbol string, side options.Side, price float64, quantity float64, opts ...options.OrderOptionFn) (*models.Order, error)
ExecuteLimitOrder executes a limit order symbol: Trading pair (e.g. "BTC_USDC") side: Bid/Buy or Ask/Sell price: The limit price quantity: The amount to trade opts: Optional parameters like clientId, timeInForce etc.
func (*BackpackREST) ExecuteMarketOrder ¶
func (b *BackpackREST) ExecuteMarketOrder(symbol string, side options.Side, quantity float64, opts ...options.OrderOptionFn) (*models.Order, error)
ExecuteMarketOrder executes a market order symbol: Trading pair (e.g. "BTC_USDC") side: Bid/Buy or Ask/Sell quantity: The amount to trade opts: Optional parameters like clientId, timeInForce etc.
func (*BackpackREST) GetAccount ¶
func (b *BackpackREST) GetAccount() (*models.Account, error)
func (*BackpackREST) GetAccountCollateral ¶
func (b *BackpackREST) GetAccountCollateral() (*models.Collateral, error)
func (*BackpackREST) GetAccountMaxBorrow ¶
func (b *BackpackREST) GetAccountMaxBorrow(asset string) (*models.AccountBorrowLimit, error)
func (*BackpackREST) GetAccountMaxOrder ¶
func (b *BackpackREST) GetAccountMaxOrder(symbol string, side options.Side, args ...options.AccountOrderLimitOptions) (*models.AccountOrderLimit, error)
func (*BackpackREST) GetAccountMaxWithdrawal ¶
func (b *BackpackREST) GetAccountMaxWithdrawal(asset string, args ...options.AccountWithdrawalLimitOptions) (*models.AccountWithdrawalLimit, error)
func (*BackpackREST) GetBalance ¶
func (b *BackpackREST) GetBalance() (map[string]*models.AssetBalance, error)
func (*BackpackREST) GetBorrowLendHistory ¶
func (b *BackpackREST) GetBorrowLendHistory(options ...options.BorrowHistoryOptions) ([]*models.BorrowLendHistory, error)
func (*BackpackREST) GetBorrowLendMarkets ¶
func (b *BackpackREST) GetBorrowLendMarkets() ([]*models.BorrowLendMarket, error)
func (*BackpackREST) GetBorrowLendMarketsHistory ¶
func (b *BackpackREST) GetBorrowLendMarketsHistory(interval options.BorrowLendMarketHistoryInterval, symbol ...string) ([]*models.BorrowLendMarketHistory, error)
symbol is optional, ex USDT、USDC、SOL...
func (*BackpackREST) GetBorrowLendPositions ¶
func (b *BackpackREST) GetBorrowLendPositions() ([]*models.BorrowLend, error)
func (*BackpackREST) GetBorrowPositionsHistory ¶
func (b *BackpackREST) GetBorrowPositionsHistory(options ...options.BorrowPostionHistoryOptions) ([]*models.BorrowPositionHistory, error)
func (*BackpackREST) GetDepositAddress ¶
func (b *BackpackREST) GetDepositAddress(blockchain string) (*models.DepositAddress, error)
func (*BackpackREST) GetDeposits ¶
func (b *BackpackREST) GetDeposits(filter ...options.DateFilter) ([]*models.Deposit, error)
func (*BackpackREST) GetDepth ¶
func (b *BackpackREST) GetDepth(symbol string) (*models.Depth, error)
func (*BackpackREST) GetFillHistory ¶
func (b *BackpackREST) GetFillHistory(options ...options.FillHistoryOptions) ([]*models.FillHistory, error)
func (*BackpackREST) GetFundingHistory ¶
func (b *BackpackREST) GetFundingHistory(options ...options.FundingHistoryOptions) ([]*models.FundingHistory, error)
func (*BackpackREST) GetFundingRates ¶
func (b *BackpackREST) GetFundingRates(symbol string) (*models.PageHeaders, []*models.FundingRate, error)
func (*BackpackREST) GetInterestHistory ¶
func (b *BackpackREST) GetInterestHistory(options ...options.InterestHistoryOptions) ([]*models.InterestHistory, error)
func (*BackpackREST) GetKlines ¶
func (b *BackpackREST) GetKlines(symbol string, interval options.KLineInterval, startTime time.Time, endTime ...time.Time) ([]*models.Kline, error)
endTime is optional
func (*BackpackREST) GetMarkPrices ¶
func (b *BackpackREST) GetMarkPrices(symbol ...string) ([]*models.MarkPrice, error)
symbol is optional
func (*BackpackREST) GetMarket ¶
func (b *BackpackREST) GetMarket(symbol string) (*models.Market, error)
func (*BackpackREST) GetMarketAssets ¶
func (b *BackpackREST) GetMarketAssets() ([]*models.MarketAssets, error)
func (*BackpackREST) GetMarketCollateral ¶
func (b *BackpackREST) GetMarketCollateral() ([]*models.MarketCollateral, error)
func (*BackpackREST) GetMarkets ¶
func (b *BackpackREST) GetMarkets() ([]*models.Market, error)
func (*BackpackREST) GetOpenInterest ¶
func (b *BackpackREST) GetOpenInterest(symbol ...string) ([]*models.OpenInterest, error)
func (*BackpackREST) GetOrderByClientID ¶
func (*BackpackREST) GetOrderByOrderID ¶
func (b *BackpackREST) GetOrderByOrderID(symbol, orderID string) (*models.Order, error)
func (*BackpackREST) GetOrders ¶
func (b *BackpackREST) GetOrders(symbol *string, marketType *options.MarketType) ([]*models.Order, error)
symbol is optional marketType is optional
func (*BackpackREST) GetOrdersHistory ¶
func (b *BackpackREST) GetOrdersHistory(options ...options.OrderHistoryOptions) ([]*models.OrderHistory, error)
func (*BackpackREST) GetPnlHistory ¶
func (b *BackpackREST) GetPnlHistory(options ...options.PnlHistoryOptions) ([]*models.PnlHistory, error)
func (*BackpackREST) GetPositions ¶
func (b *BackpackREST) GetPositions() ([]*models.Position, error)
func (*BackpackREST) GetSettlementHistory ¶
func (b *BackpackREST) GetSettlementHistory(options ...options.SettlementHistoryOptions) ([]*models.SettlementHistory, error)
func (*BackpackREST) GetTicker ¶
func (b *BackpackREST) GetTicker(symbol string, interval ...options.TickerInterval) (*models.Ticker, error)
interval is optional
func (*BackpackREST) GetTickers ¶
func (b *BackpackREST) GetTickers(interval ...options.TickerInterval) ([]*models.Ticker, error)
interval is optional
func (*BackpackREST) GetTrades ¶
func (b *BackpackREST) GetTrades(symbol string, limitoffset ...options.LimitOffset) ([]*models.Trade, error)
limitoffset is optional
func (*BackpackREST) GetTradesHistory ¶
func (*BackpackREST) GetWithdrawals ¶
func (b *BackpackREST) GetWithdrawals(filter ...options.DateFilter) ([]*models.Withdrawal, error)
func (*BackpackREST) Ping ¶
func (b *BackpackREST) Ping() error
func (*BackpackREST) RequestForQuote ¶
func (*BackpackREST) RequestWithdrawal ¶
func (b *BackpackREST) RequestWithdrawal(asset string, quantity float64, address, blockchain string, options ...options.WithdrawalOptions) (*models.Withdrawal, error)
func (*BackpackREST) UpdateAccount ¶
func (b *BackpackREST) UpdateAccount(account *models.AccountUpdateble) error
type BackpackWebsocket ¶
type BackpackWebsocket struct {
BaseURL string
APIKey string
APISecret string
Windows time.Duration
// contains filtered or unexported fields
}
func NewBackpackWebsocket ¶
func NewBackpackWebsocket(options ...ops.Options) (*BackpackWebsocket, error)
func (*BackpackWebsocket) Subscribe200msDepth ¶
func (client *BackpackWebsocket) Subscribe200msDepth(symbol string, handler func(*models.DepthUpdate)) error
func (*BackpackWebsocket) SubscribeBookTicker ¶
func (client *BackpackWebsocket) SubscribeBookTicker(symbol string, handler func(*models.BookTickerUpdate)) error
func (*BackpackWebsocket) SubscribeDepth ¶
func (client *BackpackWebsocket) SubscribeDepth(symbol string, handler func(*models.DepthUpdate)) error
func (*BackpackWebsocket) SubscribeKLine ¶
func (client *BackpackWebsocket) SubscribeKLine(interval options.KLineInterval, symbol string, handler func(*models.KLineUpdate)) error
func (*BackpackWebsocket) SubscribeLiquidation ¶
func (client *BackpackWebsocket) SubscribeLiquidation(symbol string, handler func(*models.LiquidationUpdate)) error
func (*BackpackWebsocket) SubscribeMarkPrice ¶
func (client *BackpackWebsocket) SubscribeMarkPrice(symbol string, handler func(*models.MarkPriceUpdate)) error
func (*BackpackWebsocket) SubscribeOpenInterest ¶
func (client *BackpackWebsocket) SubscribeOpenInterest(symbol string, handler func(*models.OpenInterestUpdate)) error
func (*BackpackWebsocket) SubscribeOrderUpdate ¶
func (client *BackpackWebsocket) SubscribeOrderUpdate(handler func(*models.OrderUpdate)) error
func (*BackpackWebsocket) SubscribeOrderUpdateWithSymbol ¶
func (client *BackpackWebsocket) SubscribeOrderUpdateWithSymbol(symbol string, handler func(*models.OrderUpdate)) error
func (*BackpackWebsocket) SubscribePositionUpdate ¶
func (client *BackpackWebsocket) SubscribePositionUpdate(handler func(*models.PositionUpdate)) error
func (*BackpackWebsocket) SubscribePositionUpdateWithSymbol ¶
func (client *BackpackWebsocket) SubscribePositionUpdateWithSymbol(symbol string, handler func(*models.PositionUpdate)) error
func (*BackpackWebsocket) SubscribeRFQUpdate ¶
func (client *BackpackWebsocket) SubscribeRFQUpdate(handler func(*models.RFQUpdate)) error
func (*BackpackWebsocket) SubscribeRFQUpdateWithSymbol ¶
func (client *BackpackWebsocket) SubscribeRFQUpdateWithSymbol(symbol string, handler func(*models.RFQUpdate)) error
func (*BackpackWebsocket) SubscribeTicker ¶
func (client *BackpackWebsocket) SubscribeTicker(symbol string, handler func(*models.TickerUpdate)) error
func (*BackpackWebsocket) SubscribeTrade ¶
func (client *BackpackWebsocket) SubscribeTrade(symbol string, handler func(*models.TradeUpdate)) error
func (*BackpackWebsocket) Unsubscribe ¶
func (client *BackpackWebsocket) Unsubscribe(stream string) error
type Message ¶
type Message struct {
Stream string `json:"stream"`
Data encodingjson.RawMessage `json:"data"`
}