mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 07:26:45 +00:00
Migrate from gometalinter.v2 to golangci-lint (#249)
* Migrate from gometalinter.v2 to golangci-lint
This commit is contained in:
@@ -145,7 +145,7 @@ func (z *ZB) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) {
|
||||
return 0, err
|
||||
}
|
||||
if result.Code != 1000 {
|
||||
|
||||
return 0, fmt.Errorf("unsucessful new order, message: %s code: %d", result.Message, result.Code)
|
||||
}
|
||||
newOrderID, err := strconv.ParseInt(result.ID, 10, 64)
|
||||
if err != nil {
|
||||
@@ -220,10 +220,10 @@ func (z *ZB) GetOrders(currency string, pageindex, side int64) ([]Order, error)
|
||||
// GetMarkets returns market information including pricing, symbols and
|
||||
// each symbols decimal precision
|
||||
func (z *ZB) GetMarkets() (map[string]MarketResponseItem, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s", z.APIUrl, zbAPIVersion, zbMarkets)
|
||||
endpoint := fmt.Sprintf("%s/%s/%s", z.APIUrl, zbAPIVersion, zbMarkets)
|
||||
|
||||
var res interface{}
|
||||
err := z.SendHTTPRequest(url, &res)
|
||||
err := z.SendHTTPRequest(endpoint, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -256,28 +256,28 @@ func (z *ZB) GetLatestSpotPrice(symbol string) (float64, error) {
|
||||
|
||||
// GetTicker returns a ticker for a given symbol
|
||||
func (z *ZB) GetTicker(symbol string) (TickerResponse, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s?market=%s", z.APIUrl, zbAPIVersion, zbTicker, symbol)
|
||||
urlPath := fmt.Sprintf("%s/%s/%s?market=%s", z.APIUrl, zbAPIVersion, zbTicker, symbol)
|
||||
var res TickerResponse
|
||||
|
||||
err := z.SendHTTPRequest(url, &res)
|
||||
err := z.SendHTTPRequest(urlPath, &res)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// GetTickers returns ticker data for all supported symbols
|
||||
func (z *ZB) GetTickers() (map[string]TickerChildResponse, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s", z.APIUrl, zbAPIVersion, zbTickers)
|
||||
urlPath := fmt.Sprintf("%s/%s/%s", z.APIUrl, zbAPIVersion, zbTickers)
|
||||
resp := make(map[string]TickerChildResponse)
|
||||
|
||||
err := z.SendHTTPRequest(url, &resp)
|
||||
err := z.SendHTTPRequest(urlPath, &resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// GetOrderbook returns the orderbook for a given symbol
|
||||
func (z *ZB) GetOrderbook(symbol string) (OrderbookResponse, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s?market=%s", z.APIUrl, zbAPIVersion, zbDepth, symbol)
|
||||
urlPath := fmt.Sprintf("%s/%s/%s?market=%s", z.APIUrl, zbAPIVersion, zbDepth, symbol)
|
||||
var res OrderbookResponse
|
||||
|
||||
err := z.SendHTTPRequest(url, &res)
|
||||
err := z.SendHTTPRequest(urlPath, &res)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -304,11 +304,11 @@ func (z *ZB) GetSpotKline(arg KlinesRequestParams) (KLineResponse, error) {
|
||||
vals.Set("size", fmt.Sprintf("%d", arg.Size))
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s/%s?%s", z.APIUrl, zbAPIVersion, zbKline, vals.Encode())
|
||||
urlPath := fmt.Sprintf("%s/%s/%s?%s", z.APIUrl, zbAPIVersion, zbKline, vals.Encode())
|
||||
|
||||
var res KLineResponse
|
||||
var rawKlines map[string]interface{}
|
||||
err := z.SendHTTPRequest(url, &rawKlines)
|
||||
err := z.SendHTTPRequest(urlPath, &rawKlines)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -378,7 +378,7 @@ func (z *ZB) SendAuthenticatedHTTPRequest(httpMethod string, params url.Values,
|
||||
params.Set("reqTime", fmt.Sprintf("%d", common.UnixMillis(time.Now())))
|
||||
params.Set("sign", fmt.Sprintf("%x", hmac))
|
||||
|
||||
url := fmt.Sprintf("%s/%s?%s",
|
||||
urlPath := fmt.Sprintf("%s/%s?%s",
|
||||
z.APIUrlSecondary,
|
||||
params.Get("method"),
|
||||
params.Encode())
|
||||
@@ -391,7 +391,7 @@ func (z *ZB) SendAuthenticatedHTTPRequest(httpMethod string, params url.Values,
|
||||
}{}
|
||||
|
||||
err := z.SendPayload(httpMethod,
|
||||
url,
|
||||
urlPath,
|
||||
nil,
|
||||
strings.NewReader(""),
|
||||
&intermediary,
|
||||
@@ -404,7 +404,7 @@ func (z *ZB) SendAuthenticatedHTTPRequest(httpMethod string, params url.Values,
|
||||
err = common.JSONDecode(intermediary, &errCap)
|
||||
if err == nil {
|
||||
if errCap.Code != 0 {
|
||||
return fmt.Errorf("SendAuthenticatedHTTPRequest error code: %d message %s",
|
||||
return fmt.Errorf("sendAuthenticatedHTTPRequest error code: %d message %s",
|
||||
errCap.Code,
|
||||
errorCode[errCap.Code])
|
||||
}
|
||||
|
||||
@@ -281,12 +281,13 @@ func TestSubmitOrder(t *testing.T) {
|
||||
if areTestAPIKeysSet() && !canManipulateRealOrders {
|
||||
t.Skip(fmt.Sprintf("ApiKey: %s. Can place orders: %v", z.APIKey, canManipulateRealOrders))
|
||||
}
|
||||
var pair = pair.CurrencyPair{
|
||||
var currencyPair = pair.CurrencyPair{
|
||||
Delimiter: "_",
|
||||
FirstCurrency: symbol.QTUM,
|
||||
SecondCurrency: symbol.USDT,
|
||||
}
|
||||
response, err := z.SubmitOrder(pair, exchange.BuyOrderSide, exchange.MarketOrderType, 1, 10, "hi")
|
||||
|
||||
response, err := z.SubmitOrder(currencyPair, exchange.BuyOrderSide, exchange.MarketOrderType, 1, 10, "hi")
|
||||
if areTestAPIKeysSet() && (err != nil || !response.IsOrderPlaced) {
|
||||
t.Errorf("Order failed to be placed: %v", err)
|
||||
} else if !areTestAPIKeysSet() && err == nil {
|
||||
|
||||
@@ -16,21 +16,21 @@ type OrderbookResponse struct {
|
||||
|
||||
// AccountsResponseCoin holds the accounts coin details
|
||||
type AccountsResponseCoin struct {
|
||||
Freez string `json:"freez"` //冻结资产
|
||||
EnName string `json:"enName"` //币种英文名
|
||||
UnitDecimal int `json:"unitDecimal"` //保留小数位
|
||||
UnName string `json:"cnName"` //币种中文名
|
||||
UnitTag string `json:"unitTag"` //币种符号
|
||||
Available string `json:"available"` //可用资产
|
||||
Key string `json:"key"` //币种
|
||||
Freez string `json:"freez"` // 冻结资产
|
||||
EnName string `json:"enName"` // 币种英文名
|
||||
UnitDecimal int `json:"unitDecimal"` // 保留小数位
|
||||
UnName string `json:"cnName"` // 币种中文名
|
||||
UnitTag string `json:"unitTag"` // 币种符号
|
||||
Available string `json:"available"` // 可用资产
|
||||
Key string `json:"key"` // 币种
|
||||
}
|
||||
|
||||
// AccountsBaseResponse holds basic account details
|
||||
type AccountsBaseResponse struct {
|
||||
UserName string `json:"username"` //用户名
|
||||
TradePasswordEnabled bool `json:"trade_password_enabled"` //是否开通交易密码
|
||||
AuthGoogleEnabled bool `json:"auth_google_enabled"` //是否开通谷歌验证
|
||||
AuthMobileEnabled bool `json:"auth_mobile_enabled"` //是否开通手机验证
|
||||
UserName string `json:"username"` // 用户名
|
||||
TradePasswordEnabled bool `json:"trade_password_enabled"` // 是否开通交易密码
|
||||
AuthGoogleEnabled bool `json:"auth_google_enabled"` // 是否开通谷歌验证
|
||||
AuthMobileEnabled bool `json:"auth_mobile_enabled"` // 是否开通手机验证
|
||||
}
|
||||
|
||||
// Order is the order details for retrieving all orders
|
||||
@@ -51,10 +51,10 @@ type AccountsResponse struct {
|
||||
Result struct {
|
||||
Coins []AccountsResponseCoin `json:"coins"`
|
||||
Base AccountsBaseResponse `json:"base"`
|
||||
} `json:"result"` //用户名
|
||||
AssetPerm bool `json:"assetPerm"` //是否开通交易密码
|
||||
LeverPerm bool `json:"leverPerm"` //是否开通谷歌验证
|
||||
EntrustPerm bool `json:"entrustPerm"` //是否开通手机验证
|
||||
} `json:"result"` // 用户名
|
||||
AssetPerm bool `json:"assetPerm"` // 是否开通交易密码
|
||||
LeverPerm bool `json:"leverPerm"` // 是否开通谷歌验证
|
||||
EntrustPerm bool `json:"entrustPerm"` // 是否开通手机验证
|
||||
MoneyPerm bool `json:"moneyPerm"` // 资产列表
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@ type TickerResponse struct {
|
||||
|
||||
// TickerChildResponse holds the ticker child response data
|
||||
type TickerChildResponse struct {
|
||||
Vol float64 `json:"vol,string"` //成交量(最近的24小时)
|
||||
Last float64 `json:"last,string"` //最新成交价
|
||||
Sell float64 `json:"sell,string"` //卖一价
|
||||
Buy float64 `json:"buy,string"` //买一价
|
||||
High float64 `json:"high,string"` //最高价
|
||||
Low float64 `json:"low,string"` //最低价
|
||||
Vol float64 `json:"vol,string"` // 成交量(最近的24小时)
|
||||
Last float64 `json:"last,string"` // 最新成交价
|
||||
Sell float64 `json:"sell,string"` // 卖一价
|
||||
Buy float64 `json:"buy,string"` // 买一价
|
||||
High float64 `json:"high,string"` // 最高价
|
||||
Low float64 `json:"low,string"` // 最低价
|
||||
}
|
||||
|
||||
// SpotNewOrderRequestParamsType ZB 交易类型
|
||||
@@ -100,19 +100,19 @@ type SpotNewOrderRequestParams struct {
|
||||
|
||||
// SpotNewOrderResponse stores the new order response data
|
||||
type SpotNewOrderResponse struct {
|
||||
Code int `json:"code"` //返回代码
|
||||
Message string `json:"message"` //提示信息
|
||||
ID string `json:"id"` //委托挂单号
|
||||
Code int `json:"code"` // 返回代码
|
||||
Message string `json:"message"` // 提示信息
|
||||
ID string `json:"id"` // 委托挂单号
|
||||
}
|
||||
|
||||
// //-------------Kline
|
||||
|
||||
// KlinesRequestParams represents Klines request data.
|
||||
type KlinesRequestParams struct {
|
||||
Symbol string //交易对, zb_qc,zb_usdt,zb_btc...
|
||||
Type TimeInterval //K线类型, 1min, 3min, 15min, 30min, 1hour......
|
||||
Since string //从这个时间戳之后的
|
||||
Size int //返回数据的条数限制(默认为1000,如果返回数据多于1000条,那么只返回1000条)
|
||||
Symbol string // 交易对, zb_qc,zb_usdt,zb_btc...
|
||||
Type TimeInterval // K线类型, 1min, 3min, 15min, 30min, 1hour......
|
||||
Since string // 从这个时间戳之后的
|
||||
Size int // 返回数据的条数限制(默认为1000,如果返回数据多于1000条,那么只返回1000条)
|
||||
}
|
||||
|
||||
// KLineResponseData Kline Data
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/currency/pair"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges"
|
||||
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
|
||||
)
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ func (z *ZB) GetActiveOrders(getOrdersRequest exchange.GetOrdersRequest) ([]exch
|
||||
// This function is not concurrency safe due to orderSide/orderType maps
|
||||
func (z *ZB) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) ([]exchange.OrderDetail, error) {
|
||||
if getOrdersRequest.OrderSide == exchange.AnyOrderSide || getOrdersRequest.OrderSide == "" {
|
||||
return nil, errors.New("Specific order side is required")
|
||||
return nil, errors.New("specific order side is required")
|
||||
}
|
||||
|
||||
var allOrders []Order
|
||||
|
||||
Reference in New Issue
Block a user