From 78d6571160eb881061fe3b34c5869692b76d793d Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Fri, 17 Apr 2015 23:50:02 +1000 Subject: [PATCH] Added Huobi Websocket additional parameters. --- huobiwebsocket.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/huobiwebsocket.go b/huobiwebsocket.go index e9e58a7a..2885fe6b 100644 --- a/huobiwebsocket.go +++ b/huobiwebsocket.go @@ -130,7 +130,7 @@ func (h *HUOBI) BuildHuobiWebsocketRequestExtra(msgType string, requestIndex int return request } -func (h *HUOBI) BuildHuobiWebsocketParamsList(objectName, currency, pushType, period, percentage string) (interface{}) { +func (h *HUOBI) BuildHuobiWebsocketParamsList(objectName, currency, pushType, period, count, from, to, percentage string) (interface{}) { list := map[string]interface{}{} list["symbolId"] = currency list["pushType"] = pushType @@ -139,7 +139,16 @@ func (h *HUOBI) BuildHuobiWebsocketParamsList(objectName, currency, pushType, pe list["period"] = period } if percentage != "" { - list["percentage"] = percentage + list["percent"] = percentage + } + if count != "" { + list["count"] = count + } + if from != "" { + list["from"] = from + } + if to != "" { + list["to"] = to } listArray := []map[string]interface{}{} @@ -155,14 +164,14 @@ func (h *HUOBI) OnConnect(output chan socketio.Message) { log.Printf("%s Connected to Websocket.", h.GetName()) } - msg := h.BuildHuobiWebsocketRequestExtra(HUOBI_SOCKET_REQ_SUBSCRIBE, 100, h.BuildHuobiWebsocketParamsList(HUOBI_SOCKET_MARKET_OVERVIEW, "btccny", "pushLong", "", "")) + msg := h.BuildHuobiWebsocketRequestExtra(HUOBI_SOCKET_REQ_SUBSCRIBE, 100, h.BuildHuobiWebsocketParamsList(HUOBI_SOCKET_MARKET_OVERVIEW, "btccny", "pushLong", "", "", "", "", "")) result, err := JSONEncode(msg) if err != nil { log.Println(err) } output <- socketio.CreateMessageEvent("request", string(result), nil) - msg = h.BuildHuobiWebsocketRequestExtra(HUOBI_SOCKET_REQ_SUBSCRIBE, 100, h.BuildHuobiWebsocketParamsList(HUOBI_SOCKET_MARKET_OVERVIEW, "ltccny", "pushLong", "", "")) + msg = h.BuildHuobiWebsocketRequestExtra(HUOBI_SOCKET_REQ_SUBSCRIBE, 100, h.BuildHuobiWebsocketParamsList(HUOBI_SOCKET_MARKET_OVERVIEW, "ltccny", "pushLong", "", "", "", "", "")) result, err = JSONEncode(msg) if err != nil { log.Println(err)