spot

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubAccountListEndPoint                    = "/sapi/v1/sub-account/list"
	SubAccountTransferHistoryEndPoint         = "/sapi/v1/sub-account/sub/transfer/history"
	SubAccountFuturesInternalTransferEndPoint = "/sapi/v1/sub-account/futures/internalTransfer"
	SubAccountAssetEndPoint                   = "/sapi/v3/sub-account/assets"

	TransferHistoryLimit = 500
)
View Source
const (
	TradeEvent    = "trade"
	AggTradeEvent = "aggTrade"
)
View Source
const (
	AccountEndPoint = "/api/v3/account"
)
View Source
const (
	DepositHisrecEndPoint = "/sapi/v1/capital/deposit/hisrec"
)
View Source
const (
	MethodSubscibe = "SUBSCRIBE"
)
View Source
const (
	MyTradesEndPoint = "/api/v3/myTrades"
)
View Source
const (
	TradeFeeEndPoint = "/sapi/v1/asset/tradeFee"
)
View Source
const (
	WSClientEndPoint = "wss://stream.binance.com:9443/ws"
)

Variables

View Source
var (
	ErrPair = errors.New("symbol pair not support")
)

Functions

func Init

func Init(ctx context.Context) error

func NewAggTradeChannel added in v0.5.8

func NewAggTradeChannel(symbol string) exchange.Channel

func NewSymbol

func NewSymbol(base, quote string) exchange.SpotSymbol

func NewTickerChannel added in v0.5.8

func NewTickerChannel(symbol string) exchange.Channel

func NewTradeChannel added in v0.5.8

func NewTradeChannel(symbol string) exchange.Channel

func ParseSymbol

func ParseSymbol(sym string) (exchange.SpotSymbol, error)

Types

type AccountBalance added in v0.5.4

type AccountBalance struct {
	Asset  string          `json:"asset"`
	Free   decimal.Decimal `json:"free"`
	Locked decimal.Decimal `json:"locked"`
}

type AccountReq added in v0.5.4

type AccountReq struct {
	*binance.RestReq
}

func NewAccountReq added in v0.5.4

func NewAccountReq() *AccountReq

type AccountResp added in v0.5.4

type AccountResp struct {
	MakerCommision int              `json:"makerCommision"`
	Balances       []AccountBalance `json:"balances"`
}

type AggTradeChannel added in v0.5.8

type AggTradeChannel struct {
	// contains filtered or unexported fields
}

func (*AggTradeChannel) String added in v0.5.8

func (ac *AggTradeChannel) String() string

type BookTickerChannel added in v0.5.8

type BookTickerChannel struct {
	// contains filtered or unexported fields
}

BookTickerChannel xxx@bookTicker channel

func (*BookTickerChannel) String added in v0.5.8

func (tc *BookTickerChannel) String() string

type BookTickerNotify added in v0.5.8

type BookTickerNotify struct {
	UpdateID   int64  `json:"u"`
	Symbol     string `json:"s"`
	Bid1Price  string `json:"b"`
	Bid1Amount string `json:"B"`
	Ask1Price  string `json:"a"`
	Ask1Amount string `json:"A"`
}

BookTickerNotify binance spot bookticker notify

func ParseBookTickerNotify added in v0.5.8

func ParseBookTickerNotify(g *gjson.Result) *BookTickerNotify

type CodeC added in v0.5.8

type CodeC struct {
	*binance.CodeC
}

CodeC used to decode binance websocket notify message to coresponding struct and encode sbuscribe request

func NewCodeC added in v0.5.8

func NewCodeC() *CodeC

func (*CodeC) Decode added in v0.5.8

func (cc *CodeC) Decode(raw []byte) (rpc.Response, error)

Decode binance websocket notify message

type DepositHisrecRecord added in v0.5.4

type DepositHisrecRecord struct {
	Amount        string `json:"amount"`
	Coin          string `json:"coin"`
	Network       string `json:"network"`
	Status        int    `json:"status"`
	Address       string `json:"address"`
	AddressTag    string `json:"addressTag"`
	TxID          string `json:"txId"`
	InsertTime    int64  `json:"insertTime"`
	TransferType  int    `json:"transferType"`
	UnlockConfirm int    `json:"unlockConfirm"`
	ConfirmTimes  string `json:"confirmTimes"`
}

type DepositHisrecReq added in v0.5.4

type DepositHisrecReq struct {
	*binance.RestReq
}

func NewDepositHisrecReq added in v0.5.4

func NewDepositHisrecReq() *DepositHisrecReq

type ExchangeInfo

type ExchangeInfo struct {
	Symbols []Symbol `json:"symbols"`
}

type RestClient

