coinbene

package
v0.0.0-...-c17c338 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 34 Imported by: 0

README

GoCryptoTrader package Coinbene

Build Status Software License GoDoc Coverage Status Go Report Card

This coinbene package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Coinbene Exchange

Current Features
  • REST Support
  • Websocket Support
How to enable
	// Exchanges will be abstracted out in further updates and examples will be
	// supplied then
How to do REST public/private calls
  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var c exchange.IBotExchange

for i := range Bot.Exchanges {
	if Bot.Exchanges[i].GetName() == "Coinbene" {
		c = Bot.Exchanges[i]
	}
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := c.FetchTicker()
if err != nil {
	// Handle error
}

// Fetches current orderbook information
ob, err := c.FetchOrderbook()
if err != nil {
	// Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := c.GetAccountInfo()
if err != nil {
	// Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := c.GetTicker()
if err != nil {
	// Handle error
}

// Fetches current orderbook information
ob, err := c.GetOrderbook()
if err != nil {
	// Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// GetUserInfo returns account info
accountInfo, err := c.GetUserInfo(...)
if err != nil {
	// Handle error
}

// Submits an order and the exchange and returns its tradeID
resp, err := c.SubmitOrder(...)
if err != nil {
	// Handle error
}
How to do Websocket public/private calls
	// Exchanges will be abstracted out in further updates and examples will be
	// supplied then
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

View Source
const (
	APISpotPath uint8 = iota
	APISwapPath
	APICapitalPath
)

Coinbene path vals

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelOrdersResponse

type CancelOrdersResponse struct {
	OrderID string `json:"orderId"`
	Message string `json:"message"`
}

CancelOrdersResponse stores data for a cancelled order

type CandleResponse

type CandleResponse struct {
	Code    int64           `json:"code"`
	Message string          `json:"message"`
	Data    [][]interface{} `json:"data"`
}

CandleResponse stores returned kline data

type Coinbene

type Coinbene struct {
	exchange.Base
}

Coinbene is the overarching type across this package

func (*Coinbene) AuthenticateWebsocket

func (c *Coinbene) AuthenticateWebsocket(_ context.Context) error

AuthenticateWebsocket sends an authentication message to the websocket

func (*Coinbene) CancelAllOrders

func (c *Coinbene) CancelAllOrders(ctx context.Context, orderCancellation *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*Coinbene) CancelBatchOrders

func (c *Coinbene) CancelBatchOrders(ctx context.Context, o []order.Cancel) (order.CancelBatchResponse, error)

CancelBatchOrders cancels an orders by their corresponding ID numbers

func (*Coinbene) CancelOrder

func (c *Coinbene) CancelOrder(ctx context.Context, o *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*Coinbene) CancelSpotOrder

func (c *Coinbene) CancelSpotOrder(ctx context.Context, orderID string) (string, error)

CancelSpotOrder removes a given order

func (*Coinbene) CancelSpotOrders

func (c *Coinbene) CancelSpotOrders(ctx context.Context, orderIDs []string) ([]OrderCancellationResponse, error)

CancelSpotOrders cancels a batch of orders

func (*Coinbene) CancelSwapOrder

func (c *Coinbene) CancelSwapOrder(ctx context.Context, orderID string) (string, error)

CancelSwapOrder cancels a swap order

func (*Coinbene) CancelSwapOrders

func (c *Coinbene) CancelSwapOrders(ctx context.Context, orderIDs []string) ([]OrderCancellationResponse, error)

CancelSwapOrders cancels multiple swap order IDs

func (*Coinbene) FetchAccountInfo

func (c *Coinbene) FetchAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*Coinbene) FetchClosedOrders

func (c *Coinbene) FetchClosedOrders(ctx context.Context, symbol, latestID string) (OrdersInfo, error)

FetchClosedOrders finds open orders

func (*Coinbene) FetchOpenSpotOrders

func (c *Coinbene) FetchOpenSpotOrders(ctx context.Context, symbol string) (OrdersInfo, error)

FetchOpenSpotOrders finds open orders

func (*Coinbene) FetchOrderbook

func (c *Coinbene) FetchOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns orderbook base on the currency pair

func (*Coinbene) FetchSpotOrderInfo

func (c *Coinbene) FetchSpotOrderInfo(ctx context.Context, orderID string) (OrderInfo, error)

FetchSpotOrderInfo gets order info

func (*Coinbene) FetchTicker

func (c *Coinbene) FetchTicker(ctx context.Context, p currency.Pair, assetType asset.Item) (*ticker.Price, error)

FetchTicker returns the ticker for a currency pair

func (*Coinbene) FetchTradablePairs

func (c *Coinbene) FetchTradablePairs(ctx context.Context, a asset.Item) ([]string, error)

FetchTradablePairs returns a list of exchange tradable pairs

func (*Coinbene) FormatExchangeKlineInterval

func (c *Coinbene) FormatExchangeKlineInterval(in kline.Interval) string

FormatExchangeKlineInterval returns Interval to string

func (*Coinbene) GenerateAuthSubs

func (c *Coinbene) GenerateAuthSubs() ([]stream.ChannelSubscription, error)

GenerateAuthSubs generates auth subs

func (*Coinbene) GenerateDefaultSubscriptions

func (c *Coinbene) GenerateDefaultSubscriptions() ([]stream.ChannelSubscription, error)

GenerateDefaultSubscriptions generates stuff

func (*Coinbene) GetAccountAssetBalance

func (c *Coinbene) GetAccountAssetBalance(ctx context.Context, symbol string) (UserBalanceData, error)

GetAccountAssetBalance gets user balanace info

func (*Coinbene) GetAccountBalances

func (c *Coinbene) GetAccountBalances(ctx context.Context) ([]UserBalanceData, error)

GetAccountBalances gets user balanace info

func (*Coinbene) GetActiveOrders

func (c *Coinbene) GetActiveOrders(ctx context.Context, getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)

GetActiveOrders retrieves any orders that are active/open

func (*Coinbene) GetAllPairs

func (c *Coinbene) GetAllPairs(ctx context.Context) ([]PairData, error)

GetAllPairs gets all pairs on the exchange

func (*Coinbene) GetAvailableTransferChains

func (c *Coinbene) GetAvailableTransferChains(ctx context.Context, cryptocurrency currency.Code) ([]string, error)

GetAvailableTransferChains returns the available transfer blockchains for the specific cryptocurrency

func (*Coinbene) GetDefaultConfig

func (c *Coinbene) GetDefaultConfig() (*config.Exchange, error)

GetDefaultConfig returns a default exchange config

func (*Coinbene) GetDepositAddress

func (c *Coinbene) GetDepositAddress(ctx context.Context, curr currency.Code, _, chain string) (*deposit.Address, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Coinbene) GetFeeByType

func (c *Coinbene) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on the type of transaction

func (*Coinbene) GetFundingHistory

func (c *Coinbene) GetFundingHistory(ctx context.Context) ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*Coinbene) GetHistoricCandles

func (c *Coinbene) GetHistoricCandles(ctx context.Context, pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandles returns candles between a time period for a set time interval

func (*Coinbene) GetHistoricCandlesExtended

func (c *Coinbene) GetHistoricCandlesExtended(ctx context.Context, pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandlesExtended returns candles between a time period for a set time interval

func (*Coinbene) GetHistoricTrades

func (c *Coinbene) GetHistoricTrades(_ context.Context, _ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error)

GetHistoricTrades returns historic trade data within the timeframe provided

func (*Coinbene) GetKlines

func (c *Coinbene) GetKlines(ctx context.Context, pair string, start, end time.Time, period string) (resp CandleResponse, err error)

GetKlines data returns the kline data for a specific symbol

func (*Coinbene) GetOrderHistory

func (c *Coinbene) GetOrderHistory(ctx context.Context, getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)

GetOrderHistory retrieves account order information Can Limit response to specific order status

func (*Coinbene) GetOrderInfo

func (c *Coinbene) GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error)

GetOrderInfo returns order information based on order ID

func (*Coinbene) GetOrderbook

func (c *Coinbene) GetOrderbook(ctx context.Context, symbol string, size int64) (Orderbook, error)

GetOrderbook gets and stores orderbook data for given pair

func (*Coinbene) GetPairInfo

func (c *Coinbene) GetPairInfo(ctx context.Context, symbol string) (PairData, error)

GetPairInfo gets info about a single pair

func (*Coinbene) GetRecentTrades

func (c *Coinbene) GetRecentTrades(ctx context.Context, p currency.Pair, assetType asset.Item) ([]trade.Data, error)

GetRecentTrades returns the most recent trades for a currency and asset

func (*Coinbene) GetSpotOrderFills

func (c *Coinbene) GetSpotOrderFills(ctx context.Context, orderID string) ([]OrderFills, error)

GetSpotOrderFills returns a list of fills related to an order ID

func (*Coinbene) GetSwapAccountInfo

func (c *Coinbene) GetSwapAccountInfo(ctx context.Context) (SwapAccountInfo, error)

GetSwapAccountInfo returns a users swap account balance info

func (*Coinbene) GetSwapFundingRates

func (c *Coinbene) GetSwapFundingRates(ctx context.Context, pageNum, pageSize int) ([]SwapFundingRate, error)

GetSwapFundingRates returns a list of funding rates

func (*Coinbene) GetSwapInstruments

func (c *Coinbene) GetSwapInstruments(ctx context.Context) ([]Instrument, error)

GetSwapInstruments returns a list of tradable instruments

func (*Coinbene) GetSwapKlines

func (c *Coinbene) GetSwapKlines(ctx context.Context, symbol string, start, end time.Time, resolution string) (resp CandleResponse, err error)

GetSwapKlines data returns the kline data for a specific symbol

func (*Coinbene) GetSwapOpenOrders

func (c *Coinbene) GetSwapOpenOrders(ctx context.Context, symbol string, pageNum, pageSize int) (SwapOrders, error)

GetSwapOpenOrders gets a list of open swap orders

func (*Coinbene) GetSwapOpenOrdersByPage

func (c *Coinbene) GetSwapOpenOrdersByPage(ctx context.Context, symbol string, latestOrderID int64) (SwapOrders, error)

GetSwapOpenOrdersByPage gets a list of open orders by page

func (*Coinbene) GetSwapOrderFills

func (c *Coinbene) GetSwapOrderFills(ctx context.Context, symbol, orderID string, lastTradeID int64) (SwapOrderFills, error)

GetSwapOrderFills returns a list of swap order fills

func (*Coinbene) GetSwapOrderHistory

func (c *Coinbene) GetSwapOrderHistory(ctx context.Context, beginTime, endTime, symbol string, pageNum,
	pageSize int, direction, orderType string) (SwapOrders, error)

GetSwapOrderHistory returns the swap order history for a given symbol

func (*Coinbene) GetSwapOrderHistoryByOrderID

func (c *Coinbene) GetSwapOrderHistoryByOrderID(ctx context.Context, beginTime, endTime, symbol, status string,
	latestOrderID int64) (SwapOrders, error)

GetSwapOrderHistoryByOrderID returns a list of historic orders based on user params

func (*Coinbene) GetSwapOrderInfo

func (c *Coinbene) GetSwapOrderInfo(ctx context.Context, orderID string) (SwapOrder, error)

GetSwapOrderInfo gets order info for a specific order

func (*Coinbene) GetSwapOrderbook

func (c *Coinbene) GetSwapOrderbook(ctx context.Context, symbol string, size int64) (Orderbook, error)

GetSwapOrderbook returns an orderbook for the specified currency

func (*Coinbene) GetSwapPositions

func (c *Coinbene) GetSwapPositions(ctx context.Context, symbol string) (SwapPositions, error)

GetSwapPositions returns a list of open swap positions

func (*Coinbene) GetSwapTicker

func (c *Coinbene) GetSwapTicker(ctx context.Context, symbol string) (SwapTicker, error)

GetSwapTicker returns a specific swap ticker

func (*Coinbene) GetSwapTickers

func (c *Coinbene) GetSwapTickers(ctx context.Context) (SwapTickers, error)

GetSwapTickers returns a map of swap tickers

func (*Coinbene) GetSwapTrades

func (c *Coinbene) GetSwapTrades(ctx context.Context, symbol string, limit int) (SwapTrades, error)

GetSwapTrades returns a list of trades for a swap symbol

func (*Coinbene) GetTicker

func (c *Coinbene) GetTicker(ctx context.Context, symbol string) (TickerData, error)

GetTicker gets and stores ticker data for a currency pair

func (*Coinbene) GetTickers

func (c *Coinbene) GetTickers(ctx context.Context) ([]TickerData, error)

GetTickers gets and all spot tickers supported by the exchange

func (*Coinbene) GetTrades

func (c *Coinbene) GetTrades(ctx context.Context, symbol string, limit int64) (Trades, error)

GetTrades gets recent trades from the exchange

func (*Coinbene) GetWithdrawalsHistory

func (c *Coinbene) GetWithdrawalsHistory(_ context.Context, _ currency.Code) (resp []exchange.WithdrawalHistory, err error)

GetWithdrawalsHistory returns previous withdrawals data

func (*Coinbene) ListDepositAddress

func (c *Coinbene) ListDepositAddress(ctx context.Context, crypto currency.Code) ([]DepositAddress, error)

ListDepositAddress returns a list of deposit addresses for a given cryptocurrency

func (*Coinbene) Login

func (c *Coinbene) Login() error

Login logs in

func (*Coinbene) ModifyOrder

func (c *Coinbene) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error)

ModifyOrder will allow of changing orderbook placement and limit to market conversion

func (*Coinbene) PlaceSpotOrder

func (c *Coinbene) PlaceSpotOrder(ctx context.Context, price, quantity float64, symbol, direction,
	orderType, clientID string, notional int) (OrderPlacementResponse, error)

PlaceSpotOrder creates an order

func (*Coinbene) PlaceSpotOrders

func (c *Coinbene) PlaceSpotOrders(ctx context.Context, orders []PlaceOrderRequest) ([]OrderPlacementResponse, error)

PlaceSpotOrders sets a batchful order request

func (*Coinbene) PlaceSwapOrder

func (c *Coinbene) PlaceSwapOrder(ctx context.Context, symbol, direction, orderType, marginMode,
	clientID string, price, quantity float64, leverage int) (SwapPlaceOrderResponse, error)

PlaceSwapOrder places a swap order

func (*Coinbene) Run

func (c *Coinbene) Run()

Run implements the Coinbene wrapper

func (*Coinbene) SendAuthHTTPRequest

func (c *Coinbene) SendAuthHTTPRequest(ctx context.Context, ep exchange.URL, method, epPath string, epAuthPath uint8,
	params, result interface{}, f request.EndpointLimit) error

SendAuthHTTPRequest sends an authenticated HTTP request

func (*Coinbene) SendHTTPRequest

func (c *Coinbene) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, f request.EndpointLimit, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*Coinbene) SetDefaults

func (c *Coinbene) SetDefaults()

SetDefaults sets the basic defaults for Coinbene

func (*Coinbene) Setup

func (c *Coinbene) Setup(exch *config.Exchange) error

Setup takes in the supplied exchange configuration details and sets params

func (*Coinbene) Start

func (c *Coinbene) Start(wg *sync.WaitGroup) error

Start starts the Coinbene go routine

func (*Coinbene) SubmitOrder

func (c *Coinbene) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitResponse, error)

