coinut

package
v0.0.0-...-eb07c7e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2019 License: MIT Imports: 19 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 progresss 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.GetTickerPrice()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := c.GetOrderbookEx()
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:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

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
	WebsocketConn *websocket.Conn
	InstrumentMap map[string]int
	// contains filtered or unexported fields
}

COINUT is the overarching type across the coinut package

func (*COINUT) AuthenticateWebsocket

func (c *COINUT) AuthenticateWebsocket() error

AuthenticateWebsocket sends an authentication message to the websocket

func (*COINUT) CancelAllOrders

CancelAllOrders cancels all orders associated with a currency pair

func (*COINUT) CancelExistingOrder

func (c *COINUT) CancelExistingOrder(instrumentID, orderID int) (bool, error)

CancelExistingOrder cancels a specific order and returns if it was actioned

func (*COINUT) CancelOrder

func (c *COINUT) CancelOrder(order *exchange.OrderCancellation) error

CancelOrder cancels an order by its corresponding ID number

func (*COINUT) CancelOrders

func (c *COINUT) CancelOrders(orders []CancelOrders) (CancelOrdersResponse, error)

CancelOrders cancels multiple orders

func (*COINUT) GenerateDefaultSubscriptions

func (c *COINUT) GenerateDefaultSubscriptions()

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

func (*COINUT) GetAccountInfo

func (c *COINUT) GetAccountInfo() (exchange.AccountInfo, error)

GetAccountInfo retrieves balances for all enabled currencies for the COINUT exchange

func (*COINUT) GetActiveOrders

func (c *COINUT) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error)

GetActiveOrders retrieves any orders that are active/open

func (*COINUT) GetDepositAddress

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

GetDepositAddress returns a deposit address for a specified currency

func (*COINUT) GetDerivativeInstruments

func (c *COINUT) GetDerivativeInstruments(secType string) (interface{}, error)

GetDerivativeInstruments returns a list of derivative instruments

func (*COINUT) GetExchangeHistory

func (c *COINUT) GetExchangeHistory(p currency.Pair, assetType string) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

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(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*COINUT) GetFundingHistory

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

GetFundingHistory returns funding history, deposits and withdrawals

func (*COINUT) GetIndexTicker

func (c *COINUT) GetIndexTicker(asset string) (IndexTicker, error)

GetIndexTicker returns the index ticker for an asset

func (*COINUT) GetInstrumentOrderbook

func (c *COINUT) GetInstrumentOrderbook(instrumentID, limit int) (Orderbook, error)

GetInstrumentOrderbook returns the orderbooks for a specific instrument

func (*COINUT) GetInstrumentTicker

func (c *COINUT) GetInstrumentTicker(instrumentID int) (Ticker, error)

GetInstrumentTicker returns a ticker for a specific instrument

func (*COINUT) GetInstruments

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

GetInstruments returns instruments

func (*COINUT) GetNonce

func (c *COINUT) GetNonce() int64

GetNonce returns a nonce for a required request

func (*COINUT) GetOpenOrders

func (c *COINUT) GetOpenOrders(instrumentID int) (GetOpenOrdersResponse, error)

GetOpenOrders returns a list of open order and relevant information

func (*COINUT) GetOpenPositions

func (c *COINUT) GetOpenPositions(instrumentID int) ([]OpenPosition, error)

GetOpenPositions returns all your current opened positions

func (*COINUT) GetOptionChain

func (c *COINUT) GetOptionChain(asset, secType string) (OptionChainResponse, error)

GetOptionChain returns option chain

func (*COINUT) GetOrderHistory

func (c *COINUT) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error)

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

func (*COINUT) GetOrderInfo

func (c *COINUT) GetOrderInfo(orderID string) (exchange.OrderDetail, error)

GetOrderInfo returns information on a current open order

func (*COINUT) GetOrderbookEx

