hitbtc

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 35 Imported by: 0

README

GoCryptoTrader package Hitbtc

Build Status Software License GoDoc Coverage Status Go Report Card

This hitbtc 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

HitBTC 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 h exchange.IBotExchange

for i := range bot.Exchanges {
	if bot.Exchanges[i].GetName() == "HitBTC" {
		h = bot.Exchanges[i]
	}
}

// Public calls - wrapper functions

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

// Fetches current orderbook information
ob, err := h.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 := h.GetAccountInfo()
if err != nil {
	// Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

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

// Fetches current orderbook information
ob, err := h.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 := h.GetUserInfo(...)
if err != nil {
	// Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := h.Trade(...)
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 ActiveLoans

type ActiveLoans struct {
	Provided []LoanOffer `json:"provided"`
	Used     []LoanOffer `json:"used"`
}

ActiveLoans holds information about your active loans

type AuthenticatedTradeHistoryAll

type AuthenticatedTradeHistoryAll struct {
	Data map[string][]AuthentictedTradeHistory
}

AuthenticatedTradeHistoryAll contains the full trade history

type AuthenticatedTradeHistoryResponse

type AuthenticatedTradeHistoryResponse struct {
	Data []AuthentictedTradeHistory
}

AuthenticatedTradeHistoryResponse is the resp type for trade history

type AuthentictedTradeHistory

type AuthentictedTradeHistory struct {
	GlobalTradeID int64   `json:"globalTradeID"`
	TradeID       int64   `json:"tradeID,string"`
	Date          string  `json:"date"`
	Rate          float64 `json:"rate,string"`
	Amount        float64 `json:"amount,string"`
	Total         float64 `json:"total,string"`
	Fee           float64 `json:"fee,string"`
	OrderNumber   int64   `json:"orderNumber,string"`
	Type          string  `json:"type"`
	Category      string  `json:"category"`
}

AuthentictedTradeHistory contains trade history data

type Balance

type Balance struct {
	Currency  string  `json:"currency"`
	Available float64 `json:"available,string"` // Amount available for trading or transfer to main account
	Reserved  float64 `json:"reserved,string"`  // Amount reserved for active orders or incomplete transfers to main account

}

Balance is a simple balance type

type ChartData

type ChartData struct {
	Timestamp   time.Time `json:"timestamp"`
	Max         float64   `json:"max,string"`         // Max price
	Min         float64   `json:"min,string"`         // Min price
	Open        float64   `json:"open,string"`        // Open price
	Close       float64   `json:"close,string"`       // Close price
	Volume      float64   `json:"volume,string"`      // Volume in base currency
	VolumeQuote float64   `json:"volumeQuote,string"` // Volume in quote currency
}

ChartData contains chart data

type Currencies

type Currencies struct {
	ID                 string `json:"id"`                 // Currency identifier.
	FullName           string `json:"fullName"`           // Currency full name
	Crypto             bool   `json:"crypto"`             // Is currency belongs to blockchain (false for ICO and fiat, like EUR)
	PayinEnabled       bool   `json:"payinEnabled"`       // Is allowed for deposit (false for ICO)
	PayinPaymentID     bool   `json:"payinPaymentId"`     // Is required to provide additional information other than the address for deposit
	PayinConfirmations int64  `json:"payinConfirmations"` // Blocks confirmations count for deposit
	PayoutEnabled      bool   `json:"payoutEnabled"`      // Is allowed for withdraw (false for ICO)
	PayoutIsPaymentID  bool   `json:"payoutIsPaymentId"`  // Is allowed to provide additional information for withdraw
	TransferEnabled    bool   `json:"transferEnabled"`    // Is allowed to transfer between trading and account (may be disabled on maintain)
	Delisted           bool   `json:"delisted"`           // True if currency delisted (stopped deposit and trading)
	PayoutFee          string `json:"payoutFee"`          // Default withdraw fee
}

Currencies hold the full range of data for a specified currency

type DepositCryptoAddresses

type DepositCryptoAddresses struct {
	Address   string `json:"address"`   // Address for deposit
	PaymentID string `json:"paymentId"` // Optional additional parameter. Required for deposit if persist
}

DepositCryptoAddresses contains address information

type Fee

type Fee struct {
	TakeLiquidityRate    float64 `json:"takeLiquidityRate,string"`    // Taker
	ProvideLiquidityRate float64 `json:"provideLiquidityRate,string"` // Maker
}

Fee holds fee structure

type GenericResponse

type GenericResponse struct {
	Success int    `json:"success"`
	Error   string `json:"error"`
}

GenericResponse is the common response from HitBTC

type HitBTC

type HitBTC struct {
	exchange.Base
}

HitBTC is the overarching type across the hitbtc package

func (*HitBTC) AuthenticateWebsocket

func (h *HitBTC) AuthenticateWebsocket(ctx context.Context) error

AuthenticateWebsocket sends an authentication message to the websocket

func (*HitBTC) CancelAllExistingOrders

func (h *HitBTC) CancelAllExistingOrders(ctx context.Context) ([]Order, error)

CancelAllExistingOrders cancels all open orders

func (*HitBTC) CancelAllOrders

func (h *HitBTC) CancelAllOrders(ctx context.Context, _ *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*HitBTC) CancelBatchOrders

func (h *HitBTC) CancelBatchOrders(_ context.Context, _ []order.Cancel) (*order.CancelBatchResponse, error)

CancelBatchOrders cancels an orders by their corresponding ID numbers

func (*HitBTC) CancelExistingOrder

func (h *HitBTC) CancelExistingOrder(ctx context.Context, orderID int64) (bool, error)

CancelExistingOrder cancels a specific order by OrderID

func (*HitBTC) CancelOrder

func (h *HitBTC) CancelOrder(ctx context.Context, o *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*HitBTC) FetchAccountInfo

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

FetchAccountInfo retrieves balances for all enabled currencies

func (*HitBTC) FetchOrderbook

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

FetchOrderbook returns orderbook base on the currency pair

func (*HitBTC) FetchTicker

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

FetchTicker returns the ticker for a currency pair

func (*HitBTC) FetchTradablePairs

func (h *HitBTC) FetchTradablePairs(ctx context.Context, _ asset.Item) (currency.Pairs, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*HitBTC) FormatExchangeKlineInterval

func (h *HitBTC) FormatExchangeKlineInterval(in kline.Interval) (string, error)

FormatExchangeKlineInterval returns Interval to exchange formatted string

func (*HitBTC) GenerateDefaultSubscriptions

func (h *HitBTC) GenerateDefaultSubscriptions() ([]subscription.Subscription, error)

GenerateDefaultSubscriptions Adds default subscriptions to websocket to be handled by ManageSubscriptions()

func (*HitBTC) GenerateNewAddress

func (h *HitBTC) GenerateNewAddress(ctx context.Context, currency string) (DepositCryptoAddresses, error)

GenerateNewAddress generates a new deposit address for a currency

func (*HitBTC) GetAccountFundingHistory

func (h *HitBTC) GetAccountFundingHistory(_ context.Context) ([]exchange.FundingHistory, error)

GetAccountFundingHistory returns funding history, deposits and withdrawals

func (*HitBTC) GetActiveOrderByClientOrderID

func (h *HitBTC) GetActiveOrderByClientOrderID(ctx context.Context, clientOrderID string) (OrderHistoryResponse, error)

GetActiveOrderByClientOrderID Get an active order by id

func (*HitBTC) GetActiveOrders

func (h *HitBTC) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

GetActiveOrders retrieves any orders that are active/open

func (*HitBTC) GetActiveorders

func (h *HitBTC) GetActiveorders(ctx context.Context, currency string) ([]Order, error)

GetActiveorders returns all your active orders

func (*HitBTC) GetBalances

func (h *HitBTC) GetBalances(ctx context.Context) (map[string]Balance, error)

GetBalances returns full balance for your account

func (*HitBTC) GetCandles

func (h *HitBTC) GetCandles(ctx context.Context, currencyPair, limit, period string, start, end time.Time) ([]ChartData, error)

GetCandles returns candles which is used for OHLC a specific currency. Note: Result contain candles only with non zero volume.

func (*HitBTC) GetCurrencies

func (h *HitBTC) GetCurrencies(ctx context.Context) (map[string]Currencies, error)

GetCurrencies returns the actual list of available currencies, tokens, ICO etc.

func (*HitBTC) GetCurrency

func (h *HitBTC) GetCurrency(ctx context.Context, currency string) (Currencies, error)

GetCurrency returns the actual list of available currencies, tokens, ICO etc.

func (*HitBTC) GetCurrencyTradeURL

func (h *HitBTC) GetCurrencyTradeURL(_ context.Context, a asset.Item, cp currency.Pair) (string, error)

GetCurrencyTradeURL returns the URL to the exchange's trade page for the given asset and currency pair

func (*HitBTC) GetDepositAddress

func (h *HitBTC) GetDepositAddress(ctx context.Context, currency currency.Code, _, _ string) (*deposit.Address, error)

GetDepositAddress returns a deposit address for a specified currency

func (*HitBTC) GetDepositAddresses

func (h *HitBTC) GetDepositAddresses(ctx context.Context, currency string) (DepositCryptoAddresses, error)

GetDepositAddresses returns a deposit address for a specific currency

func (*HitBTC) GetFee

func (h *HitBTC) GetFee(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*HitBTC) GetFeeByType

func (h *HitBTC) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*HitBTC) GetFeeInfo

func (h *HitBTC) GetFeeInfo(ctx context.Context, currencyPair string) (Fee, error)

GetFeeInfo returns current fee information

func (*HitBTC) GetFuturesContractDetails

func (h *HitBTC) GetFuturesContractDetails(context.Context, asset.Item) ([]futures.Contract, error)

GetFuturesContractDetails returns all contracts from the exchange by asset type

func (*HitBTC) GetHistoricCandles

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

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

func (*HitBTC) GetHistoricCandlesExtended

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

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

func (*HitBTC) GetHistoricTrades

func (h *HitBTC) GetHistoricTrades(ctx context.Context, p currency.Pair, assetType asset.Item, timestampStart, timestampEnd time.Time) ([]trade.Data, error)

GetHistoricTrades returns historic trade data within the timeframe provided

func (*HitBTC) GetLatestFundingRates

GetLatestFundingRates returns the latest funding rates data

func (*HitBTC) GetOpenOrders

func (h *HitBTC) GetOpenOrders(ctx context.Context, currency string) ([]OrderHistoryResponse, error)

GetOpenOrders List of your currently open orders.

func (*HitBTC) GetOrderHistory

func (h *HitBTC) GetOrderHistory(ctx context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

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

func (*HitBTC) GetOrderInfo

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

GetOrderInfo returns order information based on order ID

func (*HitBTC) GetOrderbook

func (h *HitBTC) GetOrderbook(ctx context.Context, currencyPair string, limit int) (*Orderbook, error)

GetOrderbook an order book is an electronic list of buy and sell orders for a specific symbol, organized by price level.

func (*HitBTC) GetOrders

func (h *HitBTC) GetOrders(ctx context.Context, currency string) ([]OrderHistoryResponse, error)

GetOrders List of your order history.

func (*HitBTC) GetRecentTrades

func (h *HitBTC) 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 (*HitBTC) GetServerTime

func (h *HitBTC) GetServerTime(_ context.Context, _ asset.Item) (time.Time, error)

GetServerTime returns the current exchange server time.

func (*HitBTC) GetSymbols

func (h *HitBTC) GetSymbols(ctx context.Context, symbol string) ([]string, error)

GetSymbols Return the actual list of currency symbols (currency pairs) traded on HitBTC exchange. The first listed currency of a symbol is called the base currency, and the second currency is called the quote currency. The currency pair indicates how much of the quote currency is needed to purchase one unit of the base currency.

func (*HitBTC) GetSymbolsDetailed

func (h *HitBTC) GetSymbolsDetailed(ctx context.Context) ([]Symbol, error)

GetSymbolsDetailed is the same as above but returns an array of symbols with all their details.

func (*HitBTC) GetTicker

func (h *HitBTC) GetTicker(ctx context.Context, symbol string) (TickerResponse, error)

GetTicker returns ticker information

func (*HitBTC) GetTickers

func (h *HitBTC) GetTickers(ctx context.Context) ([]TickerResponse, error)

GetTickers returns ticker information

func (*HitBTC) GetTradableBalances

func (h *HitBTC) GetTradableBalances(ctx context.Context) (map[string]map[string]float64, error)

GetTradableBalances returns current tradable balances

func (*HitBTC) GetTradeHistoryForAllCurrencies

func (h *HitBTC) GetTradeHistoryForAllCurrencies(ctx context.Context, start, end string) (AuthenticatedTradeHistoryAll, error)

GetTradeHistoryForAllCurrencies returns your trade history

func (*HitBTC) GetTradeHistoryForCurrency

func (h *HitBTC) GetTradeHistoryForCurrency(ctx context.Context, currency, start, end string) (AuthenticatedTradeHistoryResponse, error)

GetTradeHistoryForCurrency returns your trade history

func (*HitBTC) GetTrades

func (h *HitBTC) GetTrades(ctx context.Context, currencyPair, by, sort string, from, till, limit, offset int64) ([]TradeHistory, error)

GetTrades returns trades from hitbtc

func (*HitBTC) GetWithdrawalsHistory

func (h *HitBTC) GetWithdrawalsHistory(_ context.Context, _ currency.Code, _ asset.Item) ([]exchange.WithdrawalHistory, error)

GetWithdrawalsHistory returns previous withdrawals data

func (*HitBTC) ModifyOrder

func (h *HitBTC) ModifyOrder(_ context.Context, _ *order.Modify) (*order.ModifyResponse, error)

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

func (*HitBTC) MoveOrder

func (h *HitBTC) MoveOrder(ctx context.Context, orderID int64, rate, amount float64) (MoveOrderResponse, error)

MoveOrder generates a new move order

func (*HitBTC) PlaceOrder

func (h *HitBTC) PlaceOrder(ctx context.Context, currency string, rate, amount float64, orderType, side string) (OrderResponse, error)

PlaceOrder places an order on the exchange

func (*HitBTC) SendAuthenticatedHTTPRequest

func (h *HitBTC) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.URL, method, endpoint string, values url.Values, f request.EndpointLimit, result interface{}) error

SendAuthenticatedHTTPRequest sends an authenticated http request

func (*HitBTC) SendHTTPRequest

func (h *HitBTC) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*HitBTC) SetDefaults