SubmitOrder submits a new order

func (*Coinbene) Subscribe

func (c *Coinbene) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error

Subscribe sends a websocket message to receive data from the channel

func (*Coinbene) Unsubscribe

func (c *Coinbene) Unsubscribe(channelToUnsubscribe []stream.ChannelSubscription) error

Unsubscribe sends a websocket message to receive data from the channel

func (*Coinbene) UpdateAccountInfo

func (c *Coinbene) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error)

UpdateAccountInfo retrieves balances for all enabled currencies for the Coinbene exchange

func (*Coinbene) UpdateOrderbook

func (c *Coinbene) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Coinbene) UpdateTicker

func (c *Coinbene) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Coinbene) UpdateTickers

func (c *Coinbene) UpdateTickers(ctx context.Context, a asset.Item) error

UpdateTickers updates the ticker for all currency pairs of a given asset type

func (*Coinbene) UpdateTradablePairs

func (c *Coinbene) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error

UpdateTradablePairs updates the exchanges available pairs and stores them

func (*Coinbene) ValidateCredentials

func (c *Coinbene) ValidateCredentials(ctx context.Context, assetType asset.Item) error

ValidateCredentials validates current credentials used for wrapper functionality

func (*Coinbene) Withdraw

func (c *Coinbene) Withdraw(ctx context.Context, curr currency.Code, address, tag, chain string, amount float64) (*WithdrawResponse, error)

