Documentation
¶
Index ¶
- Variables
- type Account
- type AccountBalance
- type CancelOrderBatch
- type Depth
- type Detail
- type DetailMerged
- type HUOBI
- func (h *HUOBI) BuildHuobiWebsocketParamsList(objectName, currency, pushType, period, count, from, to, percentage string) interface{}
- func (h *HUOBI) BuildHuobiWebsocketRequest(msgType string, requestIndex int64, symbolRequest []string) map[string]interface{}
- func (h *HUOBI) BuildHuobiWebsocketRequestExtra(msgType string, requestIndex int64, symbolIDList interface{}) interface{}
- func (h *HUOBI) CancelOrder(orderID int64) (int64, error)
- func (h *HUOBI) CancelOrderBatch(orderIDs []int64) ([]CancelOrderBatch, error)
- func (h *HUOBI) CancelWithdraw(withdrawID int64) (int64, error)
- func (h *HUOBI) GetAccountBalance(accountID string) ([]AccountBalance, error)
- func (h *HUOBI) GetAccounts() ([]Account, error)
- func (h *HUOBI) GetCurrencies() ([]string, error)
- func (h *HUOBI) GetDepth(symbol, depthType string) (Orderbook, error)
- func (h *HUOBI) GetExchangeAccountInfo() (exchange.AccountInfo, error)
- func (h *HUOBI) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error)
- func (h *HUOBI) GetFee() float64
- func (h *HUOBI) GetKline(symbol, period, size string) ([]Klines, error)
- func (h *HUOBI) GetMarginAccountBalance(symbol string) ([]MarginAccountBalance, error)
- func (h *HUOBI) GetMarginLoanOrders(symbol, currency, start, end, states, from, direct, size string) ([]MarginOrder, error)
- func (h *HUOBI) GetMarketDetail(symbol string) (Detail, error)
- func (h *HUOBI) GetMarketDetailMerged(symbol string) (DetailMerged, error)
- func (h *HUOBI) GetOrder(orderID int64) (OrderInfo, error)
- func (h *HUOBI) GetOrderMatchResults(orderID int64) ([]OrderMatchInfo, error)
- func (h *HUOBI) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error)
- func (h *HUOBI) GetOrders(symbol, types, start, end, states, from, direct, size string) ([]OrderInfo, error)
- func (h *HUOBI) GetOrdersMatch(symbol, types, start, end, from, direct, size string) ([]OrderMatchInfo, error)
- func (h *HUOBI) GetSymbols() ([]Symbol, error)
- func (h *HUOBI) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)
- func (h *HUOBI) GetTimestamp() (int64, error)
- func (h *HUOBI) GetTradeHistory(symbol, size string) ([]TradeHistory, error)
- func (h *HUOBI) GetTrades(symbol string) ([]Trade, error)
- func (h *HUOBI) MarginOrder(symbol, currency string, amount float64) (int64, error)
- func (h *HUOBI) MarginRepayment(orderID int64, amount float64) (int64, error)
- func (h *HUOBI) MarginTransfer(symbol, currency string, amount float64, in bool) (int64, error)
- func (h *HUOBI) OnConnect(output chan socketio.Message)
- func (h *HUOBI) OnDisconnect(output chan socketio.Message)
- func (h *HUOBI) OnError()
- func (h *HUOBI) OnMessage(message []byte, output chan socketio.Message)
- func (h *HUOBI) OnRequest(message []byte, output chan socketio.Message)
- func (h *HUOBI) PlaceOrder(symbol, source, accountID, orderType string, amount, price float64) (int64, error)
- func (h *HUOBI) Run()
- func (h *HUOBI) SendAuthenticatedHTTPRequest(method, endpoint string, values url.Values, result interface{}) error
- func (h *HUOBI) SendHTTPRequest(path string, result interface{}) error
- func (h *HUOBI) SetDefaults()
- func (h *HUOBI) Setup(exch config.ExchangeConfig)
- func (h *HUOBI) Start()
- func (h *HUOBI) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)
- func (h *HUOBI) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)
- func (h *HUOBI) WebsocketClient()
- func (h *HUOBI) Withdraw(address, currency, addrTag string, amount, fee float64) (int64, error)
- type KlineItem
- type Klines
- type MarginAccountBalance
- type MarginOrder
- type OrderInfo
- type OrderMatchInfo
- type Orderbook
- type Response
- type Symbol
- type Trade
- type TradeHistory
- type WebsocketLastTimeline
- type WebsocketMarketOverview
- type WebsocketResponse
- type WebsocketTrade
- type WebsocketTradeDetail
Constants ¶
This section is empty.
Variables ¶
var HuobiSocket *socketio.SocketIO
HuobiSocket is a pointer to a IO Socket
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID int64 `json:"id"` Type string `json:"type"` State string `json:"working"` UserID int64 `json:"user-id"` }
Account stores the account data
type AccountBalance ¶
type AccountBalance struct { Currency string `json:"currency"` Type string `json:"type"` Balance float64 `json:"balance,string"` }
AccountBalance stores the user account balance
type CancelOrderBatch ¶
type CancelOrderBatch struct { Success []string `json:"success"` Failed []struct { OrderID int64 `json:"order-id,string"` ErrorCode string `json:"err-code"` ErrorMessage string `json:"err-msg"` } `json:"failed"` }
CancelOrderBatch stores the cancel order batch data
type Depth ¶
type Depth struct { SymbolID string `json:"symbolId"` Time float64 `json:"time"` Version float64 `json:"version"` BidName string `json:"bidName"` BidPrice []float64 `json:"bidPrice"` BidTotal []float64 `json:"bidTotal"` BidAmount []float64 `json:"bidAmount"` AskName string `json:"askName"` AskPrice []float64 `json:"askPrice"` AskTotal []float64 `json:"askTotal"` AskAmount []float64 `json:"askAmount"` }
Depth holds depth information
type Detail ¶
type Detail struct { Amount float64 `json:"amount"` Open float64 `json:"open"` Close float64 `json:"close"` High float64 `json:"high"` Timestamp int64 `json:"timestamp"` ID int `json:"id"` Count int `json:"count"` Low float64 `json:"low"` Volume float64 `json:"vol"` }
Detail stores the ticker detail data
type DetailMerged ¶
type DetailMerged struct { Detail Version int `json:"version"` Ask []float64 `json:"ask"` Bid []float64 `json:"bid"` }
DetailMerged stores the ticker detail merged data
type HUOBI ¶
HUOBI is the overarching type across this package
func (*HUOBI) BuildHuobiWebsocketParamsList ¶
func (h *HUOBI) BuildHuobiWebsocketParamsList(objectName, currency, pushType, period, count, from, to, percentage string) interface{}
BuildHuobiWebsocketParamsList packages a parameter list
func (*HUOBI) BuildHuobiWebsocketRequest ¶
func (h *HUOBI) BuildHuobiWebsocketRequest(msgType string, requestIndex int64, symbolRequest []string) map[string]interface{}
BuildHuobiWebsocketRequest packages a new request
func (*HUOBI) BuildHuobiWebsocketRequestExtra ¶
func (h *HUOBI) BuildHuobiWebsocketRequestExtra(msgType string, requestIndex int64, symbolIDList interface{}) interface{}
BuildHuobiWebsocketRequestExtra packages an extra request
func (*HUOBI) CancelOrder ¶
CancelOrder cancels an order on Huobi
func (*HUOBI) CancelOrderBatch ¶
func (h *HUOBI) CancelOrderBatch(orderIDs []int64) ([]CancelOrderBatch, error)
CancelOrderBatch cancels a batch of orders -- to-do
func (*HUOBI) CancelWithdraw ¶
CancelWithdraw cancels a withdraw request
func (*HUOBI) GetAccountBalance ¶
func (h *HUOBI) GetAccountBalance(accountID string) ([]AccountBalance, error)
GetAccountBalance returns the users Huobi account balance
func (*HUOBI) GetAccounts ¶
GetAccounts returns the Huobi user accounts
func (*HUOBI) GetCurrencies ¶
GetCurrencies returns a list of currencies supported by Huobi
func (*HUOBI) GetExchangeAccountInfo ¶
GetExchangeAccountInfo retrieves balances for all enabled currencies for the HUOBI exchange - to-do
func (*HUOBI) GetExchangeHistory ¶
func (h *HUOBI) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error)
GetExchangeHistory returns historic trade data since exchange opening.
func (*HUOBI) GetMarginAccountBalance ¶
func (h *HUOBI) GetMarginAccountBalance(symbol string) ([]MarginAccountBalance, error)
GetMarginAccountBalance returns the margin account balances
func (*HUOBI) GetMarginLoanOrders ¶
func (h *HUOBI) GetMarginLoanOrders(symbol, currency, start, end, states, from, direct, size string) ([]MarginOrder, error)
GetMarginLoanOrders returns the margin loan orders
func (*HUOBI) GetMarketDetail ¶
GetMarketDetail returns the ticker for the specified symbol
func (*HUOBI) GetMarketDetailMerged ¶
func (h *HUOBI) GetMarketDetailMerged(symbol string) (DetailMerged, error)
GetMarketDetailMerged returns the ticker for the specified symbol
func (*HUOBI) GetOrderMatchResults ¶
func (h *HUOBI) GetOrderMatchResults(orderID int64) ([]OrderMatchInfo, error)
GetOrderMatchResults returns matched order info for the specified order
func (*HUOBI) GetOrderbookEx ¶
GetOrderbookEx returns orderbook base on the currency pair
func (*HUOBI) GetOrders ¶
func (h *HUOBI) GetOrders(symbol, types, start, end, states, from, direct, size string) ([]OrderInfo, error)
GetOrders returns a list of orders
func (*HUOBI) GetOrdersMatch ¶
func (h *HUOBI) GetOrdersMatch(symbol, types, start, end, from, direct, size string) ([]OrderMatchInfo, error)
GetOrdersMatch returns a list of matched orders
func (*HUOBI) GetSymbols ¶
GetSymbols returns an array of symbols supported by Huobi
func (*HUOBI) GetTickerPrice ¶
GetTickerPrice returns the ticker for a currency pair
func (*HUOBI) GetTimestamp ¶
GetTimestamp returns the Huobi server time
func (*HUOBI) GetTradeHistory ¶
func (h *HUOBI) GetTradeHistory(symbol, size string) ([]TradeHistory, error)
GetTradeHistory returns the trades for the specified symbol
func (*HUOBI) MarginOrder ¶
MarginOrder submits a margin order application
func (*HUOBI) MarginRepayment ¶
MarginRepayment repays a margin amount for a margin ID
func (*HUOBI) MarginTransfer ¶
MarginTransfer transfers assets into or out of the margin account
func (*HUOBI) OnDisconnect ¶
OnDisconnect handles disconnection
func (*HUOBI) PlaceOrder ¶
func (h *HUOBI) PlaceOrder(symbol, source, accountID, orderType string, amount, price float64) (int64, error)
PlaceOrder submits an order to Huobi
func (*HUOBI) SendAuthenticatedHTTPRequest ¶
func (h *HUOBI) SendAuthenticatedHTTPRequest(method, endpoint string, values url.Values, result interface{}) error
SendAuthenticatedHTTPRequest sends authenticated requests to the HUOBI API
func (*HUOBI) SendHTTPRequest ¶
SendHTTPRequest sends an unauthenticated HTTP request
func (*HUOBI) SetDefaults ¶
func (h *HUOBI) SetDefaults()
SetDefaults sets default values for the exchange
func (*HUOBI) Setup ¶
func (h *HUOBI) Setup(exch config.ExchangeConfig)
Setup sets user configuration
func (*HUOBI) UpdateOrderbook ¶
UpdateOrderbook updates and returns the orderbook for a currency pair
func (*HUOBI) UpdateTicker ¶
UpdateTicker updates and returns the ticker for a currency pair
func (*HUOBI) WebsocketClient ¶
func (h *HUOBI) WebsocketClient()
WebsocketClient creates a new websocket client
type KlineItem ¶
type KlineItem struct { ID int `json:"id"` Open float64 `json:"open"` Close float64 `json:"close"` Low float64 `json:"low"` High float64 `json:"high"` Amount float64 `json:"amount"` Vol float64 `json:"vol"` Count int `json:"count"` }
KlineItem stores a kline item
type Klines ¶
type Klines struct {
Klines []KlineItem `json:"data"`
}
Klines stores tan array of kline items
type MarginAccountBalance ¶
type MarginAccountBalance struct { ID int `json:"id"` Type string `json:"type"` State string `json:"state"` Symbol string `json:"symbol"` FlPrice string `json:"fl-price"` FlType string `json:"fl-type"` RiskRate string `json:"risk-rate"` List []AccountBalance `json:"list"` }
MarginAccountBalance stores the margin account balance info
type MarginOrder ¶
type MarginOrder struct { Currency string `json:"currency"` Symbol string `json:"symbol"` AccruedAt int64 `json:"accrued-at"` LoanAmount string `json:"loan-amount"` LoanBalance string `json:"loan-balance"` InterestBalance string `json:"interest-balance"` CreatedAt int64 `json:"created-at"` InterestAmount string `json:"interest-amount"` InterestRate string `json:"interest-rate"` AccountID int `json:"account-id"` UserID int `json:"user-id"` UpdatedAt int64 `json:"updated-at"` ID int `json:"id"` State string `json:"state"` }
MarginOrder stores the margin order info
type OrderInfo ¶
type OrderInfo struct { ID int `json:"id"` Symbol string `json:"symbol"` AccountID int `json:"account-id"` Amount string `json:"amount"` Price string `json:"price"` CreatedAt int64 `json:"created-at"` Type string `json:"type"` FieldAmount string `json:"field-amount"` FieldCashAmount string `json:"field-cash-amount"` FieldFees string `json:"field-fees"` FinishedAt int64 `json:"finished-at"` UserID int `json:"user-id"` Source string `json:"source"` State string `json:"state"` CanceledAt int `json:"canceled-at"` Exchange string `json:"exchange"` Batch string `json:"batch"` }
OrderInfo stores the order info
type OrderMatchInfo ¶
type OrderMatchInfo struct { ID int `json:"id"` OrderID int `json:"order-id"` MatchID int `json:"match-id"` Symbol string `json:"symbol"` Type string `json:"type"` Source string `json:"source"` Price string `json:"price"` FilledAmount string `json:"filled-amount"` FilledFees string `json:"filled-fees"` CreatedAt int64 `json:"created-at"` }
OrderMatchInfo stores the order match info
type Orderbook ¶
type Orderbook struct { ID int64 `json:"id"` Timetstamp int64 `json:"ts"` Bids [][]float64 `json:"bids"` Asks [][]float64 `json:"asks"` }
Orderbook stores the orderbook data
type Response ¶
type Response struct { Status string `json:"status"` Channel string `json:"ch"` Timestamp int64 `json:"ts"` ErrorCode string `json:"err-code"` ErrorMessage string `json:"err-msg"` }
Response stores the Huobi response information
type Symbol ¶
type Symbol struct { BaseCurrency string `json:"base-currency"` QuoteCurrency string `json:"quote-currency"` PricePrecision int `json:"price-precision"` AmountPrecision int `json:"amount-precision"` SymbolPartition string `json:"symbol-partition"` }
Symbol stores the symbol data
type Trade ¶
type Trade struct { ID float64 `json:"id"` Price float64 `json:"price"` Amount float64 `json:"amount"` Direction string `json:"direction"` Timestamp int64 `json:"ts"` }
Trade stores the trade data
type TradeHistory ¶
type TradeHistory struct { ID int64 `json:"id"` Timestamp int64 `json:"ts"` Trades []Trade `json:"data"` }
TradeHistory stores the the trade history data
type WebsocketLastTimeline ¶
type WebsocketLastTimeline struct { ID int64 `json:"_id"` SymbolID string `json:"symbolId"` Time int64 `json:"time"` LastPrice float64 `json:"priceLast"` Amount float64 `json:"amount"` Volume float64 `json:"volume"` Count int64 `json:"count"` }
WebsocketLastTimeline holds timeline data
type WebsocketMarketOverview ¶
type WebsocketMarketOverview struct { SymbolID string `json:"symbolId"` Last float64 `json:"priceNew"` Open float64 `json:"priceOpen"` High float64 `json:"priceHigh"` Low float64 `json:"priceLow"` Ask float64 `json:"priceAsk"` Bid float64 `json:"priceBid"` Volume float64 `json:"totalVolume"` TotalAmount float64 `json:"totalAmount"` }
WebsocketMarketOverview holds market overview data
type WebsocketResponse ¶
type WebsocketResponse struct { Version int `json:"version"` MsgType string `json:"msgType"` RequestIndex int64 `json:"requestIndex"` RetCode int64 `json:"retCode"` RetMessage string `json:"retMsg"` Payload map[string]interface{} `json:"payload"` }
WebsocketResponse is a general response type for websocket
type WebsocketTrade ¶
type WebsocketTrade struct { Price []float64 `json:"price"` Level []float64 `json:"level"` Amount []float64 `json:"amount"` AccuAmount []float64 `json:"accuAmount"` }
WebsocketTrade holds full trade data
type WebsocketTradeDetail ¶
type WebsocketTradeDetail struct { SymbolID string `json:"symbolId"` TradeID []int64 `json:"tradeId"` Price []float64 `json:"price"` Time []int64 `json:"time"` Amount []float64 `json:"amount"` TopBids []WebsocketTrade `json:"topBids"` TopAsks []WebsocketTrade `json:"topAsks"` }
WebsocketTradeDetail holds specific trade details