Documentation ¶
Index ¶
- Constants
- Variables
- func Init(ctx context.Context) error
- func InitTest(ctx context.Context) error
- func ParseSymbol(symbol string) (exchange.SwapSymbol, error)
- func UpdateSymbolMap(ctx context.Context) error
- type AccountAsset
- type AccountPosition
- type AccountReq
- type AccountResp
- type AddOrderReq
- type BookTickerChannel
- type BookTickerNotify
- type CodeC
- type CommisionRate
- type ExchangeInfo
- type Filter
- type GetPositionSideRequest
- type GetPositionSideResp
- type Income
- type IncomeType
- type OrderReq
- type OrderResp
- type RestClient
- func (rc *RestClient) Account(ctx context.Context, req *AccountReq) (*AccountResp, error)
- func (cl *RestClient) AddOrder(ctx context.Context, req *AddOrderReq) (*OrderResp, error)
- func (cl *RestClient) CancelOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)
- func (rc *RestClient) CommisionRate(ctx context.Context, symbol string) (*CommisionRate, error)
- func (cl *RestClient) CreateOrder(ctx context.Context, req *exchange.OrderRequest) (*exchange.Order, error)
- func (cl *RestClient) DeleteOrder(ctx context.Context, req *OrderReq) (*OrderResp, error)
- func (rc *RestClient) ExchangeInfo(ctx context.Context) (*ExchangeInfo, error)
- func (rc *RestClient) FeeRate(ctx context.Context, symbols []exchange.Symbol) ([]*exchange.TradeFee, error)
- func (cl *RestClient) FetchOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)
- func (rc *RestClient) Finance(ctx context.Context, req *exchange.FinanceReqParam) ([]exchange.Finance, error)
- func (cl *RestClient) GetOrder(ctx context.Context, req *OrderReq) (*OrderResp, error)
- func (rc *RestClient) GetPositionSide(ctx context.Context, req *GetPositionSideRequest) (*GetPositionSideResp, error)
- func (rc *RestClient) Income(ctx context.Context, symbol string, it IncomeType, st int64, et int64, ...) ([]Income, error)
- func (rc *RestClient) Property() exchange.Property
- func (rc *RestClient) SetPositionSide(ctx context.Context, req *SetPositionSideRequest) error
- func (rc *RestClient) Symbols(ctx context.Context) ([]exchange.SwapSymbol, error)
- func (rc *RestClient) Trades(ctx context.Context, req *exchange.TradeReqParam) ([]exchange.Trade, error)
- func (rc *RestClient) UserTrades(ctx context.Context, symbol string, st int64, et int64, fid int64, limit int) ([]Trade, error)
- type SetPositionSideRequest
- type SetPositionSideResp
- type SwapSymbol
- type Symbol
- type Trade
- type WSClient
Constants ¶
View Source
const ( SwapAPIHost string = "fapi.binance.com" SwapTestAPIHost string = "testnet.binancefuture.com" )
View Source
const ( OrderEndPoint = "/fapi/v1/order" PositionSideBoth = "BOTH" PositionSideLong = "LONG" PositionSideShort = "SHORT" SideBuy = "BUY" SideSell = "SELL" OrderTypeMarket = "MARKET" OrderTypeLimit = "LIMIT" TimeInForce = "GTC" )
View Source
const (
AccountEndPoint = "/fapi/v2/account"
)
View Source
const (
CommiionRateEndPoint = "/fapi/v1/commissionRate"
)
View Source
const (
IncomeEndPoint = "/fapi/v1/income"
)
View Source
const (
PositionSidePath = "/fapi/v1/positionSide/dual"
)
View Source
const (
UserTradesEndPoint = "/fapi/v1/userTrades"
)
View Source
const (
WSClientEndPoint = "wss://fstream.binance.com/ws"
)
Variables ¶
View Source
var ( OrderType2ExType = map[string]exchange.OrderType{ OrderTypeLimit: exchange.OrderTypeLimit, OrderTypeMarket: exchange.OrderTypeMarket, } ExType2OrderType = map[exchange.OrderType]string{ exchange.OrderTypeLimit: OrderTypeLimit, exchange.OrderTypeMarket: OrderTypeMarket, } Status2ExStatus = map[string]exchange.OrderStatus{ "NEW": exchange.OrderStatusOpen, "PARTIALLY_FILLED ": exchange.OrderStatusOpen, "FILLED": exchange.OrderStatusDone, "CANCELED": exchange.OrderStatusCancel, "REJECTED": exchange.OrderStatusFailed, "EXPIRED": exchange.OrderStatusFailed, } )
Functions ¶
func ParseSymbol ¶ added in v0.3.0
func ParseSymbol(symbol string) (exchange.SwapSymbol, error)
func UpdateSymbolMap ¶ added in v0.5.5
Types ¶
type AccountAsset ¶ added in v0.5.5
type AccountAsset struct { Asset string `json:"asset"` WalletBalance decimal.Decimal `json:"walletBalance"` UnrealizedProfit decimal.Decimal `json:"unrealizedProfit"` MarginBalance decimal.Decimal `json:"marginBalance"` InitialMargin decimal.Decimal `json:"initialMargin"` PositionInitialMargin decimal.Decimal `json:"positionInitialMargin"` OpenOrderInitialMargin decimal.Decimal `json:"openOrderInitialMargin"` CrossWalletBalance decimal.Decimal `json:"crossWalletBalance"` CrossUnPNL decimal.Decimal `json:"crossUnPnl"` AvailableBalance decimal.Decimal `json:"availableBalance"` MaxWithdrawAmount decimal.Decimal `json:"maxWithdrawAmount"` MarginAvailable bool `json:"marginAvailable"` UpdateTime int64 `json:"updateTime"` }
type AccountPosition ¶ added in v0.5.5
type AccountPosition struct { Symbol string `json:"symbol"` InitialMargin decimal.Decimal `json:"initialMargin"` MaintMargin decimal.Decimal `json:"maintMargin"` UnrealizedProfit decimal.Decimal `json:"unrealizedProfit"` PositionInitialMargin decimal.Decimal `json:"positionInitialMargin"` OpenOrderInitialMargin decimal.Decimal `json:"openOrderInitialMargin"` Leverage decimal.Decimal `json:"leverage"` Isolated bool `json:"isolated"` EntryPrice decimal.Decimal `json:"entryPrice"` MaxNotional decimal.Decimal `json:"maxNotional"` PositionSide string `json:"positionSide"` PositionAmt decimal.Decimal `json:"positionAmt"` UpdateTime int64 `json:"updateTime"` }
type AccountReq ¶ added in v0.5.5
func NewAccountReq ¶ added in v0.5.5
func NewAccountReq() *AccountReq
type AccountResp ¶ added in v0.5.5
type AccountResp struct { binance.APIError //in case of error FeeTier int `json:"feeTier"` CanTrade bool `json:"canTrade"` CanDeposit bool `json:"canDeposit"` CanWithdraw bool `json:"canWithdraw"` UpdateTime int64 `json:"updateTime"` TotalInitialMargin decimal.Decimal `json:"totalInitialMargin"` TotalMaintMargin decimal.Decimal `json:"totalMaintMargin"` TotalWalletBalance decimal.Decimal `json:"totalWalletBalance"` TotalUnrealizedProfit decimal.Decimal `json:"totalUnrealizedPorfit"` TotalMarginBalance decimal.Decimal `json:"totalMarginBalance"` TotalPositionInitialMargin decimal.Decimal `json:"totalPositionInitialMargin"` Assets []AccountAsset `json:"assets"` Positions []AccountPosition `json:"positions"` }
func (*AccountResp) GetAsset ¶ added in v0.5.5
func (ar *AccountResp) GetAsset(currency string) (*AccountAsset, error)
func (*AccountResp) GetPosition ¶ added in v0.5.5
func (ar *AccountResp) GetPosition(symbol string) ([]AccountPosition, error)
type AddOrderReq ¶ added in v0.5.5
func NewAddOrderReq ¶ added in v0.5.5
func NewAddOrderReq(symbol string, side string, typ string) *AddOrderReq
NewAddOrderReq according symbol, side, type
func (*AddOrderReq) PositionSide ¶ added in v0.5.5
func (req *AddOrderReq) PositionSide(side string) *AddOrderReq
func (*AddOrderReq) Price ¶ added in v0.5.5
func (req *AddOrderReq) Price(prc decimal.Decimal) *AddOrderReq
func (*AddOrderReq) Quantity ¶ added in v0.5.5
func (req *AddOrderReq) Quantity(q decimal.Decimal) *AddOrderReq
func (*AddOrderReq) TimeInForce ¶ added in v0.5.5
func (req *AddOrderReq) TimeInForce(tif string) *AddOrderReq
type BookTickerChannel ¶ added in v0.5.8
type BookTickerChannel struct {
// contains filtered or unexported fields
}
func NewBookTickerChannel ¶ added in v0.5.8
func NewBookTickerChannel(sym string) *BookTickerChannel
func (*BookTickerChannel) String ¶ added in v0.5.8
func (btc *BookTickerChannel) String() string
type BookTickerNotify ¶ added in v0.5.8
type BookTickerNotify struct { Event string `json:"e"` UpdateID int64 `json:"u"` PushTime int64 `json:"E"` MatchTime int64 `json:"T"` Symbol string `json:"s"` Bid1Price string `json:"b"` Bid1Amount string `json:"B"` Ask1Price string `json:"a"` Ask1Amount string `json:"A"` }
func ParseBookTickerNotify ¶ added in v0.5.8
func ParseBookTickerNotify(g *gjson.Result) *BookTickerNotify
type CommisionRate ¶ added in v0.3.0
type ExchangeInfo ¶ added in v0.3.0
type ExchangeInfo struct { Timezone string `json:"timezone"` ServerTime int64 `json:"serverTime"` Symbols []Symbol `json:"symbols"` }
TODO add additinoal field parse
type Filter ¶ added in v0.3.0
type Filter struct { MinPrice decimal.Decimal `json:"minPrice"` MaxPrice decimal.Decimal `json:"maxPrice"` FilterType string `json:"filterType"` TickSize decimal.Decimal `json:"tickSize"` StepSize decimal.Decimal `json:"stepSize"` MaxQty decimal.Decimal `json:"maxQty"` MinQty decimal.Decimal `json:"minQty"` Limit int `json:"limit"` MultiplierDown decimal.Decimal `json:"multiplierDown"` MultiplierUp decimal.Decimal `json:"multiplierUp"` MultiplierDecimal decimal.Decimal `json:"multiplierDecimal"` Notional decimal.Decimal `json:"notional"` }
type GetPositionSideRequest ¶ added in v0.5.5
func NewGetPositionSideRequest ¶ added in v0.5.5
func NewGetPositionSideRequest() *GetPositionSideRequest
type GetPositionSideResp ¶ added in v0.5.5
type Income ¶ added in v0.3.0
type IncomeType ¶ added in v0.3.0
type IncomeType string
const ( IncomeTypeNone IncomeType = "" IncomeTypeTransfer IncomeType = "TRANSFER" IncomeTypeWelcomeBonus IncomeType = "WELCOME_BONUS" IncomeTypeRealizedPnl IncomeType = "REALIZED_PNL" IncomeTypeFundingFee IncomeType = "FUNDING_FEE" IncomeTypeCommission IncomeType = "COMMISSION" IncomeTypeInsuranceClear IncomeType = "INSURANCE_CLEAR" )
func (IncomeType) Parse ¶ added in v0.3.0
func (ic IncomeType) Parse() exchange.FinanceType
type OrderReq ¶ added in v0.5.5
func NewOrderReq ¶ added in v0.5.5
type OrderResp ¶ added in v0.5.5
type OrderResp struct { binance.APIError //in case of error ClientOrderID string `json:"newOrderId"` CumQty decimal.Decimal `json:"cumQty"` CumQuote decimal.Decimal `json:"cumQuote"` ExecutedQty decimal.Decimal `json:"executedQty"` OrderID int64 `json:"orderId"` AvgPrice decimal.Decimal `json:"avgPrice"` OrigQty decimal.Decimal `json:"origQty"` Price decimal.Decimal `json:"price"` ReduceOnly bool `json:"reduceOnly"` Side string `json:"side"` PositionSide string `json:"positionSide"` Status string `json:"status"` StopPrice decimal.Decimal `json:"stopPrice"` ClosePosition bool `json:"closePosition"` Symbol string `json:"symbol"` TimeInForce string `json:"timeInForce"` Type string `json:"type"` OrigType string `json:"origType"` ActivatePrice decimal.Decimal `json:"activatePrice"` PriceRate decimal.Decimal `json:"priceRate"` UpdateTime int64 `json:"updateTime"` WorkingType string `json:"workingType"` PriceProtect bool `json:"priceProtect"` }
type RestClient ¶
type RestClient struct { *binance.RestClient // contains filtered or unexported fields }
RestClient struct
func NewRestClient ¶
func NewRestClient(key, secret string) *RestClient
func NewTestRestClient ¶ added in v0.5.5
func NewTestRestClient(key, secret string) *RestClient
func (*RestClient) Account ¶ added in v0.5.5
func (rc *RestClient) Account(ctx context.Context, req *AccountReq) (*AccountResp, error)
func (*RestClient) AddOrder ¶ added in v0.5.5
func (cl *RestClient) AddOrder(ctx context.Context, req *AddOrderReq) (*OrderResp, error)
func (*RestClient) CancelOrder ¶ added in v0.5.5
func (*RestClient) CommisionRate ¶ added in v0.3.0
func (rc *RestClient) CommisionRate(ctx context.Context, symbol string) (*CommisionRate, error)
func (*RestClient) CreateOrder ¶ added in v0.5.5
func (cl *RestClient) CreateOrder(ctx context.Context, req *exchange.OrderRequest) (*exchange.Order, error)
func (*RestClient) DeleteOrder ¶ added in v0.5.5
func (*RestClient) ExchangeInfo ¶ added in v0.3.0
func (rc *RestClient) ExchangeInfo(ctx context.Context) (*ExchangeInfo, error)
func (*RestClient) FetchOrder ¶ added in v0.5.5
func (*RestClient) Finance ¶ added in v0.3.0
func (rc *RestClient) Finance(ctx context.Context, req *exchange.FinanceReqParam) ([]exchange.Finance, error)
func (*RestClient) GetPositionSide ¶ added in v0.5.5
func (rc *RestClient) GetPositionSide(ctx context.Context, req *GetPositionSideRequest) (*GetPositionSideResp, error)
func (*RestClient) Income ¶ added in v0.3.0
func (rc *RestClient) Income(ctx context.Context, symbol string, it IncomeType, st int64, et int64, limit int) ([]Income, error)
func (*RestClient) Property ¶ added in v0.3.0
func (rc *RestClient) Property() exchange.Property
func (*RestClient) SetPositionSide ¶ added in v0.5.5
func (rc *RestClient) SetPositionSide(ctx context.Context, req *SetPositionSideRequest) error
func (*RestClient) Symbols ¶
func (rc *RestClient) Symbols(ctx context.Context) ([]exchange.SwapSymbol, error)
func (*RestClient) Trades ¶ added in v0.3.0
func (rc *RestClient) Trades(ctx context.Context, req *exchange.TradeReqParam) ([]exchange.Trade, error)
type SetPositionSideRequest ¶ added in v0.5.5
func NewSetPositionSideRequest ¶ added in v0.5.5
func NewSetPositionSideRequest(dualSide bool) *SetPositionSideRequest
type SetPositionSideResp ¶ added in v0.5.5
type SwapSymbol ¶
type SwapSymbol struct { *exchange.BaseSwapSymbol Symbol string }
func (*SwapSymbol) String ¶
func (s *SwapSymbol) String() string
type Symbol ¶ added in v0.3.0
type Symbol struct { Symbol string `json:"symbol"` Status string `json:"status"` MaintMarginPercent decimal.Decimal `json:"maintMarginPercent"` RequiredMarginPercent decimal.Decimal `json:"requiredMarginPercent"` BaseAsset string `json:"baseAsset"` QuoteAsset string `json:"quoteAsset"` PricePrecision int `json:"pricePrecision"` QuantityPrecision int `json:"quantityPrecision"` BaseAssetPrecision int `json:"baseAssetPrecision"` QuotePrecision int `json:"quotePrecision"` UnderlyingType string `json:"COIN"` Filters []Filter `json:"filters"` OrderTypes []string `json:"orderTypes"` TimeInForce []string `json:"timeInForce"` }
type Trade ¶ added in v0.3.0
type Trade struct { Symbol string `json:"symbol"` ID int64 `json:"id"` OrderID int64 `json:"orderId"` Price decimal.Decimal `json:"price"` Qty decimal.Decimal `json:"qty"` QuoteQty decimal.Decimal `json:"quoteQty"` Commission decimal.Decimal `json:"commission"` CommissionAsset string `json:"commissionAsset"` RealizedPnl decimal.Decimal `json:"realizedPnl"` Side string `json:"SIDE"` PositionSide string `json:"positionSide"` Time int64 `json:"time"` Maker bool `json:"Maker"` }
type WSClient ¶ added in v0.5.8
type WSClient struct {
*binance.NotifyClient
}
func NewWSClient ¶ added in v0.5.8
func NewWSClient(data chan interface{}) *WSClient
Click to show internal directories.
Click to hide internal directories.