okcoin

package
v0.0.0-...-a2c5123 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 18 Imported by: 0

README

GoCryptoTrader package Okcoin

Build Status Software License GoDoc Coverage Status Go Report Card

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

OKCoin 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 o exchange.IBotExchange

for i := range bot.exchanges {
  if bot.exchanges[i].GetName() == "OKCoin" {
    y = bot.exchanges[i]
  }
}

// Public calls - wrapper functions

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

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

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

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

// Submits an order and the exchange and returns its tradeID
tradeID, err := o.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 AccountRecords

type AccountRecords struct {
	Records []Record `json:"records"`
	Symbol  string   `json:"symbol"`
}

AccountRecords holds account record data

type BatchTrade

type BatchTrade struct {
	OrderInfo []struct {
		OrderID   int64 `json:"order_id"`
		ErrorCode int64 `json:"error_code"`
	} `json:"order_info"`
	Result bool `json:"result"`
}

BatchTrade holds data on a batch of trades

type BorrowInfo

type BorrowInfo struct {
	BorrowBTC        float64 `json:"borrow_btc"`
	BorrowLTC        float64 `json:"borrow_ltc"`
	BorrowCNY        float64 `json:"borrow_cny"`
	CanBorrow        float64 `json:"can_borrow"`
	InterestBTC      float64 `json:"interest_btc"`
	InterestLTC      float64 `json:"interest_ltc"`
	Result           bool    `json:"result"`
	DailyInterestBTC float64 `json:"today_interest_btc"`
	DailyInterestLTC float64 `json:"today_interest_ltc"`
	DailyInterestCNY float64 `json:"today_interest_cny"`
}

BorrowInfo holds borrowing amount data

type BorrowOrder

type BorrowOrder struct {
	Amount      float64 `json:"amount"`
	BorrowDate  int64   `json:"borrow_date"`
	BorrowID    int64   `json:"borrow_id"`
	Days        int64   `json:"days"`
	TradeAmount float64 `json:"deal_amount"`
	Rate        float64 `json:"rate"`
	Status      int64   `json:"status"`
	Symbol      string  `json:"symbol"`
}

BorrowOrder holds order data

type BorrowResponse

type BorrowResponse struct {
	Result   bool `json:"result"`
	BorrowID int  `json:"borrow_id"`
}

BorrowResponse is a response type for borrow

type CancelOrderResponse

type CancelOrderResponse struct {
	Success string
	Error   string
}

CancelOrderResponse is a response type for a cancelled order

type FuturesExplosive

type FuturesExplosive struct {
	Amount      float64 `json:"amount,string"`
	DateCreated string  `json:"create_date"`
	Loss        float64 `json:"loss,string"`
	Type        int64   `json:"type"`
}

FuturesExplosive holds inforamtion about explosive futures

type FuturesHoldAmount

type FuturesHoldAmount struct {
	Amount       float64 `json:"amount"`
	ContractName string  `json:"contract_name"`
}

FuturesHoldAmount contains futures hold amount data

type FuturesOrder

type FuturesOrder struct {
	Amount       float64 `json:"amount"`
	ContractName string  `json:"contract_name"`
	DateCreated  float64 `json:"create_date"`
	TradeAmount  float64 `json:"deal_amount"`
	Fee          float64 `json:"fee"`
	LeverageRate float64 `json:"lever_rate"`
	OrderID      int64   `json:"order_id"`
	Price        float64 `json:"price"`
	AvgPrice     float64 `json:"avg_price"`
	Status       float64 `json:"status"`
	Symbol       string  `json:"symbol"`
	Type         int64   `json:"type"`
	UnitAmount   int64   `json:"unit_amount"`
}

FuturesOrder holds information about a futures order

type FuturesTicker

type FuturesTicker struct {
	Last       float64
	Buy        float64
	Sell       float64
	High       float64
	Low        float64
	Vol        float64
	ContractID int64
	UnitAmount float64
}

