Migrate from gometalinter.v2 to golangci-lint (#249)

* Migrate from gometalinter.v2 to golangci-lint
This commit is contained in:
Adrian Gallagher
2019-03-01 16:10:29 +11:00
committed by GitHub
parent 81852f2e01
commit 7dcb1ab553
133 changed files with 2179 additions and 2204 deletions

View File

@@ -481,10 +481,13 @@ func (o *OKEX) GetContractCandlestickData(symbol, typeInput, contractType string
// GetContractHoldingsNumber returns current number of holdings
func (o *OKEX) GetContractHoldingsNumber(symbol, contractType string) (number float64, contract string, err error) {
if err = o.CheckSymbol(symbol); err != nil {
err = o.CheckSymbol(symbol)
if err != nil {
return number, contract, err
}
if err = o.CheckContractType(contractType); err != nil {
err = o.CheckContractType(contractType)
if err != nil {
return number, contract, err
}
@@ -495,7 +498,8 @@ func (o *OKEX) GetContractHoldingsNumber(symbol, contractType string) (number fl
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, contractFutureHoldAmount, values.Encode())
var resp interface{}
if err = o.SendHTTPRequest(path, &resp); err != nil {
err = o.SendHTTPRequest(path, &resp)
if err != nil {
return number, contract, err
}
@@ -511,7 +515,7 @@ func (o *OKEX) GetContractHoldingsNumber(symbol, contractType string) (number fl
contract = holdingMap["contract_name"].(string)
}
}
return
return number, contract, err
}
// GetContractlimit returns upper and lower price limit
@@ -716,7 +720,10 @@ func (o *OKEX) SpotCancelOrder(symbol string, argOrderID int64) (int64, error) {
}
if res.ErrorCode != 0 {
return returnOrderID, fmt.Errorf("ErrCode:%d ErrMsg:%s", res.ErrorCode, o.ErrorCodes[strconv.Itoa(res.ErrorCode)])
return returnOrderID, fmt.Errorf("failed to cancel order. code: %d err: %s",
res.ErrorCode,
o.ErrorCodes[strconv.Itoa(res.ErrorCode)],
)
}
returnOrderID, _ = common.Int64FromString(res.OrderID)
@@ -755,7 +762,7 @@ func (o *OKEX) GetSpotTicker(symbol string) (SpotPrice, error) {
return resp, nil
}
//GetSpotMarketDepth returns Market Depth
// GetSpotMarketDepth returns Market Depth
func (o *OKEX) GetSpotMarketDepth(asd ActualSpotDepthRequestParams) (ActualSpotDepth, error) {
resp := SpotDepth{}
fullDepth := ActualSpotDepth{}
@@ -963,7 +970,7 @@ func (o *OKEX) SendAuthenticatedHTTPRequest(method string, values url.Values, re
err = common.JSONDecode(intermediary, &errCap)
if err == nil {
if !errCap.Result {
return fmt.Errorf("SendAuthenticatedHTTPRequest error - %s",
return fmt.Errorf("sendAuthenticatedHTTPRequest error - %s",
o.ErrorCodes[strconv.FormatInt(errCap.Error, 10)])
}
}
@@ -974,24 +981,24 @@ func (o *OKEX) SendAuthenticatedHTTPRequest(method string, values url.Values, re
// SetErrorDefaults sets the full error default list
func (o *OKEX) SetErrorDefaults() {
o.ErrorCodes = map[string]error{
//Spot Errors
"10000": errors.New("Required field, can not be null"),
"10001": errors.New("Request frequency too high to exceed the limit allowed"),
"10002": errors.New("System error"),
"10004": errors.New("Request failed - Your API key might need to be recreated"),
"10005": errors.New("'SecretKey' does not exist"),
"10006": errors.New("'Api_key' does not exist"),
"10007": errors.New("Signature does not match"),
"10008": errors.New("Illegal parameter"),
"10009": errors.New("Order does not exist"),
"10010": errors.New("Insufficient funds"),
"10011": errors.New("Amount too low"),
"10012": errors.New("Only btc_usd ltc_usd supported"),
"10013": errors.New("Only support https request"),
"10014": errors.New("Order price must be between 0 and 1,000,000"),
"10015": errors.New("Order price differs from current market price too much"),
"10016": errors.New("Insufficient coins balance"),
"10017": errors.New("API authorization error"),
// Spot Errors
"10000": errors.New("required field, can not be null"),
"10001": errors.New("request frequency too high to exceed the limit allowed"),
"10002": errors.New("system error"),
"10004": errors.New("request failed - Your API key might need to be recreated"),
"10005": errors.New("'secretKey' does not exist"),
"10006": errors.New("'api_key' does not exist"),
"10007": errors.New("signature does not match"),
"10008": errors.New("illegal parameter"),
"10009": errors.New("order does not exist"),
"10010": errors.New("insufficient funds"),
"10011": errors.New("amount too low"),
"10012": errors.New("only btc_usd ltc_usd supported"),
"10013": errors.New("only support https request"),
"10014": errors.New("order price must be between 0 and 1,000,000"),
"10015": errors.New("order price differs from current market price too much"),
"10016": errors.New("insufficient coins balance"),
"10017": errors.New("api authorization error"),
"10018": errors.New("borrow amount less than lower limit [usd:100,btc:0.1,ltc:1]"),
"10019": errors.New("loan agreement not checked"),
"10020": errors.New("rate cannot exceed 1%"),
@@ -999,119 +1006,119 @@ func (o *OKEX) SetErrorDefaults() {
"10023": errors.New("fail to get latest ticker"),
"10024": errors.New("balance not sufficient"),
"10025": errors.New("quota is full, cannot borrow temporarily"),
"10026": errors.New("Loan (including reserved loan) and margin cannot be withdrawn"),
"10027": errors.New("Cannot withdraw within 24 hrs of authentication information modification"),
"10028": errors.New("Withdrawal amount exceeds daily limit"),
"10029": errors.New("Account has unpaid loan, please cancel/pay off the loan before withdraw"),
"10031": errors.New("Deposits can only be withdrawn after 6 confirmations"),
"10032": errors.New("Please enabled phone/google authenticator"),
"10033": errors.New("Fee higher than maximum network transaction fee"),
"10034": errors.New("Fee lower than minimum network transaction fee"),
"10035": errors.New("Insufficient BTC/LTC"),
"10036": errors.New("Withdrawal amount too low"),
"10037": errors.New("Trade password not set"),
"10040": errors.New("Withdrawal cancellation fails"),
"10041": errors.New("Withdrawal address not exsit or approved"),
"10042": errors.New("Admin password error"),
"10043": errors.New("Account equity error, withdrawal failure"),
"10026": errors.New("loan (including reserved loan) and margin cannot be withdrawn"),
"10027": errors.New("cannot withdraw within 24 hrs of authentication information modification"),
"10028": errors.New("withdrawal amount exceeds daily limit"),
"10029": errors.New("account has unpaid loan, please cancel/pay off the loan before withdraw"),
"10031": errors.New("deposits can only be withdrawn after 6 confirmations"),
"10032": errors.New("please enabled phone/google authenticator"),
"10033": errors.New("fee higher than maximum network transaction fee"),
"10034": errors.New("fee lower than minimum network transaction fee"),
"10035": errors.New("insufficient BTC/LTC"),
"10036": errors.New("withdrawal amount too low"),
"10037": errors.New("trade password not set"),
"10040": errors.New("withdrawal cancellation fails"),
"10041": errors.New("withdrawal address not exsit or approved"),
"10042": errors.New("admin password error"),
"10043": errors.New("account equity error, withdrawal failure"),
"10044": errors.New("fail to cancel borrowing order"),
"10047": errors.New("this function is disabled for sub-account"),
"10048": errors.New("withdrawal information does not exist"),
"10049": errors.New("User can not have more than 50 unfilled small orders (amount<0.15BTC)"),
"10049": errors.New("user can not have more than 50 unfilled small orders (amount<0.15BTC)"),
"10050": errors.New("can't cancel more than once"),
"10051": errors.New("order completed transaction"),
"10052": errors.New("not allowed to withdraw"),
"10064": errors.New("after a USD deposit, that portion of assets will not be withdrawable for the next 48 hours"),
"10100": errors.New("User account frozen"),
"10100": errors.New("user account frozen"),
"10101": errors.New("order type is wrong"),
"10102": errors.New("incorrect ID"),
"10103": errors.New("the private otc order's key incorrect"),
"10216": errors.New("Non-available API"),
"1002": errors.New("The transaction amount exceed the balance"),
"1003": errors.New("The transaction amount is less than the minimum requirement"),
"1004": errors.New("The transaction amount is less than 0"),
"1007": errors.New("No trading market information"),
"1008": errors.New("No latest market information"),
"1009": errors.New("No order"),
"1010": errors.New("Different user of the cancelled order and the original order"),
"1011": errors.New("No documented user"),
"1013": errors.New("No order type"),
"1014": errors.New("No login"),
"1015": errors.New("No market depth information"),
"1017": errors.New("Date error"),
"1018": errors.New("Order failed"),
"1019": errors.New("Undo order failed"),
"1024": errors.New("Currency does not exist"),
"1025": errors.New("No chart type"),
"1026": errors.New("No base currency quantity"),
"1027": errors.New("Incorrect parameter may exceeded limits"),
"1028": errors.New("Reserved decimal failed"),
"1029": errors.New("Preparing"),
"1030": errors.New("Account has margin and futures, transactions can not be processed"),
"1031": errors.New("Insufficient Transferring Balance"),
"1032": errors.New("Transferring Not Allowed"),
"1035": errors.New("Password incorrect"),
"1036": errors.New("Google Verification code Invalid"),
"1037": errors.New("Google Verification code incorrect"),
"1038": errors.New("Google Verification replicated"),
"1039": errors.New("Message Verification Input exceed the limit"),
"1040": errors.New("Message Verification invalid"),
"1041": errors.New("Message Verification incorrect"),
"1042": errors.New("Wrong Google Verification Input exceed the limit"),
"1043": errors.New("Login password cannot be same as the trading password"),
"1044": errors.New("Old password incorrect"),
"10216": errors.New("non-available API"),
"1002": errors.New("the transaction amount exceed the balance"),
"1003": errors.New("the transaction amount is less than the minimum requirement"),
"1004": errors.New("the transaction amount is less than 0"),
"1007": errors.New("no trading market information"),
"1008": errors.New("no latest market information"),
"1009": errors.New("no order"),
"1010": errors.New("different user of the cancelled order and the original order"),
"1011": errors.New("no documented user"),
"1013": errors.New("no order type"),
"1014": errors.New("no login"),
"1015": errors.New("no market depth information"),
"1017": errors.New("date error"),
"1018": errors.New("order failed"),
"1019": errors.New("undo order failed"),
"1024": errors.New("currency does not exist"),
"1025": errors.New("no chart type"),
"1026": errors.New("no base currency quantity"),
"1027": errors.New("incorrect parameter may exceeded limits"),
"1028": errors.New("reserved decimal failed"),
"1029": errors.New("preparing"),
"1030": errors.New("account has margin and futures, transactions can not be processed"),
"1031": errors.New("insufficient Transferring Balance"),
"1032": errors.New("transferring Not Allowed"),
"1035": errors.New("password incorrect"),
"1036": errors.New("google Verification code Invalid"),
"1037": errors.New("google Verification code incorrect"),
"1038": errors.New("google Verification replicated"),
"1039": errors.New("message Verification Input exceed the limit"),
"1040": errors.New("message Verification invalid"),
"1041": errors.New("message Verification incorrect"),
"1042": errors.New("wrong Google Verification Input exceed the limit"),
"1043": errors.New("login password cannot be same as the trading password"),
"1044": errors.New("old password incorrect"),
"1045": errors.New("2nd Verification Needed"),
"1046": errors.New("Please input old password"),
"1048": errors.New("Account Blocked"),
"1201": errors.New("Account Deleted at 00: 00"),
"1202": errors.New("Account Not Exist"),
"1203": errors.New("Insufficient Balance"),
"1204": errors.New("Invalid currency"),
"1205": errors.New("Invalid Account"),
"1206": errors.New("Cash Withdrawal Blocked"),
"1207": errors.New("Transfer Not Support"),
"1208": errors.New("No designated account"),
"1209": errors.New("Invalid api"),
"1216": errors.New("Market order temporarily suspended. Please send limit order"),
"1217": errors.New("Order was sent at ±5% of the current market price. Please resend"),
"1218": errors.New("Place order failed. Please try again later"),
"1046": errors.New("please input old password"),
"1048": errors.New("account Blocked"),
"1201": errors.New("account Deleted at 00: 00"),
"1202": errors.New("account Not Exist"),
"1203": errors.New("insufficient Balance"),
"1204": errors.New("invalid currency"),
"1205": errors.New("invalid Account"),
"1206": errors.New("cash Withdrawal Blocked"),
"1207": errors.New("transfer Not Support"),
"1208": errors.New("no designated account"),
"1209": errors.New("invalid api"),
"1216": errors.New("market order temporarily suspended. Please send limit order"),
"1217": errors.New("order was sent at ±5% of the current market price. Please resend"),
"1218": errors.New("place order failed. Please try again later"),
// Errors for both
"HTTP ERROR CODE 403": errors.New("Too many requests, IP is shielded"),
"Request Timed Out": errors.New("Too many requests, IP is shielded"),
"HTTP ERROR CODE 403": errors.New("too many requests, IP is shielded"),
"Request Timed Out": errors.New("too many requests, IP is shielded"),
// contract errors
"405": errors.New("method not allowed"),
"20001": errors.New("User does not exist"),
"20002": errors.New("Account frozen"),
"20003": errors.New("Account frozen due to liquidation"),
"20004": errors.New("Contract account frozen"),
"20005": errors.New("User contract account does not exist"),
"20006": errors.New("Required field missing"),
"20007": errors.New("Illegal parameter"),
"20008": errors.New("Contract account balance is too low"),
"20009": errors.New("Contract status error"),
"20010": errors.New("Risk rate ratio does not exist"),
"20011": errors.New("Risk rate lower than 90%/80% before opening BTC position with 10x/20x leverage. or risk rate lower than 80%/60% before opening LTC position with 10x/20x leverage"),
"20012": errors.New("Risk rate lower than 90%/80% after opening BTC position with 10x/20x leverage. or risk rate lower than 80%/60% after opening LTC position with 10x/20x leverage"),
"20013": errors.New("Temporally no counter party price"),
"20014": errors.New("System error"),
"20015": errors.New("Order does not exist"),
"20016": errors.New("Close amount bigger than your open positions"),
"20017": errors.New("Not authorized/illegal operation"),
"20018": errors.New("Order price cannot be more than 103% or less than 97% of the previous minute price"),
"20019": errors.New("IP restricted from accessing the resource"),
"20001": errors.New("user does not exist"),
"20002": errors.New("account frozen"),
"20003": errors.New("account frozen due to liquidation"),
"20004": errors.New("contract account frozen"),
"20005": errors.New("user contract account does not exist"),
"20006": errors.New("required field missing"),
"20007": errors.New("illegal parameter"),
"20008": errors.New("contract account balance is too low"),
"20009": errors.New("contract status error"),
"20010": errors.New("risk rate ratio does not exist"),
"20011": errors.New("risk rate lower than 90%/80% before opening BTC position with 10x/20x leverage. or risk rate lower than 80%/60% before opening LTC position with 10x/20x leverage"),
"20012": errors.New("risk rate lower than 90%/80% after opening BTC position with 10x/20x leverage. or risk rate lower than 80%/60% after opening LTC position with 10x/20x leverage"),
"20013": errors.New("temporally no counter party price"),
"20014": errors.New("system error"),
"20015": errors.New("order does not exist"),
"20016": errors.New("close amount bigger than your open positions"),
"20017": errors.New("not authorized/illegal operation"),
"20018": errors.New("order price cannot be more than 103% or less than 97% of the previous minute price"),
"20019": errors.New("ip restricted from accessing the resource"),
"20020": errors.New("secretKey does not exist"),
"20021": errors.New("Index information does not exist"),
"20022": errors.New("Wrong API interface (Cross margin mode shall call cross margin API, fixed margin mode shall call fixed margin API)"),
"20023": errors.New("Account in fixed-margin mode"),
"20024": errors.New("Signature does not match"),
"20025": errors.New("Leverage rate error"),
"20026": errors.New("API Permission Error"),
"20021": errors.New("index information does not exist"),
"20022": errors.New("wrong API interface (Cross margin mode shall call cross margin API, fixed margin mode shall call fixed margin API)"),
"20023": errors.New("account in fixed-margin mode"),
"20024": errors.New("signature does not match"),
"20025": errors.New("leverage rate error"),
"20026": errors.New("api permission error"),
"20027": errors.New("no transaction record"),
"20028": errors.New("no such contract"),
"20029": errors.New("Amount is large than available funds"),
"20030": errors.New("Account still has debts"),
"20038": errors.New("Due to regulation, this function is not available in the country/region your currently reside in"),
"20049": errors.New("Request frequency too high"),
"20029": errors.New("amount is large than available funds"),
"20030": errors.New("account still has debts"),
"20038": errors.New("due to regulation, this function is not available in the country/region your currently reside in"),
"20049": errors.New("request frequency too high"),
}
}

View File

@@ -61,8 +61,8 @@ func (o *OKEX) WsConnect() error {
err = o.WsSubscribe()
if err != nil {
return fmt.Errorf("Error: Could not subscribe to the OKEX websocket %s",
err)
return fmt.Errorf("%s could not subscribe to websocket %s",
o.Name, err)
}
return nil
@@ -90,17 +90,11 @@ func (o *OKEX) WsSubscribe() error {
myEnabledSubscriptionChannels = append(myEnabledSubscriptionChannels,
fmt.Sprintf("{'event':'addChannel','channel':'ok_sub_spot_%s_ticker'}",
symbolRedone))
myEnabledSubscriptionChannels = append(myEnabledSubscriptionChannels,
symbolRedone),
fmt.Sprintf("{'event':'addChannel','channel':'ok_sub_spot_%s_depth'}",
symbolRedone))
myEnabledSubscriptionChannels = append(myEnabledSubscriptionChannels,
symbolRedone),
fmt.Sprintf("{'event':'addChannel','channel':'ok_sub_spot_%s_deals'}",
symbolRedone))
myEnabledSubscriptionChannels = append(myEnabledSubscriptionChannels,
symbolRedone),
fmt.Sprintf("{'event':'addChannel','channel':'ok_sub_spot_%s_kline_1min'}",
symbolRedone))
}
@@ -221,7 +215,8 @@ func (o *OKEX) WsHandleData() {
assetType = currencyPairSlice[2]
}
if strings.Contains(multiStreamData.Channel, "ticker") {
switch multiStreamData.Channel {
case "ticker":
var ticker TickerStreamData
err = common.JSONDecode(multiStreamData.Data, &ticker)
@@ -235,8 +230,7 @@ func (o *OKEX) WsHandleData() {
Exchange: o.GetName(),
AssetType: assetType,
}
} else if strings.Contains(multiStreamData.Channel, "deals") {
case "deals":
var deals DealsStreamData
err = common.JSONDecode(multiStreamData.Data, &deals)
@@ -248,10 +242,10 @@ func (o *OKEX) WsHandleData() {
for _, trade := range deals {
price, _ := strconv.ParseFloat(trade[1], 64)
amount, _ := strconv.ParseFloat(trade[2], 64)
time, _ := time.Parse(time.RFC3339, trade[3])
tradeTime, _ := time.Parse(time.RFC3339, trade[3])
o.Websocket.DataHandler <- exchange.TradeData{
Timestamp: time,
Timestamp: tradeTime,
Exchange: o.GetName(),
AssetType: assetType,
CurrencyPair: pair.NewCurrencyPairFromString(newPair),
@@ -260,8 +254,7 @@ func (o *OKEX) WsHandleData() {
EventType: trade[4],
}
}
} else if strings.Contains(multiStreamData.Channel, "kline") {
case "kline":
var klines KlineStreamData
err := common.JSONDecode(multiStreamData.Data, &klines)
@@ -275,7 +268,7 @@ func (o *OKEX) WsHandleData() {
open, _ := strconv.ParseFloat(kline[1], 64)
high, _ := strconv.ParseFloat(kline[2], 64)
low, _ := strconv.ParseFloat(kline[3], 64)
close, _ := strconv.ParseFloat(kline[4], 64)
klineClose, _ := strconv.ParseFloat(kline[4], 64)
volume, _ := strconv.ParseFloat(kline[5], 64)
o.Websocket.DataHandler <- exchange.KlineData{
@@ -286,12 +279,11 @@ func (o *OKEX) WsHandleData() {
OpenPrice: open,
HighPrice: high,
LowPrice: low,
ClosePrice: close,
ClosePrice: klineClose,
Volume: volume,
}
}
} else if strings.Contains(multiStreamData.Channel, "depth") {
case "depth":
var depth DepthStreamData
err := common.JSONDecode(multiStreamData.Data, &depth)

View File

@@ -196,20 +196,19 @@ func (o *OKEX) SubmitOrder(p pair.CurrencyPair, side exchange.OrderSide, orderTy
var submitOrderResponse exchange.SubmitOrderResponse
var oT SpotNewOrderRequestType
if orderType == exchange.LimitOrderType {
switch orderType {
case exchange.LimitOrderType:
oT = SpotNewOrderRequestTypeSell
if side == exchange.BuyOrderSide {
oT = SpotNewOrderRequestTypeBuy
} else {
oT = SpotNewOrderRequestTypeSell
}
} else if orderType == exchange.MarketOrderType {
case exchange.MarketOrderType:
oT = SpotNewOrderRequestTypeSellMarket
if side == exchange.BuyOrderSide {
oT = SpotNewOrderRequestTypeBuyMarket
} else {
oT = SpotNewOrderRequestTypeSellMarket
}
} else {
return submitOrderResponse, errors.New("Unsupported order type")
default:
return submitOrderResponse, errors.New("unsupported order type")
}
var params = SpotNewOrderRequestParams{
@@ -263,7 +262,7 @@ func (o *OKEX) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAll
}
if !openOrders.Result {
return cancelAllOrdersResponse, fmt.Errorf("Something went wrong for currency %s", formattedCurrency)
return cancelAllOrdersResponse, fmt.Errorf("something went wrong for currency %s", formattedCurrency)
}
allOpenOrders = append(allOpenOrders, openOrders.Orders...)