option

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

Documentation

Index

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 Init

func Init(ctx context.Context, testNet bool) error

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 CodeC

type CodeC struct {
}

func NewCodeC

func NewCodeC() *CodeC

func (*CodeC) Decode

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

func (*CodeC) Encode

func (cc *CodeC) Encode(rpc rpc.Request) ([]byte, error)

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

type GetOrderReq struct {
	*binance.RestReq
}

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

func ParseOrderResp(order *exchange.Order) (*OrderResp, error)

ParseOrderResp extract orderResp info from order.Raw field the order param must be get via CreateOrder, FetchOrder, CancelOrder

func (*OrderResp) Transfer

func (resp *OrderResp) Transfer() (*exchange.Order, error)

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"`
}

func (*Position) Transfer

func (p *Position) Transfer() (*exchange.Position, error)

type PositionReq

type PositionReq struct {
	*binance.RestReq
}

func NewPositionReq

func NewPositionReq() *PositionReq

func (*PositionReq) Symbol

func (pr *PositionReq) Symbol(sym string) *PositionReq

type PostOrdreReq

type PostOrdreReq struct {
	*binance.RestReq
}

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

func (rc *RestClient) Account(ctx context.Context) ([]Account, error)

func (*RestClient) CancelOrder

func (rc *RestClient) CancelOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)

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 (rc *RestClient) FetchBalance(ctx context.Context, currencies ...string) ([]exchange.Balance, error)

func (*RestClient) FetchOrder

func (rc *RestClient) FetchOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)

func (*RestClient) FetchPosition

func (rc *RestClient) FetchPosition(ctx context.Context, sym ...exchange.Symbol) ([]exchange.Position, error)

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 RestResp

type RestResp struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type Symbol

type Symbol struct {
	*exchange.BaseOptionSymbol
	// contains filtered or unexported fields
}

Symbol implement OptionSymbol interface

func (*Symbol) String

func (s *Symbol) String() string

type WSClient

type WSClient struct {
	*binance.WSClient
	// contains filtered or unexported fields
}

func NewTestWSClient

func NewTestWSClient(data chan interface{}, key, secret string) *WSClient

NewTestWSClient return a wsclient which connect to binance option testnet

func (*WSClient) Handle

func (wl *WSClient) Handle(ctx context.Context, notify *rpc.Notify)

func (*WSClient) Subscribe

func (wl *WSClient) Subscribe(ctx context.Context, channels ...exchange.Channel) error

Jump to

Keyboard shortcuts

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