Withdraw issues a withdrawawl request based on the supplied parameters

func (*Coinbene) WithdrawCryptocurrencyFunds

func (c *Coinbene) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Coinbene) WithdrawFiatFunds

func (c *Coinbene) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Coinbene) WithdrawFiatFundsToInternationalBank

func (c *Coinbene) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*Coinbene) WsConnect

func (c *Coinbene) WsConnect() error

WsConnect connects to websocket

type DepositAddress

type DepositAddress struct {
	Asset        string  `json:"asset"`
	Chain        string  `json:"chain"`
	Address      string  `json:"address"`
	AddressTag   string  `json:"addressTag"`
	DepositLimit float64 `json:"depositLimit,string"`
	BlockNumber  uint8   `json:"blockNumber,string"`
}

DepositAddress stores the deposit address data

type Instrument

type Instrument struct {
	InstrumentID       currency.Pair `json:"instrumentId"`
	Multiplier         float64       `json:"multiplier,string"`
	MinimumAmount      float64       `json:"minAmount,string"`
	MaximumAmount      float64       `json:"maxAmount,string"`
	MinimumPriceChange float64       `json:"minPriceChange,string"`
	PricePrecision     int64         `json:"pricePrecision,string"`
}

Instrument stores an individual tradable instrument

type OrderCancellationResponse

