mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 23:16:53 +00:00
CI: Fix golangci-lint linter issues, add prealloc linter and bump version depends for Go 1.18 (#915)
* Bump CI versions * Specifically set go version as 1.17.x bumps it to 1.18 * Another * Adjust AppVeyor * Part 1 of linter issues * Part 2 * Fix various linters and improvements * Part 3 * Finishing touches * Tests and EqualFold * Fix nitterinos plus bonus requester jobs bump for exchanges with large number of tests * Fix nitterinos and bump golangci-lint timeout for AppVeyor * Address nits, ensure all books are returned on err due to syncer regression * Fix the wiggins * Fix duplication * Fix nitterinos
This commit is contained in:
@@ -58,8 +58,8 @@ const (
|
||||
|
||||
// Authenticated endpoints
|
||||
bitmexEndpointAPIkeys = "/apiKey"
|
||||
bitmexEndpointDisableAPIkey = "/apiKey/disable"
|
||||
bitmexEndpointEnableAPIkey = "/apiKey/enable"
|
||||
bitmexEndpointDisableAPIkey = "/apiKey/disable" // nolint:gosec // false positive
|
||||
bitmexEndpointEnableAPIkey = "/apiKey/enable" // nolint:gosec // false positive
|
||||
bitmexEndpointTrollboxSend = "/chat"
|
||||
bitmexEndpointExecution = "/execution"
|
||||
bitmexEndpointExecutionTradeHistory = "/execution/tradeHistory"
|
||||
|
||||
@@ -781,7 +781,7 @@ func TestWithdraw(t *testing.T) {
|
||||
Amount: -1,
|
||||
Currency: currency.BTC,
|
||||
Description: "WITHDRAW IT ALL",
|
||||
OneTimePassword: 000000,
|
||||
OneTimePassword: 000000, // nolint // gocritic false positive
|
||||
}
|
||||
|
||||
if areTestAPIKeysSet() && !canManipulateRealOrders {
|
||||
@@ -860,7 +860,11 @@ func TestWsAuth(t *testing.T) {
|
||||
timer := time.NewTimer(sharedtestvalues.WebsocketResponseDefaultTimeout)
|
||||
select {
|
||||
case resp := <-b.Websocket.DataHandler:
|
||||
if !resp.(WebsocketSubscribeResp).Success {
|
||||
sub, ok := resp.(WebsocketSubscribeResp)
|
||||
if !ok {
|
||||
t.Fatal("unable to type assert WebsocketSubscribeResp")
|
||||
}
|
||||
if !sub.Success {
|
||||
t.Error("Expected successful subscription")
|
||||
}
|
||||
case <-timer.C:
|
||||
|
||||
@@ -97,18 +97,20 @@ func (b *Bitmex) WsConnect() error {
|
||||
b.Websocket.Wg.Add(1)
|
||||
go b.wsReadData()
|
||||
|
||||
err = b.websocketSendAuth(context.TODO())
|
||||
if err != nil {
|
||||
log.Errorf(log.ExchangeSys,
|
||||
"%v - authentication failed: %v\n",
|
||||
b.Name,
|
||||
err)
|
||||
} else {
|
||||
authsubs, err := b.GenerateAuthenticatedSubscriptions()
|
||||
if b.Websocket.CanUseAuthenticatedEndpoints() {
|
||||
err = b.websocketSendAuth(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
log.Errorf(log.ExchangeSys,
|
||||
"%v - authentication failed: %v\n",
|
||||
b.Name,
|
||||
err)
|
||||
} else {
|
||||
authsubs, err := b.GenerateAuthenticatedSubscriptions()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return b.Websocket.SubscribeToChannels(authsubs)
|
||||
}
|
||||
return b.Websocket.SubscribeToChannels(authsubs)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -491,7 +493,11 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, p currency.
|
||||
|
||||
switch action {
|
||||
case bitmexActionInitialData:
|
||||
var book orderbook.Base
|
||||
book := orderbook.Base{
|
||||
Asks: make(orderbook.Items, 0, len(data)),
|
||||
Bids: make(orderbook.Items, 0, len(data)),
|
||||
}
|
||||
|
||||
for i := range data {
|
||||
item := orderbook.Item{
|
||||
Price: data[i].Price,
|
||||
@@ -520,7 +526,8 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, p currency.
|
||||
err)
|
||||
}
|
||||
default:
|
||||
var asks, bids []orderbook.Item
|
||||
asks := make([]orderbook.Item, 0, len(data))
|
||||
bids := make([]orderbook.Item, 0, len(data))
|
||||
for i := range data {
|
||||
nItem := orderbook.Item{
|
||||
Price: data[i].Price,
|
||||
|
||||
@@ -233,9 +233,9 @@ func (b *Bitmex) FetchTradablePairs(ctx context.Context, asset asset.Item) ([]st
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var products []string
|
||||
products := make([]string, len(marketInfo))
|
||||
for x := range marketInfo {
|
||||
products = append(products, marketInfo[x].Symbol.String())
|
||||
products[x] = marketInfo[x].Symbol.String()
|
||||
}
|
||||
|
||||
return products, nil
|
||||
@@ -394,16 +394,20 @@ func (b *Bitmex) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType
|
||||
return book, err
|
||||
}
|
||||
|
||||
book.Asks = make(orderbook.Items, 0, len(orderbookNew))
|
||||
book.Bids = make(orderbook.Items, 0, len(orderbookNew))
|
||||
for i := range orderbookNew {
|
||||
switch {
|
||||
case strings.EqualFold(orderbookNew[i].Side, order.Sell.String()):
|
||||
book.Asks = append(book.Asks, orderbook.Item{
|
||||
Amount: float64(orderbookNew[i].Size),
|
||||
Price: orderbookNew[i].Price})
|
||||
Price: orderbookNew[i].Price,
|
||||
})
|
||||
case strings.EqualFold(orderbookNew[i].Side, order.Buy.String()):
|
||||
book.Bids = append(book.Bids, orderbook.Item{
|
||||
Amount: float64(orderbookNew[i].Size),
|
||||
Price: orderbookNew[i].Price})
|
||||
Price: orderbookNew[i].Price,
|
||||
})
|
||||
default:
|
||||
return book,
|
||||
fmt.Errorf("could not process orderbook, order side [%s] could not be matched",
|
||||
@@ -748,10 +752,9 @@ func (b *Bitmex) GetActiveOrders(ctx context.Context, req *order.GetOrdersReques
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var orders []order.Detail
|
||||
params := OrdersRequest{}
|
||||
params.Filter = "{\"open\":true}"
|
||||
|
||||
params := OrdersRequest{
|
||||
Filter: "{\"open\":true}",
|
||||
}
|
||||
resp, err := b.GetOrders(ctx, ¶ms)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -762,6 +765,7 @@ func (b *Bitmex) GetActiveOrders(ctx context.Context, req *order.GetOrdersReques
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orders := make([]order.Detail, len(resp))
|
||||
for i := range resp {
|
||||
orderSide := orderSideMap[resp[i].Side]
|
||||
orderStatus, err := order.StringToOrderStatus(resp[i].OrdStatus)
|
||||
@@ -789,7 +793,7 @@ func (b *Bitmex) GetActiveOrders(ctx context.Context, req *order.GetOrdersReques
|
||||
format.Delimiter),
|
||||
}
|
||||
|
||||
orders = append(orders, orderDetail)
|
||||
orders[i] = orderDetail
|
||||
}
|
||||
|
||||
order.FilterOrdersBySide(&orders, req.Side)
|
||||
@@ -807,7 +811,6 @@ func (b *Bitmex) GetOrderHistory(ctx context.Context, req *order.GetOrdersReques
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var orders []order.Detail
|
||||
params := OrdersRequest{}
|
||||
resp, err := b.GetOrders(ctx, ¶ms)
|
||||
if err != nil {
|
||||
@@ -819,6 +822,7 @@ func (b *Bitmex) GetOrderHistory(ctx context.Context, req *order.GetOrdersReques
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orders := make([]order.Detail, len(resp))
|
||||
for i := range resp {
|
||||
orderSide := orderSideMap[resp[i].Side]
|
||||
orderStatus, err := order.StringToOrderStatus(resp[i].OrdStatus)
|
||||
@@ -848,7 +852,7 @@ func (b *Bitmex) GetOrderHistory(ctx context.Context, req *order.GetOrdersReques
|
||||
}
|
||||
orderDetail.InferCostsAndTimes()
|
||||
|
||||
orders = append(orders, orderDetail)
|
||||
orders[i] = orderDetail
|
||||
}
|
||||
|
||||
order.FilterOrdersBySide(&orders, req.Side)
|
||||
|
||||
Reference in New Issue
Block a user