coinbene

package
v0.0.0-...-1ca2487 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: MIT Imports: 31 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

This section is empty.

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 Coinbene

type Coinbene struct {
	exchange.Base
	WebsocketConn *wshandler.WebsocketConnection
}

Coinbene is the overarching type across this package

func (*Coinbene) AuthenticateWebsocket

func (c *Coinbene) AuthenticateWebsocket() error

AuthenticateWebsocket sends an authentication message to the websocket

func (*Coinbene) CancelAllOrders

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

CancelAllOrders cancels all orders associated with a currency pair

func (*Coinbene) CancelOrder

func (c *Coinbene) CancelOrder(order *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*Coinbene) CancelSpotOrder

func (c *Coinbene) CancelSpotOrder(orderID string) (string, error)

CancelSpotOrder removes a given order

func (*Coinbene) CancelSpotOrders

func (c *Coinbene) CancelSpotOrders(orderIDs []string) ([]OrderCancellationResponse, error)

CancelSpotOrders cancels a batch of orders

func (*Coinbene) CancelSwapOrder

func (c *Coinbene) CancelSwapOrder(orderID string) (string, error)

CancelSwapOrder cancels a swap order

func (*Coinbene) CancelSwapOrders

func (c *Coinbene) CancelSwapOrders(orderIDs []string) ([]OrderCancellationResponse, error)

CancelSwapOrders cancels multiple swap order IDs

func (*Coinbene) FetchAccountInfo

func (c *Coinbene) FetchAccountInfo() (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*Coinbene) FetchClosedOrders

func (c *Coinbene) FetchClosedOrders(symbol, latestID string) (OrdersInfo, error)

FetchClosedOrders finds open orders

func (*Coinbene) FetchOpenSpotOrders

func (c *Coinbene) FetchOpenSpotOrders(symbol string) (OrdersInfo, error)

FetchOpenSpotOrders finds open orders

func (*Coinbene) FetchOrderbook

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

FetchOrderbook returns orderbook base on the currency pair

func (*Coinbene) FetchSpotOrderInfo

func (c *Coinbene) FetchSpotOrderInfo(orderID string) (OrderInfo, error)

FetchSpotOrderInfo gets order info

func (*Coinbene) FetchTicker

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

FetchTicker returns the ticker for a currency pair

func (*Coinbene) FetchTradablePairs

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

FetchTradablePairs returns a list of exchange tradable pairs

func (*Coinbene) GenerateAuthSubs

func (c *Coinbene) GenerateAuthSubs()

GenerateAuthSubs generates auth subs

func (*Coinbene) GenerateDefaultSubscriptions

func (c *Coinbene) GenerateDefaultSubscriptions()

GenerateDefaultSubscriptions generates stuff

func (*Coinbene) GetAccountAssetBalance

func (c *Coinbene) GetAccountAssetBalance(symbol string) (UserBalanceData, error)

GetAccountAssetBalance gets user balanace info

func (*Coinbene) GetAccountBalances

func (c *Coinbene) GetAccountBalances() ([]UserBalanceData, error)

GetAccountBalances gets user balanace info

func (*Coinbene) GetActiveOrders

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

GetActiveOrders retrieves any orders that are active/open

func (*Coinbene) GetAllPairs

func (c *Coinbene) GetAllPairs() ([]PairData, error)

GetAllPairs gets all pairs on the exchange

func (*Coinbene) GetDefaultConfig

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

GetDefaultConfig returns a default exchange config

func (*Coinbene) GetDepositAddress

func (c *Coinbene) GetDepositAddress(cryptocurrency currency.Code, accountID string) (string, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Coinbene) GetExchangeHistory

func (c *Coinbene) GetExchangeHistory(p currency.Pair, assetType asset.Item) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

func (*Coinbene) GetFeeByType

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

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

func (*Coinbene) GetFundingHistory

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

GetFundingHistory returns funding history, deposits and withdrawals

func (*Coinbene) GetHistoricCandles

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

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