func (h *HitBTC) SetDefaults()

SetDefaults sets default settings for hitbtc

func (*HitBTC) Setup

func (h *HitBTC) Setup(exch *config.Exchange) error

Setup sets user exchange configuration settings

func (*HitBTC) SubmitOrder

func (h *HitBTC) SubmitOrder(ctx context.Context, o *order.Submit) (*order.SubmitResponse, error)

SubmitOrder submits a new order

func (*HitBTC) SubmitOrders added in v1.0.7

func (h *HitBTC) SubmitOrders(ctx context.Context, ss ...*order.Submit) ([]*order.SubmitResponse, error)

func (*HitBTC) Subscribe

func (h *HitBTC) Subscribe(channelsToSubscribe []subscription.Subscription) error

Subscribe sends a websocket message to receive data from the channel

func (*HitBTC) TransferBalance

func (h *HitBTC) TransferBalance(ctx context.Context, currency, from, to string, amount float64) (bool, error)

TransferBalance transfers a balance

func (*HitBTC) Unsubscribe

func (h *HitBTC) Unsubscribe(channelsToUnsubscribe []subscription.Subscription) error

Unsubscribe sends a websocket message to stop receiving data from the channel

func (*HitBTC) UpdateAccountInfo

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

UpdateAccountInfo retrieves balances for all enabled currencies for the HitBTC exchange