func (c *COINUT) GetOrderbookEx(p currency.Pair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns orderbook base on the currency pair

func (*COINUT) GetPositionHistory

func (c *COINUT) GetPositionHistory(secType string, start, limit int) (PositionHistory, error)

GetPositionHistory returns position history

func (*COINUT) GetSubscriptions

func (c *COINUT) GetSubscriptions() ([]exchange.WebsocketChannelSubscription, error)

GetSubscriptions returns a copied list of subscriptions

func (*COINUT) GetTickerPrice

func (c *COINUT) GetTickerPrice(p currency.Pair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*COINUT) GetTradeHistory

func (c *COINUT) GetTradeHistory(instrumentID, start, limit int) (TradeHistory, error)

GetTradeHistory returns trade history for a specific instrument.

func (*COINUT) GetTrades

func (c *COINUT) GetTrades(instrumentID int) (Trades, error)

GetTrades returns trade information

func (*COINUT) GetUserBalance

func (c *COINUT) GetUserBalance() (UserBalance, error)

GetUserBalance returns the full user balance

func (*COINUT) GetWebsocket

func (c *COINUT) GetWebsocket() (*exchange.Websocket, error)

GetWebsocket returns a pointer to the exchange websocket

func (*COINUT) ModifyOrder

func (c *COINUT) ModifyOrder(action *exchange.ModifyOrder) (string, error)

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

func (*COINUT) NewOrder

func (c *COINUT) NewOrder(instrumentID int, quantity, price float64, buy bool, orderID uint32) (interface{}, error)

NewOrder places a new order on the exchange

func (*COINUT) NewOrders

func (c *COINUT) NewOrders(orders []Order) ([]OrdersBase, error)

NewOrders places multiple orders on the exchange

func (*COINUT) Run

func (c *COINUT) Run()

Run implements the COINUT wrapper

func (*COINUT) SendHTTPRequest

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

Setup sets the current exchange configuration

func (*COINUT) Start

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

Start starts the COINUT go routine

func (*COINUT) SubmitOrder

func (c *COINUT) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (exchange.SubmitOrderResponse, error)

SubmitOrder submits a new order

func (*COINUT) Subscribe

func (c *COINUT) Subscribe(channelToSubscribe exchange.WebsocketChannelSubscription) error

Subscribe sends a websocket message to receive data from the channel

func (*COINUT) SubscribeToWebsocketChannels

func (c *COINUT) SubscribeToWebsocketChannels(channels []exchange.WebsocketChannelSubscription) error

SubscribeToWebsocketChannels appends to ChannelsToSubscribe which lets websocket.manageSubscriptions handle subscribing

func (*COINUT) Unsubscribe

func (c *COINUT) Unsubscribe(channelToSubscribe exchange.WebsocketChannelSubscription) error

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

func (*COINUT) UnsubscribeToWebsocketChannels

func (c *COINUT) UnsubscribeToWebsocketChannels(channels []exchange.WebsocketChannelSubscription) error

UnsubscribeToWebsocketChannels removes from ChannelsToSubscribe which lets websocket.manageSubscriptions handle unsubscribing

func (*COINUT) UpdateOrderbook

func (c *COINUT) UpdateOrderbook(p currency.Pair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*COINUT) UpdateTicker

func (c *COINUT) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*COINUT) WithdrawCryptocurrencyFunds

func (c *COINUT) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*COINUT) WithdrawFiatFunds

func (c *COINUT) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*COINUT) WithdrawFiatFundsToInternationalBank

func (c *COINUT) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*COINUT) WsConnect

func (c *COINUT) WsConnect() error

WsConnect intiates a websocket connection

func (*COINUT) WsHandleData

func (c *COINUT) WsHandleData()

WsHandleData handles read data

func (*COINUT) WsProcessOrderbookSnapshot

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

WsProcessOrderbookSnapshot processes the orderbook snapshot

func (*COINUT) WsProcessOrderbookUpdate

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

WsProcessOrderbookUpdate process an orderbook update

func (*COINUT) WsReadData

func (c *COINUT) WsReadData() (exchange.WebsocketResponse, error)

WsReadData reads data from the websocket connection

func (*COINUT) WsSetInstrumentList

func (c *COINUT) WsSetInstrumentList() error

WsSetInstrumentList fetches instrument list and propagates a local cache

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 int    `json:"inst_id"`
	} `json:"results"`
}

CancelOrdersResponse is response for a cancelled order

type Commission

