coinut

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 36 Imported by: 0

README

GoCryptoTrader package Coinut

Build Status Software License GoDoc Coverage Status Go Report Card

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

Coinut 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() == "Coinut" {
		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
tradeID, err := c.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 COINUT

type COINUT struct {
	exchange.Base
	// contains filtered or unexported fields
}

COINUT is the overarching type across the coinut package

func (*COINUT) AuthenticateWebsocket

func (c *COINUT) AuthenticateWebsocket(ctx context.Context) error

AuthenticateWebsocket sends an authentication message to the websocket

func (*COINUT) CancelAllOrders

func (c *COINUT) CancelAllOrders(ctx context.Context, details *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*COINUT) CancelBatchOrders

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

CancelBatchOrders cancels an orders by their corresponding ID numbers

func (*COINUT) CancelExistingOrder

func (c *COINUT) CancelExistingOrder(ctx context.Context, instrumentID, orderID int64) (bool, error)

CancelExistingOrder cancels a specific order and returns if it was actioned

func (*COINUT) CancelOrder

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

CancelOrder cancels an order by its corresponding ID number

func (*COINUT) CancelOrders

func (c *COINUT) CancelOrders(ctx context.Context, orders []CancelOrders) (CancelOrdersResponse, error)

CancelOrders cancels multiple orders

func (*COINUT) FetchAccountInfo

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

FetchAccountInfo retrieves balances for all enabled currencies

func (*COINUT) FetchOrderbook

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

FetchOrderbook returns orderbook base on the currency pair

func (*COINUT) FetchTicker

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

FetchTicker returns the ticker for a currency pair

func (*COINUT) FetchTradablePairs

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

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*COINUT) GenerateDefaultSubscriptions

func (c *COINUT) GenerateDefaultSubscriptions() ([]subscription.Subscription, error)

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

func (*COINUT) GetAccountFundingHistory

func (c *COINUT) GetAccountFundingHistory(_ context.Context) ([]exchange.FundingHistory, error)

GetAccountFundingHistory returns funding history, deposits and withdrawals

func (*COINUT) GetActiveOrders

func (c *COINUT) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

GetActiveOrders retrieves any orders that are active/open

func (*COINUT) GetCurrencyTradeURL

func (c *COINUT) 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 (*COINUT) GetDepositAddress

func (c *COINUT) GetDepositAddress(_ context.Context, _ currency.Code, _, _ string) (*deposit.Address, error)

GetDepositAddress returns a deposit address for a specified currency

func (*COINUT) GetDerivativeInstruments

func (c *COINUT) GetDerivativeInstruments(ctx context.Context, secType string) (interface{}, error)

GetDerivativeInstruments returns a list of derivative instruments

func (*COINUT) GetFee

func (c *COINUT) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*COINUT) GetFeeByType

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

GetFeeByType returns an estimate of fee based on type of transaction

func (*COINUT) GetFuturesContractDetails

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

GetFuturesContractDetails returns all contracts from the exchange by asset type

func (*COINUT) GetHistoricCandles

func (c *COINUT) GetHistoricCandles(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error)

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

func (*COINUT) GetHistoricCandlesExtended

func (c *COINUT) GetHistoricCandlesExtended(_ context.Context, _ currency.Pair, _ asset.Item, _ kline.Interval, _, _ time.Time) (*kline.Item, error)

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

func (*COINUT) GetHistoricTrades

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

GetHistoricTrades returns historic trade data within the timeframe provided

func (*COINUT) GetIndexTicker

func (c *COINUT) GetIndexTicker(ctx context.Context, asset string) (IndexTicker, error)

GetIndexTicker returns the index ticker for an asset

func (*COINUT) GetInstrumentOrderbook

func (c *COINUT) GetInstrumentOrderbook(ctx context.Context, instrumentID, limit int64) (*Orderbook, error)

GetInstrumentOrderbook returns the orderbooks for a specific instrument

func (*COINUT) GetInstrumentTicker

func (c *COINUT) GetInstrumentTicker(ctx context.Context, instrumentID int64) (Ticker, error)

GetInstrumentTicker returns a ticker for a specific instrument

func (*COINUT) GetInstruments

func (c *COINUT) GetInstruments(ctx context.Context) (Instruments, error)

GetInstruments returns instruments

func (*COINUT) GetLatestFundingRates

GetLatestFundingRates returns the latest funding rates data

func (*COINUT) GetOpenOrders