FuturesTicker holds futures ticker data

type FuturesTickerResponse

type FuturesTickerResponse struct {
	Date   string
	Ticker FuturesTicker
}

FuturesTickerResponse is a response type

type FuturesTrades

type FuturesTrades struct {
	Amount  float64 `json:"amount"`
	Date    int64   `json:"date"`
	DateMS  int64   `json:"date_ms"`
	Price   float64 `json:"price"`
	TradeID int64   `json:"tid"`
	Type    string  `json:"type"`
}

FuturesTrades holds trade data for the futures market

type LendDepth

type LendDepth struct {
	Amount float64 `json:"amount"`
	Days   string  `json:"days"`
	Num    int64   `json:"num"`
	Rate   float64 `json:"rate,string"`
}

LendDepth hold lend depths

type OKCoin

type OKCoin struct {
	exchange.Base
	RESTErrors      map[string]string
	WebsocketErrors map[string]string
	FuturesValues   []string
	WebsocketConn   *websocket.Conn
}

OKCoin is the overarching type across this package

func (*OKCoin) AddChannel

func (o *OKCoin) AddChannel(channel string)

AddChannel adds a new channel on the websocket client

func (*OKCoin) AddChannelAuthenticated

func (o *OKCoin) AddChannelAuthenticated(channel string, values map[string]string)

AddChannelAuthenticated adds an authenticated channel on the websocket client

func (*OKCoin) BatchTrade

func (o *OKCoin) BatchTrade(orderData string, symbol, orderType string) (BatchTrade, error)

BatchTrade initiates a trade by batch order

func (*OKCoin) Borrow

func (o *OKCoin) Borrow(symbol, days string, amount, rate float64) (int, error)

Borrow initiates a borrow request

func (*OKCoin) CancelAllExchangeOrders

func (o *OKCoin) CancelAllExchangeOrders() error

CancelAllExchangeOrders cancels all orders associated with a currency pair

func (*OKCoin) CancelBorrow

func (o *OKCoin) CancelBorrow(symbol string, borrowID int64) (bool, error)

CancelBorrow cancels a borrow request

func (*OKCoin) CancelExchangeOrder

func (o *OKCoin) CancelExchangeOrder(orderID int64) error

CancelExchangeOrder cancels an order by its corresponding ID number

func (*OKCoin) CancelFuturesOrder

func (o *OKCoin) CancelFuturesOrder(orderID int64, symbol, contractType string)

CancelFuturesOrder cancels a futures contract order

func (*OKCoin) CancelOrder

func (o *OKCoin) CancelOrder(orderID []int64, symbol string) (CancelOrderResponse, error)

CancelOrder cancels a specific order or list of orders by orderID

func (*OKCoin) CancelWithdrawal

func (o *OKCoin) CancelWithdrawal(symbol string, withdrawalID int64) (int, error)

CancelWithdrawal cancels a withdrawal

func (*OKCoin) ConvertToURLValues

func (o *OKCoin) ConvertToURLValues(values map[string]string) url.Values

ConvertToURLValues converts values to url.Values

func (*OKCoin) FuturesBatchTrade

func (o *OKCoin) FuturesBatchTrade(orderData, symbol, contractType string, leverage int64, orderType string)

FuturesBatchTrade initiates a batch of futures contract trades

func (*OKCoin) FuturesTrade

func (o *OKCoin) FuturesTrade(amount, price float64, matchPrice, leverage int64, symbol, contractType, orderType string)

FuturesTrade initiates a new futures trade

func (*OKCoin) GetAccountRecords

func (o *OKCoin) GetAccountRecords(symbol string, recType, currentPage, pageLength int) ([]AccountRecords, error)

GetAccountRecords returns account records

func (*OKCoin) GetBorrowInfo

func (o *OKCoin) GetBorrowInfo(symbol string) (BorrowInfo, error)

GetBorrowInfo returns borrow information