type OrderCancellationResponse struct {
	OrderID string `json:"orderId"`
	Code    int    `json:"code,string"`
	Message string `json:"message"`
}

OrderCancellationResponse returns a list of cancel order status

type OrderFills

type OrderFills struct {
	Price     float64   `json:"price,string"`
	Quantity  float64   `json:"quantity,string"`
	Amount    float64   `json:"amount,string"`
	Fee       float64   `json:"fee,string"`
	Direction string    `json:"direction"`
	TradeTime time.Time `json:"tradeTime"`
	FeeByConi float64   `json:"feeByConi,string"`
}

OrderFills stores the fill info

type OrderInfo

type OrderInfo struct {
	OrderID      string    `json:"orderId"`
	BaseAsset    string    `json:"baseAsset"`
	QuoteAsset   string    `json:"quoteAsset"`
	OrderType    string    `json:"orderDirection"`
	Quantity     float64   `json:"quntity,string"`
	Amount       float64   `json:"amout,string"`
	FilledAmount float64   `json:"filledAmount"`
	TakerRate    float64   `json:"takerFeeRate,string"`
	MakerRate    float64   `json:"makerFeeRate,string"`
	AvgPrice     float64   `json:"avgPrice,string"`
	OrderPrice   float64   `json:"orderPrice,string"`
	OrderStatus  string    `json:"orderStatus"`
	OrderTime    time.Time `json:"orderTime"`
	TotalFee     float64   `json:"totalFee"`
}

