Skip to content

Commit

Permalink
Fix linter issues for BTCC
Browse files Browse the repository at this point in the history
  • Loading branch information
shazbert committed Feb 25, 2018
1 parent 17df327 commit 111c678
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
21 changes: 21 additions & 0 deletions exchanges/btcc/btcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func (b *BTCC) GetOrderBook(currencyPair string, limit int) (Orderbook, error) {
return result, common.SendHTTPGetRequest(req, true, b.Verbose, &result)
}

// GetAccountInfo returns account information
func (b *BTCC) GetAccountInfo(infoType string) error {
params := make([]interface{}, 0)

Expand All @@ -149,6 +150,7 @@ func (b *BTCC) GetAccountInfo(infoType string) error {
return b.SendAuthenticatedHTTPRequest(btccAccountInfo, params)
}

// PlaceOrder places a new order
func (b *BTCC) PlaceOrder(buyOrder bool, price, amount float64, symbol string) {
params := make([]interface{}, 0)
params = append(params, strconv.FormatFloat(price, 'f', -1, 64))
Expand All @@ -170,6 +172,7 @@ func (b *BTCC) PlaceOrder(buyOrder bool, price, amount float64, symbol string) {
}
}

// CancelOrder cancels an order
func (b *BTCC) CancelOrder(orderID int64, symbol string) {
params := make([]interface{}, 0)
params = append(params, orderID)
Expand All @@ -185,6 +188,7 @@ func (b *BTCC) CancelOrder(orderID int64, symbol string) {
}
}

// GetDeposits returns deposit information
func (b *BTCC) GetDeposits(currency string, pending bool) {
params := make([]interface{}, 0)
params = append(params, currency)
Expand All @@ -200,6 +204,7 @@ func (b *BTCC) GetDeposits(currency string, pending bool) {
}
}

// GetMarketDepth returns market depth at limit
func (b *BTCC) GetMarketDepth(symbol string, limit int64) {
params := make([]interface{}, 0)

Expand All @@ -218,6 +223,7 @@ func (b *BTCC) GetMarketDepth(symbol string, limit int64) {
}
}

// GetOrder returns information about a specific order
func (b *BTCC) GetOrder(orderID int64, symbol string, detailed bool) {
params := make([]interface{}, 0)
params = append(params, orderID)
Expand All @@ -237,6 +243,7 @@ func (b *BTCC) GetOrder(orderID int64, symbol string, detailed bool) {
}
}

// GetOrders returns information of a range of orders
func (b *BTCC) GetOrders(openonly bool, symbol string, limit, offset, since int64, detailed bool) {
params := make([]interface{}, 0)

Expand Down Expand Up @@ -271,6 +278,7 @@ func (b *BTCC) GetOrders(openonly bool, symbol string, limit, offset, since int6
}
}

// GetTransactions returns transaction lists
func (b *BTCC) GetTransactions(transType string, limit, offset, since int64, sinceType string) {
params := make([]interface{}, 0)

Expand Down Expand Up @@ -301,6 +309,7 @@ func (b *BTCC) GetTransactions(transType string, limit, offset, since int64, sin
}
}

// GetWithdrawal returns information about a withdrawal process
func (b *BTCC) GetWithdrawal(withdrawalID int64, currency string) {
params := make([]interface{}, 0)
params = append(params, withdrawalID)
Expand All @@ -316,6 +325,7 @@ func (b *BTCC) GetWithdrawal(withdrawalID int64, currency string) {
}
}

// GetWithdrawals gets information about all withdrawals
func (b *BTCC) GetWithdrawals(currency string, pending bool) {
params := make([]interface{}, 0)
params = append(params, currency)
Expand All @@ -331,6 +341,7 @@ func (b *BTCC) GetWithdrawals(currency string, pending bool) {
}
}

// RequestWithdrawal requests a new withdrawal
func (b *BTCC) RequestWithdrawal(currency string, amount float64) {
params := make([]interface{}, 0)
params = append(params, currency)
Expand All @@ -343,6 +354,8 @@ func (b *BTCC) RequestWithdrawal(currency string, amount float64) {
}
}

// IcebergOrder intiates a large order but at intervals to preserve orderbook
// integrity
func (b *BTCC) IcebergOrder(buyOrder bool, price, amount, discAmount, variance float64, symbol string) {
params := make([]interface{}, 0)
params = append(params, strconv.FormatFloat(price, 'f', -1, 64))
Expand All @@ -366,6 +379,7 @@ func (b *BTCC) IcebergOrder(buyOrder bool, price, amount, discAmount, variance f
}
}

// GetIcebergOrder returns information on your iceberg order
func (b *BTCC) GetIcebergOrder(orderID int64, symbol string) {
params := make([]interface{}, 0)
params = append(params, orderID)
Expand All @@ -381,6 +395,7 @@ func (b *BTCC) GetIcebergOrder(orderID int64, symbol string) {
}
}

// GetIcebergOrders returns information on all iceberg orders
func (b *BTCC) GetIcebergOrders(limit, offset int64, symbol string) {
params := make([]interface{}, 0)

Expand All @@ -403,6 +418,7 @@ func (b *BTCC) GetIcebergOrders(limit, offset int64, symbol string) {
}
}

// CancelIcebergOrder cancels iceberg order
func (b *BTCC) CancelIcebergOrder(orderID int64, symbol string) {
params := make([]interface{}, 0)
params = append(params, orderID)
Expand All @@ -418,6 +434,7 @@ func (b *BTCC) CancelIcebergOrder(orderID int64, symbol string) {
}
}

// PlaceStopOrder inserts a stop loss order
func (b *BTCC) PlaceStopOrder(buyOder bool, stopPrice, price, amount, trailingAmt, trailingPct float64, symbol string) {
params := make([]interface{}, 0)

Expand Down Expand Up @@ -452,6 +469,7 @@ func (b *BTCC) PlaceStopOrder(buyOder bool, stopPrice, price, amount, trailingAm
}
}

// GetStopOrder returns a stop order
func (b *BTCC) GetStopOrder(orderID int64, symbol string) {
params := make([]interface{}, 0)
params = append(params, orderID)
Expand All @@ -467,6 +485,7 @@ func (b *BTCC) GetStopOrder(orderID int64, symbol string) {
}
}

// GetStopOrders returns all stop orders
func (b *BTCC) GetStopOrders(status, orderType string, stopPrice float64, limit, offset int64, symbol string) {
params := make([]interface{}, 0)

Expand Down Expand Up @@ -501,6 +520,7 @@ func (b *BTCC) GetStopOrders(status, orderType string, stopPrice float64, limit,
}
}

// CancelStopOrder cancels a stop order
func (b *BTCC) CancelStopOrder(orderID int64, symbol string) {
params := make([]interface{}, 0)
params = append(params, orderID)
Expand All @@ -516,6 +536,7 @@ func (b *BTCC) CancelStopOrder(orderID int64, symbol string) {
}
}

// SendAuthenticatedHTTPRequest sends a valid authenticated HTTP request
func (b *BTCC) SendAuthenticatedHTTPRequest(method string, params []interface{}) (err error) {
if !b.AuthenticatedAPISupport {
return fmt.Errorf(exchange.WarningAuthenticatedRequestWithoutCredentialsSet, b.Name)
Expand Down
13 changes: 11 additions & 2 deletions exchanges/btcc/btcc_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
)

const (
BTCC_SOCKETIO_ADDRESS = "https://websocket.btcc.com"
btccSocketioAddress = "https://websocket.btcc.com"
)

// BTCCSocket is a pointer to a IO socket
var BTCCSocket *socketio.SocketIO

// OnConnect gets information from the server when its connected
func (b *BTCC) OnConnect(output chan socketio.Message) {
if b.Verbose {
log.Printf("%s Connected to Websocket.", b.GetName())
Expand All @@ -37,23 +39,27 @@ func (b *BTCC) OnConnect(output chan socketio.Message) {
}
}

// OnDisconnect alerts when disconnection occurs
func (b *BTCC) OnDisconnect(output chan socketio.Message) {
log.Printf("%s Disconnected from websocket server.. Reconnecting.\n", b.GetName())
b.WebsocketClient()
}

// OnError alerts when error occurs
func (b *BTCC) OnError() {
log.Printf("%s Error with Websocket connection.. Reconnecting.\n", b.GetName())
b.WebsocketClient()
}

// OnMessage if message received and verbose it is printed out
func (b *BTCC) OnMessage(message []byte, output chan socketio.Message) {
if b.Verbose {
log.Printf("%s Websocket message received which isn't handled by default.\n", b.GetName())
log.Println(string(message))
}
}

// OnTicker handles ticker information
func (b *BTCC) OnTicker(message []byte, output chan socketio.Message) {
type Response struct {
Ticker WebsocketTicker `json:"ticker"`
Expand All @@ -67,6 +73,7 @@ func (b *BTCC) OnTicker(message []byte, output chan socketio.Message) {
}
}

// OnGroupOrder handles group order information
func (b *BTCC) OnGroupOrder(message []byte, output chan socketio.Message) {
type Response struct {
GroupOrder WebsocketGroupOrder `json:"grouporder"`
Expand All @@ -80,6 +87,7 @@ func (b *BTCC) OnGroupOrder(message []byte, output chan socketio.Message) {
}
}

// OnTrade handles group trade information
func (b *BTCC) OnTrade(message []byte, output chan socketio.Message) {
trade := WebsocketTrade{}
err := common.JSONDecode(message, &trade)
Expand All @@ -90,6 +98,7 @@ func (b *BTCC) OnTrade(message []byte, output chan socketio.Message) {
}
}

// WebsocketClient initiates a websocket client
func (b *BTCC) WebsocketClient() {
events := make(map[string]func(message []byte, output chan socketio.Message))
events["grouporder"] = b.OnGroupOrder
Expand All @@ -106,7 +115,7 @@ func (b *BTCC) WebsocketClient() {
}

for b.Enabled && b.Websocket {
err := socketio.ConnectToSocket(BTCC_SOCKETIO_ADDRESS, BTCCSocket)
err := socketio.ConnectToSocket(btccSocketioAddress, BTCCSocket)
if err != nil {
log.Printf("%s Unable to connect to Websocket. Err: %s\n", b.GetName(), err)
continue
Expand Down

0 comments on commit 111c678

Please sign in to comment.