func (c *COINUT) GetOpenOrders(ctx context.Context, instrumentID int64) (GetOpenOrdersResponse, error)

GetOpenOrders returns a list of open order and relevant information

func (*COINUT) GetOpenPositionsForInstrument

func (c *COINUT) GetOpenPositionsForInstrument(ctx context.Context, instrumentID int) ([]OpenPosition, error)

GetOpenPositionsForInstrument returns all your current opened positions

func (*COINUT) GetOptionChain

func (c *COINUT) GetOptionChain(ctx context.Context, asset, secType string) (OptionChainResponse, error)

GetOptionChain returns option chain

func (*COINUT) GetOrderHistory

func (c *COINUT) GetOrderHistory(ctx context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

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

func (*COINUT) GetOrderInfo

func (c *COINUT) GetOrderInfo(_ context.Context, _ string, _ currency.Pair, _ asset.Item) (*order.Detail, error)

GetOrderInfo returns order information based on order ID

func (*COINUT) GetPositionHistory

func (c *COINUT) GetPositionHistory(ctx context.Context, secType string, start, limit int) (PositionHistory, error)

GetPositionHistory returns position history

func (*COINUT) GetRecentTrades

func (c *COINUT) 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 (*COINUT) GetServerTime

func (c *COINUT) GetServerTime(_ context.Context, _ asset.Item) (time.Time, error)

GetServerTime returns the current exchange server time.

func (*COINUT) GetTradeHistory

func (c *COINUT) GetTradeHistory(ctx context.Context, instrumentID, start, limit int64) (TradeHistory, error)

GetTradeHistory returns trade history for a specific instrument.

func (*COINUT) GetTrades

func (c *COINUT) GetTrades(ctx context.Context, instrumentID int64) (Trades, error)

GetTrades returns trade information

func (*COINUT) GetUserBalance

func (c *COINUT) GetUserBalance(ctx context.Context) (*UserBalance, error)

GetUserBalance returns the full user balance

func (*COINUT) GetWithdrawalsHistory

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

GetWithdrawalsHistory returns previous withdrawals data

func (*COINUT) ModifyOrder

func (c *COINUT) ModifyOrder(_ context.Context, _ *order.Modify) (*order.ModifyResponse, error)

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

func (*COINUT) NewOrder

func (c *COINUT) NewOrder(ctx context.Context, instrumentID int64, quantity, price float64, buy bool, orderID uint32) (interface{}, error)

NewOrder places a new order on the exchange

func (*COINUT) NewOrders

func (c *COINUT) NewOrders(ctx context.Context, orders []Order) ([]OrdersBase, error)

NewOrders places multiple orders on the exchange

func (*COINUT) SeedInstruments

func (c *COINUT) SeedInstruments(ctx context.Context) error

SeedInstruments seeds the instrument map

func (*COINUT) SendHTTPRequest

func (c *COINUT) SendHTTPRequest(ctx context.Context, ep exchange.URL, apiRequest string, params map[string]interface{}, authenticated bool, result interface{}) (err error)

SendHTTPRequest sends either an authenticated or unauthenticated HTTP request

func (*COINUT) SetDefaults

func (c *COINUT) SetDefaults()

SetDefaults sets current default values

func (*COINUT) Setup

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

Setup sets the current exchange configuration

func (*COINUT) SubmitOrder

func (c *COINUT) SubmitOrder(ctx context.Context, o *order.Submit) (*order.SubmitResponse, error)

SubmitOrder submits a new order

func (*COINUT) SubmitOrders added in v1.0.7

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

func (*COINUT) Subscribe

func (c *COINUT) Subscribe(channelsToSubscribe []subscription.Subscription) error

Subscribe sends a websocket message to receive data from the channel

func (*COINUT) Unsubscribe

func (c *COINUT) Unsubscribe(channelToUnsubscribe []subscription.Subscription) error

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

func (*COINUT) UpdateAccountInfo

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

UpdateAccountInfo retrieves balances for all enabled currencies for the COINUT exchange

func (*COINUT) UpdateOrderExecutionLimits

func (c *COINUT) UpdateOrderExecutionLimits(_ context.Context, _ asset.Item) error

UpdateOrderExecutionLimits updates order execution limits

func (*COINUT) UpdateOrderbook

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

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*COINUT) UpdateTicker

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

UpdateTicker updates and returns the ticker for a currency pair

func (*COINUT) UpdateTickers

func (c *COINUT) UpdateTickers(_ context.Context, _ asset.Item) error

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