func (*OKCoin) GetBorrowOrderInfo

func (o *OKCoin) GetBorrowOrderInfo(borrowID int64) (BorrowInfo, error)

GetBorrowOrderInfo returns information about a borrow order

func (*OKCoin) GetExchangeAccountInfo

func (o *OKCoin) GetExchangeAccountInfo() (exchange.AccountInfo, error)

GetExchangeAccountInfo retrieves balances for all enabled currencies for the OKCoin exchange

func (*OKCoin) GetExchangeDepositAddress

func (o *OKCoin) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error)

GetExchangeDepositAddress returns a deposit address for a specified currency

func (*OKCoin) GetExchangeFundTransferHistory

func (o *OKCoin) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error)

GetExchangeFundTransferHistory returns funding history, deposits and withdrawals

func (*OKCoin) GetExchangeHistory

func (o *OKCoin) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

func (*OKCoin) GetExchangeOrderInfo

func (o *OKCoin) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error)

GetExchangeOrderInfo returns information on a current open order

func (*OKCoin) GetFee

func (o *OKCoin) GetFee(maker bool) float64

GetFee returns current fees for the exchange

func (*OKCoin) GetFutureOrdersInfo

func (o *OKCoin) GetFutureOrdersInfo(orderID int64, contractType, symbol string)

GetFutureOrdersInfo returns information on a range of futures orders

func (*OKCoin) GetFuturesDepth

func (o *OKCoin) GetFuturesDepth(symbol, contractType string, size int64, merge bool) (Orderbook, error)

GetFuturesDepth returns current depth for the futures market

func (*OKCoin) GetFuturesEstimatedPrice

func (o *OKCoin) GetFuturesEstimatedPrice(symbol string) (float64, error)

GetFuturesEstimatedPrice returns a current estimated futures price for a currency

func (*OKCoin) GetFuturesExchangeRate

func (o *OKCoin) GetFuturesExchangeRate() (float64, error)

GetFuturesExchangeRate returns the exchange rate for the futures market

func (*OKCoin) GetFuturesExplosive

func (o *OKCoin) GetFuturesExplosive(symbol, contractType string, status, currentPage, pageLength int64) ([]FuturesExplosive, error)

GetFuturesExplosive returns the explosive for a futures contract

func (*OKCoin) GetFuturesHoldAmount

func (o *OKCoin) GetFuturesHoldAmount(symbol, contractType string) ([]FuturesHoldAmount, error)

GetFuturesHoldAmount returns the hold amount for a futures trade

func (*OKCoin) GetFuturesIndex

func (o *OKCoin) GetFuturesIndex(symbol string) (float64, error)

GetFuturesIndex returns an index for the futures market

func (*OKCoin) GetFuturesKline

func (o *OKCoin) GetFuturesKline(symbol, klineType, contractType string, size, since int64) ([]interface{}, error)

GetFuturesKline returns kline data for a specific currency on the futures market

func (*OKCoin) GetFuturesOrderInfo

func (o *OKCoin) GetFuturesOrderInfo(orderID, status, currentPage, pageLength int64, symbol, contractType string)

GetFuturesOrderInfo returns information on a specific futures contract order

func (*OKCoin) GetFuturesPosition

func (o *OKCoin) GetFuturesPosition(symbol, contractType string)

GetFuturesPosition returns position on a futures contract

func (*OKCoin) GetFuturesTicker

func (o *OKCoin) GetFuturesTicker(symbol, contractType string) (FuturesTicker, error)

GetFuturesTicker returns a current ticker for the futures market

func (*OKCoin) GetFuturesTrades

func (o *OKCoin) GetFuturesTrades(symbol, contractType string) ([]FuturesTrades, error)

GetFuturesTrades returns historic trades for the futures market

func (*OKCoin) GetFuturesUserInfo

func (o *OKCoin) GetFuturesUserInfo()

GetFuturesUserInfo returns information on a users futures