OrderInfo stores order info

type OrderPlacementResponse

type OrderPlacementResponse OrderCancellationResponse

OrderPlacementResponse stores the order placement data

type Orderbook

type Orderbook struct {
	Bids   []OrderbookItem
	Asks   []OrderbookItem
	Symbol string
	Time   time.Time
}

Orderbook stores the orderbook data

type OrderbookItem

type OrderbookItem struct {
	Price  float64
	Amount float64
	Count  int64
}

OrderbookItem stores an individual orderbook item

type OrdersInfo

type OrdersInfo []OrderInfo

OrdersInfo stores a collection of orders

type PairData

type PairData struct {
	Symbol           string  `json:"symbol"`
	BaseAsset        string  `json:"baseAsset"`
	QuoteAsset       string  `json:"quoteAsset"`
	PricePrecision   int64   `json:"pricePrecision,string"`
	AmountPrecision  int64   `json:"amountPrecision,string"`
	TakerFeeRate     float64 `json:"takerFeeRate,string"`
	MakerFeeRate     float64 `json:"makerFeeRate,string"`
	MinAmount        float64 `json:"minAmount,string"`
	Site             string  `json:"site"`
	PriceFluctuation float64 `json:"priceFluctuation,string"`
}

PairData stores pair data

type PlaceOrderRequest

type PlaceOrderRequest struct {
	Price     float64
	Quantity  float64
	Symbol    string
	Direction string
	OrderType string
	ClientID  string
	Notional  int
}

PlaceOrderRequest places an order request

type RateLimit