func (*HitBTC) UpdateOrderExecutionLimits

func (h *HitBTC) UpdateOrderExecutionLimits(_ context.Context, _ asset.Item) error

UpdateOrderExecutionLimits updates order execution limits

func (*HitBTC) UpdateOrderbook

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

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*HitBTC) UpdateTicker

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

UpdateTicker updates and returns the ticker for a currency pair

func (*HitBTC) UpdateTickers

func (h *HitBTC) UpdateTickers(ctx context.Context, a asset.Item) error

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

func (*HitBTC) UpdateTradablePairs

func (h *HitBTC) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error

UpdateTradablePairs updates the exchanges available pairs and stores them in the exchanges config

func (*HitBTC) ValidateAPICredentials

func (h *HitBTC) ValidateAPICredentials(ctx context.Context, assetType asset.Item) error

ValidateAPICredentials validates current credentials used for wrapper functionality

func (*HitBTC) Withdraw

func (h *HitBTC) Withdraw(ctx context.Context, currency, address string, amount float64) (bool, error)

Withdraw allows for the withdrawal to a specific address

func (*HitBTC) WithdrawCryptocurrencyFunds

func (h *HitBTC) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*HitBTC) WithdrawFiatFunds

func (h *HitBTC) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*HitBTC) WithdrawFiatFundsToInternationalBank

