backpack

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateClientID

func GenerateClientID() string

GenerateClientID returns a Backpack-compatible client order ID. The returned value is a base-10 numeric string in the valid uint32 range and is never "0".

Types

type Adapter

type Adapter struct {
	*exchanges.BaseAdapter
	// contains filtered or unexported fields
}

func NewAdapter

func NewAdapter(ctx context.Context, opts Options) (*Adapter, error)

func (*Adapter) CancelAllOrders

func (a *Adapter) CancelAllOrders(ctx context.Context, symbol string) error

func (*Adapter) CancelOrder

func (a *Adapter) CancelOrder(ctx context.Context, orderID, symbol string) error

func (*Adapter) CancelOrderWS added in v0.2.9

func (a *Adapter) CancelOrderWS(context.Context, string, string) error

func (*Adapter) Close

func (a *Adapter) Close() error

func (*Adapter) ExtractSymbol

func (a *Adapter) ExtractSymbol(symbol string) string

func (*Adapter) FetchAccount

func (a *Adapter) FetchAccount(ctx context.Context) (*exchanges.Account, error)

func (*Adapter) FetchAllFundingRates

func (a *Adapter) FetchAllFundingRates(ctx context.Context) ([]exchanges.FundingRate, error)

func (*Adapter) FetchBalance

func (a *Adapter) FetchBalance(ctx context.Context) (decimal.Decimal, error)

func (*Adapter) FetchFeeRate

func (a *Adapter) FetchFeeRate(ctx context.Context, symbol string) (*exchanges.FeeRate, error)

func (*Adapter) FetchFundingRate

func (a *Adapter) FetchFundingRate(ctx context.Context, symbol string) (*exchanges.FundingRate, error)

func (*Adapter) FetchKlines

func (a *Adapter) FetchKlines(ctx context.Context, symbol string, interval exchanges.Interval, opts *exchanges.KlineOpts) ([]exchanges.Kline, error)

func (*Adapter) FetchOpenOrders

func (a *Adapter) FetchOpenOrders(ctx context.Context, symbol string) ([]exchanges.Order, error)

func (*Adapter) FetchOrderBook

func (a *Adapter) FetchOrderBook(ctx context.Context, symbol string, limit int) (*exchanges.OrderBook, error)

func (*Adapter) FetchOrderByID

func (a *Adapter) FetchOrderByID(ctx context.Context, orderID, symbol string) (*exchanges.Order, error)

func (*Adapter) FetchOrders

func (a *Adapter) FetchOrders(ctx context.Context, symbol string) ([]exchanges.Order, error)

func (*Adapter) FetchPositions

func (a *Adapter) FetchPositions(ctx context.Context) ([]exchanges.Position, error)

func (*Adapter) FetchSymbolDetails

func (a *Adapter) FetchSymbolDetails(ctx context.Context, symbol string) (*exchanges.SymbolDetails, error)

func (*Adapter) FetchTicker

func (a *Adapter) FetchTicker(ctx context.Context, symbol string) (*exchanges.Ticker, error)

func (*Adapter) FetchTrades

func (a *Adapter) FetchTrades(ctx context.Context, symbol string, limit int) ([]exchanges.Trade, error)

func (*Adapter) FormatSymbol

func (a *Adapter) FormatSymbol(symbol string) string

func (*Adapter) GetLocalOrderBook

func (a *Adapter) GetLocalOrderBook(symbol string, depth int) *exchanges.OrderBook

func (*Adapter) ModifyOrder

func (a *Adapter) ModifyOrder(ctx context.Context, orderID, symbol string, params *exchanges.ModifyOrderParams) (*exchanges.Order, error)

func (*Adapter) ModifyOrderWS added in v0.2.9

func (*Adapter) PlaceOrder

func (a *Adapter) PlaceOrder(ctx context.Context, params *exchanges.OrderParams) (*exchanges.Order, error)

func (*Adapter) PlaceOrderWS added in v0.2.9

func (a *Adapter) PlaceOrderWS(context.Context, *exchanges.OrderParams) error

func (*Adapter) SetLeverage

func (a *Adapter) SetLeverage(ctx context.Context, symbol string, leverage int) error

func (*Adapter) StopWatchFills added in v0.2.7

func (a *Adapter) StopWatchFills(ctx context.Context) error

func (*Adapter) StopWatchKlines