func (*Coinbene) GetOrderHistory

func (c *Coinbene) GetOrderHistory(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(orderID string) (order.Detail, error)

GetOrderInfo returns information on a current open order

func (*Coinbene) GetOrderbook

func (c *Coinbene) GetOrderbook(symbol string, size int64) (Orderbook, error)

GetOrderbook gets and stores orderbook data for given pair

func (*Coinbene) GetPairInfo

func (c *Coinbene) GetPairInfo(symbol string) (PairData, error)

GetPairInfo gets info about a single pair

func (*Coinbene) GetSpotOrderFills

func (c *Coinbene) GetSpotOrderFills(orderID string) ([]OrderFills, error)

GetSpotOrderFills returns a list of fills related to an order ID

func (*Coinbene) GetSubscriptions

func (c *Coinbene) GetSubscriptions() ([]wshandler.WebsocketChannelSubscription, error)

GetSubscriptions returns a copied list of subscriptions

func (*Coinbene) GetSwapAccountInfo

func (c *Coinbene) GetSwapAccountInfo() (SwapAccountInfo, error)

GetSwapAccountInfo returns a users swap account balance info

func (*Coinbene) GetSwapFundingRates

func (c *Coinbene) GetSwapFundingRates(pageNum, pageSize int) ([]SwapFundingRate, error)

GetSwapFundingRates returns a list of funding rates

func (*Coinbene) GetSwapKlines

func (c *Coinbene) GetSwapKlines(symbol, startTime, endTime, resolution string) (SwapKlines, error)

GetSwapKlines data returns the kline data for a specific symbol

func (*Coinbene) GetSwapOpenOrders

func (c *Coinbene) GetSwapOpenOrders(symbol string, pageNum, pageSize int) (SwapOrders, error)

GetSwapOpenOrders gets a list of open swap orders

func (*Coinbene) GetSwapOpenOrdersByPage

func (c *Coinbene) GetSwapOpenOrdersByPage(symbol string, latestOrderID int64) (SwapOrders, error)

GetSwapOpenOrdersByPage gets a list of open orders by page

func (*Coinbene) GetSwapOrderFills

func (c *Coinbene) GetSwapOrderFills(symbol, orderID string, lastTradeID int64) (SwapOrderFills, error)

GetSwapOrderFills returns a list of swap order fills

func (*Coinbene) GetSwapOrderHistory

func (c *Coinbene) GetSwapOrderHistory(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(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(orderID string) (SwapOrder, error)

GetSwapOrderInfo gets order info for a specific order

func (*Coinbene) GetSwapOrderbook

func (c *Coinbene) GetSwapOrderbook(symbol string, size int64) (Orderbook, error)

GetSwapOrderbook returns an orderbook for the specified currency

func (*Coinbene) GetSwapPositions

func (c *Coinbene) GetSwapPositions(symbol string) (SwapPositions, error)

GetSwapPositions returns a list of open swap positions

func (*Coinbene) GetSwapTicker

func (c *Coinbene) GetSwapTicker(symbol string) (SwapTicker, error)

GetSwapTicker returns a specific swap ticker

func (*Coinbene) GetSwapTickers

func (c *Coinbene) GetSwapTickers() (SwapTickers, error)

GetSwapTickers returns a map of swap tickers

func (*Coinbene) GetSwapTrades

func (c *Coinbene) GetSwapTrades(symbol string, limit int) (SwapTrades, error)

GetSwapTrades returns a list of trades for a swap symbol

func (*Coinbene) GetTicker

func (c *Coinbene) GetTicker(symbol string) (TickerData, error)

GetTicker gets and stores ticker data for a currency pair

func (*Coinbene) GetTickers

func (c *Coinbene) GetTickers() ([]TickerData, error)

GetTickers gets and all spot tickers supported by the exchange

func (*Coinbene) GetTrades

func (c *Coinbene) GetTrades(symbol string) (Trades, error)

GetTrades gets recent trades from the exchange

func (*Coinbene) GetWebsocket

func (c *Coinbene) GetWebsocket() (*wshandler.Websocket, error)

GetWebsocket returns a pointer to the exchange websocket

func (*Coinbene) Login

func (c *Coinbene) Login() error

Login logs in

func (*Coinbene) ModifyOrder

func (c *Coinbene) ModifyOrder(action *order.Modify) (string, error)

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

func (*Coinbene) PlaceSpotOrder

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

PlaceSpotOrder creates an order

func (*Coinbene) PlaceSpotOrders

func (c *Coinbene) PlaceSpotOrders(orders []PlaceOrderRequest) ([]OrderPlacementResponse, error)

PlaceSpotOrders sets a batchful order request

func (*Coinbene) PlaceSwapOrder

func (c *Coinbene) PlaceSwapOrder(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(method, path, epPath string, isSwap bool,
	params, result interface{}, f request.EndpointLimit) error

SendAuthHTTPRequest sends an authenticated HTTP request

func (*Coinbene) SendHTTPRequest

func (c *Coinbene) SendHTTPRequest(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.ExchangeConfig) error

Setup takes in the supplied exchange configuration details and sets params

func (*Coinbene) Start

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

Start starts the Coinbene go routine

func (*Coinbene) SubmitOrder

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

SubmitOrder submits a new order

func (*Coinbene) Subscribe

func (c *Coinbene) Subscribe(channelToSubscribe wshandler.WebsocketChannelSubscription) error

Subscribe sends a websocket message to receive data from the channel

func (*Coinbene) SubscribeToWebsocketChannels

func (c *Coinbene) SubscribeToWebsocketChannels(channels []wshandler.WebsocketChannelSubscription) error

SubscribeToWebsocketChannels appends to ChannelsToSubscribe which lets websocket.manageSubscriptions handle subscribing

func (*Coinbene) Unsubscribe

func (c *Coinbene) Unsubscribe(channelToSubscribe wshandler.WebsocketChannelSubscription) error

Unsubscribe sends a websocket message to receive data from the channel

func (*Coinbene) UnsubscribeToWebsocketChannels

func (c *Coinbene) UnsubscribeToWebsocketChannels(channels []wshandler.WebsocketChannelSubscription) error

UnsubscribeToWebsocketChannels removes from ChannelsToSubscribe which lets websocket.manageSubscriptions handle unsubscribing

func (*Coinbene) UpdateAccountInfo

func (c *Coinbene) UpdateAccountInfo() (account.Holdings, error)

UpdateAccountInfo retrieves balances for all enabled currencies for the Coinbene exchange

func (*Coinbene) UpdateOrderbook

func (c *Coinbene) UpdateOrderbook(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(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Coinbene) UpdateTradablePairs

func (c *Coinbene) UpdateTradablePairs(forceUpdate bool) error

UpdateTradablePairs updates the exchanges available pairs and stores them

func (*Coinbene) ValidateCredentials

func (c *Coinbene) ValidateCredentials() error

ValidateCredentials validates current credentials used for wrapper functionality

func (*Coinbene) WithdrawCryptocurrencyFunds

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

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Coinbene) WithdrawFiatFunds

func (c *Coinbene) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Coinbene) WithdrawFiatFundsToInternationalBank

func (c *Coinbene) WithdrawFiatFundsToInternationalBank(withdrawRequest *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 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
	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
}

RateLimit implements the request.Limiter interface

func SetRateLimit

func SetRateLimit() *RateLimit

SetRateLimit returns the rate limit for the exchange

func (*RateLimit) Limit

func (r *RateLimit) Limit(f request.EndpointLimit) error

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

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 WsKline

type WsKline struct {
	Topic string          `json:"topic"`
	Data  [][]interface{} `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 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     time.Time `json:"timestamp"`
}

WsTickerData stores websocket ticker data

type WsTradeList

type WsTradeList struct {
	Topic string     `json:"topic"`
	Data  [][]string `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