func (h *HitBTC) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*HitBTC) WsConnect

func (h *HitBTC) WsConnect() error

WsConnect starts a new connection with the websocket API

func (*HitBTC) WsProcessOrderbookSnapshot

func (h *HitBTC) WsProcessOrderbookSnapshot(ob *WsOrderbook) error

WsProcessOrderbookSnapshot processes a full orderbook snapshot to a local cache

func (*HitBTC) WsProcessOrderbookUpdate

func (h *HitBTC) WsProcessOrderbookUpdate(update *WsOrderbook) error

WsProcessOrderbookUpdate updates a local cache

type LendingHistory

type LendingHistory struct {
	ID       int64   `json:"id"`
	Currency string  `json:"currency"`
	Rate     float64 `json:"rate,string"`
	Amount   float64 `json:"amount,string"`
	Duration float64 `json:"duration,string"`
	Interest float64 `json:"interest,string"`
	Fee      float64 `json:"fee,string"`
	Earned   float64 `json:"earned,string"`
	Open     string  `json:"open"`
	Close    string  `json:"close"`
}

LendingHistory contains lending history data

type LoanOffer

type LoanOffer struct {
	ID        int64   `json:"id"`
	Rate      float64 `json:"rate,string"`
	Amount    float64 `json:"amount,string"`
	Duration  int     `json:"duration"`
	AutoRenew bool    `json:"autoRenew"`
	Date      string  `json:"date"`
}

LoanOffer holds information about your loan offers

type LoanOrder

type LoanOrder struct {
	Rate     float64 `json:"rate,string"`
	Amount   float64 `json:"amount,string"`
	RangeMin int     `json:"rangeMin"`
	RangeMax int     `json:"rangeMax"`
}

LoanOrder contains information about your loans

type LoanOrders

type LoanOrders struct {
	Offers  []LoanOrder `json:"offers"`
	Demands []LoanOrder `json:"demands"`
}

LoanOrders holds information on the full range of loan orders

type Margin

type Margin struct {
	TotalValue    float64 `json:"totalValue,string"`
	ProfitLoss    float64 `json:"pl,string"`
	LendingFees   float64 `json:"lendingFees,string"`
	NetValue      float64 `json:"netValue,string"`
	BorrowedValue float64 `json:"totalBorrowedValue,string"`
	CurrentMargin float64 `json:"currentMargin,string"`
}

Margin holds full margin information

type MarginPosition

type MarginPosition struct {
	Amount            float64 `json:"amount,string"`
	Total             float64 `json:"total,string"`
	BasePrice         float64 `json:"basePrice,string"`
	LiquidiationPrice float64 `json:"liquidiationPrice"`
	ProfitLoss        float64 `json:"pl,string"`
	LendingFees       float64 `json:"lendingFees,string"`
	Type              string  `json:"type"`
}

MarginPosition holds information about your current margin position

type MoveOrderResponse

type MoveOrderResponse struct {
	Success     int                          `json:"success"`
	Error       string                       `json:"error"`
	OrderNumber int64                        `json:"orderNumber,string"`
	Trades      map[string][]ResultingTrades `json:"resultingTrades"`
}

MoveOrderResponse holds information about a move order

type OpenOrdersResponse

type OpenOrdersResponse struct {
	Data []Order
}

OpenOrdersResponse contains open order information

type OpenOrdersResponseAll

type OpenOrdersResponseAll struct {
	Data map[string][]Order
}

OpenOrdersResponseAll holds the full open order response

type Order

