Documentation
¶
Index ¶
- Constants
- func Init(ctx context.Context, testNet bool) error
- func ParseSymbol(symbol string) (exchange.OptionSymbol, error)
- type Account
- type CodeC
- type DepthChannel
- type GetOrderReq
- type ListenKeyResp
- type OptionInfo
- type OrderResp
- type OrderStatus
- type Position
- type PositionReq
- type PostOrdreReq
- type RestClient
- func (rc *RestClient) Account(ctx context.Context) ([]Account, error)
- func (rc *RestClient) CancelOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)
- func (rc *RestClient) CreateOrder(ctx context.Context, req *exchange.OrderRequest, ...) (*exchange.Order, error)
- func (rc *RestClient) DeleteListenKey(ctx context.Context) error
- func (rc *RestClient) DeleteOrder(ctx context.Context, req *GetOrderReq) (*OrderResp, error)
- func (rc *RestClient) FetchBalance(ctx context.Context, currencies ...string) ([]exchange.Balance, error)
- func (rc *RestClient) FetchOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)
- func (rc *RestClient) FetchPosition(ctx context.Context, sym ...exchange.Symbol) ([]exchange.Position, error)
- func (rc *RestClient) GetListenKeyAddr(ctx context.Context) (string, error)
- func (rc *RestClient) GetOrder(ctx context.Context, req *GetOrderReq) (*OrderResp, error)
- func (rc *RestClient) GetRequest(ctx context.Context, endPoint string, req binance.GetRestReq, sign bool, ...) error
- func (rc *RestClient) OptionInfo(ctx context.Context) ([]OptionInfo, error)
- func (rc *RestClient) PersistListenKey(ctx context.Context) error
- func (rc *RestClient) Position(ctx context.Context, req *PositionReq) ([]Position, error)
- func (rc *RestClient) PostOrder(ctx context.Context, req *PostOrdreReq) (*OrderResp, error)
- func (rc *RestClient) Symbols(ctx context.Context) ([]exchange.OptionSymbol, error)
- type RestResp
- type Symbol
- type WSClient
Constants ¶
View Source
const ( MethodSubscribe = "SUBSCRIBE" MethodPing = "PING" )
View Source
const ( OrderEndPoint = "/vapi/v1/order" OrderSideBuy = "BUY" OrderSideSell = "SELL" OrderTypeLimit = "LIMIT" OrderTypeMarket = "MARKET" )
View Source
const ( PositionEndPoint = "/vapi/v1/position" PositionSideShort = "SHORT" PositionSideLong = "LONG" )
View Source
const ( OptionInfoEndPoint = "/vapi/v1/optionInfo" SideCall = "CALL" SidePut = "PUT" )
View Source
const (
AccountEndPoint = "/vapi/v1/account"
)
View Source
const (
ListenKeyEndPoint = "/vapi/v1/userDataStream"
)
Variables ¶
This section is empty.
Functions ¶
func ParseSymbol ¶
func ParseSymbol(symbol string) (exchange.OptionSymbol, error)
Types ¶
type Account ¶
type Account struct {
Currency string `json:"currency"`
Equity decimal.Decimal `json:"equity"`
Available decimal.Decimal `json:"available"`
OverMargin decimal.Decimal `json:"overMargin"`
PositionMargin decimal.Decimal `json:"positionMargin"`
UnrealizedPNL decimal.Decimal `json:"unrealizedPNL"`
MaintMargin decimal.Decimal `json:"maintMargin"`
Balance decimal.Decimal `json:"balance"`
}
type DepthChannel ¶
type DepthChannel struct {
// contains filtered or unexported fields
}
func NewDepthChannel ¶
func NewDepthChannel(sym exchange.OptionSymbol, level int) *DepthChannel
func (*DepthChannel) String ¶
func (dc *DepthChannel) String() string
type GetOrderReq ¶
func NewDeleteOrderReq ¶
func NewDeleteOrderReq(symbol string, orderID string) *GetOrderReq
func NewGetOrderReq ¶
func NewGetOrderReq(symbol string) *GetOrderReq
func (*GetOrderReq) ClientOrderID ¶
func (gor *GetOrderReq) ClientOrderID(cid string) *GetOrderReq
func (*GetOrderReq) OrderID ¶
func (gor *GetOrderReq) OrderID(orderId string) *GetOrderReq
type ListenKeyResp ¶
type ListenKeyResp struct {
ListenKey string `json:"listenKey"`
}
type OptionInfo ¶
type OptionInfo struct {
ID int `json:"id"`
ContractID int `json:"contractId"`
Underlying string `json:"underlying"`
QuoteAsset string `json:"quoteAsset"`
Symbol string `json:"symbol"`
Unit decimal.Decimal `json:"unit"`
MinQty decimal.Decimal `json:"minQty"`
MaxQty decimal.Decimal `json:"maxQty"`
PriceScale int `json:"priceScale"`
QuantityScale int `json:"quantityScale"`
Side string `json:"side"`
Leverage decimal.Decimal `json:"leverage"`
StrikePrice decimal.Decimal `json:"strikePrice"`
MakerFeeRate decimal.Decimal `json:"makerFeeRate"`
TakerFeeRate decimal.Decimal `json:"takerFeeRate"`
InitialMargin decimal.Decimal `json:"initialMargin"`
AutoReduceMargin decimal.Decimal `json:"autoReduceMargin"`
MaintenanceMargin decimal.Decimal `json:"maintenanceMargin"`
MinInitialMargin decimal.Decimal `json:"minInitialMargin"`
MinAutoReduceMargin decimal.Decimal `json:"minAutoReduceMargin"`
MinMaintenanceMargin decimal.Decimal `json:"minMaintenanceMargin"`
ExpiryDate int64 `json:"expiryDate"`
}
OptionInfo option info of binance option contract
func (*OptionInfo) Parse ¶
func (oi *OptionInfo) Parse() (*Symbol, error)
type OrderResp ¶
type OrderResp struct {
ID string `json:"id"`
Symbol string `json:"symbol"`
Price decimal.Decimal `json:"price"`
Quantity decimal.Decimal `json:"quantity"`
ExecutedQty decimal.Decimal `json:"executedQty"`
Fee decimal.Decimal `json:"fee"`
Side string `json:"side"`
Type string `json:"type"`
TimeInForce string `json:"timeInForce"`
CreateDate int64 `json:"createDate"`
Status string `json:"status"`
AvgPrice decimal.Decimal `json:"avgPrice"`
Source string `json:"source"`
ReduceOnly bool `json:"reduceOnly"`
ClientOrderID string `json:"clientOrderId"`
}
func ParseOrderResp ¶
ParseOrderResp extract orderResp info from order.Raw field the order param must be get via CreateOrder, FetchOrder, CancelOrder
type OrderStatus ¶
type OrderStatus int
const ( OrderStatusReceived OrderStatus = iota OrderStatusUntriggered OrderStatusAccepted OrderStatusRejected OrderStatusPartiallyFilled OrderStatusFilled OrderStatusCancelling OrderStatusCancelled )
func (OrderStatus) String ¶
func (os OrderStatus) String() string
type Position ¶
type Position struct {
EntryPrice decimal.Decimal `json:"entryPrice"`
Symbol string `json:"symbol"`
Side string `json:"side"`
Leverage int `json:"leverage"`
Quantity decimal.Decimal `json:"quantity"`
ReducibleQty decimal.Decimal `json:"reducibleQty"`
MarkValue decimal.Decimal `json:"markValue"`
AutoReducePriority int `json:"autoReducePriority"`
Ror decimal.Decimal `json:"ror"`
UnrealizedPNL decimal.Decimal `json:"unrealizedPNL"`
MarkPrice decimal.Decimal `json:"markPrice"`
StrikePrice decimal.Decimal `json:"strikePrice"`
ExpiryDate int64 `json:"expiryDate"`
}
type PositionReq ¶
func NewPositionReq ¶
func NewPositionReq() *PositionReq
func (*PositionReq) Symbol ¶
func (pr *PositionReq) Symbol(sym string) *PositionReq
type PostOrdreReq ¶
func NewPostOrderReq ¶
func NewPostOrderReq(symbol string, side string, typ string, amount float64, price float64) (*PostOrdreReq, error)
NewPostOrderReq build create order request, the amount and price param will be formatted according to symbol precision
func (*PostOrdreReq) ReduceOnly ¶
func (or *PostOrdreReq) ReduceOnly(r bool) *PostOrdreReq
type RestClient ¶
type RestClient struct {
*binance.RestClient
// contains filtered or unexported fields
}
func NewRestClient ¶
func NewRestClient(key, secret string) *RestClient
func NewTestRestClient ¶
func NewTestRestClient(key, secret string) *RestClient
func (*RestClient) CancelOrder ¶
func (*RestClient) CreateOrder ¶
func (rc *RestClient) CreateOrder(ctx context.Context, req *exchange.OrderRequest, options ...exchange.OrderReqOption) (*exchange.Order, error)
func (*RestClient) DeleteListenKey ¶
func (rc *RestClient) DeleteListenKey(ctx context.Context) error
func (*RestClient) DeleteOrder ¶
func (rc *RestClient) DeleteOrder(ctx context.Context, req *GetOrderReq) (*OrderResp, error)
func (*RestClient) FetchBalance ¶
func (*RestClient) FetchOrder ¶
func (*RestClient) FetchPosition ¶
func (*RestClient) GetListenKeyAddr ¶
func (rc *RestClient) GetListenKeyAddr(ctx context.Context) (string, error)
func (*RestClient) GetOrder ¶
func (rc *RestClient) GetOrder(ctx context.Context, req *GetOrderReq) (*OrderResp, error)
func (*RestClient) GetRequest ¶
func (rc *RestClient) GetRequest(ctx context.Context, endPoint string, req binance.GetRestReq, sign bool, dst interface{}) error
GetRequest do get request. the dst field will be wrapped in restResp data field
func (*RestClient) OptionInfo ¶
func (rc *RestClient) OptionInfo(ctx context.Context) ([]OptionInfo, error)
func (*RestClient) PersistListenKey ¶
func (rc *RestClient) PersistListenKey(ctx context.Context) error
func (*RestClient) Position ¶
func (rc *RestClient) Position(ctx context.Context, req *PositionReq) ([]Position, error)
func (*RestClient) PostOrder ¶
func (rc *RestClient) PostOrder(ctx context.Context, req *PostOrdreReq) (*OrderResp, error)
func (*RestClient) Symbols ¶
func (rc *RestClient) Symbols(ctx context.Context) ([]exchange.OptionSymbol, error)
type Symbol ¶
type Symbol struct {
*exchange.BaseOptionSymbol
// contains filtered or unexported fields
}
Symbol implement OptionSymbol interface
type WSClient ¶
func NewTestWSClient ¶
NewTestWSClient return a wsclient which connect to binance option testnet
Click to show internal directories.
Click to hide internal directories.