type RateLimit struct {
	ContractOrderbook             *rate.Limiter
	ContractTickers               *rate.Limiter
	ContractKline                 *rate.Limiter
	ContractTrades                *rate.Limiter
	ContractInstruments           *rate.Limiter
	ContractAccountInfo           *rate.Limiter
	ContractPositionInfo          *rate.Limiter
	ContractPlaceOrder            *rate.Limiter
	ContractCancelOrder           *rate.Limiter
	ContractGetOpenOrders         *rate.Limiter
	ContractOpenOrdersByPage      *rate.Limiter
	ContractGetOrderInfo          *rate.Limiter
	ContractGetClosedOrders       *rate.Limiter
	ContractGetClosedOrdersbyPage *rate.Limiter
	ContractCancelMultipleOrders  *rate.Limiter
	ContractGetOrderFills         *rate.Limiter
	ContractGetFundingRates       *rate.Limiter
	SpotPairs                     *rate.Limiter
	SpotPairInfo                  *rate.Limiter
	SpotOrderbook                 *rate.Limiter
	SpotTickerList                *rate.Limiter
	SpotSpecificTicker            *rate.Limiter
	SpotMarketTrades              *rate.Limiter
	// spotKline        // Not implemented yet
	// spotExchangeRate // Not implemented yet
	SpotAccountInfo       *rate.Limiter
	SpotAccountAssetInfo  *rate.Limiter
	SpotPlaceOrder        *rate.Limiter
	SpotBatchOrder        *rate.Limiter
	SpotQueryOpenOrders   *rate.Limiter
	SpotQueryClosedOrders *rate.Limiter
	SpotQuerySpecficOrder *rate.Limiter
	SpotQueryTradeFills   *rate.Limiter
	SpotCancelOrder       *rate.Limiter
	SpotCancelOrdersBatch *rate.Limiter
	CapitalDeposit        *rate.Limiter
	CapitalWithdraw       *rate.Limiter
}

RateLimit implements the request.Limiter interface

func SetRateLimit

func SetRateLimit() *RateLimit

SetRateLimit returns the rate limit for the exchange

func (*RateLimit) Limit

Limit limits outbound requests

type SwapAccountInfo

type SwapAccountInfo struct {
	AvailableBalance        float64 `json:"availableBalance,string"`
	FrozenBalance           float64 `json:"frozenBalance,string"`
	MarginBalance           float64 `json:"marginBalance,string"`
	MarginRate              float64 `json:"marginRate,string"`
	Balance                 float64 `json:"balance,string"`
	UnrealisedProfitAndLoss float64 `json:"unrealisedPnl,string"`
}

SwapAccountInfo returns the swap account balance info

type SwapFundingRate

type SwapFundingRate struct {
	Symbol        string  `json:"symbol"`
	Side          string  `json:"side"`
	MarkPrice     float64 `json:"markPrice,string"`
	PositionValue float64 `json:"positionValue,string"`
	Fee           float64 `json:"fee,string"`
	FeeRate       float64 `json:"feeRate,string"`
	Leverage      int64   `json:"leverage"`
}

SwapFundingRate stores a collection of funding rates

type SwapKlineItem

type SwapKlineItem struct {
	Time        time.Time
	Open        float64
	Close       float64
	High        float64
	Low         float64
	Volume      float64
	Turnover    float64
	BuyVolume   float64
	BuyTurnover float64
}

SwapKlineItem stores an individual kline data item

type SwapKlines

type SwapKlines []SwapKlineItem

SwapKlines stores an array of kline data

type SwapOrder

type SwapOrder struct {
	OrderID        string    `json:"orderId"`
	Direction      string    `json:"direction"`
	Leverage       int64     `json:"leverage,string"`
	OrderType      string    `json:"orderType"`
	Quantity       float64   `json:"quantity,string"`
	OrderPrice     float64   `json:"orderPrice,string"`
	OrderValue     float64   `json:"orderValue,string"`
	Fee            float64   `json:"fee"`
	FilledQuantity float64   `json:"filledQuantity,string"`
	AveragePrice   float64   `json:"averagePrice,string"`
	OrderTime      time.Time `json:"orderTime"`
	Status         string    `json:"status"`
}

SwapOrder stores the swap order data

type SwapOrderFill

type SwapOrderFill struct {
	Symbol    string    `json:"symbol"`
	TradeTime time.Time `json:"tradeTime"`
	TradeID   int64     `json:"tradeId,string"`
	OrderID   int64     `json:"orderId,string"`
	Price     float64   `json:"price,string"`
	Fee       float64   `json:"fee,string"`
	ExecType  string    `json:"execType"`
	Side      string    `json:"side"`
	Quantity  float64   `json:"quantity,string"`
}

SwapOrderFill stores a swap orders fill info

type SwapOrderFills

type SwapOrderFills []SwapOrderFill

SwapOrderFills stores a collection of swap order fills

type SwapOrders

type SwapOrders []SwapOrder

SwapOrders stores a collection of swap orders

type SwapPlaceOrderResponse

type SwapPlaceOrderResponse struct {
	OrderID  string `json:"orderId"`
	ClientID string `json:"clientId"`
}

SwapPlaceOrderResponse stores the response data for placing a swap order

type SwapPosition