func (a *Adapter) StopWatchKlines(ctx context.Context, symbol string, interval exchanges.Interval) error

func (*Adapter) StopWatchOrderBook

func (a *Adapter) StopWatchOrderBook(ctx context.Context, symbol string) error

func (*Adapter) StopWatchOrders

func (a *Adapter) StopWatchOrders(ctx context.Context) error

func (*Adapter) StopWatchPositions

func (a *Adapter) StopWatchPositions(ctx context.Context) error

func (*Adapter) StopWatchTicker

func (a *Adapter) StopWatchTicker(ctx context.Context, symbol string) error

func (*Adapter) StopWatchTrades

func (a *Adapter) StopWatchTrades(ctx context.Context, symbol string) error

func (*Adapter) WatchFills added in v0.2.7

func (a *Adapter) WatchFills(ctx context.Context, cb exchanges.FillCallback) error

func (*Adapter) WatchKlines

func (a *Adapter) WatchKlines(ctx context.Context, symbol string, interval exchanges.Interval, cb exchanges.KlineCallback) error

func (*Adapter) WatchOrderBook

func (a *Adapter) WatchOrderBook(ctx context.Context, symbol string, depth int, cb exchanges.OrderBookCallback) error

func (*Adapter) WatchOrders

func (a *Adapter) WatchOrders(ctx context.Context, cb exchanges.OrderUpdateCallback) error

func (*Adapter) WatchPositions

func (a *Adapter) WatchPositions(ctx context.Context, cb exchanges.PositionUpdateCallback) error

func (*Adapter) WatchTicker

func (a *Adapter) WatchTicker(ctx context.Context, symbol string, cb exchanges.TickerCallback) error

func (*Adapter) WatchTrades

func (a *Adapter) WatchTrades(ctx context.Context, symbol string, cb exchanges.TradeCallback) error

type Options

type Options struct {
	APIKey        string
	PrivateKey    string
	QuoteCurrency exchanges.QuoteCurrency
	Logger        exchanges.Logger
}

type OrderBook

type OrderBook struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewOrderBook

func NewOrderBook(symbol string) *OrderBook

func (*OrderBook) ApplySnapshot

func (ob *OrderBook) ApplySnapshot(snap *sdk.Depth) error

func (*OrderBook) GetDepth

func (ob *OrderBook) GetDepth(limit int) ([]exchanges.Level, []exchanges.Level)

func (*OrderBook) IsInitialized

func (ob *OrderBook) IsInitialized() bool

func (*OrderBook) ProcessUpdate

func (ob *OrderBook) ProcessUpdate(event *sdk.DepthEvent) error

func (*OrderBook) Timestamp

func (ob *OrderBook) Timestamp() int64

func (*OrderBook) WaitReady

func (ob *OrderBook) WaitReady(ctx context.Context, timeout time.Duration) bool

type SpotAdapter

type SpotAdapter struct {
	*exchanges.BaseAdapter
	// contains filtered or unexported fields
}

func NewSpotAdapter

func NewSpotAdapter(ctx context.Context, opts Options) (*SpotAdapter, error)

func (*SpotAdapter) CancelAllOrders

func (a *SpotAdapter) CancelAllOrders(ctx context.Context, symbol string) error

func (*SpotAdapter) CancelOrder

func (a *SpotAdapter) CancelOrder(ctx context.Context, orderID, symbol string) error

func (*SpotAdapter) CancelOrderWS added in v0.2.9

func (a *SpotAdapter) CancelOrderWS(context.Context, string, string) error

func (*SpotAdapter) Close

func (a *SpotAdapter) Close() error

func (*SpotAdapter) ExtractSymbol

func (a *SpotAdapter) ExtractSymbol(symbol string) string

func (*SpotAdapter) FetchAccount

func (a *SpotAdapter) FetchAccount(ctx context.Context) (*exchanges.Account, error)

func (*SpotAdapter) FetchBalance

func (a *SpotAdapter) FetchBalance(ctx context.Context) (decimal.Decimal, error)

func (*SpotAdapter) FetchFeeRate

func (a *SpotAdapter) FetchFeeRate(ctx context.Context, symbol string) (*exchanges.FeeRate, error)

func (*SpotAdapter) FetchKlines