func (*COINUT) UpdateTradablePairs

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

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

func (*COINUT) ValidateAPICredentials

func (c *COINUT) ValidateAPICredentials(ctx context.Context, assetType asset.Item) error

ValidateAPICredentials validates current credentials used for wrapper functionality

func (*COINUT) WithdrawCryptocurrencyFunds

func (c *COINUT) WithdrawCryptocurrencyFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*COINUT) WithdrawFiatFunds

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

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*COINUT) WithdrawFiatFundsToInternationalBank

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

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*COINUT) WsConnect

func (c *COINUT) WsConnect() error

WsConnect initiates a websocket connection

func (*COINUT) WsGetInstruments

func (c *COINUT) WsGetInstruments() (Instruments, error)

WsGetInstruments fetches instrument list and propagates a local cache

func (*COINUT) WsProcessOrderbookSnapshot

func (c *COINUT) WsProcessOrderbookSnapshot(ob *WsOrderbookSnapshot) error

WsProcessOrderbookSnapshot processes the orderbook snapshot

func (*COINUT) WsProcessOrderbookUpdate

func (c *COINUT) WsProcessOrderbookUpdate(update *WsOrderbookUpdate) error

WsProcessOrderbookUpdate process an orderbook update

type CancelOrders

type CancelOrders struct {
	InstrumentID int64 `json:"inst_id"`
	OrderID      int64 `json:"order_id"`
}

CancelOrders holds information about a cancelled order

type CancelOrdersResponse

type CancelOrdersResponse struct {
	GenericResponse
	Results []struct {
		OrderID      int64  `json:"order_id"`
		Status       string `json:"status"`
		InstrumentID int64  `json:"inst_id"`
	} `json:"results"`
}

CancelOrdersResponse is response for a cancelled order

type Commission

type Commission struct {
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount,string"`
}

Commission holds trade commission structure

type GenericResponse

type GenericResponse struct {
	Nonce         int64    `json:"nonce"`
	Reply         string   `json:"reply"`
	Status        []string `json:"status"`
	TransactionID int64    `json:"trans_id"`
}

GenericResponse is the generic response you will get from coinut

type GetOpenOrdersResponse

type GetOpenOrdersResponse struct {
	Nonce         int             `json:"nonce"`
	Orders        []OrderResponse `json:"orders"`
	Reply         string          `json:"reply"`
	Status        []string        `json:"status"`
	TransactionID int             `json:"trans_id"`
}

GetOpenOrdersResponse holds all order data from GetOpenOrders request

type IndexTicker

type IndexTicker struct {
	Asset string  `json:"asset"`
	Price float64 `json:"price,string"`
}

IndexTicker holds indexed ticker information

type InstrumentBase

type InstrumentBase struct {
	Base          string `json:"base"`
	DecimalPlaces int    `json:"decimal_places"`
	InstrumentID  int64  `json:"inst_id"`
	Quote         string `json:"quote"`
}

InstrumentBase holds information on base currency

type Instruments

type Instruments struct {
	Instruments map[string][]InstrumentBase `json:"SPOT"`
}

Instruments holds the full information on base currencies

type OpenPosition

type OpenPosition struct {
	PositionID    int        `json:"position_id"`
	Commission    Commission `json:"commission"`
	OpenPrice     float64    `json:"open_price,string"`
	RealizedPL    float64    `json:"realized_pl,string"`
	Quantity      float64    `json:"qty,string"`
	OpenTimestamp int64      `json:"open_timestamp"`
	InstrumentID  int        `json:"inst_id"`
}

OpenPosition holds information on an open position

type Option

type Option struct {
	HighestBuy   float64 `json:"highest_buy,string"`
	InstrumentID int     `json:"inst_id"`
	Last         float64 `json:"last,string"`
	LowestSell   float64 `json:"lowest_sell,string"`
	OpenInterest float64 `json:"open_interest,string"`
}

Option holds options information

type OptionChainResponse

type OptionChainResponse struct {
	ExpiryTime   int64  `json:"expiry_time"`
	SecurityType string `json:"sec_type"`
	Asset        string `json:"asset"`
	Entries      []struct {
		Call   Option  `json:"call"`
		Put    Option  `json:"put"`
		Strike float64 `json:"strike,string"`
	}
}

OptionChainResponse is the response type for options

type OptionChainUpdate

