Documentation ¶
Index ¶
- Variables
- func MapSortByKey(mapValue map[string]string) map[string]string
- type Account
- type AccountsData
- type AccountsReturn
- type Balance
- type BalanceReturn
- type DepthlListener
- type DetailListener
- type Huobi
- func (h *Huobi) GetAccountBalance() (*Balance, error)
- func (h *Huobi) GetAccounts() AccountsReturn
- func (h *Huobi) GetExchangeName() string
- func (h *Huobi) GetOrderInfo(strOrderID string) (*Order, error)
- func (h *Huobi) GetOrders(params OrdersRequestParams) ([]Order, error)
- func (h *Huobi) Place(amount, price float64, symbol, typ string) (string, error)
- func (h *Huobi) SetDepthlListener(listener DepthlListener)
- func (h *Huobi) SetDetailListener(listener DetailListener)
- func (h *Huobi) SubmitCancel(strOrderID string) error
- func (h *Huobi) SubscribeDepth(symbols ...string)
- func (h *Huobi) SubscribeDetail(symbols ...string)
- type Listener
- type Market
- type MarketDepth
- type MarketTradeDetail
- type Order
- type OrderReturn
- type OrdersRequestParams
- type OrdersReturn
- type PlaceRequestParams
- type PlaceReturn
- type SafeWebSocket
- type SafeWebSocketAliveHandler
- type SafeWebSocketMessageListener
- type SubAccount
Constants ¶
This section is empty.
Variables ¶
View Source
var ConnectionClosedError = fmt.Errorf("websocket connection closed")
ConnectionClosedError Websocket未连接错误
View Source
var Endpoint = "wss://api.huobi.pro/ws"
Endpoint 行情的Websocket入口
View Source
var SafeWebSocketDestroyError = fmt.Errorf("connection destroy by user")
Functions ¶
Types ¶
type AccountsData ¶
type AccountsReturn ¶
type AccountsReturn struct { Status string `json:"status"` // 请求状态 Data []AccountsData `json:"data"` // 用户数据 ErrCode string `json:"err-code"` ErrMsg string `json:"err-msg"` }
type Balance ¶
type Balance struct { ID int64 `json:"id"` // 账户ID State string `json:"state"` // 账户状态, working: 正常, lock: 账户被锁定 Type string `json:"type"` // 账户类型, spot: 现货账户 List []SubAccount `json:"list"` // 子账户数组 UserID int64 `json:"user-id"` }
type BalanceReturn ¶
type DepthlListener ¶
type DepthlListener = func(symbol string, depth *MarketDepth)
Listener 订阅事件监听器
type DetailListener ¶
type DetailListener = func(symbol string, detail *MarketTradeDetail)
Listener 订阅事件监听器
type Huobi ¶
type Huobi struct {
// contains filtered or unexported fields
}
func (*Huobi) GetAccountBalance ¶
根据账户ID查询账户余额 return: BalanceReturn对象
func (*Huobi) GetAccounts ¶
func (h *Huobi) GetAccounts() AccountsReturn
查询当前用户的所有账户, 根据包含的私钥查询 return: AccountsReturn对象
func (*Huobi) GetExchangeName ¶
func (*Huobi) GetOrderInfo ¶
查询订单详情 strOrderID: 订单ID return: OrderReturn对象
func (*Huobi) SetDepthlListener ¶
func (h *Huobi) SetDepthlListener(listener DepthlListener)
func (*Huobi) SetDetailListener ¶
func (h *Huobi) SetDetailListener(listener DetailListener)
func (*Huobi) SubmitCancel ¶
申请撤销一个订单请求 strOrderID: 订单ID return: PlaceReturn对象
func (*Huobi) SubscribeDepth ¶
func (*Huobi) SubscribeDetail ¶
type Market ¶
type Market struct { // 主动发送心跳的时间间隔,默认5秒 HeartbeatInterval time.Duration // 接收消息超时时间,默认10秒 ReceiveTimeout time.Duration // contains filtered or unexported fields }
type MarketDepth ¶
type MarketTradeDetail ¶
type MarketTradeDetail struct { Ch string `json:"ch"` Tick struct { Data []struct { Amount float64 `json:"amount"` Direction string `json:"direction"` Price float64 `json:"price"` TS int64 `json:"ts"` } `json:"data"` } `json:"tick"` }
func (*MarketTradeDetail) String ¶
func (m *MarketTradeDetail) String() string
type OrderReturn ¶
type OrdersRequestParams ¶
type OrdersReturn ¶
type PlaceRequestParams ¶
type PlaceRequestParams struct { AccountID string `json:"account-id"` // 账户ID Amount string `json:"amount"` // 限价表示下单数量, 市价买单时表示买多少钱, 市价卖单时表示卖多少币 Price string `json:"price"` // 下单价格, 市价单不传该参数 Source string `json:"source"` // 订单来源, api: API调用, margin-api: 借贷资产交易 Symbol string `json:"symbol"` // 交易对, btcusdt, bccbtc...... Type string `json:"type"` // 订单类型, buy-market: 市价买, sell-market: 市价卖, buy-limit: 限价买, sell-limit: 限价卖 }
type PlaceReturn ¶
type SafeWebSocket ¶
type SafeWebSocket struct {
// contains filtered or unexported fields
}
SafeWebSocket 安全的WebSocket封装 保证读取和发送操作是并发安全的,支持自定义保持alive函数
func NewSafeWebSocket ¶
func NewSafeWebSocket(endpoint string) (*SafeWebSocket, error)
NewSafeWebSocket 创建安全的WebSocket实例并连接
func (*SafeWebSocket) KeepAlive ¶
func (s *SafeWebSocket) KeepAlive(v time.Duration, h SafeWebSocketAliveHandler)
KeepAlive 设置alive周期及函数
func (*SafeWebSocket) Listen ¶
func (s *SafeWebSocket) Listen(h SafeWebSocketMessageListener)
Listen 监听消息
type SafeWebSocketAliveHandler ¶
type SafeWebSocketAliveHandler = func()
type SafeWebSocketMessageListener ¶
type SafeWebSocketMessageListener = func(b []byte)
type SubAccount ¶
type SubAccount struct { Currency string `json:"currency"` // 币种 Balance string `json:"balance"` // 结余 Type string `json:"type"` // 类型, trade: 交易余额, frozen: 冻结余额 }
子账户结构
Click to show internal directories.
Click to hide internal directories.