type RestClient struct {
	*binance.RestClient
}

func NewRestClient

func NewRestClient(key, secret string) *RestClient

func (*RestClient) Account added in v0.5.4

func (rc *RestClient) Account(ctx context.Context, req *AccountReq) (*AccountResp, error)

func (*RestClient) DepositHisrec added in v0.5.4

func (rc *RestClient) DepositHisrec(ctx context.Context, req *DepositHisrecReq) ([]DepositHisrecRecord, error)

func (*RestClient) ExchangeInfo

func (rc *RestClient) ExchangeInfo(ctx context.Context) (*ExchangeInfo, error)

func (*RestClient) FeeRate

func (rc *RestClient) FeeRate(ctx context.Context, symbols []exchange.Symbol) ([]*exchange.TradeFee, error)

func (*RestClient) MyTrades

func (rc *RestClient) MyTrades(ctx context.Context, symbol string, st int64, et int64, fid int64, limit int) ([]Trade, error)

func (*RestClient) Property

func (rc *RestClient) Property() exchange.Property

func (*RestClient) SubAccountAsset added in v0.5.4

func (rc *RestClient) SubAccountAsset(ctx context.Context, req *SubAccountAssetReq) (*SubAccountAssetResp, error)

func (*RestClient) SubAccountFuturesInternalTransfer added in v0.5.4

func (*RestClient) SubAccountList added in v0.5.4

func (rc *RestClient) SubAccountList(ctx context.Context, req *SubAccountReq) (*SubAccountResp, error)

func (*RestClient) SubAccountTransferHistory added in v0.5.4

func (rc *RestClient) SubAccountTransferHistory(ctx context.Context, req *SubAccountTransferHistoryReq) ([]SubAccountTransferHistory, error)

func (*RestClient) Symbols

func (rc *RestClient) Symbols(ctx context.Context) ([]exchange.SpotSymbol, error)

func (*RestClient) TradeFee

func (rc *RestClient) TradeFee(ctx context.Context, symbol string) ([]TradeFee, error)

func (*RestClient) Trades

func (rc *RestClient) Trades(ctx context.Context, req *exchange.TradeReqParam) ([]exchange.Trade, error)

type SpotSymbol

type SpotSymbol struct {
	*exchange.BaseSpotSymbol
	Symbol string
}

func (*SpotSymbol) String

func (ss *SpotSymbol) String() string

type SubAccount added in v0.5.4

type SubAccount struct {
	Email      string `json:"email"`
	IsFreeze   bool   `json:"isFreeze"`
	CreateTime int64  `json:"createTime"`
}

type SubAccountAssetReq added in v0.5.4

type SubAccountAssetReq struct {
	*binance.RestReq
}

func NewSubAccountAssetReq added in v0.5.4

func NewSubAccountAssetReq(email string) *SubAccountAssetReq

type SubAccountAssetResp added in v0.5.4

type SubAccountAssetResp struct {
	Balances []SubAccountBalance `json:"balances"`
}

type SubAccountBalance added in v0.5.4

type SubAccountBalance struct {
	Asset  string  `json:"asset"`
	Free   float64 `json:"free"`
	Locked float64 `json:"locked"`
}

type SubAccountFuturesInternalTransfer added in v0.5.4

type SubAccountFuturesInternalTransfer struct {
	From   string `json:"from"`
	To     string `json:"to"`
	Asset  string `json:"asset"`
	Qty    string `json:"qty"`
	TranID int    `json:"tranId"`
	Time   int64  `json:"time"`
}

type SubAccountFuturesInternalTransferReq added in v0.5.4

type SubAccountFuturesInternalTransferReq struct {
	*binance.RestReq
}

func NewSubAccountFuturesInternalTransferReq added in v0.5.4

func NewSubAccountFuturesInternalTransferReq(email string, typ int) *SubAccountFuturesInternalTransferReq

func (*SubAccountFuturesInternalTransferReq) EndTime added in v0.5.4

func (*SubAccountFuturesInternalTransferReq) Limit added in v0.5.4

func (*SubAccountFuturesInternalTransferReq) Page added in v0.5.4

func (*SubAccountFuturesInternalTransferReq) StartTime added in v0.5.4

type SubAccountFuturesInternalTransferResp added in v0.5.4

type SubAccountFuturesInternalTransferResp struct {
	Success     bool                                `json:"success"`
	FuturesType int                                 `json:"futuresType"`
	Transfers   []SubAccountFuturesInternalTransfer `json:"transfers"`
}

type SubAccountReq added in v0.5.4

type SubAccountReq struct {
	*binance.RestReq
}

func NewSubAccountReq added in v0.5.4

func NewSubAccountReq() *SubAccountReq