type OptionChainUpdate struct {
	Option
	GenericResponse
	Asset        string  `json:"asset"`
	ExpiryTime   int64   `json:"expiry_time"`
	SecurityType string  `json:"sec_type"`
	Volume       float64 `json:"volume,string"`
}

OptionChainUpdate contains information on the chain update options

type Order

type Order struct {
	InstrumentID  int64   `json:"inst_id"`
	Price         float64 `json:"price,string"`
	Quantity      float64 `json:"qty,string"`
	ClientOrderID int     `json:"client_ord_id"`
	Side          string  `json:"side,string"`
}

Order holds order information

type OrderFilledResponse

type OrderFilledResponse struct {
	GenericResponse
	Commission   Commission    `json:"commission"`
	FillPrice    float64       `json:"fill_price,string"`
	FillQuantity float64       `json:"fill_qty,string"`
	Order        OrderResponse `json:"order"`
}

OrderFilledResponse contains order filled response

type OrderRejectResponse

type OrderRejectResponse struct {
	OrderResponse
	Reasons []string `json:"reasons"`
}

OrderRejectResponse holds information on a rejected order

type OrderResponse

type OrderResponse struct {
	OrderID       int64   `json:"order_id"`
	OpenQuantity  float64 `json:"open_qty,string"`
	Price         float64 `json:"price,string"`
	Quantity      float64 `json:"qty,string"`
	InstrumentID  int64   `json:"inst_id"`
	ClientOrderID int64   `json:"client_ord_id"`
	Timestamp     int64   `json:"timestamp"`
	OrderPrice    float64 `json:"order_price,string"`
	Side          string  `json:"side"`
}

OrderResponse is a response for orders

type Orderbook

type Orderbook struct {
	Buy           []OrderbookBase `json:"buy"`
	Sell          []OrderbookBase `json:"sell"`
	InstrumentID  int             `json:"inst_id"`
	TotalBuy      float64         `json:"total_buy,string"`
	TotalSell     float64         `json:"total_sell,string"`
	TransactionID int64           `json:"trans_id"`
}

Orderbook is the full order book

type OrderbookBase

type OrderbookBase struct {
	Count    int     `json:"count"`
	Price    float64 `json:"price,string"`
	Quantity float64 `json:"qty,string"`
}

OrderbookBase is a sub-type holding price and quantity

type OrdersBase

type OrdersBase struct {
	GenericResponse
	OrderResponse
}

OrdersBase contains generic response and order responses

type OrdersResponse

type OrdersResponse struct {
	Data []OrdersBase
}

OrdersResponse holds the full data range on orders

type PositionHistory

type PositionHistory struct {
	Positions []struct {
		PositionID int `json:"position_id"`
		Records    []struct {
			Commission    Commission `json:"commission"`
			FillPrice     float64    `json:"fill_price,string,omitempty"`
			TransactionID int        `json:"trans_id"`
			FillQuantity  float64    `json:"fill_qty,omitempty"`
			Position      struct {
				Commission Commission `json:"commission"`
				Timestamp  int64      `json:"timestamp"`
				OpenPrice  float64    `json:"open_price,string"`
				RealizedPL float64    `json:"realized_pl,string"`
				Quantity   float64    `json:"qty,string"`
			} `json:"position"`
			AssetAtExpiry float64 `json:"asset_at_expiry,string,omitempty"`
		} `json:"records"`
		Instrument struct {
			ExpiryTime     int64   `json:"expiry_time"`
			ContractSize   float64 `json:"contract_size,string"`
			ConversionRate float64 `json:"conversion_rate,string"`
			OptionType     string  `json:"option_type"`
			InstrumentID   int     `json:"inst_id"`
			SecType        string  `json:"sec_type"`
			Asset          string  `json:"asset"`
			Strike         float64 `json:"strike,string"`
		} `json:"inst"`
		OpenTimestamp int64 `json:"open_timestamp"`
	} `json:"positions"`
	TotalNumber int `json:"total_number"`
}

PositionHistory holds the complete position history

type Ticker

type Ticker struct {
	High24                float64 `json:"high24,string"`
	HighestBuy            float64 `json:"highest_buy,string"`
	InstrumentID          int     `json:"inst_id"`
	Last                  float64 `json:"last,string"`
	Low24                 float64 `json:"low24,string"`
	LowestSell            float64 `json:"lowest_sell,string"`
	PreviousTransactionID int64   `json:"prev_trans_id"`
	PriceChange24         float64 `json:"price_change_24,string"`
	Reply                 string  `json:"reply"`
	OpenInterest          float64 `json:"open_interest,string"`
	Timestamp             int64   `json:"timestamp"`
	TransactionID         int64   `json:"trans_id"`
	Volume                float64 `json:"volume,string"`
	Volume24              float64 `json:"volume24,string"`
	Volume24Quote         float64 `json:"volume24_quote,string"`
	VolumeQuote           float64 `json:"volume_quote,string"`
}

