binance

package module
v0.0.0-...-eddac47 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 22 Imported by: 0

README

Binance

Go Report Card Go Doc

About the package

This package provides an unofficial client library to interface with Binance's REST API. I am in no way affiliated with Binance.

This package is a work in progress, and not fully tested. Use at your own risk.

I am following the API documentation for Binance found here.

Contributions are welcome.

Example Usage

import (
	"github.com/nickcorin/binance"
)

func main() {
	// Create a new client with an API Key and Secret Key.
	client := binance.NewClient(
		binance.WithAPIKey("MyKey"),
		binance.WithSecretKey("MySecret"),
	)

	// Create an order request.
	req := binance.NewOrderRequest{
		Price:			0.81,
		Side:			binance.OrderSideBuy,
		Symbol:			"ETHBTC",
		TimeInForce:	binance.GTC,
		Type:			binance.OrderTypeLimit,
		Quantity:		0.5,
	}

	// Test the order.
	err := client.NewOrderTest(context.Background(), &req)
	if err != nil {
		log.Fatal(err)
	}

	// Place the order.
	res, err := client.NewOrder(context.Background(), &req) 
	if err != nil {
		log.Fatal(err)
	}
}

Supported Endpoints

Public API
  • Ping
  • Server Time
  • Exchange Info
Market Data
  • Order Book
  • Recent Trades
  • Old Trade Data
  • Aggregated Trades
  • Kline / Candlestick Data
  • Current Average Price
  • 24 Hour Ticker
  • Price Ticker
  • Order Book Ticker
Account
  • New Order
  • Test New Order
  • Query Order
  • Cancel Order
  • Current Open Orders
  • All Orders
  • New OCO
  • Cancel OCO
  • Query OCO
  • Query All OCO
  • Query Open OCO
  • Account Info
  • Account Trade List

Donations

If this package helped you out, feel free to donate.

  • BTC: 34vfza4AWUsYtSG2zheNntrUtHircvkgUC
  • BCH: pq8lwev3qykw3yqcfrrcelzafd0uact3wyjp3j3pnc
  • ETH: 0xa9a84846b43FAb5d3694222De29F0973FDfc07a2

Documentation

Overview

Package binance provides an HTTP Client implementation for the Binance REST API.

It records system metrics using Prometheus by default.

Index

Constants

View Source
const (
	OrderResponseTypeAck    = "ACK"
	OrderResponseTypeResult = "RESULT"
	OrderResponseTypeFull   = "FULL"
)

Enumerated types for OrderResponseType.

View Source
const (
	// GoodUntilCancelled keeps the order active until explicitly
	// cancelled.
	GoodUntilCancelled = "GTC"

	// FillOrKill cancels the order if it is not executed as soon as it
	// becomes available. This is usually to ensure that the order is
	// filled at a single price.
	FillOrKill = "FOK"

	// ImmediateOrCancel cancels the order if it cannot be completely
	// filled immediately.
	ImmediateOrCancel = "IOC"
)
View Source
const HeaderAPIKey = "X-MBX-APIKEY"

HeaderAPIKey defines the request header to set with the client's API key.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	AccountType      string    `json:"accountType"`
	Balances         []Balance `json:"balances"`
	BuyerCommission  int       `json:"buyerCommission"`
	CanDeposit       bool      `json:"canDesposit"`
	CanTrade         bool      `json:"canTrade"`
	CanWithdraw      bool      `json:"canWithdraw"`
	MakerCommission  int       `json:"makerCommission"`
	SellerCommission int       `json:"sellerCommission"`
	TakerCommission  int       `json:"takerCommission"`
	UpdateTime       int64     `json:"updateTime"`
}

AccountInfo contains all information pertaining to a user's account.

type Balance

type Balance struct {
	Asset  string
	Free   float64
	Locked float64
}

Balance contains a breakdown of a wallet's funds.

type CancelOrderRequest

