Documentation
¶
Index ¶
- Constants
- func GenerateSignature(secretKey, data string) string
- func Timestamp() int64
- type AccountAsset
- type AccountGreek
- type AccountResponse
- type Client
- func (c *Client) CancelOrder(ctx context.Context, symbol, orderID, clientOrderID string) (*OrderResponse, error)
- func (c *Client) CloseListenKey(ctx context.Context, key string) error
- func (c *Client) CreateListenKey(ctx context.Context) (string, error)
- func (c *Client) GetAccount(ctx context.Context) (*AccountResponse, error)
- func (c *Client) GetExchangeInfo(ctx context.Context) (*ExchangeInfoResponse, error)
- func (c *Client) GetMark(ctx context.Context, symbol string) (MarkResponse, error)
- func (c *Client) GetOpenOrders(ctx context.Context, symbol string) ([]OrderResponse, error)
- func (c *Client) GetOrder(ctx context.Context, symbol, orderID, clientOrderID string) (*OrderResponse, error)
- func (c *Client) GetPositions(ctx context.Context, symbol string) (PositionResponse, error)
- func (c *Client) KeepAliveListenKey(ctx context.Context, key string) error
- func (c *Client) PlaceOrder(ctx context.Context, req *OrderRequest) (*OrderResponse, error)
- func (c *Client) WithCredentials(apiKey, secretKey string) *Client
- func (c *Client) WithHTTPClient(httpClient *http.Client) *Client
- type ErrorResponse
- type ExchangeInfoResponse
- type ListenKeyResponse
- type MarkEntry
- type MarkResponse
- type OptionAsset
- type OptionContract
- type OptionSymbol
- type OrderRequest
- type OrderResponse
- type PositionEntry
- type PositionResponse
Constants ¶
const ( BaseURL = "https://eapi.binance.com" WSBaseURL = "wss://nbstream.binance.com/eoptions" WSPublicPath = "/ws" // wss://nbstream.binance.com/eoptions/ws/<stream> WSPrivatePath = "/ws" // user data stream uses /ws/<listenKey> )
REST and WS endpoints for Binance European Options API.
const ( EndpointExchangeInfo = "/eapi/v1/exchangeInfo" EndpointMark = "/eapi/v1/mark" EndpointDepth = "/eapi/v1/depth" EndpointTicker = "/eapi/v1/ticker" EndpointKlines = "/eapi/v1/klines" EndpointOrder = "/eapi/v1/order" EndpointOpenOrders = "/eapi/v1/openOrders" EndpointHistoryOrders = "/eapi/v1/historyOrders" EndpointAccount = "/eapi/v1/account" EndpointPosition = "/eapi/v1/position" EndpointListenKey = "/eapi/v1/listenKey" )
REST endpoint paths.
Variables ¶
This section is empty.
Functions ¶
func GenerateSignature ¶
GenerateSignature returns the HMAC-SHA256 signature Binance expects for signed REST/WS calls. Same algorithm as fapi/spapi.
Types ¶
type AccountAsset ¶
type AccountGreek ¶
type AccountResponse ¶
type AccountResponse struct {
Asset []AccountAsset `json:"asset"`
GreekRecord []AccountGreek `json:"greek"`
Time int64 `json:"time"`
RiskLevel string `json:"riskLevel"`
}
AccountResponse is /eapi/v1/account.
type Client ¶
type Client struct {
BaseURL string
APIKey string
SecretKey string
HTTPClient *http.Client
Logger *zap.SugaredLogger
}
Client is the REST client for Binance European Options (eapi.binance.com).
Only the methods needed by the Tier 2 reference adapter are implemented here: chain/mark/positions/account + place/cancel/query orders.
func (*Client) CancelOrder ¶
func (c *Client) CancelOrder(ctx context.Context, symbol, orderID, clientOrderID string) (*OrderResponse, error)
CancelOrder cancels either by orderID or clientOrderID (one is required).
func (*Client) CloseListenKey ¶
func (*Client) CreateListenKey ¶
func (*Client) GetAccount ¶
func (c *Client) GetAccount(ctx context.Context) (*AccountResponse, error)
func (*Client) GetExchangeInfo ¶
func (c *Client) GetExchangeInfo(ctx context.Context) (*ExchangeInfoResponse, error)
func (*Client) GetMark ¶
GetMark returns mark info. If symbol is empty, all option symbols are returned.
func (*Client) GetOpenOrders ¶
func (*Client) GetPositions ¶
GetPositions returns open option positions. symbol filter is optional.
func (*Client) KeepAliveListenKey ¶
func (*Client) PlaceOrder ¶
func (c *Client) PlaceOrder(ctx context.Context, req *OrderRequest) (*OrderResponse, error)
func (*Client) WithCredentials ¶
type ErrorResponse ¶
ErrorResponse — Binance error envelope.
type ExchangeInfoResponse ¶
type ExchangeInfoResponse struct {
Timezone string `json:"timezone"`
ServerTime int64 `json:"serverTime"`
OptionContracts []OptionContract `json:"optionContracts"`
OptionAssets []OptionAsset `json:"optionAssets"`
OptionSymbols []OptionSymbol `json:"optionSymbols"`
}
ExchangeInfoResponse is /eapi/v1/exchangeInfo.
type ListenKeyResponse ¶
type ListenKeyResponse struct {
ListenKey string `json:"listenKey"`
}
type MarkEntry ¶
type MarkEntry struct {
Symbol string `json:"symbol"`
MarkPrice string `json:"markPrice"`
BidIV string `json:"bidIV"`
AskIV string `json:"askIV"`
MarkIV string `json:"markIV"`
Delta string `json:"delta"`
Theta string `json:"theta"`
Gamma string `json:"gamma"`
Vega string `json:"vega"`
HighPriceLimit string `json:"highPriceLimit"`
LowPriceLimit string `json:"lowPriceLimit"`
RiskFreeInterest string `json:"riskFreeInterest"`
}
type MarkResponse ¶
type MarkResponse []MarkEntry
MarkResponse is /eapi/v1/mark — one entry per option symbol queried.
type OptionAsset ¶
type OptionContract ¶
type OptionContract struct {
BaseAsset string `json:"baseAsset"`
QuoteAsset string `json:"quoteAsset"`
Underlying string `json:"underlying"` // e.g. "BTCUSDT"
SettleAsset string `json:"settleAsset"`
ID int64 `json:"id,omitempty"`
}
OptionContract describes one underlying (e.g. BTC) and its quote asset.
type OptionSymbol ¶
type OptionSymbol struct {
Symbol string `json:"symbol"`
Side string `json:"side"` // "CALL" or "PUT"
StrikePrice string `json:"strikePrice"`
Underlying string `json:"underlying"`
Unit int64 `json:"unit"` // 1 (contract size in underlying)
MakerFeeRate string `json:"makerFeeRate"`
TakerFeeRate string `json:"takerFeeRate"`
MinQty string `json:"minQty"`
MaxQty string `json:"maxQty"`
InitialMargin string `json:"initialMargin"`
MaintenanceMargin string `json:"maintenanceMargin"`
MinInitialMargin string `json:"minInitialMargin"`
MinMaintenanceMargin string `json:"minMaintenanceMargin"`
PriceScale int `json:"priceScale"`
QuantityScale int `json:"quantityScale"`
ExpiryDate int64 `json:"expiryDate"` // ms epoch
ID int64 `json:"id,omitempty"`
QuoteAsset string `json:"quoteAsset"`
ContractStatus string `json:"contractStatus,omitempty"`
}
OptionSymbol is one tradable option instrument. Wire format of Symbol: "BTC-251226-100000-C".
type OrderRequest ¶
type OrderRequest struct {
Symbol string // option symbol, e.g. "BTC-251226-100000-C"
Side string // "BUY" or "SELL"
Type string // "LIMIT" or "MARKET"
Quantity string // contracts
Price string // premium, required for LIMIT
TimeInForce string // "GTC", "IOC", "FOK"
ReduceOnly bool
PostOnly bool
ClientOrderID string // user-defined ID
}
OrderRequest is used when placing an order.
type OrderResponse ¶
type OrderResponse struct {
OrderID int64 `json:"orderId"`
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"`
ReduceOnly bool `json:"reduceOnly"`
PostOnly bool `json:"postOnly"`
CreateTime int64 `json:"createTime"`
UpdateTime int64 `json:"updateTime"`
Status string `json:"status"` // "ACCEPTED", "REJECTED", "PARTIALLY_FILLED", "FILLED", "CANCELLED"
AvgPrice string `json:"avgPrice"`
ClientOrderID string `json:"clientOrderId"`
}
OrderResponse — POST/GET /eapi/v1/order.
type PositionEntry ¶
type PositionEntry struct {
EntryPrice string `json:"entryPrice"`
Symbol string `json:"symbol"`
Side string `json:"side"` // "LONG" or "SHORT"
Quantity string `json:"quantity"`
ReducibleQty string `json:"reducibleQty"`
MarkValue string `json:"markValue"`
Ror string `json:"ror"`
UnrealizedPNL string `json:"unrealizedPNL"`
MarkPrice string `json:"markPrice"`
StrikePrice string `json:"strikePrice"`
PositionCost string `json:"positionCost"`
ExpiryDate int64 `json:"expiryDate"`
PriceScale int `json:"priceScale"`
QuantityScale int `json:"quantityScale"`
OptionSide string `json:"optionSide"` // "CALL" or "PUT"
QuoteAsset string `json:"quoteAsset"`
Time int64 `json:"time"`
}
type PositionResponse ¶
type PositionResponse []PositionEntry
PositionResponse is /eapi/v1/position.