func (*SubAccountReq) Email added in v0.5.4

func (sr *SubAccountReq) Email(email string) *SubAccountReq

func (*SubAccountReq) IsFreeze added in v0.5.4

func (sr *SubAccountReq) IsFreeze(freeze bool) *SubAccountReq

func (*SubAccountReq) Limit added in v0.5.4

func (sr *SubAccountReq) Limit(limit int) *SubAccountReq

func (*SubAccountReq) Page added in v0.5.4

func (sr *SubAccountReq) Page(page int) *SubAccountReq

type SubAccountResp added in v0.5.4

type SubAccountResp struct {
	SubAccounts []SubAccount `json:"subAccounts"`
}

type SubAccountTransferHistory added in v0.5.4

type SubAccountTransferHistory struct {
	From   string `json:"from"`
	To     string `json:"to"`
	Asset  string `json:"asset"`
	Qty    string `json:"qty"`
	Status string `json:"status"`
	TranID int    `json:"tranId"`
	Time   int64  `json:"time"`
}

type SubAccountTransferHistoryReq added in v0.5.4

type SubAccountTransferHistoryReq struct {
	*binance.RestReq
}

func NewSubAccountTransferHistoryReq added in v0.5.4

func NewSubAccountTransferHistoryReq() *SubAccountTransferHistoryReq

func (*SubAccountTransferHistoryReq) EndTime added in v0.5.4

func (*SubAccountTransferHistoryReq) FromEmail added in v0.5.4

func (*SubAccountTransferHistoryReq) Limit added in v0.5.4

func (*SubAccountTransferHistoryReq) Page added in v0.5.4

func (*SubAccountTransferHistoryReq) StartTime added in v0.5.4

func (*SubAccountTransferHistoryReq) ToEmail added in v0.5.4

type Symbol

type Symbol struct {
	Symbol              string `json:"symbol"`
	BaseAsset           string `json:"baseAsset"`
	QuoteAsset          string `json:"quoteAsset"`
	BaseAssetPrecision  int    `json:"baseAssetPrecision"`
	QuoteAssetPrecision int    `json:"quoteAssetPrecision"`
}

Symbol info TODO: refactor Symbol add more info pricePrecison ...

func (*Symbol) Parse

func (sym *Symbol) Parse() (exchange.SpotSymbol, error)

type Trade

type Trade struct {
	Symbol          string          `json:"symbol"`
	ID              int64           `json:"id"`
	OrderID         int64           `json:"orderId"`
	OrderListID     int64           `json:"orderListId"`
	Price           decimal.Decimal `json:"price"`
	Qty             decimal.Decimal `json:"qty"`
	QuoteQty        decimal.Decimal `json:"quoteQty"`
	Commission      decimal.Decimal `json:"commission"`
	CommissionAsset string          `json:"commissionAsset"`
	Time            int64           `json:"time"`
	IsBuyer         bool            `json:"isBuyer"`
	IsMaker         bool            `json:"isMaker"`
	IsBestMatch     bool            `json:"isBestMatch"`
}

func (*Trade) Parse

func (t *Trade) Parse() (*exchange.Trade, error)

type TradeChannel added in v0.5.8

type TradeChannel struct {
	// contains filtered or unexported fields
}

func (*TradeChannel) String added in v0.5.8

func (tc *TradeChannel) String() string

type TradeFee

type TradeFee struct {
	Symbol string          `json:"symbol"`
	Maker  decimal.Decimal `json:"makerCommission"`
	Taker  decimal.Decimal `json:"takerCommission"`
}

func (*TradeFee) Parse

func (tf *TradeFee) Parse() (*exchange.TradeFee, error)

type TradeNotify added in v0.5.8

type TradeNotify struct {
	Event       string `json:"e"`
	EventTS     int64  `json:"E"`
	Symbol      string `json:"s"`
	TradeID     int64  `json:"t"`
	Price       string `json:"p"`
	Quantity    string `json:"q"`
	BuyOrderID  int64  `json:"b"`
	SellOrderID int64  `json:"a"`
	TradeTS     int64  `json:"T"`
	Taker       bool   `json:"m"`
}

func ParseTradeNotify added in v0.5.8

func ParseTradeNotify(gs *gjson.Result) *TradeNotify

func (*TradeNotify) Parse added in v0.5.8

func (tn *TradeNotify) Parse() ([]*exchange.Trade, error)

type WSClient added in v0.5.8

type WSClient struct {
	*binance.NotifyClient
}

WSClient binance spot websocket client for public notify

func NewWSClient added in v0.5.8

func NewWSClient(data chan interface{}) *WSClient

Jump to

Keyboard shortcuts

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