aster

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter Aster 适配器

func NewAdapter

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

NewAdapter 创建 Aster 适配器

func (*Adapter) CancelAllOrders

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

func (*Adapter) CancelOrder

func (a *Adapter) CancelOrder(ctx context.Context, orderID, symbol string) (retErr 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, retErr error)

func (*Adapter) FetchAllFundingRates

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

FetchAllFundingRates retrieves funding rates for all perpetual symbols

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, retErr error)

func (*Adapter) FetchFundingRate

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

FetchFundingRate retrieves funding rate for a symbol

func (*Adapter) FetchKlines

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

func (*Adapter) FetchOpenOrders

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

func (*Adapter) FetchOrder

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

func (*Adapter) FetchOrderBook

func (a *Adapter) FetchOrderBook(ctx context.Context, symbol string, limit int) (_ *exchanges.OrderBook, retErr 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, retErr error)

func (*Adapter) FetchTrades

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

func (*Adapter) FormatSymbol

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

func (*Adapter) GetLocalOrderBook

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

GetLocalOrderBook get local orderbook

func (*Adapter) ModifyOrder

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

func (*Adapter) PlaceOrder

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

func (*Adapter) RefreshSymbolDetails

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

func (*Adapter) SetLeverage

func (a *Adapter) SetLeverage(ctx context.Context, symbol string, leverage int) (retErr 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) WatchKlines

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

func (*Adapter) WatchOrderBook

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

WatchOrderBook subscribes to orderbook updates, maintains a local copy, and optionally calls the callback on each update. Pass nil callback for pull-only mode. This method blocks until the initial snapshot is synced.

func (*Adapter) WatchOrders

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

func (*Adapter) WatchPositions

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

func (*Adapter) WatchTicker

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

func (*Adapter) WatchTrades

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

func (*Adapter) WsAccountConnected

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

func (*Adapter) WsMarketConnected

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

func (*Adapter) WsOrderConnected

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

aster not support ws place order

type Options

type Options struct {
	APIKey        string
	SecretKey     string
	QuoteCurrency exchanges.QuoteCurrency // "USDC" (default for DEX) or "USDT"
	Logger        exchanges.Logger
}

Options configures an Aster adapter.

type OrderBook

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

OrderBook maintains a local orderbook replica for Aster (Binance-compatible protocol). Uses string-keyed maps because decimal.Decimal is not comparable (can't be map key).

func NewOrderBook

func NewOrderBook(symbol string) *OrderBook

NewOrderBook creates a new OrderBook instance

func (*OrderBook) ApplySnapshot

func (ob *OrderBook) ApplySnapshot(snap *perp.DepthResponse) error

ApplySnapshot applies a REST API depth snapshot

func (*OrderBook) GetBestAsk

func (ob *OrderBook) GetBestAsk() (decimal.Decimal, decimal.Decimal)

GetBestAsk returns the best ask price and quantity

func (*OrderBook) GetBestBid

func (ob *OrderBook) GetBestBid() (decimal.Decimal, decimal.Decimal)

GetBestBid returns the best bid price and quantity

func (*OrderBook) GetDepth

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

GetDepth returns the sorted top `limit` depth levels.

func (*OrderBook) IsInitialized

func (ob *OrderBook) IsInitialized() bool

IsInitialized returns whether the snapshot has been applied

func (*OrderBook) ProcessUpdate

func (ob *OrderBook) ProcessUpdate(event *perp.WsDepthEvent) error

ProcessUpdate processes a WebSocket incremental update

func (*OrderBook) Reset

func (ob *OrderBook) Reset()

Reset resets the OrderBook state

func (*OrderBook) Timestamp

func (ob *OrderBook) Timestamp() int64

Timestamp satisfies the LocalOrderBook interface

func (*OrderBook) WaitReady

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

WaitReady waits for the OrderBook to be initialized

type SpotAdapter

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

func NewSpotAdapter

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

NewSpotAdapter creates a new Aster Spot Adapter

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) 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) FetchOrder

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

func (*SpotAdapter) FetchOrderBook

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

func (*SpotAdapter) FetchPositions

func (a *SpotAdapter) FetchPositions(ctx context.Context) ([]exchanges.Position, 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) ModifyOrder

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

func (*SpotAdapter) PlaceOrder

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

func (*SpotAdapter) RefreshSymbolDetails

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

func (*SpotAdapter) SetLeverage

func (a *SpotAdapter) SetLeverage(ctx context.Context, symbol string, leverage int) 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) WatchKlines

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

func (*SpotAdapter) WatchOrderBook

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

WatchOrderBook subscribes to orderbook updates and waits for the book to be ready.

func (*SpotAdapter) WatchOrders

func (a *SpotAdapter) WatchOrders(ctx context.Context, callback exchanges.OrderUpdateCallback) error

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, callback exchanges.TickerCallback) error

func (*SpotAdapter) WatchTrades

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

func (*SpotAdapter) WsAccountConnected

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

func (*SpotAdapter) WsMarketConnected

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

func (*SpotAdapter) WsOrderConnected

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

type SpotOrderBook

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

SpotOrderBook maintains a local orderbook replica for Aster spot

func NewSpotOrderBook

func NewSpotOrderBook(symbol string) *SpotOrderBook

func (*SpotOrderBook) ApplySnapshot

func (ob *SpotOrderBook) ApplySnapshot(snap *spot.DepthResponse) error

func (*SpotOrderBook) GetBestAsk

func (ob *SpotOrderBook) GetBestAsk() (decimal.Decimal, decimal.Decimal)

func (*SpotOrderBook) GetBestBid

func (ob *SpotOrderBook) GetBestBid() (decimal.Decimal, decimal.Decimal)

func (*SpotOrderBook) GetDepth

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

func (*SpotOrderBook) IsInitialized

func (ob *SpotOrderBook) IsInitialized() bool

func (*SpotOrderBook) ProcessUpdate

func (ob *SpotOrderBook) ProcessUpdate(event *spot.WsDepthEvent) error

func (*SpotOrderBook) Reset

func (ob *SpotOrderBook) Reset()

func (*SpotOrderBook) Timestamp

func (ob *SpotOrderBook) Timestamp() int64

func (*SpotOrderBook) WaitReady

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

Directories

Path Synopsis
sdk

Jump to

Keyboard shortcuts

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