func (*OKCoin) GetFuturesUserInfo4Fix

func (o *OKCoin) GetFuturesUserInfo4Fix()

GetFuturesUserInfo4Fix returns futures user info fix rate

func (*OKCoin) GetFuturesUserPosition4Fix

func (o *OKCoin) GetFuturesUserPosition4Fix(symbol, contractType string)

GetFuturesUserPosition4Fix returns futures user info on a fixed position

func (*OKCoin) GetKline

func (o *OKCoin) GetKline(symbol, klineType string, size, since int64) ([]interface{}, error)

GetKline returns kline data

func (*OKCoin) GetLendDepth

func (o *OKCoin) GetLendDepth(symbol string) ([]LendDepth, error)

GetLendDepth returns the depth of lends

func (*OKCoin) GetOrderBook

func (o *OKCoin) GetOrderBook(symbol string, size int64, merge bool) (Orderbook, error)

GetOrderBook returns the current order book by size

func (*OKCoin) GetOrderFeeInfo

func (o *OKCoin) GetOrderFeeInfo(symbol string, orderID int64) (OrderFeeInfo, error)

GetOrderFeeInfo returns order fee information

func (*OKCoin) GetOrderHistory

func (o *OKCoin) GetOrderHistory(pageLength, currentPage int64, status, symbol string) (OrderHistory, error)

GetOrderHistory returns a history of orders

func (*OKCoin) GetOrderInfo

func (o *OKCoin) GetOrderInfo(orderID int64, symbol string) ([]OrderInfo, error)

GetOrderInfo returns order information by orderID

func (*OKCoin) GetOrderInfoBatch

func (o *OKCoin) GetOrderInfoBatch(orderID []int64, symbol string) ([]OrderInfo, error)

GetOrderInfoBatch returns order info on a batch of orders

func (*OKCoin) GetOrderbookEx

func (o *OKCoin) GetOrderbookEx(currency pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns orderbook base on the currency pair

func (*OKCoin) GetRepaymentInfo

func (o *OKCoin) GetRepaymentInfo(borrowID int64) (bool, error)

GetRepaymentInfo returns information on a repayment

func (*OKCoin) GetTicker

func (o *OKCoin) GetTicker(symbol string) (Ticker, error)

GetTicker returns the current ticker

func (*OKCoin) GetTickerPrice

func (o *OKCoin) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*OKCoin) GetTradeHistory

func (o *OKCoin) GetTradeHistory(symbol string, TradeID int64) ([]Trades, error)

GetTradeHistory returns client trade history

func (*OKCoin) GetTrades

func (o *OKCoin) GetTrades(symbol string, since int64) ([]Trades, error)

GetTrades returns historic trades since a timestamp

func (*OKCoin) GetUnrepaymentsInfo

func (o *OKCoin) GetUnrepaymentsInfo(symbol string, currentPage, pageLength int) ([]BorrowOrder, error)

GetUnrepaymentsInfo returns information on an unrepayment

func (*OKCoin) GetUserInfo

func (o *OKCoin) GetUserInfo() (UserInfo, error)

GetUserInfo returns user information associated with the calling APIkeys

func (*OKCoin) GetWithdrawalInfo

func (o *OKCoin) GetWithdrawalInfo(symbol string, withdrawalID int64) ([]WithdrawInfo, error)

GetWithdrawalInfo returns withdrawal information

func (*OKCoin) ModifyExchangeOrder

func (o *OKCoin) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error)

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

func (*OKCoin) PingHandler

func (o *OKCoin) PingHandler(message string) error

PingHandler handles the keep alive

func (*OKCoin) RemoveChannel

func (o *OKCoin) RemoveChannel(channel string)

RemoveChannel removes a channel on the websocket client

func (*OKCoin) RemoveChannelAuthenticated

func (o *OKCoin) RemoveChannelAuthenticated(conn *websocket.Conn, channel string, values map[string]string)