type SwapPosition struct {
	AvailableQuantity       float64   `json:"availableQuantity,string"`
	AveragePrice            float64   `json:"averagePrice,string"`
	CreateTime              time.Time `json:"createTime"`
	DeleveragePercentile    int64     `json:"deleveragePercentile,string"`
	Leverage                int64     `json:"leverage,string"`
	LiquidationPrice        float64   `json:"liquidationPrice,string"`
	MarkPrice               float64   `json:"markPrice,string"`
	PositionMargin          float64   `json:"positionMargin,string"`
	PositionValue           float64   `json:"positionValue,string"`
	Quantity                float64   `json:"quantity,string"`
	RateOfReturn            float64   `json:"roe,string"`
	Side                    string    `json:"side"`
	Symbol                  string    `json:"symbol"`
	UnrealisedProfitAndLoss float64   `json:"UnrealisedPnl,string"`
}

SwapPosition stores a single swap position's data

type SwapPositions

type SwapPositions []SwapPosition

SwapPositions stores a collection of swap positions

type SwapTicker

type SwapTicker struct {
	LastPrice      float64   `json:"lastPrice,string"`
	MarkPrice      float64   `json:"markPrice,string"`
	BestAskPrice   float64   `json:"bestAskPrice,string"`
	BestBidPrice   float64   `json:"bestBidPrice,string"`
	High24Hour     float64   `json:"high24h,string"`
	Low24Hour      float64   `json:"low24h,string"`
	Volume24Hour   float64   `json:"volume24h,string"`
	BestAskVolume  float64   `json:"bestAskVolume,string"`
	BestBidVolume  float64   `json:"bestBidVolume,string"`
	Turnover       float64   `json:"turnover,string"`
	Timestamp      time.Time `json:"timeStamp"`
	Change24Hour   float64   `json:"chg24h,string"`
	ChangeZeroHour float64   `json:"chg0h,string"`
}

SwapTicker stores the swap ticker info

type SwapTickers

type SwapTickers map[string]SwapTicker

SwapTickers stores a map of swap tickers

type SwapTrade

type SwapTrade struct {
	Price  float64
	Side   order.Side
	Volume float64
	Time   time.Time
}

SwapTrade stores an individual trade

type SwapTrades

type SwapTrades []SwapTrade

SwapTrades stores an array of swap trades

type TickerData

type TickerData struct {
	Symbol      string  `json:"symbol"`
	LatestPrice float64 `json:"latestPrice,string"`
	BestBid     float64 `json:"bestBid,string"`
	BestAsk     float64 `json:"bestAsk,string"`
	DailyHigh   float64 `json:"high24h,string"`
	DailyLow    float64 `json:"low24h,string"`
	DailyVolume float64 `json:"volume24h,string"`
}

TickerData stores ticker data

type TradeItem

type TradeItem struct {
	CurrencyPair string
	Price        float64
	Volume       float64
	Direction    string
	TradeTime    time.Time
}

TradeItem stores a single trade

type Trades

type Trades []TradeItem

Trades stores trade data

type UserBalanceData

type UserBalanceData struct {
	Asset     string  `json:"asset"`
	Available float64 `json:"available,string"`
	Reserved  float64 `json:"reserved,string"`
	Total     float64 `json:"total,string"`
}

UserBalanceData stores user balance data

type WithdrawResponse

type WithdrawResponse struct {
	ID      string  `json:"id"`
	Amount  float64 `json:"amount"`
	Asset   string  `json:"asset"`
	Address string  `json:"address"`
	Tag     string  `json:"tag"`
	Chain   string  `json:"chain"`
}

WithdrawResponse stores the withdrawal request response data

type WsKLineData

type WsKLineData struct {
	Open      float64 `json:"o"`
	High      float64 `json:"h"`
	Low       float64 `json:"l"`
	Close     float64 `json:"c"`
	Volume    float64 `json:"v"`
	Timestamp int64   `json:"t"`
}

WsKLineData holds OHLCV data

type WsKline

type WsKline struct {
	Topic string        `json:"topic"`
	Data  []WsKLineData `json:"data"`
}

WsKline stores websocket kline data

type WsOrderData

type WsOrderData struct {
	OrderID          string    `json:"orderId"`
	Direction        string    `json:"direction"`
	Leverage         int64     `json:"leverage,string"`
	Symbol           string    `json:"symbol"`
	OrderType        string    `json:"orderType"`
	Quantity         float64   `json:"quantity,string"`
	OrderPrice       float64   `json:"orderPrice,string"`
	OrderValue       float64   `json:"orderValue,string"`
	Fee              float64   `json:"fee,string"`
	FilledQuantity   float64   `json:"filledQuantity,string"`
	AveragePrice     float64   `json:"averagePrice,string"`
	OrderTime        time.Time `json:"orderTime"`
	Status           string    `json:"status"`
	LastFillQuantity float64   `json:"lastFillQuantity,string"`
	LastFillPrice    float64   `json:"lastFillPrice,string"`
	LastFillTime     string    `json:"lastFillTime"`
}