func (a *SpotAdapter) FetchKlines(ctx context.Context, symbol string, interval exchanges.Interval, opts *exchanges.KlineOpts) ([]exchanges.Kline, error)

func (*SpotAdapter) FetchOpenOrders

func (a *SpotAdapter) FetchOpenOrders(ctx context.Context, symbol string) ([]exchanges.Order, error)

func (*SpotAdapter) FetchOrderBook

func (a *SpotAdapter) FetchOrderBook(ctx context.Context, symbol string, limit int) (*exchanges.OrderBook, error)

func (*SpotAdapter) FetchOrderByID

func (a *SpotAdapter) FetchOrderByID(ctx context.Context, orderID, symbol string) (*exchanges.Order, error)

func (*SpotAdapter) FetchOrders

func (a *SpotAdapter) FetchOrders(ctx context.Context, symbol string) ([]exchanges.Order, error)

func (*SpotAdapter) FetchSpotBalances

func (a *SpotAdapter) FetchSpotBalances(ctx context.Context) ([]exchanges.SpotBalance, error)

func (*SpotAdapter) FetchSymbolDetails

func (a *SpotAdapter) FetchSymbolDetails(ctx context.Context, symbol string) (*exchanges.SymbolDetails, error)

func (*SpotAdapter) FetchTicker

func (a *SpotAdapter) FetchTicker(ctx context.Context, symbol string) (*exchanges.Ticker, error)

func (*SpotAdapter) FetchTrades

func (a *SpotAdapter) FetchTrades(ctx context.Context, symbol string, limit int) ([]exchanges.Trade, error)

func (*SpotAdapter) FormatSymbol

func (a *SpotAdapter) FormatSymbol(symbol string) string

func (*SpotAdapter) GetLocalOrderBook

func (a *SpotAdapter) GetLocalOrderBook(symbol string, depth int) *exchanges.OrderBook

func (*SpotAdapter) PlaceOrder

func (a *SpotAdapter) PlaceOrder(ctx context.Context, params *exchanges.OrderParams) (*exchanges.Order, error)

func (*SpotAdapter) PlaceOrderWS added in v0.2.9

func (*SpotAdapter) StopWatchFills added in v0.2.7

func (a *SpotAdapter) StopWatchFills(ctx context.Context) error

func (*SpotAdapter) StopWatchKlines

func (a *SpotAdapter) StopWatchKlines(ctx context.Context, symbol string, interval exchanges.Interval) error

func (*SpotAdapter) StopWatchOrderBook

func (a *SpotAdapter) StopWatchOrderBook(ctx context.Context, symbol string) error

func (*SpotAdapter) StopWatchOrders

func (a *SpotAdapter) StopWatchOrders(ctx context.Context) error

func (*SpotAdapter) StopWatchPositions

func (a *SpotAdapter) StopWatchPositions(ctx context.Context) error

func (*SpotAdapter) StopWatchTicker

func (a *SpotAdapter) StopWatchTicker(ctx context.Context, symbol string) error

func (*SpotAdapter) StopWatchTrades

func (a *SpotAdapter) StopWatchTrades(ctx context.Context, symbol string) error

func (*SpotAdapter) TransferAsset

func (a *SpotAdapter) TransferAsset(ctx context.Context, params *exchanges.TransferParams) error

func (*SpotAdapter) WatchFills added in v0.2.7

func (a *SpotAdapter) WatchFills(ctx context.Context, cb exchanges.FillCallback) error

func (*SpotAdapter) WatchKlines

func (a *SpotAdapter) WatchKlines(ctx context.Context, symbol string, interval exchanges.Interval, cb exchanges.KlineCallback) error

func (*SpotAdapter) WatchOrderBook

func (a *SpotAdapter) WatchOrderBook(ctx context.Context, symbol string, depth int, cb exchanges.OrderBookCallback) error

func (*SpotAdapter) WatchOrders

func (*SpotAdapter) WatchPositions

func (a *SpotAdapter) WatchPositions(ctx context.Context, cb exchanges.PositionUpdateCallback) error

func (*SpotAdapter) WatchTicker

func (a *SpotAdapter) WatchTicker(ctx context.Context, symbol string, cb exchanges.TickerCallback) error

func (*SpotAdapter) WatchTrades

func (a *SpotAdapter) WatchTrades(ctx context.Context, symbol string, cb exchanges.TradeCallback) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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