RemoveChannelAuthenticated removes the added authenticated channel on the websocket client

func (*OKCoin) Run

func (o *OKCoin) Run()

Run implements the OKCoin wrapper

func (*OKCoin) SendAuthenticatedHTTPRequest

func (o *OKCoin) SendAuthenticatedHTTPRequest(method string, v url.Values, result interface{}) (err error)

SendAuthenticatedHTTPRequest sends an authenticated HTTP request

func (*OKCoin) SendHTTPRequest

func (o *OKCoin) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*OKCoin) SetDefaults

func (o *OKCoin) SetDefaults()

SetDefaults sets current default values for this package

func (*OKCoin) SetErrorDefaults

func (o *OKCoin) SetErrorDefaults()

SetErrorDefaults sets default error map

func (*OKCoin) SetWebsocketErrorDefaults

func (o *OKCoin) SetWebsocketErrorDefaults()

SetWebsocketErrorDefaults sets default errors for websocket

func (*OKCoin) Setup

func (o *OKCoin) Setup(exch config.ExchangeConfig)

Setup sets exchange configuration parameters

func (*OKCoin) Start

func (o *OKCoin) Start(wg *sync.WaitGroup)

Start starts the OKCoin go routine

func (*OKCoin) SubmitExchangeOrder

func (o *OKCoin) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (int64, error)

SubmitExchangeOrder submits a new order

func (*OKCoin) Trade

func (o *OKCoin) Trade(amount, price float64, symbol, orderType string) (int64, error)

Trade initiates a new trade

func (*OKCoin) UpdateOrderbook

func (o *OKCoin) UpdateOrderbook(currency pair.CurrencyPair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*OKCoin) UpdateTicker

func (o *OKCoin) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*OKCoin) WebsocketClient

func (o *OKCoin) WebsocketClient()

WebsocketClient starts a websocket client

func (*OKCoin) WebsocketFuturesCancel

func (o *OKCoin) WebsocketFuturesCancel(symbol, contractType string, orderID int64)

WebsocketFuturesCancel cancels a futures contract on the websocket client

func (*OKCoin) WebsocketFuturesOrderInfo

func (o *OKCoin) WebsocketFuturesOrderInfo(symbol, contractType string, orderID int64, orderStatus, currentPage, pageLength int)

WebsocketFuturesOrderInfo requests futures order info on the websocket client

func (*OKCoin) WebsocketFuturesTrade

func (o *OKCoin) WebsocketFuturesTrade(symbol, contractType string, price, amount float64, orderType, matchPrice, leverage int)

WebsocketFuturesTrade handles a futures trade on the websocket client

func (*OKCoin) WebsocketSign

func (o *OKCoin) WebsocketSign(values map[string]string) string

WebsocketSign signs values on the webcoket client

func (*OKCoin) WebsocketSpotCancel

func (o *OKCoin) WebsocketSpotCancel(symbol string, orderID int64)

WebsocketSpotCancel cancels a spot trade on the websocket client

func (*OKCoin) WebsocketSpotOrderInfo

func (o *OKCoin) WebsocketSpotOrderInfo(symbol string, orderID int64)

WebsocketSpotOrderInfo request information on an order on the websocket client

func (*OKCoin) WebsocketSpotTrade

func (o *OKCoin) WebsocketSpotTrade(symbol, orderType string, price, amount float64)

WebsocketSpotTrade handles spot trade request on the websocket client

func (*OKCoin) WithdrawCryptoExchangeFunds

func (o *OKCoin) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error)

WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*OKCoin) WithdrawFiatExchangeFunds

func (o *OKCoin) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*OKCoin) WithdrawFiatExchangeFundsToInternationalBank

func (o *OKCoin) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*OKCoin) Withdrawal

func (o *OKCoin) Withdrawal(symbol string, fee float64, tradePWD, address string, amount float64) (int, error)

Withdrawal withdraws a cryptocurrency to a supplied address

type OrderFeeInfo