type CancelOrderRequest struct {
	// NewClientOrderID represents the unique identifier for this cancel.
	// Randomly generated string if not provided.
	NewClientOrderID string `schema:"newClientOrderId,omitempty"`

	// OrderID represents the unique identifier provided by Binance on order
	// creation.
	//
	// Either OrderID or OrigClientOrderID must be sent.
	OrderID int64 `schema:"orderId,omitempty"`

	// OrigClientOrderID is the unique identifier provided by the client on
	// order created.
	//
	// Either OrderID or OrigClientOrderID must be sent.
	OrigClientOrderID string `schema:"origClientOrderId,omitempty"`

	// Symbol represents the market the order was placed on.
	Symbol string `schema:"symbol"`
}

CancelOrderRequest contains the parameters for cancelling an open order.

type CancelOrderResponse

type CancelOrderResponse struct {
	// ClientOrderID represents the unique identifier provided by the client on
	// order creation.
	ClientOrderID       string `json:"clientOrderId"`
	CummulativeQuoteQty string `json:"cummulativeQuoteQty"`

	// ExecutedQty represents how much of the original quantity has been
	// executed.
	ExecutedQty string `json:"executedQty"`

	// OrderID represents the unique identifier provided by Binance on order
	// creation.
	OrderID int64 `json:"orderId"`

	// OrderListID will always be -1 if the order was not an OCO order.
	OrderListID int64 `json:"orderListId"`

	// OriginalQty represents the original amount the order was placed for.
	OriginalQty string `json:"origQty"`
	// Price represents the price that the order was placed at.
	Price string `json:"price"`

	// Side represents whether the order was a buy or sell.
	Side OrderSide `json:"side"`

	// Status represents the current status of the order.
	Status OrderStatus `json:"status"`

	// Symbol represents the market the order was placed on.
	Symbol string `json:"symbol"`

	// TimeInForce represents the duration of validity of the order.
	TimeInForce TimeInForce `json:"timeInForce"`

	// Type represents the type of the order.
	Type OrderType `json:"type"`
}

CancelOrderResponse contains information about an order that was cancelled on the exchange.

type Client

Client provides the methods relating to Binance's REST API.

func NewClient

func NewClient(opts ...ClientOption) Client

NewClient returns a Client implementation.

type ClientOption

type ClientOption func(*ClientOptions)

ClientOption is a func-to-ClientOption adapter.

func WithAPIKey

func WithAPIKey(key string) ClientOption

WithAPIKey returns a ClientOption to set the API Key a Client uses to authenticate requests. Not using this option will cause all authenticated requests to fail.

func WithBaseURL

func WithBaseURL(url string) ClientOption

WithBaseURL returns a ClientOption to set the prefix a Client uses to prefix request. This is useful for testing.

func WithLogLevel

func WithLogLevel(level LogLevel) ClientOption

WithLogLevel returns a ClientOption to set the verbosity of a Client's logs. Defaults to `LogLevelNone`.

func WithSecretKey

func WithSecretKey(key string) ClientOption

WithSecretKey returns a ClientOption to set the secret key a Client uses to generate request signatures. Not using this option will cause all signed requests to fail.

func WithTransport

func WithTransport(transport *http.Client) ClientOption

WithTransport returns a client option to set the underlying HTTP Client used for requests. Defaults to the DefaultClient.

type ClientOptions

type ClientOptions struct {
	// contains filtered or unexported fields
}

ClientOptions provides configurable fields for Client.

type Error