Ticker holds ticker information

type TradeBase

type TradeBase struct {
	Price         float64 `json:"price,string"`
	Quantity      float64 `json:"qty,string"`
	Side          string  `json:"side"`
	Timestamp     int64   `json:"timestamp"`
	TransactionID int64   `json:"trans_id"`
}

TradeBase is a sub-type holding information on trades

type TradeHistory

type TradeHistory struct {
	TotalNumber int64                 `json:"total_number"`
	Trades      []OrderFilledResponse `json:"trades"`
}

TradeHistory holds trade history information

type Trades

type Trades struct {
	Trades []TradeBase `json:"trades"`
}

Trades holds the full amount of trades associated with API keys

type UserBalance

type UserBalance struct {
	BCH     float64  `json:"BCH,string"`
	BTC     float64  `json:"BTC,string"`
	BTG     float64  `json:"BTG,string"`
	CAD     float64  `json:"CAD,string"`
	ETC     float64  `json:"ETC,string"`
	ETH     float64  `json:"ETH,string"`
	LCH     float64  `json:"LCH,string"`
	LTC     float64  `json:"LTC,string"`
	MYR     float64  `json:"MYR,string"`
	SGD     float64  `json:"SGD,string"`
	USD     float64  `json:"USD,string"`
	USDT    float64  `json:"USDT,string"`
	XMR     float64  `json:"XMR,string"`
	ZEC     float64  `json:"ZEC,string"`
	Nonce   int64    `json:"nonce"`
	Reply   string   `json:"reply"`
	Status  []string `json:"status"`
	TransID int64    `json:"trans_id"`
}

UserBalance holds user balances on the exchange

type WsCancelOrderParameters

type WsCancelOrderParameters struct {
	Currency currency.Pair
	OrderID  int64
}

WsCancelOrderParameters ws request parameters

type WsCancelOrderRequest

type WsCancelOrderRequest struct {
	InstrumentID int64 `json:"inst_id"`
	OrderID      int64 `json:"order_id"`
	WsRequest
}

WsCancelOrderRequest data required for cancelling an order

type WsCancelOrderResponse

type WsCancelOrderResponse struct {
	Nonce         int64    `json:"nonce"`
	Reply         string   `json:"reply"`
	OrderID       int64    `json:"order_id"`
	ClientOrderID int64    `json:"client_ord_id"`
	Status        []string `json:"status"`
}

WsCancelOrderResponse contains cancelled order data

type WsCancelOrdersRequest

type WsCancelOrdersRequest struct {
	Entries []WsCancelOrdersRequestEntry `json:"entries"`
	WsRequest
}

WsCancelOrdersRequest ws request

type WsCancelOrdersRequestEntry

type WsCancelOrdersRequestEntry struct {
	InstID  int64 `json:"inst_id"`
	OrderID int64 `json:"order_id"`
}

WsCancelOrdersRequestEntry ws request entry

type WsCancelOrdersResponse

type WsCancelOrdersResponse struct {
	Nonce         int64                        `json:"nonce"`
	Reply         string                       `json:"reply"`
	Results       []WsCancelOrdersResponseData `json:"results"`
	Status        []string                     `json:"status"`
	TransactionID int64                        `json:"trans_id"`
}

WsCancelOrdersResponse contains all cancelled order data

type WsCancelOrdersResponseData

type WsCancelOrdersResponseData struct {
	InstrumentID int64  `json:"inst_id"`
	OrderID      int64  `json:"order_id"`
	Status       string `json:"status"`
}

WsCancelOrdersResponseData individual cancellation response data

type WsGetAccountBalanceResponse