type OrderFeeInfo struct {
	Fee     float64 `json:"fee,string"`
	OrderID int64   `json:"order_id"`
	Type    string  `json:"type"`
}

OrderFeeInfo holds data on order fees

type OrderHistory

type OrderHistory struct {
	CurrentPage int         `json:"current_page"`
	Orders      []OrderInfo `json:"orders"`
	PageLength  int         `json:"page_length"`
	Result      bool        `json:"result"`
	Total       int         `json:"total"`
}

OrderHistory holds information on order history

type OrderInfo

type OrderInfo struct {
	Amount     float64 `json:"amount"`
	AvgPrice   float64 `json:"avg_price"`
	Created    int64   `json:"create_date"`
	DealAmount float64 `json:"deal_amount"`
	OrderID    int64   `json:"order_id"`
	OrdersID   int64   `json:"orders_id"`
	Price      float64 `json:"price"`
	Status     int     `json:"status"`
	Symbol     string  `json:"symbol"`
	Type       string  `json:"type"`
}

OrderInfo holds data on an order

type Orderbook

type Orderbook struct {
	Asks [][]float64 `json:"asks"`
	Bids [][]float64 `json:"bids"`
}

Orderbook holds orderbook data

type Record

type Record struct {
	Address            string  `json:"addr"`
	Account            int64   `json:"account,string"`
	Amount             float64 `json:"amount"`
	Bank               string  `json:"bank"`
	BenificiaryAddress string  `json:"benificiary_addr"`
	TransactionValue   float64 `json:"transaction_value"`
	Fee                float64 `json:"fee"`
	Date               float64 `json:"date"`
}

Record hold record data

type Ticker

type Ticker struct {
	Buy  float64 `json:",string"`
	High float64 `json:",string"`
	Last float64 `json:",string"`
	Low  float64 `json:",string"`
	Sell float64 `json:",string"`
	Vol  float64 `json:",string"`
}

Ticker holds ticker data

type TickerResponse

type TickerResponse struct {
	Date   string
	Ticker Ticker
}

TickerResponse is the response type for ticker

type Trades

type Trades struct {
	Amount  float64 `json:"amount,string"`
	Date    int64   `json:"date"`
	DateMS  int64   `json:"date_ms"`
	Price   float64 `json:"price,string"`
	TradeID int64   `json:"tid"`
	Type    string  `json:"type"`
}

Trades holds trade data

type UserInfo

type UserInfo struct {
	Info struct {
		Funds struct {
			Asset struct {
				Net   float64 `json:"net,string"`
				Total float64 `json:"total,string"`
			} `json:"asset"`
			Borrow struct {
				BTC float64 `json:"btc,string"`
				LTC float64 `json:"ltc,string"`
				USD float64 `json:"usd,string"`
				CNY float64 `json:"cny,string"`
			} `json:"borrow"`
			Free struct {
				BTC float64 `json:"btc,string"`
				LTC float64 `json:"ltc,string"`
				USD float64 `json:"usd,string"`
				CNY float64 `json:"cny,string"`
			} `json:"free"`
			Freezed struct {
				BTC float64 `json:"btc,string"`
				LTC float64 `json:"ltc,string"`
				USD float64 `json:"usd,string"`
				CNY float64 `json:"cny,string"`
			} `json:"freezed"`
			UnionFund struct {
				BTC float64 `json:"btc,string"`
				LTC float64 `json:"ltc,string"`
			} `json:"union_fund"`
		} `json:"funds"`
	} `json:"info"`
	Result bool `json:"result"`
}

UserInfo holds user account details

type WebsocketEvent

type WebsocketEvent struct {
	Event   string `json:"event"`
	Channel string `json:"channel"`
}

WebsocketEvent holds websocket events

type WebsocketEventAuth

type WebsocketEventAuth struct {
	Event      string            `json:"event"`
	Channel    string            `json:"channel"`
	Parameters map[string]string `json:"parameters"`
}