WsOrderData stores websocket user order data

type WsOrderbookData

type WsOrderbookData struct {
	Topic  string `json:"topic"`
	Action string `json:"action"`
	Data   []struct {
		Bids      [][2]string `json:"bids"`
		Asks      [][2]string `json:"asks"`
		Version   int64       `json:"version"`
		Timestamp int64       `json:"timestamp"`
	} `json:"data"`
}

WsOrderbookData stores ws orderbook data

type WsPosition

type WsPosition struct {
	Topic string           `json:"topic"`
	Data  []WsPositionData `json:"data"`
}

WsPosition stores websocket info on user's positions

type WsPositionData

type WsPositionData struct {
	AvailableQuantity float64   `json:"availableQuantity,string"`
	AveragePrice      float64   `json:"avgPrice,string"`
	Leverage          int64     `json:"leverage,string"`
	LiquidationPrice  float64   `json:"liquidationPrice,string"`
	MarkPrice         float64   `json:"markPrice,string"`
	PositionMargin    float64   `json:"positionMargin,string"`
	Quantity          float64   `json:"quantity,string"`
	RealisedPNL       float64   `json:"realisedPnl,string"`
	Side              string    `json:"side"`
	Symbol            string    `json:"symbol"`
	MarginMode        int64     `json:"marginMode,string"`
	CreateTime        time.Time `json:"createTime"`
}

WsPositionData stores websocket info on user's position

type WsSub

type WsSub struct {
	Operation string   `json:"op"`
	Arguments []string `json:"args"`
}

WsSub stores subscription data

type WsTicker

type WsTicker struct {
	Topic string         `json:"topic"`
	Data  []WsTickerData `json:"data"`
}

WsTicker stores websocket ticker

type WsTickerData

type WsTickerData struct {
	Symbol        string  `json:"symbol"`
	LastPrice     float64 `json:"lastPrice,string"`
	MarkPrice     float64 `json:"markPrice,string"`
	BestAskPrice  float64 `json:"bestAskPrice,string"`
	BestBidPrice  float64 `json:"bestBidPrice,string"`
	BestAskVolume float64 `json:"bestAskVolume,string"`
	BestBidVolume float64 `json:"bestBidVolume,string"`
	High24h       float64 `json:"high24h,string"`
	Low24h        float64 `json:"low24h,string"`
	Volume24h     float64 `json:"volume24h,string"`
	Timestamp     int64   `json:"timestamp"`
}

WsTickerData stores websocket ticker data

type WsTradeData

type WsTradeData struct {
	BestAskPrice float64 `json:"bestAskPrice,string"`
	BestBidPrice float64 `json:"bestBidPrice,string"`
	High24h      float64 `json:"high24h,string"`
	LastPrice    float64 `json:"lastPrice,string"`
	Low24h       float64 `json:"low24h,string"`
	Open24h      float64 `json:"open24h,string"`
	OpenPrice    float64 `json:"openPrice,string"`
	Symbol       string  `json:"symbol"`
	Timestamp    int64   `json:"timestamp"`
	Volume24h    float64 `json:"volume24h,string"`
}

WsTradeData stores trade data for websocket

type WsTradeList

type WsTradeList struct {
	Topic string           `json:"topic"`
	Data  [][4]interface{} `json:"data"`
}

WsTradeList stores websocket tradelist data

type WsUserData

type WsUserData struct {
	Asset     string    `json:"string"`
	Available float64   `json:"availableBalance,string"`
	Locked    float64   `json:"frozenBalance,string"`
	Total     float64   `json:"balance,string"`
	Timestamp time.Time `json:"timestamp"`
}

WsUserData stores websocket user data

type WsUserInfo

type WsUserInfo struct {
	Topic string       `json:"topic"`
	Data  []WsUserData `json:"data"`
}

WsUserInfo stores websocket user info

type WsUserOrders

type WsUserOrders struct {
	Topic string        `json:"topic"`
	Data  []WsOrderData `json:"data"`
}

WsUserOrders stores websocket user orders' data

Jump to

Keyboard shortcuts

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