type Error struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"msg"`
}

Error defines the structured error that is returned in some reponses.

More information regarding errors can be found in the error codes documentation:

https://github.com/binance-exchange/binance-official-api-docs/blob/master/errors.md

func (Error) Error

func (e Error) Error() string

Error returns the error as a string. Satisfied the stdlib error interface.

func (Error) Is

func (e Error) Is(code ErrorCode) bool

Is allows easy comparisons to be done between an Error and ErrorCode.

func (Error) IsAny

func (e Error) IsAny(codes ...ErrorCode) bool

IsAny returns whether `e` is contained within a list of ErrorCode types.

type ErrorCode

type ErrorCode int

ErrorCode defines a more granular error type that can be returned from the API.

var (
	ErrUnknown                        ErrorCode = -1000
	ErrDisconnected                   ErrorCode = -1001
	ErrUnauthorized                   ErrorCode = -1002
	ErrTooManyRequests                ErrorCode = -1003
	ErrUnexpectedResponse             ErrorCode = -1006
	ErrTimeout                        ErrorCode = -1007
	ErrUnknownOrderComposition        ErrorCode = -1014
	ErrTooManyOrders                  ErrorCode = -1015
	ErrServiceShuttingDown            ErrorCode = -1016
	ErrUnsupportedOperation           ErrorCode = -1020
	ErrInvalidTimestamp               ErrorCode = -1021
	ErrInvalidSignature               ErrorCode = -1022
	ErrIllegalChars                   ErrorCode = -1100
	ErrTooManyParams                  ErrorCode = -1101
	ErrMandatoryParamEmptyOrMalformed ErrorCode = -1102
	ErrUnknownParam                   ErrorCode = -1103
	ErrUnreadParams                   ErrorCode = -1104
	ErrParamEmpty                     ErrorCode = -1105
	ErrParamNotRequired               ErrorCode = -1106
	ErrBadPrecision                   ErrorCode = -1111
	ErrNoDepth                        ErrorCode = -1112
	ErrTIFNotRequired                 ErrorCode = -1114
	ErrInvalidTIF                     ErrorCode = -1115
	ErrInvalidOrderType               ErrorCode = -1116
	ErrInvalidSide                    ErrorCode = -1117
	ErrEmptyNewClientOrderID          ErrorCode = -1118
	ErrEmptyOriginalClientOrderID     ErrorCode = -1119
	ErrBadInterval                    ErrorCode = -1120
	ErrBadSymbol                      ErrorCode = -1121
	ErrInvalidListenKey               ErrorCode = -1125
	ErrMoreThanXHours                 ErrorCode = -1127
	ErrOptionalParamsBadCombo         ErrorCode = -1128
	ErrInvalidParam                   ErrorCode = -1130
	ErrNewOrderRejected               ErrorCode = -2010
	ErrCancelRejected                 ErrorCode = -2011
	ErrNoSuchOrder                    ErrorCode = -2013
	ErrAPIKeyFormat                   ErrorCode = -2014
	ErrRejectedMBXKey                 ErrorCode = -2015
	ErrNoTradingWindow                ErrorCode = -2016
)

type Kline

type Kline struct {
	Close             string
	CloseTime         int64
	High              string
	OpenTime          int64
	Open              string
	Low               string
	QuoteassertVolume string
	TradeCount        int64
	Volume            string
}

Kline contains kline / candlestick data.

func (*Kline) UnmarshalJSON

func (k *Kline) UnmarshalJSON(data []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface for the Kline type.

type KlineInterval

type KlineInterval string

KlineInterval represents the time interval aggregated per candlestick.

const (
	OneMinute      KlineInterval = "1m"
	ThreeMinutes   KlineInterval = "3m"
	FiveMinutes    KlineInterval = "5m"
	FifteenMinutes KlineInterval = "15m"
	ThirtyMinutes  KlineInterval = "30m"
	OneHour        KlineInterval = "1h"
	TwoHours       KlineInterval = "2h"
	FourHours      KlineInterval = "4h"
	SixHours       KlineInterval = "6h"
	EightHours     KlineInterval = "8h"
	TwelveHours    KlineInterval = "12h"
	OneDay         KlineInterval = "1d"
	ThreeDays      KlineInterval = "3d"
	OneWeek        KlineInterval = "1w"
	OneMonth       KlineInterval = "1M"
)

Enumerated types for KlineInterval.

type KlinesRequest

type KlinesRequest struct {
	// EndTime represents the time to query until.
	//
	// If startTime and endTime is not sent, the most recent klines are
	// returned.
	EndTime int64 `schema:"endTime,omitempty"`

	// Interval represents the time interval to aggregate trades.
	//
	// Required.
	Interval KlineInterval `schema:"interval"`

	// Limit represents the maximum amount of klines to query.
	//
	// Default: 500.
	// Max: 1000.
	Limit int64 `schema:"limit,omitempty"`

	// StartTime represents the time to query from.
	//
	// If startTime and endTime is not sent, the most recent klines are
	// returned.
	StartTime int64 `schema:"startTime,omitempty"`

	// Symbol represents the market to query.
	//
	// Required.
	Symbol string `schema:"symbol"`
}

KlinesRequest contains the parameters to query kline / candlestick data.

type LogLevel

type LogLevel int

LogLevel configures the extent to which a Client should write output logs.

const (
	// LogLevelNone disables logging.
	LogLevelNone LogLevel = 0

	// LogLevelError only logs errors.
	LogLevelError LogLevel = 1

	// LogLevelDebug logs most activity.
	LogLevelDebug LogLevel = 2
)

func (LogLevel) Valid

func (level LogLevel) Valid() bool

Valid returns whether `level` is a declared LogLevel constant.

type NewOrderRequest

type NewOrderRequest struct {
	// ResponseType represents the kind of response you want to receive back.
	//
	// Optional.
	// Default: ACK for orders of type LIMIT or MARKET, FULL otherwise.
	ResponseType OrderResponseType `schema:"newOrderRespType,omitempty"`

	// ReceiveWindow represents the duration of validity in ms of the request.
	//
	// Optional.
	// Default: 5000ms. Maximum: 60000ms.
	ReceiveWindow int64 `schema:"recvWindow,omitempty"`

	// IcebergQty represents the maximum amount per sub-order until the total
	// quantity of the order has been filled. Orders with type LIMIT or
	// LIMIT_MAKER are automatically made an iceberg order if an IcebergQty is
	// sent. Any order with IcebergQty set, MUST have it's TimeInForce set to
	// GTC.
	//
	// Optional.
	IcebergQty float64 `schema:"icebergQty,omitempty"`

	// Price represents the price at which to place the order.
	//
	// Required for orders of type LIMIT, STOP_LOSS_LIMIT and TAKE_PROFIT_LIMIT.
	Price float64 `schema:"price,omitempty"`

	// NewClientOrderID represents a unique identifier for the order, supplied
	// by the client.
	//
	// Optional.
	// Default is a randomly generated string.
	NewClientOrderID string `schema:"newClientOrderId,omitempty"`

	// Qty represents the quantity to buy or sell.
	//
	// Required for orders of type MARKET, STOP_LOSS, TAKE_PROFIT and
	// LIMIT_MAKER.
	Qty float64 `schema:"quantity,omitempty"`

	// Required for order of type MARKET if Qty is not set.
	QuoteOrderQty float64 `schema:"quoteOrderQty,omitempty"`

	// Side represents whether this order is a buy or sell.
	//
	// Required for all order types.
	Side OrderSide `schema:"side"`

	// StopPrice represents the price the market needs to reach before placing
	// the order as a market order.
	//
	// Required for orders of type STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT and
	// TAKE_PROFIT_LIMIT.
	StopPrice float64 `schema:"stopPrice,omitempty"`

	// Symbol represents the market to place the order on.
	//
	// Required for all order types.
	Symbol string `schema:"symbol"`

	// Type represents what kind of order to place.
	//
	// Required for all order types.
	Type OrderType `schema:"type"`

	// TimeInForce represents the duration of validity of the order.
	//
	// Required for orders of type LIMIT, STOP_LOSS_LIMIT and TAKE_PROFIT_LIMIT.
	TimeInForce TimeInForce `schema:"timeInForce,omitempty"`
}

NewOrderRequest contains all request parameters for creating a new order.

type NewOrderResponse

type NewOrderResponse struct {
	// ClientOrderID represents the unique identifier for the order, sent by
	// the client on creation. If NewClientOrderID was empty in the request,
	// this will be a randomly generated string.
	ClientOrderID       string `json:"clientOrderId"`
	CummulativeQuoteQty string `json:"cummulativeQuoteQty,omitempty"`

	// ExecutedQty represents how much of the original quantity has been
	// executed.
	//
	// Returned with response types RESULT and FULL.
	ExecutedQty string `json:"executedQty,omitempty"`

	// Fills contains sub-orders executed in order to fully execute an order.
	//
	// Returned wtih response type FULL.
	Fills []OrderFill `json:"fills,omitempty"`

	// OrderID represents a unique identifier for the order, generated by
	// Binance.
	OrderID int64 `json:"orderId"`

	// OrderListID will always be -1 if the order was not an OCO order.
	OrderListID int64 `json:"orderListId"`

	// OriginalQty represents the original quantity the order was placed for.
	//
	// Returned with response types RESULT and FULL.
	OriginalQty string `json:"origQty,omitempty"`

	// Price represents the price at which the order was placed.
	//
	// Returned with response types RESULT and FULL.
	Price string `json:"price,omitempty"`

	// Side represents whether the order was a buy or sell.
	//
	// Returned with response types RESULT and FULL.
	Side OrderSide `json:"side,omitempty"`

	// Status represents the current status of the order.
	//
	// Returned with response types RESULT and FULL.
	Status OrderStatus `json:"status,omitempty"`

	// Symbol represents the market the order was placed on.
	Symbol string `json:"symbol"`

	// TimeInForce represents the duration of validity of the order.
	//
	// Returned with response types RESULT and FULL.
	TimeInForce TimeInForce `json:"timeInForce,omitempty"`

	// TransactTime represents the unix timestamp in milliseconds of the time
	// the order was placed.
	//
	// TODO: Verify this comment.
	TransactTime int64 `json:"transactTime"`

	// Type represents the type of the order.
	//
	// Returned with response types RESULT and FULL.
	Type OrderType `json:"type,omitempty"`
}

NewOrderResponse contains information about an order that was just placed.

type OrderBookTicker

type OrderBookTicker struct {
	// AskPrice represents the lowest ask price in the order book.
	AskPrice string `json:"askPrice"`

	// AskQty represents the volume at the current ask price.
	AskQty string `json:"askQty"`

	// BidPrice represents the highest bid in the order book.
	BidPrice string `json:"bidPrice"`

	// BidQty represents the volume at the current bid price.
	BidQty string `json:"bidQty"`

	// Symbol represents the market queried.
	Symbol string `json:"symbol"`
}

OrderBookTicker contains the best price and quantity on an order book.

type OrderFill

type OrderFill struct {
	// Commission represents the amount of commission earned by a sub-order.
	Commission string `schema:"commission"`

	// CommissionAsset represents the asset that commission is paid out in.
	CommissionAsset string `schema:"commissionAsset"`

	// Price represents the price at which a sub-order was executed.
	Price string `schema:"price"`

	// Qty represents the quantity of the sub-order.
	Qty string `schema:"qty"`
}

OrderFill represents a sub-order executed as part of a larger order.

type OrderResponseType

type OrderResponseType string

OrderResponseType defines the type of response you'd like to receive after creating a new order.

type OrderSide

type OrderSide string

OrderSide is an enumerated string type representing whether an order is a buy or sell.

const (
	Buy  OrderSide = "BUY"
	Sell OrderSide = "SELL"
)

Enumerated types for OrderSide.

type OrderStatus

type OrderStatus string

OrderStatus describes the current state of an order.

const (
	// OrderStatusNew indicates a newly created order.
	OrderStatusNew OrderStatus = "NEW"

	// OrderStatusPartiallyFilled indicates an order which has had some of
	// its bought or sold.
	OrderStatusPartiallyFilled OrderStatus = "PARTIALLY_FILLED"

	// OrderStatusFilled indicates a completed order.
	OrderStatusFilled OrderStatus = "FILLED"

	// OrderStatusCancelled indicates an order that has been cancelled.
	OrderStatusCancelled OrderStatus = "CANCELLED"

	// OrderStatusPendingCancel is currently unused.
	OrderStatusPendingCancel OrderStatus = "PENDING_CANCEL"

	// OrderStatusRejected indicates an order that has been rejected by
	// the exchange. This could be due to insuffienct funds in an account
	// or invalid parameters.
	OrderStatusRejected OrderStatus = "REJECTED"

	// OrderStatusExpired indicates an order that has outlived its
	// TimeInForce configuration.
	OrderStatusExpired OrderStatus = "EXPIRED"
)

type OrderType

type OrderType string

OrderType describes the behavior of an order's execution.

const (
	// OrderTypeLimit is a limit order which has a maximum or minimum price
	// to buy or sell.
	OrderTypeLimit OrderType = "LIMIT"

	// OrderTypeMarket is a market order which only specifies a quantity to
	// buy or sell at the current market price.
	OrderTypeMarket = "MARKET"

	// OrderTypeStopLoss is a market order that only executes when a given
	// stop price is reached. Usually used to minimize loss when the market
	// drops.
	OrderTypeStopLoss OrderType = "STOP_LOSS"

	// OrderTypeStopLossLimit is a limit order that only executes when a
	// given stop price is reached.
	OrderTypeStopLossLimit OrderType = "STOP_LOSS_LIMIT"

	// OrderTypeTakeProfit is a market order that only executes when a given
	// stop price is reached. Usually used to lock in profits when the
	// market suddenly rises.
	OrderTypeTakeProfit OrderType = "TAKE_PROFIT"

	// OrderTypeTakeProfitLimit is a limit order that only executed when a
	// given stop price is reached. Usually used to lock in profits when
	// the market suddenly rises.
	OrderTypeTakeProfitLimit OrderType = "TAKE_PROFIT_LIMIT"

	// OrderTypeLimitMaker is a limit order that is rejected if it would
	// get executed immediately and trade as a taker.
	OrderTypeLimitMaker OrderType = "LIMIT_MAKER"
)

type QueryOrderRequest

type QueryOrderRequest struct {
	// OrderID represents the unique identifier provided by Binance on order
	// creation.
	//
	// Either OrderID or OrigClientOrderID must be sent.
	OrderID int64 `schema:"orderId,omitempty"`

	// OrigClientOrderID is the unique identifier provided by the client on
	// order created.
	//
	// Either OrderID or OrigClientOrderID must be sent.
	OrigClientOrderID string `schema:"origClientOrderId,omitempty"`

	// Symbol represents the market the order was placed on.
	Symbol string `schema:"symbol"`
}

QueryOrderRequest contains the parameters for querying an existing order.

type QueryOrderResponse

type QueryOrderResponse struct {
	// ClientOrderID represents the unique identifier provided by the client on
	// order creation.
	ClientOrderID string `json:"clientOrderId"`

	CummulativeQuoteQty string `json:"cummulativeQuoteQty"`

	// ExecutedQty represents how much of the original quantity has been
	// executed.
	ExecutedQty string `json:"executedQty"`

	// IcebergQty represents the maximum amount per sub-order until the total
	// quantity of the order has been filled.
	IcebergQty string `json:"icebergQty"`

	// IsWorking represents whether the order is still currently being filled.
	IsWorking bool `json:"isWorking"`

	// OrderID represents the unique identifier provided by Binance on order
	// creation.
	OrderID int64 `json:"orderId"`

	// OrderListID will always be -1 if the order was not an OCO order.
	OrderListID           int64  `json:"orderListId"`
	OriginalQuoteOrderQty string `json:"origQuoteOrderQty"`

	// OriginalQty represents the original amount the order was placed for.
	OriginalQty string `json:"origQty"`

	// Price represents the price that the order was placed at.
	Price string `json:"price"`

	// Side represents whether the order was a buy or sell.
	Side OrderSide `json:"side"`

	// Status represents the current status of the order.
	Status OrderStatus `json:"status"`

	// StopPrice represents the price the market needs to reach before placing
	// the order as a market order.
	StopPrice string `json:"stopPrice"`

	// Symbol represents the market the order was placed on.
	Symbol string `json:"symbol"`

	// Time represents the unix timestamp in milliseconds for when an order
	// was created.
	//
	// TODO: Verify this comment.
	Time int64 `json:"time"`

	// TimeInForce represents the duration of validity of the order.
	TimeInForce TimeInForce `json:"timeInForce"`

	// Type represents the type of the order.
	Type OrderType `json:"type"`

	// UpdateTime represents the unix timestamp in milliseconds for when an
	// order was last updated.
	UpdateTime int64 `json:"updateTime"`
}

QueryOrderResponse contains information about an order that was previously placed on the exchange.

type SecurityLevel

type SecurityLevel int

SecurityLevel represents the required authentication a Client is required to provide when sending requests.

const (
	// SecurityLevelNone requires no authentication.
	SecurityLevelNone SecurityLevel = 0

	// SecurityLevelUserStream requires a valid API key.
	SecurityLevelUserStream SecurityLevel = 1

	// SecurityLevelMarketData requires a valid API key.
	SecurityLevelMarketData SecurityLevel = 2

	// SecurityLevelTrade requires a valid API key and a signature.
	SecurityLevelTrade SecurityLevel = 3

	// SecurityLevelUserData requires a valid API key and a signature.
	SecurityLevelUserData SecurityLevel = 4
)

func (SecurityLevel) RequiresAuth

func (level SecurityLevel) RequiresAuth() bool

RequiresAuth returns whether a SecurityLevel requires a request to have an authentication header present.

func (SecurityLevel) RequiresSigning

func (level SecurityLevel) RequiresSigning() bool

RequiresSigning returns whether a SecurityLevel requires a request to be signed.

func (SecurityLevel) Valid

func (level SecurityLevel) Valid() bool

Valid returns whether `level` is a declared SecurityLevel constant.

type Symbol

type Symbol string

Symbol represents a trading market. Created by concatenating the quote asset and the base asset.

const (
	ETHBTC   Symbol = "ETHBTC"
	LTCBTC   Symbol = "LTCBTC"
	BNBBTC   Symbol = "BNBBTC"
	NEOBTC   Symbol = "NEOBTC"
	BCCBTC   Symbol = "BCCBTC"
	GASBTC   Symbol = "GASBTC"
	HSDBTC   Symbol = "HSDBTC"
	MCOBTC   Symbol = "MCOBTC"
	WTCBTC   Symbol = "WTCBTC"
	LRCBTC   Symbol = "LRCBTC"
	QTUMBTC  Symbol = "QTUMBTC"
	YOYOBTC  Symbol = "YOYOBTC"
	OMGBTC   Symbol = "OMGBTC"
	ZRXBTC   Symbol = "ZRXBTC"
	STRATBTC Symbol = "STRATBTC"

	QTUMETH  Symbol = "QTUMETH"
	EOSETH   Symbol = "EOSETH"
	SNTETH   Symbol = "SNTETH"
	BNTETH   Symbol = "BNTETH"
	BNBETH   Symbol = "BNBETH"
	OAXETH   Symbol = "OAXETH"
	DNTETH   Symbol = "DNTETH"
	MCOETH   Symbol = "MCOETH"
	ICNETH   Symbol = "ICNETH"
	WTCETH   Symbol = "WTCETH"
	LRCETH   Symbol = "LRCETH"
	OMGETH   Symbol = "OMGETH"
	ZRXETH   Symbol = "ZRXETH"
	STRATETH Symbol = "STRATETH"

	BTCUSDT Symbol = "BTCUSDT"
	ETHUSDT Symbol = "ETHUSDT"
)

func (Symbol) BTCBase

func (s Symbol) BTCBase() bool

BTCBase checks if a Symbol has a base asset of BTC.

func (Symbol) ETHBase

func (s Symbol) ETHBase() bool

ETHBase checks if a Symbol has a base asset of ETH.

func (Symbol) Is

func (s Symbol) Is(s2 string) bool

Is compares a Symbol string to a given string and tests equality.

func (Symbol) IsAny

func (s Symbol) IsAny(sl ...string) bool

IsAny compares a Symbol string to a list of strings and returns if it is contained.

func (Symbol) USDTBase

func (s Symbol) USDTBase() bool

StableBase checks if a Symbol has a base asset of USDT.

func (Symbol) Valid

func (s Symbol) Valid() bool

Valid returns whether `s` is a declared Symbol constant.

type TimeInForce

type TimeInForce string

TimeInForce sets the duration that an order should be valid.

Jump to

Keyboard shortcuts

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