WebsocketEventAuth holds websocket authenticated events

type WebsocketEventAuthRemove

type WebsocketEventAuthRemove struct {
	Event      string            `json:"event"`
	Channel    string            `json:"channel"`
	Parameters map[string]string `json:"parameters"`
}

WebsocketEventAuthRemove holds websocket remove authenticated events

type WebsocketFutureIndex

type WebsocketFutureIndex struct {
	FutureIndex float64 `json:"futureIndex"`
	Timestamp   int64   `json:"timestamp,string"`
}

WebsocketFutureIndex holds future index data for websocket

type WebsocketFuturesContract

type WebsocketFuturesContract struct {
	Available    float64 `json:"available"`
	Balance      float64 `json:"balance"`
	Bond         float64 `json:"bond"`
	ContractID   float64 `json:"contract_id"`
	ContractType string  `json:"contract_type"`
	Frozen       float64 `json:"freeze"`
	Profit       float64 `json:"profit"`
	Loss         float64 `json:"unprofit"`
}

WebsocketFuturesContract holds futures contract information for websocket

type WebsocketFuturesOrder

type WebsocketFuturesOrder struct {
	Amount         float64 `json:"amount"`
	ContractName   string  `json:"contract_name"`
	DateCreated    float64 `json:"createdDate"`
	TradeAmount    float64 `json:"deal_amount"`
	Fee            float64 `json:"fee"`
	LeverageAmount int     `json:"lever_rate"`
	OrderID        float64 `json:"order_id"`
	Price          float64 `json:"price"`
	AvgPrice       float64 `json:"avg_price"`
	Status         int     `json:"status"`
	Symbol         string  `json:"symbol"`
	TradeType      int     `json:"type"`
	UnitAmount     float64 `json:"unit_amount"`
}

WebsocketFuturesOrder holds futures order data for websocket

type WebsocketFuturesRealtrades

type WebsocketFuturesRealtrades struct {
	Amount         float64 `json:"amount,string"`
	ContractID     float64 `json:"contract_id,string"`
	ContractName   string  `json:"contract_name"`
	ContractType   string  `json:"contract_type"`
	TradeAmount    float64 `json:"deal_amount,string"`
	Fee            float64 `json:"fee,string"`
	OrderID        float64 `json:"orderid"`
	Price          float64 `json:"price,string"`
	AvgPrice       float64 `json:"price_avg,string"`
	Status         int     `json:"status,string"`
	TradeType      int     `json:"type,string"`
	UnitAmount     float64 `json:"unit_amount,string"`
	LeverageAmount int     `json:"lever_rate,string"`
}

WebsocketFuturesRealtrades holds futures real trade data for websocket

type WebsocketFuturesTicker

type WebsocketFuturesTicker struct {
	Buy        float64 `json:"buy"`
	ContractID string  `json:"contractId"`
	High       float64 `json:"high"`
	HoldAmount float64 `json:"hold_amount"`
	Last       float64 `json:"last,string"`
	Low        float64 `json:"low"`
	Sell       float64 `json:"sell"`
	UnitAmount float64 `json:"unitAmount"`
	Volume     float64 `json:"vol,string"`
}

WebsocketFuturesTicker holds futures ticker data for websocket

type WebsocketFuturesUserInfo

type WebsocketFuturesUserInfo struct {
	Info struct {
		BTC struct {
			Balance   float64                    `json:"balance"`
			Contracts []WebsocketFuturesContract `json:"contracts"`
			Rights    float64                    `json:"rights"`
		} `json:"btc"`
		LTC struct {
			Balance   float64                    `json:"balance"`
			Contracts []WebsocketFuturesContract `json:"contracts"`
			Rights    float64                    `json:"rights"`
		} `json:"ltc"`
	} `json:"info"`
	Result bool `json:"result"`
}

WebsocketFuturesUserInfo holds futures user information for websocket

type WebsocketOrder

