mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 23:16:51 +00:00
golangci-lint/CI: Bump versions and introduce new linters (#798)
* golangci-lint/CI: Bump versions
Fix remaining linter issues
* Specifically set AppVeyor version
* Fix the infamous typos 👀
* Add go env cmd to AppVeyor
* Add go version cmd to AppVeyor
* Specify AppVeyor image, adjust linters
* Update go get to go install due to deprecation
* Bump golangci-lint timeout time for AppVeyor
* Change NW contract to NQ
* Address nitters
* GetRandomPair -> Pair{}
* Address nits
* Address time nitterinos plus additional tweaks
* More time inception upgrades!
* Bending time and space
This commit is contained in:
@@ -227,39 +227,39 @@ func (z *ZB) GetSpotKline(ctx context.Context, arg KlinesRequestParams) (KLineRe
|
||||
urlPath := fmt.Sprintf("/%s/%s/%s?%s", zbData, zbAPIVersion, zbKline, vals.Encode())
|
||||
|
||||
var res KLineResponse
|
||||
var rawKlines map[string]interface{}
|
||||
err := z.SendHTTPRequest(ctx, exchange.RestSpot, urlPath, &rawKlines, klineFunc)
|
||||
resp := struct {
|
||||
Data [][]float64 `json:"data"`
|
||||
MoneyType string `json:"moneyType"`
|
||||
Symbol string `json:"symbol"`
|
||||
}{}
|
||||
err := z.SendHTTPRequest(ctx, exchange.RestSpot, urlPath, &resp, klineFunc)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
if rawKlines == nil || rawKlines["symbol"] == nil {
|
||||
return res, errors.New("zb GetSpotKline rawKlines is nil")
|
||||
if resp.Data == nil || resp.Symbol == "" || resp.MoneyType == "" {
|
||||
return res, errors.New("GetSpotKline received empty data")
|
||||
}
|
||||
res.MoneyType = resp.MoneyType
|
||||
res.Symbol = resp.Symbol
|
||||
|
||||
res.Symbol = rawKlines["symbol"].(string)
|
||||
res.MoneyType = rawKlines["moneyType"].(string)
|
||||
for x := range resp.Data {
|
||||
if len(resp.Data[x]) < 6 {
|
||||
return res, errors.New("unexpected kline data length")
|
||||
}
|
||||
|
||||
rawKlineDatasString, _ := json.Marshal(rawKlines["data"].([]interface{}))
|
||||
var rawKlineDatas [][]interface{}
|
||||
if err := json.Unmarshal(rawKlineDatasString, &rawKlineDatas); err != nil {
|
||||
return res, errors.New("zb rawKlines unmarshal failed")
|
||||
}
|
||||
for _, k := range rawKlineDatas {
|
||||
ot, err := convert.TimeFromUnixTimestampFloat(k[0])
|
||||
ot, err := convert.TimeFromUnixTimestampFloat(resp.Data[x][0])
|
||||
if err != nil {
|
||||
return res, errors.New("zb cannot parse Kline.OpenTime")
|
||||
return res, err
|
||||
}
|
||||
res.Data = append(res.Data, &KLineResponseData{
|
||||
ID: k[0].(float64),
|
||||
KlineTime: ot,
|
||||
Open: k[1].(float64),
|
||||
High: k[2].(float64),
|
||||
Low: k[3].(float64),
|
||||
Close: k[4].(float64),
|
||||
Volume: k[5].(float64),
|
||||
Open: resp.Data[x][1],
|
||||
High: resp.Data[x][2],
|
||||
Low: resp.Data[x][3],
|
||||
Close: resp.Data[x][4],
|
||||
Volume: resp.Data[x][5],
|
||||
})
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ func (z *ZB) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.URL,
|
||||
var intermediary json.RawMessage
|
||||
newRequest := func() (*request.Item, error) {
|
||||
now := time.Now()
|
||||
params.Set("reqTime", fmt.Sprintf("%d", convert.UnixMillis(now)))
|
||||
params.Set("reqTime", strconv.FormatInt(now.UnixMilli(), 10))
|
||||
params.Set("sign", fmt.Sprintf("%x", hmac))
|
||||
|
||||
urlPath := fmt.Sprintf("%s/%s?%s",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//+build !mock_test_off
|
||||
//go:build !mock_test_off
|
||||
// +build !mock_test_off
|
||||
|
||||
// This will build if build tag mock_test_off is not parsed and will try to mock
|
||||
// all tests in _test.go
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
||||
"github.com/thrasher-corp/gocryptotrader/core"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
@@ -35,6 +34,7 @@ var z ZB
|
||||
var wsSetupRan bool
|
||||
|
||||
func setupWsAuth(t *testing.T) {
|
||||
t.Helper()
|
||||
if wsSetupRan {
|
||||
return
|
||||
}
|
||||
@@ -500,8 +500,7 @@ func TestWsTransferFunds(t *testing.T) {
|
||||
// TestGetSubUserList ws test
|
||||
func TestGetSubUserList(t *testing.T) {
|
||||
setupWsAuth(t)
|
||||
_, err := z.wsGetSubUserList()
|
||||
if err != nil {
|
||||
if _, err := z.wsGetSubUserList(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -833,7 +832,7 @@ func TestGetSpotKline(t *testing.T) {
|
||||
}
|
||||
if mockTests {
|
||||
startTime := time.Date(2020, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
arg.Since = convert.UnixMillis(startTime)
|
||||
arg.Since = startTime.UnixMilli()
|
||||
arg.Type = "1day"
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,6 @@ type KlinesRequestParams struct {
|
||||
|
||||
// KLineResponseData Kline Data
|
||||
type KLineResponseData struct {
|
||||
ID float64 `json:"id"` // K线ID
|
||||
KlineTime time.Time `json:"klineTime"`
|
||||
Open float64 `json:"open"` // 开盘价
|
||||
Close float64 `json:"close"` // 收盘价, 当K线为最晚的一根时, 时最新成交价
|
||||
|
||||
@@ -109,7 +109,7 @@ func (z *ZB) wsHandleData(respRaw []byte) error {
|
||||
Last: wsTicker.Data.Last,
|
||||
Bid: wsTicker.Data.Buy,
|
||||
Ask: wsTicker.Data.Sell,
|
||||
LastUpdated: time.Unix(0, wsTicker.Date*int64(time.Millisecond)),
|
||||
LastUpdated: time.UnixMilli(wsTicker.Date),
|
||||
AssetType: asset.Spot,
|
||||
Pair: p,
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/convert"
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
@@ -283,8 +282,7 @@ func (z *ZB) UpdateTickers(ctx context.Context, a asset.Item) error {
|
||||
|
||||
// UpdateTicker updates and returns the ticker for a currency pair
|
||||
func (z *ZB) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error) {
|
||||
err := z.UpdateTickers(ctx, a)
|
||||
if err != nil {
|
||||
if err := z.UpdateTickers(ctx, a); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ticker.GetTicker(z.Name, p, a)
|
||||
@@ -389,8 +387,7 @@ func (z *ZB) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (accou
|
||||
Currencies: balances,
|
||||
})
|
||||
|
||||
err := account.Process(&info)
|
||||
if err != nil {
|
||||
if err := account.Process(&info); err != nil {
|
||||
return account.Holdings{}, err
|
||||
}
|
||||
|
||||
@@ -864,7 +861,7 @@ func (z *ZB) GetHistoricCandles(ctx context.Context, p currency.Pair, a asset.It
|
||||
klineParams := KlinesRequestParams{
|
||||
Type: z.FormatExchangeKlineInterval(interval),
|
||||
Symbol: p.String(),
|
||||
Since: convert.UnixMillis(start),
|
||||
Since: start.UnixMilli(),
|
||||
Size: int64(z.Features.Enabled.Kline.ResultLimit),
|
||||
}
|
||||
var candles KLineResponse
|
||||
@@ -909,7 +906,7 @@ allKlines:
|
||||
klineParams := KlinesRequestParams{
|
||||
Type: z.FormatExchangeKlineInterval(interval),
|
||||
Symbol: p.String(),
|
||||
Since: convert.UnixMillis(startTime),
|
||||
Since: startTime.UnixMilli(),
|
||||
Size: int64(z.Features.Enabled.Kline.ResultLimit),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user