type WsGetAccountBalanceResponse struct {
	BCH     float64  `json:"BCH,string"`
	BTC     float64  `json:"BTC,string"`
	BTG     float64  `json:"BTG,string"`
	CAD     float64  `json:"CAD,string"`
	ETC     float64  `json:"ETC,string"`
	ETH     float64  `json:"ETH,string"`
	LCH     float64  `json:"LCH,string"`
	LTC     float64  `json:"LTC,string"`
	MYR     float64  `json:"MYR,string"`
	SGD     float64  `json:"SGD,string"`
	USD     float64  `json:"USD,string"`
	USDT    float64  `json:"USDT,string"`
	XMR     float64  `json:"XMR,string"`
	ZEC     float64  `json:"ZEC,string"`
	Nonce   int64    `json:"nonce"`
	Reply   string   `json:"reply"`
	Status  []string `json:"status"`
	TransID int64    `json:"trans_id"`
}

WsGetAccountBalanceResponse contains values of each currency

type WsGetOpenOrdersRequest

type WsGetOpenOrdersRequest struct {
	InstrumentID int64 `json:"inst_id"`
	WsRequest
}

WsGetOpenOrdersRequest ws request

type WsInstrumentList

type WsInstrumentList struct {
	Spot   map[string][]InstrumentBase `json:"SPOT"`
	Nonce  int64                       `json:"nonce,omitempty"`
	Reply  string                      `json:"inst_list,omitempty"`
	Status []interface{}               `json:"status,omitempty"`
}

WsInstrumentList defines instrument list

type WsLoginReq

type WsLoginReq struct {
	Request   string `json:"request"`
	Username  string `json:"username"`
	Nonce     int64  `json:"nonce"`
	Hmac      string `json:"hmac_sha256"`
	Timestamp int64  `json:"timestamp"`
}

WsLoginReq Login request message

type WsLoginResponse

type WsLoginResponse struct {
	APIKey          string   `json:"api_key"`
	Country         string   `json:"country"`
	DepositEnabled  bool     `json:"deposit_enabled"`
	Deposited       bool     `json:"deposited"`
	Email           string   `json:"email"`
	FailedTimes     int64    `json:"failed_times"`
	KycPassed       bool     `json:"kyc_passed"`
	Language        string   `json:"lang"`
	Nonce           int64    `json:"nonce"`
	OTPEnabled      bool     `json:"otp_enabled"`
	PhoneNumber     string   `json:"phone_number"`
	ProductsEnabled []string `json:"products_enabled"`
	Referred        bool     `json:"referred"`
	Reply           string   `json:"reply"`
	SessionID       string   `json:"session_id"`
	Status          []string `json:"status"`
	Timezone        string   `json:"timezone"`
	Traded          bool     `json:"traded"`
	UnverifiedEmail string   `json:"unverified_email"`
	Username        string   `json:"username"`
	WithdrawEnabled bool     `json:"withdraw_enabled"`
}

WsLoginResponse ws response data

type WsNewOrderResponse

type WsNewOrderResponse struct {
	Message string   `json:"msg"`
	Nonce   int64    `json:"nonce"`
	Reply   string   `json:"reply"`
	Status  []string `json:"status"`
}

WsNewOrderResponse returns if new_order response fails

type WsOrderAcceptedResponse

type WsOrderAcceptedResponse struct {
	Nonce         int64    `json:"nonce"`
	Status        []string `json:"status"`
	OrderID       int64    `json:"order_id"`
	OpenQuantity  float64  `json:"open_qty,string"`
	InstrumentID  int64    `json:"inst_id"`
	Quantity      float64  `json:"qty,string"`
	ClientOrderID int64    `json:"client_ord_id"`
	OrderPrice    float64  `json:"order_price,string"`
	Reply         string   `json:"reply"`
	Side          string   `json:"side"`
	TransactionID int64    `json:"trans_id"`
}

WsOrderAcceptedResponse ws response

type WsOrderData

type WsOrderData struct {
	ClientOrderID int64    `json:"client_ord_id"`
	InstrumentID  int64    `json:"inst_id"`
	OpenQuantity  float64  `json:"open_qty,string"`
	OrderID       int64    `json:"order_id"`
	Price         float64  `json:"price,string"`
	Quantity      float64  `json:"qty,string"`
	Side          string   `json:"side"`
	Timestamp     int64    `json:"timestamp"`
	Status        []string `json:"status"`
}

WsOrderData ws response data

type WsOrderFilledCommissionData

type WsOrderFilledCommissionData struct {
	Amount   float64 `json:"amount,string"`
	Currency string  `json:"currency"`
}

WsOrderFilledCommissionData ws response data

type WsOrderFilledResponse