type WebsocketOrder struct {
	Amount      float64 `json:"amount"`
	AvgPrice    float64 `json:"avg_price"`
	DateCreated float64 `json:"create_date"`
	TradeAmount float64 `json:"deal_amount"`
	OrderID     float64 `json:"order_id"`
	OrdersID    float64 `json:"orders_id"`
	Price       float64 `json:"price"`
	Status      int64   `json:"status"`
	Symbol      string  `json:"symbol"`
	OrderType   string  `json:"type"`
}

WebsocketOrder holds order data for websocket

type WebsocketOrderbook

type WebsocketOrderbook struct {
	Asks      [][]float64 `json:"asks"`
	Bids      [][]float64 `json:"bids"`
	Timestamp int64       `json:"timestamp,string"`
}

WebsocketOrderbook holds orderbook data for websocket

type WebsocketRealtrades

type WebsocketRealtrades struct {
	AveragePrice         float64 `json:"averagePrice,string"`
	CompletedTradeAmount float64 `json:"completedTradeAmount,string"`
	DateCreated          float64 `json:"createdDate"`
	ID                   float64 `json:"id"`
	OrderID              float64 `json:"orderId"`
	SigTradeAmount       float64 `json:"sigTradeAmount,string"`
	SigTradePrice        float64 `json:"sigTradePrice,string"`
	Status               int64   `json:"status"`
	Symbol               string  `json:"symbol"`
	TradeAmount          float64 `json:"tradeAmount,string"`
	TradePrice           float64 `json:"buy,string"`
	TradeType            string  `json:"tradeType"`
	TradeUnitPrice       float64 `json:"tradeUnitPrice,string"`
	UnTrade              float64 `json:"unTrade,string"`
}

WebsocketRealtrades holds real trade data for WebSocket

type WebsocketResponse

type WebsocketResponse struct {
	Channel string      `json:"channel"`
	Data    interface{} `json:"data"`
}

WebsocketResponse holds websocket responses

type WebsocketTicker

type WebsocketTicker struct {
	Timestamp float64
	Vol       string
	Buy       float64
	High      float64
	Last      float64
	Low       float64
	Sell      float64
}

WebsocketTicker holds ticker data for websocket

type WebsocketTradeOrderResponse

type WebsocketTradeOrderResponse struct {
	OrderID int64 `json:"order_id,string"`
	Result  bool  `json:"result,string"`
}

WebsocketTradeOrderResponse holds trade order responses for websocket

type WebsocketUserinfo

type WebsocketUserinfo struct {
	Info struct {
		Funds struct {
			Asset struct {
				Net   float64 `json:"net,string"`
				Total float64 `json:"total,string"`
			} `json:"asset"`
			Free struct {
				BTC float64 `json:"btc,string"`
				LTC float64 `json:"ltc,string"`
				USD float64 `json:"usd,string"`
				CNY float64 `json:"cny,string"`
			} `json:"free"`
			Frozen struct {
				BTC float64 `json:"btc,string"`
				LTC float64 `json:"ltc,string"`
				USD float64 `json:"usd,string"`
				CNY float64 `json:"cny,string"`
			} `json:"freezed"`
		} `json:"funds"`
	} `json:"info"`
	Result bool `json:"result"`
}

WebsocketUserinfo holds user info for websocket

type WithdrawInfo

type WithdrawInfo struct {
	Address    string  `json:"address"`
	Amount     float64 `json:"amount"`
	Created    int64   `json:"created_date"`
	ChargeFee  float64 `json:"chargefee"`
	Status     int     `json:"status"`
	WithdrawID int64   `json:"withdraw_id"`
}

WithdrawInfo holds data on a withdraw

type WithdrawalResponse

type WithdrawalResponse struct {
	WithdrawID int  `json:"withdraw_id"`
	Result     bool `json:"result"`
}

WithdrawalResponse is a response type for withdrawal

Jump to

Keyboard shortcuts

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