type Order struct {
	ID            int64  `json:"id,string"`     //  Unique identifier for Order as assigned by exchange
	ClientOrderID string `json:"clientOrderId"` // Unique identifier for Order as assigned by trader. Uniqueness must be
	// guaranteed within a single trading day, including all active orders.
	Symbol      string `json:"symbol"`      // Trading symbol
	Side        string `json:"side"`        // sell buy
	Status      string `json:"status"`      // new, suspended, partiallyFilled, filled, canceled, expired
	Type        string `json:"type"`        // Enum: limit, market, stopLimit, stopMarket
	TimeInForce string `json:"timeInForce"` // Time in force is a special instruction used when placing a trade to
	//   indicate how long an order will remain active before it is executed or expires
	// GTC - Good till cancel. GTC order won't close until it is filled.
	// IOC - An immediate or cancel order is an order to buy or sell that must be executed immediately, and any portion
	//   of the order that cannot be immediately filled is cancelled.
	// FOK - Fill or kill is a type of time-in-force designation used in securities trading that instructs a brokerage
	//   to execute a transaction immediately and completely or not at all.
	// Day - keeps the order active until the end of the trading day in UTC.
	// GTD - Good till date specified in expireTime.
	Quantity    float64   `json:"quantity,string"`    // Order quantity
	Price       float64   `json:"price,string"`       // Order price
	CumQuantity float64   `json:"cumQuantity,string"` // Cumulative executed quantity
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
	StopPrice   float64   `json:"stopPrice,string"`
	ExpireTime  time.Time `json:"expireTime"`
}

Order contains information about an order

type OrderHistoryResponse

type OrderHistoryResponse struct {
	ID            string    `json:"id"`
	ClientOrderID string    `json:"clientOrderId"`
	Symbol        string    `json:"symbol"`
	Side          string    `json:"side"`
	Status        string    `json:"status"`
	Type          string    `json:"type"`
	TimeInForce   string    `json:"timeInForce"`
	Price         float64   `json:"price,string"`
	AvgPrice      float64   `json:"avgPrice,string"`
	Quantity      float64   `json:"quantity,string"`
	PostOnly      bool      `json:"postOnly"`
	CumQuantity   float64   `json:"cumQuantity,string"`
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
}

OrderHistoryResponse used for GetOrderHistory

type OrderResponse

type OrderResponse struct {
	OrderNumber int64             `json:"orderNumber,string"`
	Trades      []ResultingTrades `json:"resultingTrades"`
}

OrderResponse holds the order response information

type Orderbook

type Orderbook struct {
	Asks []OrderbookItem `json:"ask"`
	Bids []OrderbookItem `json:"bid"`
}

Orderbook contains orderbook data

type OrderbookItem

type OrderbookItem struct {
	Price  float64 `json:"price,string"` // Price level
	Amount float64 `json:"size,string"`  // Total volume of orders with the specified price
}

OrderbookItem is a sub type for orderbook response

type Params

type Params struct {
	Symbol  string   `json:"symbol,omitempty"`
	Period  string   `json:"period,omitempty"`
	Limit   int64    `json:"limit,omitempty"`
	Symbols []string `json:"symbols,omitempty"`
}

Params is params

type RateLimit