type WsOrderFilledResponse struct {
	Commission    WsOrderFilledCommissionData `json:"commission"`
	FillPrice     float64                     `json:"fill_price,string"`
	FillQuantity  float64                     `json:"fill_qty,string"`
	Nonce         int64                       `json:"nonce"`
	Order         WsOrderData                 `json:"order"`
	Reply         string                      `json:"reply"`
	Status        []string                    `json:"status"`
	Timestamp     int64                       `json:"timestamp"`
	TransactionID int64                       `json:"trans_id"`
}

WsOrderFilledResponse ws response

type WsOrderRejectedResponse

type WsOrderRejectedResponse struct {
	Nonce         int64    `json:"nonce"`
	Status        []string `json:"status"`
	OrderID       int64    `json:"order_id"`
	OpenQuantity  float64  `json:"open_qty,string"`
	Price         float64  `json:"price,string"`
	InstrumentID  int64    `json:"inst_id"`
	Reasons       []string `json:"reasons"`
	ClientOrderID int64    `json:"client_ord_id"`
	Timestamp     int64    `json:"timestamp"`
	Reply         string   `json:"reply"`
	Quantity      float64  `json:"qty,string"`
	Side          string   `json:"side"`
	TransactionID int64    `json:"trans_id"`
}

WsOrderRejectedResponse ws response

type WsOrderbookData

type WsOrderbookData struct {
	Count  int64   `json:"count"`
	Price  float64 `json:"price,string"`
	Volume float64 `json:"qty,string"`
}

WsOrderbookData defines singular orderbook data

type WsOrderbookSnapshot

type WsOrderbookSnapshot struct {
	Buy       []WsOrderbookData `json:"buy"`
	Sell      []WsOrderbookData `json:"sell"`
	InstID    int64             `json:"inst_id"`
	Nonce     int64             `json:"nonce"`
	TotalBuy  float64           `json:"total_buy,string"`
	TotalSell float64           `json:"total_sell,string"`
	Reply     string            `json:"reply"`
	Status    []interface{}     `json:"status"`
}

WsOrderbookSnapshot defines the resp for orderbook snapshot updates from the websocket connection

type WsOrderbookUpdate

type WsOrderbookUpdate struct {
	Count    int64   `json:"count"`
	InstID   int64   `json:"inst_id"`
	Price    float64 `json:"price,string"`
	Volume   float64 `json:"qty,string"`
	TotalBuy float64 `json:"total_buy,string"`
	Reply    string  `json:"reply"`
	Side     string  `json:"side"`
	TransID  int64   `json:"trans_id"`
}

WsOrderbookUpdate defines orderbook update response from the websocket connection

type WsRequest

type WsRequest struct {
	Request string `json:"request"`
	Nonce   int64  `json:"nonce"`
}

WsRequest base request

type WsSubmitOrderParameters

type WsSubmitOrderParameters struct {
	Currency      currency.Pair
	Side          order.Side
	Amount, Price float64
	OrderID       int64
}

WsSubmitOrderParameters ws request parameters

type WsSubmitOrderRequest

type WsSubmitOrderRequest struct {
	InstrumentID int64   `json:"inst_id"`
	Price        float64 `json:"price,string"`
	Quantity     float64 `json:"qty,string"`
	OrderID      int64   `json:"client_ord_id"`
	Side         string  `json:"side"`
	WsRequest
}

WsSubmitOrderRequest ws request

type WsSubmitOrdersRequest

type WsSubmitOrdersRequest struct {
	Orders []WsSubmitOrdersRequestData `json:"orders"`
	WsRequest
}

WsSubmitOrdersRequest ws request

type WsSubmitOrdersRequestData

type WsSubmitOrdersRequestData struct {
	InstrumentID  int64   `json:"inst_id"`
	Price         float64 `json:"price,string"`
	Quantity      float64 `json:"qty,string"`
	ClientOrderID int     `json:"client_ord_id"`
	Side          string  `json:"side"`
}

WsSubmitOrdersRequestData ws request data

type WsSupportedCurrency

type WsSupportedCurrency struct {
	Base          string `json:"base"`
	InstID        int64  `json:"inst_id"`
	DecimalPlaces int64  `json:"decimal_places"`
	Quote         string `json:"quote"`
}

WsSupportedCurrency defines supported currency on the exchange

type WsTicker