type Commission struct {
	Currency currency.Pair `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"`
	TransID 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"`
	TransID 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 inforamtion

type InstrumentBase

type InstrumentBase struct {
	Base          string `json:"base"`
	DecimalPlaces int    `json:"decimal_places"`
	InstID        int    `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"`
	TransID      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 {
	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"`
	Timestamp    float64 `json:"timestamp"`
	TransID      int64   `json:"trans_id"`
	Volume       float64 `json:"volume,string"`
	Volume24     float64 `json:"volume24,string"`
}

Ticker holds ticker information

type TradeBase

type TradeBase struct {
	Price     float64 `json:"price,string"`
	Quantity  float64 `json:"quantity,string"`
	Side      string  `json:"side"`
	Timestamp float64 `json:"timestamp"`
	TransID   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 {
	InstID  int64 `json:"inst_id"`
	OrderID int64 `json:"order_id"`
	WsRequest
}

WsCancelOrderRequest ws request

type WsCancelOrderResponse

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

WsCancelOrderResponse ws response

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 {
	WsRequest
	Entries []WsCancelOrdersResponseEntry `json:"entries"`
}

WsCancelOrdersResponse ws response

type WsCancelOrdersResponseEntry

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

WsCancelOrdersResponseEntry ws response entry

type WsGetOpenOrdersRequest

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

WsGetOpenOrdersRequest ws request

type WsInstrumentList

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

WsInstrumentList defines instrument list

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"`
	Lang            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 {
	Msg    string   `json:"msg"`
	Nonce  int64    `json:"nonce"`
	Reply  string   `json:"reply"`
	Status []string `json:"status"`
}

WsNewOrderResponse returns if new_order response failes

type WsOrderAcceptedResponse

type WsOrderAcceptedResponse struct {
	Nonce       int64    `json:"nonce"`
	Status      []string `json:"status"`
	OrderID     int64    `json:"order_id"`
	OpenQty     float64  `json:"open_qty,string"`
	InstID      int64    `json:"inst_id"`
	Qty         float64  `json:"qty,string"`
	ClientOrdID int64    `json:"client_ord_id"`
	OrderPrice  float64  `json:"order_price,string"`
	Reply       string   `json:"reply"`
	Side        string   `json:"side"`
	TransID     int64    `json:"trans_id"`
}

WsOrderAcceptedResponse ws response

type WsOrderData

type WsOrderData struct {
	ClientOrdID int64   `json:"client_ord_id"`
	InstID      int64   `json:"inst_id"`
	OpenQty     float64 `json:"open_qty,string"`
	OrderID     int64   `json:"order_id"`
	Price       float64 `json:"price,string"`
	Qty         float64 `json:"qty,string"`
	Side        string  `json:"side"`
	Timestamp   int64   `json:"timestamp"`
}

WsOrderData ws response data

type WsOrderFilledCommissionData

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

WsOrderFilledCommissionData ws response data

type WsOrderFilledResponse

type WsOrderFilledResponse struct {
	Commission WsOrderFilledCommissionData `json:"commission"`
	FillPrice  float64                     `json:"fill_price,string"`
	FillQty    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"`
	TransID    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"`
	OpenQty     float64  `json:"open_qty,string"`
	Price       float64  `json:"price,string"`
	InstID      int64    `json:"inst_id"`
	Reasons     []string `json:"reasons"`
	ClientOrdID int64    `json:"client_ord_id"`
	Timestamp   int64    `json:"timestamp"`
	Reply       string   `json:"reply"`
	Qty         float64  `json:"qty,string"`
	Side        string   `json:"side"`
	TransID     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          exchange.OrderSide
	Amount, Price float64
	OrderID       int64
}

WsSubmitOrderParameters ws request parameters

type WsSubmitOrderRequest

type WsSubmitOrderRequest struct {
	InstID  int64   `json:"inst_id"`
	Price   float64 `json:"price,string"`
	Qty     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 {
	InstID      int64   `json:"inst_id"`
	Price       float64 `json:"price,string"`
	Qty         float64 `json:"qty,string"`
	ClientOrdID 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 {
	HighestBuy   float64 `json:"highest_buy,string"`
	InstID       int64   `json:"inst_id"`
	Last         float64 `json:"last,string"`
	LowestSell   float64 `json:"lowest_sell,string"`
	OpenInterest float64 `json:"open_interest,string"`
	Reply        string  `json:"reply"`
	Timestamp    int64   `json:"timestamp"`
	TransID      int64   `json:"trans_id"`
	Volume       float64 `json:"volume,string"`
	Volume24H    float64 `json:"volume24,string"`
}

WsTicker defines the resp for ticker updates from the websocket connection

type WsTradeData

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

WsTradeData defines market trade data

type WsTradeHistoryCommissionData

type WsTradeHistoryCommissionData struct {
	Amount   float64       `json:"amount,string"`
	Currency currency.Pair `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"`
	FillQty    float64                      `json:"fill_qty,string"`
	Timestamp  int64                        `json:"timestamp"`
	TransID    int64                        `json:"trans_id"`
}

WsTradeHistoryTradeData ws response data

type WsTradeSnapshot

type WsTradeSnapshot struct {
	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"`
	Price     float64 `json:"price,string"`
	Reply     string  `json:"reply"`
	Side      string  `json:"side"`
	Timestamp int64   `json:"timestamp"`
	TransID   int64   `json:"trans_id"`
}

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"`
	FloatingPl        float64  `json:"floating_pl,string"`
	InitialMargin     float64  `json:"initial_margin,string"`
	RealizedPl        float64  `json:"realized_pl,string"`
	MaintenanceMargin float64  `json:"maintenance_margin,string"`
	Equity            float64  `json:"equity,string"`
	Reply             string   `json:"reply"`
	TransID           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