type RateLimit struct {
	MarketData *rate.Limiter
	Trading    *rate.Limiter
	Other      *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 ResponseError

type ResponseError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ResponseError contains error codes from JSON responses

type ResultingTrades

type ResultingTrades struct {
	Amount  float64 `json:"amount,string"`
	Date    string  `json:"date"`
	Rate    float64 `json:"rate,string"`
	Total   float64 `json:"total,string"`
	TradeID int64   `json:"tradeID,string"`
	Type    string  `json:"type"`
}

ResultingTrades holds resulting trade information

type Symbol

type Symbol struct {
	ID                   string  `json:"id"` // Symbol identifier. In the future, the description will simply use the symbol
	BaseCurrency         string  `json:"baseCurrency"`
	QuoteCurrency        string  `json:"quoteCurrency"`
	QuantityIncrement    float64 `json:"quantityIncrement,string"`
	TickSize             float64 `json:"tickSize,string"`
	TakeLiquidityRate    float64 `json:"takeLiquidityRate,string"`    // Default fee rate
	ProvideLiquidityRate float64 `json:"provideLiquidityRate,string"` // Default fee rate for market making trades
	FeeCurrency          string  `json:"feeCurrency"`                 // Default fee rate for market making trades
}

Symbol holds symbol data

type TickerResponse

type TickerResponse struct {
	Ask         float64   `json:"ask,string"`
	Bid         float64   `json:"bid,string"`
	High        float64   `json:"high,string"`
	Last        float64   `json:"last,string"`
	Low         float64   `json:"low,string"`
	Open        float64   `json:"open,string"`
	Volume      float64   `json:"volume,string"`
	VolumeQuote float64   `json:"volumeQuote,string"`
	Symbol      string    `json:"symbol"`
	Timestamp   time.Time `json:"timestamp"`
}

TickerResponse is the response type

type TradeHistory

type TradeHistory struct {
	ID        int64     `json:"id"`              // Trade id
	Timestamp time.Time `json:"timestamp"`       // Trade timestamp
	Side      string    `json:"side"`            // Trade side sell or buy
	Price     float64   `json:"price,string"`    // Trade price
	Quantity  float64   `json:"quantity,string"` // Trade quantity
}

TradeHistory contains trade history data

type Withdraw

type Withdraw struct {
	Response string `json:"response"`
	Error    string `json:"error"`
}

Withdraw holds response for a withdrawal process

type WsCancelOrderRequest

type WsCancelOrderRequest struct {
	Method string                   `json:"method"`
	Params WsCancelOrderRequestData `json:"params"`
	ID     int64                    `json:"id"`
}

WsCancelOrderRequest WS request

type WsCancelOrderRequestData

type WsCancelOrderRequestData struct {
	ClientOrderID string `json:"clientOrderId"`
}

WsCancelOrderRequestData WS request data

type WsCancelOrderResponse

type WsCancelOrderResponse struct {
	Result WsCancelOrderResponseData `json:"result"`
	ID     int64                     `json:"id"`
	Error  ResponseError             `json:"error,omitempty"`
}

WsCancelOrderResponse WS response

type WsCancelOrderResponseData

type WsCancelOrderResponseData struct {
	ID            string    `json:"id"`
	ClientOrderID string    `json:"clientOrderId,omitempty"`
	Symbol        string    `json:"symbol"`
	Side          string    `json:"side"`
	Status        string    `json:"status"`
	Type          string    `json:"type"`
	TimeInForce   string    `json:"timeInForce"`
	Quantity      float64   `json:"quantity,string"`
	Price         float64   `json:"price,string"`
	CumQuantity   float64   `json:"cumQuantity,string"`
	PostOnly      bool      `json:"postOnly"`
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
	ReportType    string    `json:"reportType"`
}

WsCancelOrderResponseData WS response data

type WsGetActiveOrdersResponse

type WsGetActiveOrdersResponse struct {
	Result []WsGetActiveOrdersResponseData `json:"result"`
	ID     int64                           `json:"id"`
	Error  ResponseError                   `json:"error,omitempty"`
}

WsGetActiveOrdersResponse WS response

type WsGetActiveOrdersResponseData

type WsGetActiveOrdersResponseData struct {
	ID                           string    `json:"id"`
	ClientOrderID                string    `json:"clientOrderId,omitempty"`
	Symbol                       string    `json:"symbol"`
	Side                         string    `json:"side"`
	Status                       string    `json:"status"`
	Type                         string    `json:"type"`
	TimeInForce                  string    `json:"timeInForce"`
	Quantity                     float64   `json:"quantity,string"`
	Price                        float64   `json:"price,string"`
	CumQuantity                  float64   `json:"cumQuantity,string"`
	PostOnly                     bool      `json:"postOnly"`
	CreatedAt                    time.Time `json:"createdAt"`
	UpdatedAt                    time.Time `json:"updatedAt"`
	ReportType                   string    `json:"reportType"`
	OriginalRequestClientOrderID string    `json:"originalRequestClientOrderId"`
}

WsGetActiveOrdersResponseData WS response data

type WsGetCurrenciesRequest

type WsGetCurrenciesRequest struct {
	Method string                           `json:"method"`
	Params WsGetCurrenciesRequestParameters `json:"params"`
	ID     int64                            `json:"id"`
}

WsGetCurrenciesRequest gets currencies

type WsGetCurrenciesRequestParameters

type WsGetCurrenciesRequestParameters struct {
	Currency currency.Code `json:"currency"`
}

WsGetCurrenciesRequestParameters parameters

type WsGetCurrenciesResponse

type WsGetCurrenciesResponse struct {
	Result WsGetCurrenciesResponseData `json:"result"`
	ID     int64                       `json:"id"`
	Error  ResponseError               `json:"error,omitempty"`
}

WsGetCurrenciesResponse currency response

type WsGetCurrenciesResponseData

type WsGetCurrenciesResponseData struct {
	ID                 currency.Code `json:"id"`
	FullName           string        `json:"fullName"`
	Crypto             bool          `json:"crypto"`
	PayinEnabled       bool          `json:"payinEnabled"`
	PayinPaymentID     bool          `json:"payinPaymentId"`
	PayinConfirmations int64         `json:"payinConfirmations"`
	PayoutEnabled      bool          `json:"payoutEnabled"`
	PayoutIsPaymentID  bool          `json:"payoutIsPaymentId"`
	TransferEnabled    bool          `json:"transferEnabled"`
	Delisted           bool          `json:"delisted"`
	PayoutFee          string        `json:"payoutFee"`
}

WsGetCurrenciesResponseData currency response data

type WsGetSymbolsRequest

type WsGetSymbolsRequest struct {
	Method string                        `json:"method"`
	Params WsGetSymbolsRequestParameters `json:"params"`
	ID     int64                         `json:"id"`
}

WsGetSymbolsRequest request data

type WsGetSymbolsRequestParameters

type WsGetSymbolsRequestParameters struct {
	Symbol string `json:"symbol"`
}

WsGetSymbolsRequestParameters request parameters

type WsGetSymbolsResponse

type WsGetSymbolsResponse struct {
	Result WsGetSymbolsResponseData `json:"result"`
	ID     int64                    `json:"id"`
	Error  ResponseError            `json:"error,omitempty"`
}

WsGetSymbolsResponse symbol response

type WsGetSymbolsResponseData

type WsGetSymbolsResponseData struct {
	ID                   string        `json:"id"`
	BaseCurrency         currency.Code `json:"baseCurrency"`
	QuoteCurrency        currency.Code `json:"quoteCurrency"`
	QuantityIncrement    float64       `json:"quantityIncrement,string"`
	TickSize             float64       `json:"tickSize,string"`
	TakeLiquidityRate    float64       `json:"takeLiquidityRate,string"`
	ProvideLiquidityRate float64       `json:"provideLiquidityRate,string"`
	FeeCurrency          currency.Code `json:"feeCurrency"`
}

WsGetSymbolsResponseData symbol response data

type WsGetTradesRequest

type WsGetTradesRequest struct {
	Method string                       `json:"method"`
	Params WsGetTradesRequestParameters `json:"params"`
	ID     int64                        `json:"id"`
}

WsGetTradesRequest trade request

type WsGetTradesRequestParameters

type WsGetTradesRequestParameters struct {
	Symbol string `json:"symbol"`
	Limit  int64  `json:"limit"`
	Sort   string `json:"sort"`
	By     string `json:"by"`
}

WsGetTradesRequestParameters trade request params

type WsGetTradesResponse

type WsGetTradesResponse struct {
	Jsonrpc string                  `json:"jsonrpc"`
	Result  WsGetTradesResponseData `json:"result"`
	ID      int64                   `json:"id"`
	Error   ResponseError           `json:"error,omitempty"`
}

WsGetTradesResponse response

type WsGetTradesResponseData

type WsGetTradesResponseData struct {
	Data   []WsGetTradesResponseTrades `json:"data"`
	Symbol string                      `json:"symbol"`
}

WsGetTradesResponseData trade response data

type WsGetTradesResponseTrades

type WsGetTradesResponseTrades struct {
	ID        int64     `json:"id"`
	Price     float64   `json:"price,string"`
	Quantity  float64   `json:"quantity,string"`
	Side      string    `json:"side"`
	Timestamp time.Time `json:"timestamp"`
}

WsGetTradesResponseTrades trade response

type WsGetTradingBalanceResponse

type WsGetTradingBalanceResponse struct {
	Result []WsGetTradingBalanceResponseData `json:"result"`
	ID     int64                             `json:"id"`
	Error  ResponseError                     `json:"error,omitempty"`
}

WsGetTradingBalanceResponse WS response

type WsGetTradingBalanceResponseData

type WsGetTradingBalanceResponseData struct {
	Currency  currency.Code `json:"currency"`
	Available float64       `json:"available,string"`
	Reserved  float64       `json:"reserved,string"`
}

WsGetTradingBalanceResponseData WS response data

type WsLoginData

type WsLoginData struct {
	Algo      string `json:"algo"`
	PKey      string `json:"pKey"`
	Nonce     string `json:"nonce"`
	Signature string `json:"signature"`
}

WsLoginData sets credentials for WsLoginRequest

type WsLoginRequest

type WsLoginRequest struct {
	Method string      `json:"method"`
	Params WsLoginData `json:"params"`
	ID     int64       `json:"id,omitempty"`
}

WsLoginRequest defines login requirements for ws

type WsNotification

type WsNotification struct {
	JSONRPCVersion string `json:"jsonrpc,omitempty"`
	Method         string `json:"method"`
	Params         Params `json:"params"`
}

WsNotification defines a notification obj for the JSON-RPC this does not get a websocket response

type WsOrderbook

type WsOrderbook struct {
	Params struct {
		Ask []struct {
			Price float64 `json:"price,string"`
			Size  float64 `json:"size,string"`
		} `json:"ask"`
		Bid []struct {
			Price float64 `json:"price,string"`
			Size  float64 `json:"size,string"`
		} `json:"bid"`
		Symbol    string    `json:"symbol"`
		Sequence  int64     `json:"sequence"`
		Timestamp time.Time `json:"timestamp"`
	} `json:"params"`
}

WsOrderbook defines websocket orderbook feed return params

type WsReplaceOrderRequest

type WsReplaceOrderRequest struct {
	Method string                    `json:"method"`
	Params WsReplaceOrderRequestData `json:"params"`
	ID     int64                     `json:"id,omitempty"`
}

WsReplaceOrderRequest WS request

type WsReplaceOrderRequestData

type WsReplaceOrderRequestData struct {
	ClientOrderID   string  `json:"clientOrderId,omitempty"`
	RequestClientID string  `json:"requestClientId,omitempty"`
	Quantity        float64 `json:"quantity,string,omitempty"`
	Price           float64 `json:"price,string,omitempty"`
}

WsReplaceOrderRequestData WS request data

type WsReplaceOrderResponse

type WsReplaceOrderResponse struct {
	Result WsReplaceOrderResponseData `json:"result"`
	ID     int64                      `json:"id"`
	Error  ResponseError              `json:"error,omitempty"`
}

WsReplaceOrderResponse WS response

type WsReplaceOrderResponseData

type WsReplaceOrderResponseData struct {
	ID                           string    `json:"id"`
	ClientOrderID                string    `json:"clientOrderId,omitempty"`
	Symbol                       string    `json:"symbol"`
	Side                         string    `json:"side"`
	Status                       string    `json:"status"`
	Type                         string    `json:"type"`
	TimeInForce                  string    `json:"timeInForce"`
	Quantity                     float64   `json:"quantity,string"`
	Price                        float64   `json:"price,string"`
	CumQuantity                  float64   `json:"cumQuantity,string"`
	PostOnly                     bool      `json:"postOnly"`
	CreatedAt                    time.Time `json:"createdAt"`
	UpdatedAt                    time.Time `json:"updatedAt"`
	ReportType                   string    `json:"reportType"`
	OriginalRequestClientOrderID string    `json:"originalRequestClientOrderId"`
}

WsReplaceOrderResponseData WS response data

type WsReportResponse

type WsReportResponse struct {
	Params WsReportResponseData `json:"params"`
	Error  ResponseError        `json:"error,omitempty"`
}

WsReportResponse report response for auth subscription to reports

type WsReportResponseData

type WsReportResponseData struct {
	ID            string    `json:"id"`
	ClientOrderID string    `json:"clientOrderId,omitempty"`
	Symbol        string    `json:"symbol"`
	Side          string    `json:"side"`
	Status        string    `json:"status"`
	Type          string    `json:"type"`
	TimeInForce   string    `json:"timeInForce"`
	Quantity      float64   `json:"quantity,string"`
	Price         float64   `json:"price,string"`
	CumQuantity   float64   `json:"cumQuantity,string"`
	PostOnly      bool      `json:"postOnly"`
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
	ReportType    string    `json:"reportType"`
	TradeQuantity float64   `json:"tradeQuantity,string"`
	TradePrice    float64   `json:"tradePrice,string"`
	TradeID       int64     `json:"tradeId"`
	TradeFee      float64   `json:"tradeFee,string"`
}

WsReportResponseData Report data for WsReportResponse

type WsRequest

type WsRequest struct {
	Method string `json:"method"`
	Params Params `json:"params,omitempty"`
	ID     int64  `json:"id"`
}

WsRequest defines a request obj for the JSON-RPC and gets a websocket response

type WsSubmitOrderErrorResponse

type WsSubmitOrderErrorResponse struct {
	Error WsSubmitOrderErrorResponseData `json:"error,omitempty"`
	ID    int64                          `json:"id"`
}

WsSubmitOrderErrorResponse WS error response

type WsSubmitOrderErrorResponseData

type WsSubmitOrderErrorResponseData struct {
	Code        int64  `json:"code"`
	Message     string `json:"message"`
	Description string `json:"description"`
}

WsSubmitOrderErrorResponseData WS error response data

type WsSubmitOrderRequest

type WsSubmitOrderRequest struct {
	Method string                   `json:"method"`
	Params WsSubmitOrderRequestData `json:"params"`
	ID     int64                    `json:"id"`
}

WsSubmitOrderRequest WS request

type WsSubmitOrderRequestData

type WsSubmitOrderRequestData struct {
	ClientOrderID int64   `json:"clientOrderId,string,omitempty"`
	Symbol        string  `json:"symbol"`
	Side          string  `json:"side"`
	Price         float64 `json:"price,string"`
	Quantity      float64 `json:"quantity,string"`
}

WsSubmitOrderRequestData WS request data

type WsSubmitOrderSuccessResponse

type WsSubmitOrderSuccessResponse struct {
	Result WsSubmitOrderSuccessResponseData `json:"result"`
	ID     int64                            `json:"id"`
	Error  ResponseError                    `json:"error,omitempty"`
}

WsSubmitOrderSuccessResponse WS response

type WsSubmitOrderSuccessResponseData

type WsSubmitOrderSuccessResponseData struct {
	ID            string    `json:"id"`
	ClientOrderID string    `json:"clientOrderId"`
	Symbol        string    `json:"symbol"`
	Side          string    `json:"side"`
	Status        string    `json:"status"`
	Type          string    `json:"type"`
	TimeInForce   string    `json:"timeInForce"`
	Quantity      float64   `json:"quantity,string"`
	Price         float64   `json:"price,string"`
	CumQuantity   float64   `json:"cumQuantity,string"`
	PostOnly      bool      `json:"postOnly"`
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
	ReportType    string    `json:"reportType"`
}

WsSubmitOrderSuccessResponseData WS response data

type WsTicker

type WsTicker struct {
	Params struct {
		Ask         float64   `json:"ask,string"`
		Bid         float64   `json:"bid,string"`
		Last        float64   `json:"last,string"`
		Open        float64   `json:"open,string"`
		Low         float64   `json:"low,string"`
		High        float64   `json:"high,string"`
		Volume      float64   `json:"volume,string"`
		VolumeQuote float64   `json:"volumeQuote,string"`
		Timestamp   time.Time `json:"timestamp"`
		Symbol      string    `json:"symbol"`
	} `json:"params"`
}

WsTicker defines websocket ticker feed return params

type WsTrade

type WsTrade struct {
	Params struct {
		Data []struct {
			ID        int64     `json:"id"`
			Price     float64   `json:"price,string"`
			Quantity  float64   `json:"quantity,string"`
			Side      string    `json:"side"`
			Timestamp time.Time `json:"timestamp"`
		} `json:"data"`
		Symbol string `json:"symbol"`
	} `json:"params"`
}

WsTrade defines websocket trade feed return params

Jump to

Keyboard shortcuts

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