type WsTicker struct {
	High24        float64  `json:"high24,string"`
	HighestBuy    float64  `json:"highest_buy,string"`
	InstID        int64    `json:"inst_id"`
	Last          float64  `json:"last,string"`
	Low24         float64  `json:"low24,string"`
	LowestSell    float64  `json:"lowest_sell,string"`
	Nonce         int64    `json:"nonce"`
	PrevTransID   int64    `json:"prev_trans_id"`
	PriceChange24 float64  `json:"price_change_24,string"`
	Reply         string   `json:"reply"`
	Status        []string `json:"status"`
	Timestamp     int64    `json:"timestamp"`
	TransID       int64    `json:"trans_id"`
	Volume        float64  `json:"volume,string"`
	Volume24      float64  `json:"volume24,string"`
	Volume24Quote float64  `json:"volume24_quote,string"`
	VolumeQuote   float64  `json:"volume_quote,string"`
}

WsTicker defines the resp for ticker updates from the websocket connection

type WsTradeData

type WsTradeData struct {
	InstID    int64   `json:"inst_id"`
	TransID   int64   `json:"trans_id"`
	Price     float64 `json:"price,string"`
	Quantity  float64 `json:"qty,string"`
	Side      string  `json:"side"`
	Timestamp int64   `json:"timestamp"`
}

WsTradeData defines market trade data

type WsTradeHistoryCommissionData

type WsTradeHistoryCommissionData struct {
	Amount   float64 `json:"amount,string"`
	Currency string  `json:"currency"`
}

WsTradeHistoryCommissionData ws response data

type WsTradeHistoryRequest

type WsTradeHistoryRequest struct {
	InstID int64 `json:"inst_id"`
	Start  int64 `json:"start,omitempty"`
	Limit  int64 `json:"limit,omitempty"`
	WsRequest
}

WsTradeHistoryRequest ws request

type WsTradeHistoryResponse

type WsTradeHistoryResponse struct {
	Nonce       int64         `json:"nonce"`
	Reply       string        `json:"reply"`
	Status      []string      `json:"status"`
	TotalNumber int64         `json:"total_number"`
	Trades      []WsOrderData `json:"trades"`
}

WsTradeHistoryResponse ws response

type WsTradeHistoryTradeData

type WsTradeHistoryTradeData struct {
	Commission    WsTradeHistoryCommissionData `json:"commission"`
	Order         WsOrderData                  `json:"order"`
	FillPrice     float64                      `json:"fill_price,string"`
	FillQuantity  float64                      `json:"fill_qty,string"`
	Timestamp     int64                        `json:"timestamp"`
	TransactionID int64                        `json:"trans_id"`
}

WsTradeHistoryTradeData ws response data

type WsTradeSnapshot

type WsTradeSnapshot struct {
	InstrumentID int64         `json:"inst_id"`
	Nonce        int64         `json:"nonce"`
	Reply        string        `json:"reply"`
	Status       []interface{} `json:"status"`
	Trades       []WsTradeData `json:"trades"`
}

WsTradeSnapshot defines Market trade response from the websocket connection

type WsTradeUpdate

type WsTradeUpdate struct {
	InstID    int64   `json:"inst_id"`
	TransID   int64   `json:"trans_id"`
	Price     float64 `json:"price,string"`
	Quantity  float64 `json:"qty,string"`
	Side      string  `json:"side"`
	Timestamp int64   `json:"timestamp"`
	Reply     string  `json:"reply"`
}

WsTradeUpdate defines trade update response from the websocket connection

type WsUserBalanceResponse

type WsUserBalanceResponse struct {
	Nonce              int64    `json:"nonce"`
	Status             []string `json:"status"`
	Btc                float64  `json:"BTC,string"`
	Ltc                float64  `json:"LTC,string"`
	Etc                float64  `json:"ETC,string"`
	Eth                float64  `json:"ETH,string"`
	FloatingProfitLoss float64  `json:"floating_pl,string"`
	InitialMargin      float64  `json:"initial_margin,string"`
	RealisedProfitLoss float64  `json:"realized_pl,string"`
	MaintenanceMargin  float64  `json:"maintenance_margin,string"`
	Equity             float64  `json:"equity,string"`
	Reply              string   `json:"reply"`
	TransactionID      int64    `json:"trans_id"`
}

WsUserBalanceResponse ws response

type WsUserOpenOrdersResponse

type WsUserOpenOrdersResponse struct {
	Nonce  int64         `json:"nonce"`
	Reply  string        `json:"reply"`
	Status []string      `json:"status"`
	Orders []WsOrderData `json:"orders"`
}

WsUserOpenOrdersResponse ws response

Jump to

Keyboard shortcuts

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