option

package
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://eapi.binance.com"

Variables

This section is empty.

Functions

func GenerateSignature

func GenerateSignature(secretKey, data string) string

func Timestamp

func Timestamp() int64

Types

type APIError

type APIError struct {
	Code    int    `json:"code"`
	Message string `json:"msg"`
}

func (*APIError) Error

func (e *APIError) Error() string

type CancelAllOrdersParams

type CancelAllOrdersParams struct {
	Symbol string
}

type CancelOrderParams

type CancelOrderParams struct {
	Symbol        string
	OrderID       string
	ClientOrderID string
}

type Client

type Client struct {
	BaseURL    string
	APIKey     string
	SecretKey  string
	HTTPClient *http.Client
	Logger     *zap.SugaredLogger

	UsedWeight mbx.UsedWeight
	OrderCount mbx.OrderCount
}

func NewClient

func NewClient() *Client

func (*Client) CancelAllOpenOrders

func (c *Client) CancelAllOpenOrders(ctx context.Context, p CancelAllOrdersParams) error

func (*Client) CancelOrder

func (c *Client) CancelOrder(ctx context.Context, p CancelOrderParams) (*OrderResponse, error)

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, endpoint string, params map[string]interface{}, signed bool, result interface{}) error

func (*Client) Depth

func (c *Client) Depth(ctx context.Context, symbol string, limit int) (*DepthResponse, error)

func (*Client) ExchangeInfo

func (c *Client) ExchangeInfo(ctx context.Context) (*ExchangeInfoResponse, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, endpoint string, params map[string]interface{}, signed bool, result interface{}) error

func (*Client) GetOpenOrders

func (c *Client) GetOpenOrders(ctx context.Context, symbol string) ([]OrderResponse, error)

func (*Client) GetOrder

func (c *Client) GetOrder(ctx context.Context, symbol, orderID, clientOrderID string) (*OrderResponse, error)

func (*Client) GetOrderHistory

func (c *Client) GetOrderHistory(ctx context.Context, symbol string) ([]OrderResponse, error)

func (*Client) HasCredentials

func (c *Client) HasCredentials() bool

func (*Client) Klines

func (c *Client) Klines(ctx context.Context, symbol, interval string, limit int, startTime, endTime int64) ([]KlineResponse, error)

func (*Client) PlaceOrder

func (c *Client) PlaceOrder(ctx context.Context, p PlaceOrderParams) (*OrderResponse, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, endpoint string, params map[string]interface{}, signed bool, result interface{}) error

func (*Client) Ticker

func (c *Client) Ticker(ctx context.Context, symbol string) (*TickerResponse, error)

func (*Client) Trades

func (c *Client) Trades(ctx context.Context, symbol string, limit int) ([]TradeResponse, error)

func (*Client) WithBaseURL

func (c *Client) WithBaseURL(baseURL string) *Client

func (*Client) WithCredentials

func (c *Client) WithCredentials(apiKey, secretKey string) *Client

type DepthResponse

type DepthResponse struct {
	Time int64      `json:"T"`
	Bids [][]string `json:"bids"`
	Asks [][]string `json:"asks"`
}

type ExchangeInfoResponse

type ExchangeInfoResponse struct {
	OptionSymbols []OptionSymbol `json:"optionSymbols"`
}

type KlineResponse

type KlineResponse []interface{}

type NumberString

type NumberString string

func (*NumberString) UnmarshalJSON

func (n *NumberString) UnmarshalJSON(data []byte) error

type OptionSymbol

type OptionSymbol struct {
	Symbol        string       `json:"symbol"`
	Status        string       `json:"status"`
	BaseAsset     string       `json:"baseAsset"`
	QuoteAsset    string       `json:"quoteAsset"`
	Underlying    string       `json:"underlying"`
	SettleAsset   string       `json:"settleAsset"`
	Side          string       `json:"side"`
	StrikePrice   string       `json:"strikePrice"`
	ExpiryDate    int64        `json:"expiryDate"`
	Unit          NumberString `json:"unit"`
	PriceScale    int32        `json:"priceScale"`
	QuantityScale int32        `json:"quantityScale"`
	MinQty        string       `json:"minQty"`
}

type OrderResponse

type OrderResponse struct {
	ID            NumberString `json:"id"`
	OrderID       NumberString `json:"orderId"`
	ClientOrderID string       `json:"clientOrderId"`
	Symbol        string       `json:"symbol"`
	Price         string       `json:"price"`
	Quantity      string       `json:"quantity"`
	ExecutedQty   string       `json:"executedQty"`
	Fee           string       `json:"fee"`
	Side          string       `json:"side"`
	Type          string       `json:"type"`
	TimeInForce   string       `json:"timeInForce"`
	Status        string       `json:"status"`
	AvgPrice      string       `json:"avgPrice"`
	ReduceOnly    bool         `json:"reduceOnly"`
	CreateDate    int64        `json:"createDate"`
	UpdateTime    int64        `json:"updateTime"`
}

func (OrderResponse) IDString

func (o OrderResponse) IDString() string

type PlaceOrderParams

type PlaceOrderParams struct {
	Symbol        string
	Side          string
	Type          string
	Quantity      string
	Price         string
	TimeInForce   string
	ClientOrderID string
	ReduceOnly    bool
}

type TickerResponse

type TickerResponse struct {
	Symbol      string `json:"symbol"`
	LastPrice   string `json:"lastPrice"`
	BidPrice    string `json:"bidPrice"`
	AskPrice    string `json:"askPrice"`
	OpenPrice   string `json:"openPrice"`
	HighPrice   string `json:"highPrice"`
	LowPrice    string `json:"lowPrice"`
	Volume      string `json:"volume"`
	Amount      string `json:"amount"`
	CloseTime   int64  `json:"closeTime"`
	OpenTime    int64  `json:"openTime"`
	TradeCount  int64  `json:"tradeCount"`
	StrikePrice string `json:"strikePrice"`
}

type TradeResponse

type TradeResponse struct {
	ID       json.Number `json:"id"`
	TradeID  json.Number `json:"tradeId"`
	Price    string      `json:"price"`
	Quantity string      `json:"qty"`
	Side     string      `json:"side"`
	Time     int64       `json:"time"`
}

Jump to

Keyboard shortcuts

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