mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 23:16:53 +00:00
modernise: Run new gopls modernise tool against the codebase and fix minor issues (#1826)
* modernise: Run new gopls modernise tool against codebase
* Address shazbert's nits
* apichecker, gctcli: Simplify HTML scraping functions and improve depth limit handling
* refactor: Create minSyncInterval const and update order book limit handling for binance and binanceUS
* refactor: Various slice usage improvements and rename TODO
* tranches: Revert deleteByID changes due to performance decrease
Shazbert was a F1 driver in a past lifetime 🏎️
* tranches: Simply retrieve copy
Thanks to shazbert
* documentation: Sort contributors list by contributions
* tranches: Remove deadcode in deleteByID
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"maps"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
@@ -135,7 +136,7 @@ func (b *Bitfinex) GetPlatformStatus(ctx context.Context) (int, error) {
|
||||
return -1, fmt.Errorf("unexpected platform status value %d", response[0])
|
||||
}
|
||||
|
||||
func baseMarginInfo(data []interface{}) (MarginInfoV2, error) {
|
||||
func baseMarginInfo(data []any) (MarginInfoV2, error) {
|
||||
var resp MarginInfoV2
|
||||
marginInfo, ok := data[1].([]any)
|
||||
if !ok {
|
||||
@@ -159,7 +160,7 @@ func baseMarginInfo(data []interface{}) (MarginInfoV2, error) {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func symbolMarginInfo(data []interface{}) ([]MarginInfoV2, error) {
|
||||
func symbolMarginInfo(data []any) ([]MarginInfoV2, error) {
|
||||
resp := make([]MarginInfoV2, len(data))
|
||||
for x := range data {
|
||||
var tempResp MarginInfoV2
|
||||
@@ -195,7 +196,7 @@ func symbolMarginInfo(data []interface{}) ([]MarginInfoV2, error) {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func defaultMarginV2Info(data []interface{}) (MarginInfoV2, error) {
|
||||
func defaultMarginV2Info(data []any) (MarginInfoV2, error) {
|
||||
var resp MarginInfoV2
|
||||
var ok bool
|
||||
if resp.Symbol, ok = data[1].(string); !ok {
|
||||
@@ -226,7 +227,7 @@ func defaultMarginV2Info(data []interface{}) (MarginInfoV2, error) {
|
||||
// GetV2MarginInfo gets v2 margin info for a symbol provided
|
||||
// symbol: base, sym_all, any other trading symbol example tBTCUSD
|
||||
func (b *Bitfinex) GetV2MarginInfo(ctx context.Context, symbol string) ([]MarginInfoV2, error) {
|
||||
var data []interface{}
|
||||
var data []any
|
||||
err := b.SendAuthenticatedHTTPRequestV2(ctx,
|
||||
exchange.RestSpot, http.MethodPost,
|
||||
bitfinexV2MarginInfo+symbol,
|
||||
@@ -258,9 +259,9 @@ func (b *Bitfinex) GetV2MarginInfo(ctx context.Context, symbol string) ([]Margin
|
||||
|
||||
// GetV2MarginFunding gets borrowing rates for margin trading
|
||||
func (b *Bitfinex) GetV2MarginFunding(ctx context.Context, symbol, amount string, period int32) (MarginV2FundingData, error) {
|
||||
var resp []interface{}
|
||||
var resp []any
|
||||
var response MarginV2FundingData
|
||||
params := make(map[string]interface{})
|
||||
params := make(map[string]any)
|
||||
params["symbol"] = symbol
|
||||
params["period"] = period
|
||||
params["amount"] = amount
|
||||
@@ -291,7 +292,7 @@ func (b *Bitfinex) GetV2MarginFunding(ctx context.Context, symbol, amount string
|
||||
|
||||
// GetV2FundingInfo gets funding info for margin pairs
|
||||
func (b *Bitfinex) GetV2FundingInfo(ctx context.Context, key string) (MarginFundingDataV2, error) {
|
||||
var resp []interface{}
|
||||
var resp []any
|
||||
var response MarginFundingDataV2
|
||||
err := b.SendAuthenticatedHTTPRequestV2(ctx, exchange.RestSpot, http.MethodPost,
|
||||
fmt.Sprintf(bitfinexV2FundingInfo, key),
|
||||
@@ -339,7 +340,7 @@ func (b *Bitfinex) GetV2FundingInfo(ctx context.Context, key string) (MarginFund
|
||||
// GetAccountInfoV2 gets V2 account data
|
||||
func (b *Bitfinex) GetAccountInfoV2(ctx context.Context) (AccountV2Data, error) {
|
||||
var resp AccountV2Data
|
||||
var data []interface{}
|
||||
var data []any
|
||||
err := b.SendAuthenticatedHTTPRequestV2(ctx, exchange.RestSpot, http.MethodPost,
|
||||
bitfinexV2AccountInfo,
|
||||
nil,
|
||||
@@ -383,7 +384,7 @@ func (b *Bitfinex) GetAccountInfoV2(ctx context.Context) (AccountV2Data, error)
|
||||
|
||||
// GetV2Balances gets v2 balances
|
||||
func (b *Bitfinex) GetV2Balances(ctx context.Context) ([]WalletDataV2, error) {
|
||||
var data [][4]interface{}
|
||||
var data [][4]any
|
||||
err := b.SendAuthenticatedHTTPRequestV2(ctx,
|
||||
exchange.RestSpot, http.MethodPost,
|
||||
bitfinexV2Balances,
|
||||
@@ -567,7 +568,7 @@ func (b *Bitfinex) GetDerivativeStatusInfo(ctx context.Context, keys, startTime,
|
||||
params.Set("limit", strconv.FormatInt(limit, 10))
|
||||
}
|
||||
|
||||
var result [][]interface{}
|
||||
var result [][]any
|
||||
path := bitfinexAPIVersion2 + bitfinexDerivativeData +
|
||||
params.Encode()
|
||||
err := b.SendHTTPRequest(ctx, exchange.RestSpot, path, &result, status)
|
||||
@@ -768,7 +769,7 @@ func (b *Bitfinex) GetTrades(ctx context.Context, currencyPair string, limit, ti
|
||||
|
||||
path := bitfinexAPIVersion2 + bitfinexTrades + currencyPair + "/hist" + "?" + v.Encode()
|
||||
|
||||
var resp [][]interface{}
|
||||
var resp [][]any
|
||||
err := b.SendHTTPRequest(ctx, exchange.RestSpot, path, &resp, tradeRateLimit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -846,7 +847,7 @@ func (b *Bitfinex) GetOrderbook(ctx context.Context, symbol, precision string, l
|
||||
u.Set("len", strconv.FormatInt(limit, 10))
|
||||
}
|
||||
path := bitfinexAPIVersion2 + bitfinexOrderbook + symbol + "/" + precision + "?" + u.Encode()
|
||||
var response [][]interface{}
|
||||
var response [][]any
|
||||
err := b.SendHTTPRequest(ctx, exchange.RestSpot, path, &response, orderbookFunction)
|
||||
if err != nil {
|
||||
return Orderbook{}, err
|
||||
@@ -1027,7 +1028,7 @@ func (b *Bitfinex) GetCandles(ctx context.Context, symbol, timeFrame string, sta
|
||||
path += "?" + v.Encode()
|
||||
}
|
||||
|
||||
var response [][]interface{}
|
||||
var response [][]any
|
||||
err := b.SendHTTPRequest(ctx, exchange.RestSpot, path, &response, candle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1064,7 +1065,7 @@ func (b *Bitfinex) GetCandles(ctx context.Context, symbol, timeFrame string, sta
|
||||
|
||||
path += "/last"
|
||||
|
||||
var response []interface{}
|
||||
var response []any
|
||||
err := b.SendHTTPRequest(ctx, exchange.RestSpot, path, &response, candle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1159,12 +1160,12 @@ func (b *Bitfinex) GetLeaderboard(ctx context.Context, key, timeframe, symbol st
|
||||
vals.Set("end", end)
|
||||
}
|
||||
path = common.EncodeURLValues(path, vals)
|
||||
var resp []interface{}
|
||||
var resp []any
|
||||
if err := b.SendHTTPRequest(ctx, exchange.RestSpot, path, &resp, leaderBoardReqRate); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
parseTwitterHandle := func(i interface{}) string {
|
||||
parseTwitterHandle := func(i any) string {
|
||||
r, ok := i.(string)
|
||||
if !ok {
|
||||
return ""
|
||||
@@ -1174,7 +1175,7 @@ func (b *Bitfinex) GetLeaderboard(ctx context.Context, key, timeframe, symbol st
|
||||
|
||||
result := make([]LeaderboardEntry, len(resp))
|
||||
for x := range resp {
|
||||
r, ok := resp[x].([]interface{})
|
||||
r, ok := resp[x].([]any)
|
||||
if !ok {
|
||||
return nil, errors.New("unable to type assert leaderboard")
|
||||
}
|
||||
@@ -1268,11 +1269,11 @@ func (b *Bitfinex) NewDeposit(ctx context.Context, method, walletName string, re
|
||||
AcceptedWalletNames)
|
||||
}
|
||||
|
||||
req := make(map[string]interface{}, 3)
|
||||
req := make(map[string]any, 3)
|
||||
req["wallet"] = walletName
|
||||
req["method"] = strings.ToLower(method)
|
||||
req["op_renew"] = renew
|
||||
var result []interface{}
|
||||
var result []any
|
||||
|
||||
err := b.SendAuthenticatedHTTPRequestV2(ctx,
|
||||
exchange.RestSpot,
|
||||
@@ -1289,7 +1290,7 @@ func (b *Bitfinex) NewDeposit(ctx context.Context, method, walletName string, re
|
||||
return nil, errors.New("expected result to have a len of 8")
|
||||
}
|
||||
|
||||
depositInfo, ok := result[4].([]interface{})
|
||||
depositInfo, ok := result[4].([]any)
|
||||
if !ok || len(depositInfo) != 6 {
|
||||
return nil, errors.New("unable to get deposit data")
|
||||
}
|
||||
@@ -1364,7 +1365,7 @@ func (b *Bitfinex) GetAccountBalance(ctx context.Context) ([]Balance, error) {
|
||||
// WalletTo - example "deposit"
|
||||
func (b *Bitfinex) WalletTransfer(ctx context.Context, amount float64, currency, walletFrom, walletTo string) (WalletTransfer, error) {
|
||||
var response []WalletTransfer
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
|
||||
req["currency"] = currency
|
||||
req["walletfrom"] = walletFrom
|
||||
@@ -1389,7 +1390,7 @@ func (b *Bitfinex) WalletTransfer(ctx context.Context, amount float64, currency,
|
||||
// For FIAT, use WithdrawFIAT
|
||||
func (b *Bitfinex) WithdrawCryptocurrency(ctx context.Context, wallet, address, paymentID, curr string, amount float64) (Withdrawal, error) {
|
||||
var response []Withdrawal
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["withdraw_type"] = strings.ToLower(curr)
|
||||
req["walletselected"] = wallet
|
||||
req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
|
||||
@@ -1417,7 +1418,7 @@ func (b *Bitfinex) WithdrawCryptocurrency(ctx context.Context, wallet, address,
|
||||
// WithdrawFIAT Sends an authenticated request to withdraw FIAT currency
|
||||
func (b *Bitfinex) WithdrawFIAT(ctx context.Context, withdrawalType, walletType string, withdrawRequest *withdraw.Request) (Withdrawal, error) {
|
||||
var response []Withdrawal
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
|
||||
req["withdraw_type"] = withdrawalType
|
||||
req["walletselected"] = walletType
|
||||
@@ -1467,7 +1468,7 @@ func (b *Bitfinex) NewOrder(ctx context.Context, currencyPair, orderType string,
|
||||
}
|
||||
|
||||
response := Order{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["symbol"] = currencyPair
|
||||
req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
|
||||
req["price"] = strconv.FormatFloat(price, 'f', -1, 64)
|
||||
@@ -1488,7 +1489,7 @@ func (b *Bitfinex) NewOrder(ctx context.Context, currencyPair, orderType string,
|
||||
// OrderUpdate will send an update signal for an existing order
|
||||
// and attempt to modify it
|
||||
func (b *Bitfinex) OrderUpdate(ctx context.Context, orderID, groupID, clientOrderID string, amount, price, leverage float64) (*Order, error) {
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
if orderID != "" {
|
||||
req["id"] = orderID
|
||||
}
|
||||
@@ -1514,7 +1515,7 @@ func (b *Bitfinex) OrderUpdate(ctx context.Context, orderID, groupID, clientOrde
|
||||
// NewOrderMulti allows several new orders at once
|
||||
func (b *Bitfinex) NewOrderMulti(ctx context.Context, orders []PlaceOrder) (OrderMultiResponse, error) {
|
||||
response := OrderMultiResponse{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["orders"] = orders
|
||||
|
||||
return response, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
|
||||
@@ -1527,7 +1528,7 @@ func (b *Bitfinex) NewOrderMulti(ctx context.Context, orders []PlaceOrder) (Orde
|
||||
// CancelExistingOrder cancels a single order by OrderID
|
||||
func (b *Bitfinex) CancelExistingOrder(ctx context.Context, orderID int64) (Order, error) {
|
||||
response := Order{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["order_id"] = orderID
|
||||
|
||||
return response, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
|
||||
@@ -1540,7 +1541,7 @@ func (b *Bitfinex) CancelExistingOrder(ctx context.Context, orderID int64) (Orde
|
||||
// CancelMultipleOrders cancels multiple orders
|
||||
func (b *Bitfinex) CancelMultipleOrders(ctx context.Context, orderIDs []int64) (string, error) {
|
||||
response := GenericResponse{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["order_ids"] = orderIDs
|
||||
return response.Result, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
|
||||
bitfinexOrderCancelMulti,
|
||||
@@ -1551,8 +1552,8 @@ func (b *Bitfinex) CancelMultipleOrders(ctx context.Context, orderIDs []int64) (
|
||||
|
||||
// CancelMultipleOrdersV2 cancels multiple orders
|
||||
func (b *Bitfinex) CancelMultipleOrdersV2(ctx context.Context, orderID, clientOrderID, groupOrderID int64, clientOrderIDDate time.Time, allOrders bool) ([]CancelMultiOrderResponse, error) {
|
||||
var response []interface{}
|
||||
req := make(map[string]interface{})
|
||||
var response []any
|
||||
req := make(map[string]any)
|
||||
if orderID > 0 {
|
||||
req["id"] = orderID
|
||||
}
|
||||
@@ -1579,12 +1580,12 @@ func (b *Bitfinex) CancelMultipleOrdersV2(ctx context.Context, orderID, clientOr
|
||||
}
|
||||
var cancelledOrders []CancelMultiOrderResponse
|
||||
for x := range response {
|
||||
cancelledOrdersSlice, ok := response[x].([]interface{})
|
||||
cancelledOrdersSlice, ok := response[x].([]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
for y := range cancelledOrdersSlice {
|
||||
cancelledOrderFields, ok := cancelledOrdersSlice[y].([]interface{})
|
||||
cancelledOrderFields, ok := cancelledOrdersSlice[y].([]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
@@ -1709,7 +1710,7 @@ func (b *Bitfinex) CancelAllExistingOrders(ctx context.Context) (string, error)
|
||||
// ReplaceOrder replaces an older order with a new order
|
||||
func (b *Bitfinex) ReplaceOrder(ctx context.Context, orderID int64, symbol string, amount, price float64, buy bool, orderType string, hidden bool) (Order, error) {
|
||||
response := Order{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["order_id"] = orderID
|
||||
req["symbol"] = symbol
|
||||
req["amount"] = strconv.FormatFloat(amount, 'f', -1, 64)
|
||||
@@ -1734,7 +1735,7 @@ func (b *Bitfinex) ReplaceOrder(ctx context.Context, orderID int64, symbol strin
|
||||
// GetOrderStatus returns order status information
|
||||
func (b *Bitfinex) GetOrderStatus(ctx context.Context, orderID int64) (Order, error) {
|
||||
orderStatus := Order{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["order_id"] = orderID
|
||||
|
||||
return orderStatus, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
|
||||
@@ -1747,7 +1748,7 @@ func (b *Bitfinex) GetOrderStatus(ctx context.Context, orderID int64) (Order, er
|
||||
// GetInactiveOrders returns order status information
|
||||
func (b *Bitfinex) GetInactiveOrders(ctx context.Context, symbol string, ids ...int64) ([]Order, error) {
|
||||
var response []Order
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["limit"] = 2500
|
||||
if len(ids) > 0 {
|
||||
req["ids"] = ids
|
||||
@@ -1765,7 +1766,7 @@ func (b *Bitfinex) GetInactiveOrders(ctx context.Context, symbol string, ids ...
|
||||
// GetOpenOrders returns all active orders and statuses
|
||||
func (b *Bitfinex) GetOpenOrders(ctx context.Context, ids ...int64) ([]Order, error) {
|
||||
var response []Order
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
if len(ids) > 0 {
|
||||
req["ids"] = ids
|
||||
}
|
||||
@@ -1790,7 +1791,7 @@ func (b *Bitfinex) GetActivePositions(ctx context.Context) ([]Position, error) {
|
||||
// ClaimPosition allows positions to be claimed
|
||||
func (b *Bitfinex) ClaimPosition(ctx context.Context, positionID int) (Position, error) {
|
||||
response := Position{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["position_id"] = positionID
|
||||
|
||||
return response, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
|
||||
@@ -1803,7 +1804,7 @@ func (b *Bitfinex) ClaimPosition(ctx context.Context, positionID int) (Position,
|
||||
// GetBalanceHistory returns balance history for the account
|
||||
func (b *Bitfinex) GetBalanceHistory(ctx context.Context, symbol string, timeSince, timeUntil time.Time, limit int, wallet string) ([]BalanceHistory, error) {
|
||||
var response []BalanceHistory
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["currency"] = symbol
|
||||
|
||||
if !timeSince.IsZero() {
|
||||
@@ -1828,8 +1829,8 @@ func (b *Bitfinex) GetBalanceHistory(ctx context.Context, symbol string, timeSin
|
||||
|
||||
// GetMovementHistory returns an array of past deposits and withdrawals
|
||||
func (b *Bitfinex) GetMovementHistory(ctx context.Context, symbol, method string, timeSince, timeUntil time.Time, limit int) ([]MovementHistory, error) {
|
||||
var response [][]interface{}
|
||||
req := make(map[string]interface{})
|
||||
var response [][]any
|
||||
req := make(map[string]any)
|
||||
req["currency"] = symbol
|
||||
|
||||
if method != "" {
|
||||
@@ -1924,7 +1925,7 @@ func (b *Bitfinex) GetMovementHistory(ctx context.Context, symbol, method string
|
||||
// GetTradeHistory returns past executed trades
|
||||
func (b *Bitfinex) GetTradeHistory(ctx context.Context, currencyPair string, timestamp, until time.Time, limit, reverse int) ([]TradeHistory, error) {
|
||||
var response []TradeHistory
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["currency"] = currencyPair
|
||||
req["timestamp"] = timestamp
|
||||
|
||||
@@ -1948,7 +1949,7 @@ func (b *Bitfinex) GetTradeHistory(ctx context.Context, currencyPair string, tim
|
||||
// NewOffer submits a new offer
|
||||
func (b *Bitfinex) NewOffer(ctx context.Context, symbol string, amount, rate float64, period int64, direction string) (Offer, error) {
|
||||
response := Offer{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["currency"] = symbol
|
||||
req["amount"] = amount
|
||||
req["rate"] = rate
|
||||
@@ -1965,7 +1966,7 @@ func (b *Bitfinex) NewOffer(ctx context.Context, symbol string, amount, rate flo
|
||||
// CancelOffer cancels offer by offerID
|
||||
func (b *Bitfinex) CancelOffer(ctx context.Context, offerID int64) (Offer, error) {
|
||||
response := Offer{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["offer_id"] = offerID
|
||||
|
||||
return response, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
|
||||
@@ -1979,7 +1980,7 @@ func (b *Bitfinex) CancelOffer(ctx context.Context, offerID int64) (Offer, error
|
||||
// is still active
|
||||
func (b *Bitfinex) GetOfferStatus(ctx context.Context, offerID int64) (Offer, error) {
|
||||
response := Offer{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["offer_id"] = offerID
|
||||
|
||||
return response, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
|
||||
@@ -2049,7 +2050,7 @@ func (b *Bitfinex) GetMarginTotalTakenFunds(ctx context.Context) ([]MarginTotalT
|
||||
// CloseMarginFunding closes an unused or used taken fund
|
||||
func (b *Bitfinex) CloseMarginFunding(ctx context.Context, swapID int64) (Offer, error) {
|
||||
response := Offer{}
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["swap_id"] = swapID
|
||||
|
||||
return response, b.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,
|
||||
@@ -2060,7 +2061,7 @@ func (b *Bitfinex) CloseMarginFunding(ctx context.Context, swapID int64) (Offer,
|
||||
}
|
||||
|
||||
// SendHTTPRequest sends an unauthenticated request
|
||||
func (b *Bitfinex) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result interface{}, e request.EndpointLimit) error {
|
||||
func (b *Bitfinex) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result any, e request.EndpointLimit) error {
|
||||
endpoint, err := b.API.Endpoints.GetURL(ep)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -2081,7 +2082,7 @@ func (b *Bitfinex) SendHTTPRequest(ctx context.Context, ep exchange.URL, path st
|
||||
|
||||
// SendAuthenticatedHTTPRequest sends an authenticated http request and json
|
||||
// unmarshals result to a supplied variable
|
||||
func (b *Bitfinex) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.URL, method, path string, params map[string]interface{}, result interface{}, endpoint request.EndpointLimit) error {
|
||||
func (b *Bitfinex) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.URL, method, path string, params map[string]any, result any, endpoint request.EndpointLimit) error {
|
||||
creds, err := b.GetCredentials(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -2094,13 +2095,11 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange
|
||||
|
||||
fullPath := ePoint + bitfinexAPIVersion + path
|
||||
return b.SendPayload(ctx, endpoint, func() (*request.Item, error) {
|
||||
req := make(map[string]interface{})
|
||||
req := make(map[string]any)
|
||||
req["request"] = bitfinexAPIVersion + path
|
||||
req["nonce"] = b.Requester.GetNonce(nonce.UnixNano).String()
|
||||
|
||||
for key, value := range params {
|
||||
req[key] = value
|
||||
}
|
||||
maps.Copy(req, params)
|
||||
|
||||
PayloadJSON, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
@@ -2134,7 +2133,7 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange
|
||||
|
||||
// SendAuthenticatedHTTPRequestV2 sends an authenticated http request and json
|
||||
// unmarshals result to a supplied variable
|
||||
func (b *Bitfinex) SendAuthenticatedHTTPRequestV2(ctx context.Context, ep exchange.URL, method, path string, params map[string]interface{}, result interface{}, endpoint request.EndpointLimit) error {
|
||||
func (b *Bitfinex) SendAuthenticatedHTTPRequestV2(ctx context.Context, ep exchange.URL, method, path string, params map[string]any, result any, endpoint request.EndpointLimit) error {
|
||||
creds, err := b.GetCredentials(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -2285,7 +2284,7 @@ func (b *Bitfinex) PopulateAcceptableMethods(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var response [][][]interface{}
|
||||
var response [][][]any
|
||||
err := b.SendHTTPRequest(ctx,
|
||||
exchange.RestSpot,
|
||||
bitfinexAPIVersion2+bitfinexDepositMethod,
|
||||
@@ -2311,7 +2310,7 @@ func (b *Bitfinex) PopulateAcceptableMethods(ctx context.Context) error {
|
||||
}
|
||||
|
||||
var availOptions []string
|
||||
options, ok := data[x][1].([]interface{})
|
||||
options, ok := data[x][1].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert options")
|
||||
}
|
||||
|
||||
@@ -1114,11 +1114,11 @@ func TestWSAuth(t *testing.T) {
|
||||
testexch.SetupWs(t, b)
|
||||
require.True(t, b.Websocket.CanUseAuthenticatedEndpoints(), "CanUseAuthenticatedEndpoints should be turned on")
|
||||
|
||||
var resp map[string]interface{}
|
||||
var resp map[string]any
|
||||
catcher := func() (ok bool) {
|
||||
select {
|
||||
case v := <-b.Websocket.ToRoutine:
|
||||
resp, ok = v.(map[string]interface{})
|
||||
resp, ok = v.(map[string]any)
|
||||
default:
|
||||
}
|
||||
return
|
||||
|
||||
@@ -254,7 +254,7 @@ type AccountInfoFees struct {
|
||||
|
||||
// AccountFees stores withdrawal account fee data from Bitfinex
|
||||
type AccountFees struct {
|
||||
Withdraw map[string]interface{} `json:"withdraw"`
|
||||
Withdraw map[string]any `json:"withdraw"`
|
||||
}
|
||||
|
||||
// AccountSummary holds account summary data
|
||||
@@ -639,7 +639,7 @@ type WsFundingOffer struct {
|
||||
Amount float64
|
||||
OriginalAmount float64
|
||||
Type string
|
||||
Flags interface{}
|
||||
Flags any
|
||||
Status string
|
||||
Rate float64
|
||||
Period int64
|
||||
@@ -658,7 +658,7 @@ type WsCredit struct {
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
Amount float64
|
||||
Flags interface{} // Future params object (stay tuned)
|
||||
Flags any // Future params object (stay tuned)
|
||||
Status string
|
||||
Rate float64
|
||||
Period int64
|
||||
|
||||
@@ -205,14 +205,14 @@ func (b *Bitfinex) WsDataHandler() {
|
||||
}
|
||||
|
||||
func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
var result interface{}
|
||||
var result any
|
||||
if err := json.Unmarshal(respRaw, &result); err != nil {
|
||||
return err
|
||||
}
|
||||
switch d := result.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
return b.handleWSEvent(respRaw)
|
||||
case []interface{}:
|
||||
case []any:
|
||||
chanIDFloat, ok := d[0].(float64)
|
||||
if !ok {
|
||||
return common.GetTypeAssertError("float64", d[0], "chanID")
|
||||
@@ -244,17 +244,17 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
case wsNotification:
|
||||
return b.handleWSNotification(d, respRaw)
|
||||
case wsOrderSnapshot:
|
||||
if snapBundle, ok := d[2].([]interface{}); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]interface{}); ok {
|
||||
if snapBundle, ok := d[2].([]any); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]any); ok {
|
||||
for i := range snapBundle {
|
||||
if positionData, ok := snapBundle[i].([]interface{}); ok {
|
||||
if positionData, ok := snapBundle[i].([]any); ok {
|
||||
b.wsHandleOrder(positionData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case wsOrderCancel, wsOrderNew, wsOrderUpdate:
|
||||
if oData, ok := d[2].([]interface{}); ok && len(oData) > 0 {
|
||||
if oData, ok := d[2].([]any); ok && len(oData) > 0 {
|
||||
b.wsHandleOrder(oData)
|
||||
}
|
||||
case wsPositionSnapshot:
|
||||
@@ -264,11 +264,11 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
case wsTradeExecuted, wsTradeUpdated:
|
||||
return b.handleWSMyTradeUpdate(d, eventType)
|
||||
case wsFundingOfferSnapshot:
|
||||
if snapBundle, ok := d[2].([]interface{}); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]interface{}); ok {
|
||||
if snapBundle, ok := d[2].([]any); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]any); ok {
|
||||
snapshot := make([]*WsFundingOffer, len(snapBundle))
|
||||
for i := range snapBundle {
|
||||
data, ok := snapBundle[i].([]interface{})
|
||||
data, ok := snapBundle[i].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert wsFundingOrderSnapshot snapBundle data")
|
||||
}
|
||||
@@ -282,7 +282,7 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
}
|
||||
case wsFundingOfferNew, wsFundingOfferUpdate, wsFundingOfferCancel:
|
||||
if data, ok := d[2].([]interface{}); ok && len(data) > 0 {
|
||||
if data, ok := d[2].([]any); ok && len(data) > 0 {
|
||||
offer, err := wsHandleFundingOffer(data, true /* include rate real */)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -290,11 +290,11 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
b.Websocket.DataHandler <- offer
|
||||
}
|
||||
case wsFundingCreditSnapshot:
|
||||
if snapBundle, ok := d[2].([]interface{}); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]interface{}); ok {
|
||||
if snapBundle, ok := d[2].([]any); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]any); ok {
|
||||
snapshot := make([]*WsCredit, len(snapBundle))
|
||||
for i := range snapBundle {
|
||||
data, ok := snapBundle[i].([]interface{})
|
||||
data, ok := snapBundle[i].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert wsFundingCreditSnapshot snapBundle data")
|
||||
}
|
||||
@@ -308,7 +308,7 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
}
|
||||
case wsFundingCreditNew, wsFundingCreditUpdate, wsFundingCreditCancel:
|
||||
if data, ok := d[2].([]interface{}); ok && len(data) > 0 {
|
||||
if data, ok := d[2].([]any); ok && len(data) > 0 {
|
||||
fundingCredit, err := wsHandleFundingCreditLoanData(data, true /* include position pair */)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -316,11 +316,11 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
b.Websocket.DataHandler <- fundingCredit
|
||||
}
|
||||
case wsFundingLoanSnapshot:
|
||||
if snapBundle, ok := d[2].([]interface{}); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]interface{}); ok {
|
||||
if snapBundle, ok := d[2].([]any); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]any); ok {
|
||||
snapshot := make([]*WsCredit, len(snapBundle))
|
||||
for i := range snapBundle {
|
||||
data, ok := snapBundle[i].([]interface{})
|
||||
data, ok := snapBundle[i].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert wsFundingLoanSnapshot snapBundle data")
|
||||
}
|
||||
@@ -334,7 +334,7 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
}
|
||||
case wsFundingLoanNew, wsFundingLoanUpdate, wsFundingLoanCancel:
|
||||
if data, ok := d[2].([]interface{}); ok && len(data) > 0 {
|
||||
if data, ok := d[2].([]any); ok && len(data) > 0 {
|
||||
fundingData, err := wsHandleFundingCreditLoanData(data, false /* include position pair */)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -342,11 +342,11 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
b.Websocket.DataHandler <- fundingData
|
||||
}
|
||||
case wsWalletSnapshot:
|
||||
if snapBundle, ok := d[2].([]interface{}); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]interface{}); ok {
|
||||
if snapBundle, ok := d[2].([]any); ok && len(snapBundle) > 0 {
|
||||
if _, ok := snapBundle[0].([]any); ok {
|
||||
snapshot := make([]WsWallet, len(snapBundle))
|
||||
for i := range snapBundle {
|
||||
data, ok := snapBundle[i].([]interface{})
|
||||
data, ok := snapBundle[i].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert wsWalletSnapshot snapBundle data")
|
||||
}
|
||||
@@ -374,7 +374,7 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
}
|
||||
case wsWalletUpdate:
|
||||
if data, ok := d[2].([]interface{}); ok && len(data) > 0 {
|
||||
if data, ok := d[2].([]any); ok && len(data) > 0 {
|
||||
var wallet WsWallet
|
||||
if wallet.Type, ok = data[0].(string); !ok {
|
||||
return errors.New("unable to type assert wallet snapshot type")
|
||||
@@ -396,7 +396,7 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
b.Websocket.DataHandler <- wallet
|
||||
}
|
||||
case wsBalanceUpdate:
|
||||
if data, ok := d[2].([]interface{}); ok && len(data) > 0 {
|
||||
if data, ok := d[2].([]any); ok && len(data) > 0 {
|
||||
var balance WsBalanceInfo
|
||||
if balance.TotalAssetsUnderManagement, ok = data[0].(float64); !ok {
|
||||
return errors.New("unable to type assert balance total assets under management")
|
||||
@@ -407,9 +407,9 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
b.Websocket.DataHandler <- balance
|
||||
}
|
||||
case wsMarginInfoUpdate:
|
||||
if data, ok := d[2].([]interface{}); ok && len(data) > 0 {
|
||||
if data, ok := d[2].([]any); ok && len(data) > 0 {
|
||||
if eventType, ok := data[0].(string); ok && eventType == "base" {
|
||||
baseData, ok := data[1].([]interface{})
|
||||
baseData, ok := data[1].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert wsMarginInfoUpdate baseData")
|
||||
}
|
||||
@@ -433,9 +433,9 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
}
|
||||
case wsFundingInfoUpdate:
|
||||
if data, ok := d[2].([]interface{}); ok && len(data) > 0 {
|
||||
if data, ok := d[2].([]any); ok && len(data) > 0 {
|
||||
if fundingType, ok := data[0].(string); ok && fundingType == "sym" {
|
||||
symbolData, ok := data[2].([]interface{})
|
||||
symbolData, ok := data[2].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert wsFundingInfoUpdate symbolData")
|
||||
}
|
||||
@@ -459,7 +459,7 @@ func (b *Bitfinex) wsHandleData(respRaw []byte) error {
|
||||
}
|
||||
}
|
||||
case wsFundingTradeExecuted, wsFundingTradeUpdated:
|
||||
if data, ok := d[2].([]interface{}); ok && len(data) > 0 {
|
||||
if data, ok := d[2].([]any); ok && len(data) > 0 {
|
||||
var wsFundingTrade WsFundingTrade
|
||||
tradeID, ok := data[0].(float64)
|
||||
if !ok {
|
||||
@@ -540,7 +540,7 @@ func (b *Bitfinex) handleWSEvent(respRaw []byte) error {
|
||||
return fmt.Errorf("%w 'status': %w from message: %s", common.ErrParsingWSField, err, respRaw)
|
||||
}
|
||||
if status == "OK" {
|
||||
var glob map[string]interface{}
|
||||
var glob map[string]any
|
||||
if err := json.Unmarshal(respRaw, &glob); err != nil {
|
||||
return fmt.Errorf("unable to Unmarshal auth resp; Error: %w Msg: %v", err, respRaw)
|
||||
}
|
||||
@@ -606,7 +606,7 @@ func (b *Bitfinex) handleWSSubscribed(respRaw []byte) error {
|
||||
return b.Websocket.Match.RequireMatchWithData("subscribe:"+subID, respRaw)
|
||||
}
|
||||
|
||||
func (b *Bitfinex) handleWSChannelUpdate(s *subscription.Subscription, respRaw []byte, eventType string, d []interface{}) error {
|
||||
func (b *Bitfinex) handleWSChannelUpdate(s *subscription.Subscription, respRaw []byte, eventType string, d []any) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("%w: Subscription param", common.ErrNilPointer)
|
||||
}
|
||||
@@ -636,7 +636,7 @@ func (b *Bitfinex) handleWSChannelUpdate(s *subscription.Subscription, respRaw [
|
||||
return fmt.Errorf("%s unhandled channel update: %s", b.Name, s.Channel)
|
||||
}
|
||||
|
||||
func (b *Bitfinex) handleWSChecksum(c *subscription.Subscription, d []interface{}) error {
|
||||
func (b *Bitfinex) handleWSChecksum(c *subscription.Subscription, d []any) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("%w: Subscription param", common.ErrNilPointer)
|
||||
}
|
||||
@@ -670,7 +670,7 @@ func (b *Bitfinex) handleWSChecksum(c *subscription.Subscription, d []interface{
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Bitfinex) handleWSBookUpdate(c *subscription.Subscription, d []interface{}) error {
|
||||
func (b *Bitfinex) handleWSBookUpdate(c *subscription.Subscription, d []any) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("%w: Subscription param", common.ErrNilPointer)
|
||||
}
|
||||
@@ -678,7 +678,7 @@ func (b *Bitfinex) handleWSBookUpdate(c *subscription.Subscription, d []interfac
|
||||
return subscription.ErrNotSinglePair
|
||||
}
|
||||
var newOrderbook []WebsocketBook
|
||||
obSnapBundle, ok := d[1].([]interface{})
|
||||
obSnapBundle, ok := d[1].([]any)
|
||||
if !ok {
|
||||
return errors.New("orderbook interface cast failed")
|
||||
}
|
||||
@@ -694,9 +694,9 @@ func (b *Bitfinex) handleWSBookUpdate(c *subscription.Subscription, d []interfac
|
||||
}
|
||||
var fundingRate bool
|
||||
switch id := obSnapBundle[0].(type) {
|
||||
case []interface{}:
|
||||
case []any:
|
||||
for i := range obSnapBundle {
|
||||
data, ok := obSnapBundle[i].([]interface{})
|
||||
data, ok := obSnapBundle[i].([]any)
|
||||
if !ok {
|
||||
return errors.New("type assertion failed for orderbok item data")
|
||||
}
|
||||
@@ -775,23 +775,23 @@ func (b *Bitfinex) handleWSBookUpdate(c *subscription.Subscription, d []interfac
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Bitfinex) handleWSCandleUpdate(c *subscription.Subscription, d []interface{}) error {
|
||||
func (b *Bitfinex) handleWSCandleUpdate(c *subscription.Subscription, d []any) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("%w: Subscription param", common.ErrNilPointer)
|
||||
}
|
||||
if len(c.Pairs) != 1 {
|
||||
return subscription.ErrNotSinglePair
|
||||
}
|
||||
candleBundle, ok := d[1].([]interface{})
|
||||
candleBundle, ok := d[1].([]any)
|
||||
if !ok || len(candleBundle) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch candleData := candleBundle[0].(type) {
|
||||
case []interface{}:
|
||||
case []any:
|
||||
for i := range candleBundle {
|
||||
var element []interface{}
|
||||
element, ok = candleBundle[i].([]interface{})
|
||||
var element []any
|
||||
element, ok = candleBundle[i].([]any)
|
||||
if !ok {
|
||||
return errors.New("candle type assertion for element data")
|
||||
}
|
||||
@@ -855,14 +855,14 @@ func (b *Bitfinex) handleWSCandleUpdate(c *subscription.Subscription, d []interf
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Bitfinex) handleWSTickerUpdate(c *subscription.Subscription, d []interface{}) error {
|
||||
func (b *Bitfinex) handleWSTickerUpdate(c *subscription.Subscription, d []any) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("%w: Subscription param", common.ErrNilPointer)
|
||||
}
|
||||
if len(c.Pairs) != 1 {
|
||||
return subscription.ErrNotSinglePair
|
||||
}
|
||||
tickerData, ok := d[1].([]interface{})
|
||||
tickerData, ok := d[1].([]any)
|
||||
if !ok {
|
||||
return errors.New("type assertion for tickerData")
|
||||
}
|
||||
@@ -1007,12 +1007,12 @@ func (b *Bitfinex) handleWSPublicTradeUpdate(respRaw []byte) (*wsTrade, error) {
|
||||
return t, json.Unmarshal(v, t)
|
||||
}
|
||||
|
||||
func (b *Bitfinex) handleWSNotification(d []interface{}, respRaw []byte) error {
|
||||
notification, ok := d[2].([]interface{})
|
||||
func (b *Bitfinex) handleWSNotification(d []any, respRaw []byte) error {
|
||||
notification, ok := d[2].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert notification data")
|
||||
}
|
||||
if data, ok := notification[4].([]interface{}); ok {
|
||||
if data, ok := notification[4].([]any); ok {
|
||||
channelName, ok := notification[1].(string)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert channelName")
|
||||
@@ -1078,19 +1078,19 @@ func (b *Bitfinex) handleWSNotification(d []interface{}, respRaw []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Bitfinex) handleWSPositionSnapshot(d []interface{}) error {
|
||||
snapBundle, ok := d[2].([]interface{})
|
||||
func (b *Bitfinex) handleWSPositionSnapshot(d []any) error {
|
||||
snapBundle, ok := d[2].([]any)
|
||||
if !ok {
|
||||
return common.GetTypeAssertError("[]interface{}", d[2], "positionSnapshotBundle")
|
||||
return common.GetTypeAssertError("[]any", d[2], "positionSnapshotBundle")
|
||||
}
|
||||
if len(snapBundle) == 0 {
|
||||
return nil
|
||||
}
|
||||
snapshot := make([]WebsocketPosition, len(snapBundle))
|
||||
for i := range snapBundle {
|
||||
positionData, ok := snapBundle[i].([]interface{})
|
||||
positionData, ok := snapBundle[i].([]any)
|
||||
if !ok {
|
||||
return common.GetTypeAssertError("[]interface{}", snapBundle[i], "positionSnapshot")
|
||||
return common.GetTypeAssertError("[]any", snapBundle[i], "positionSnapshot")
|
||||
}
|
||||
var position WebsocketPosition
|
||||
if position.Pair, ok = positionData[0].(string); !ok {
|
||||
@@ -1131,10 +1131,10 @@ func (b *Bitfinex) handleWSPositionSnapshot(d []interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Bitfinex) handleWSPositionUpdate(d []interface{}) error {
|
||||
positionData, ok := d[2].([]interface{})
|
||||
func (b *Bitfinex) handleWSPositionUpdate(d []any) error {
|
||||
positionData, ok := d[2].([]any)
|
||||
if !ok {
|
||||
return common.GetTypeAssertError("[]interface{}", d[2], "positionUpdate")
|
||||
return common.GetTypeAssertError("[]any", d[2], "positionUpdate")
|
||||
}
|
||||
if len(positionData) == 0 {
|
||||
return nil
|
||||
@@ -1176,10 +1176,10 @@ func (b *Bitfinex) handleWSPositionUpdate(d []interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Bitfinex) handleWSMyTradeUpdate(d []interface{}, eventType string) error {
|
||||
tradeData, ok := d[2].([]interface{})
|
||||
func (b *Bitfinex) handleWSMyTradeUpdate(d []any, eventType string) error {
|
||||
tradeData, ok := d[2].([]any)
|
||||
if !ok {
|
||||
return common.GetTypeAssertError("[]interface{}", d[2], "tradeUpdate")
|
||||
return common.GetTypeAssertError("[]any", d[2], "tradeUpdate")
|
||||
}
|
||||
if len(tradeData) <= 4 {
|
||||
return nil
|
||||
@@ -1232,7 +1232,7 @@ func (b *Bitfinex) handleWSMyTradeUpdate(d []interface{}, eventType string) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
func wsHandleFundingOffer(data []interface{}, includeRateReal bool) (*WsFundingOffer, error) {
|
||||
func wsHandleFundingOffer(data []any, includeRateReal bool) (*WsFundingOffer, error) {
|
||||
var offer WsFundingOffer
|
||||
var ok bool
|
||||
if data[0] != nil {
|
||||
@@ -1327,7 +1327,7 @@ func wsHandleFundingOffer(data []interface{}, includeRateReal bool) (*WsFundingO
|
||||
return &offer, nil
|
||||
}
|
||||
|
||||
func wsHandleFundingCreditLoanData(data []interface{}, includePositionPair bool) (*WsCredit, error) {
|
||||
func wsHandleFundingCreditLoanData(data []any, includePositionPair bool) (*WsCredit, error) {
|
||||
var credit WsCredit
|
||||
var ok bool
|
||||
if data[0] != nil {
|
||||
@@ -1445,7 +1445,7 @@ func wsHandleFundingCreditLoanData(data []interface{}, includePositionPair bool)
|
||||
return &credit, nil
|
||||
}
|
||||
|
||||
func (b *Bitfinex) wsHandleOrder(data []interface{}) {
|
||||
func (b *Bitfinex) wsHandleOrder(data []any) {
|
||||
var od order.Detail
|
||||
var err error
|
||||
od.Exchange = b.Name
|
||||
@@ -1709,7 +1709,7 @@ func (b *Bitfinex) GetSubscriptionTemplate(_ *subscription.Subscription) (*templ
|
||||
|
||||
// ConfigureWS to send checksums and sequence numbers
|
||||
func (b *Bitfinex) ConfigureWS() error {
|
||||
return b.Websocket.Conn.SendJSONMessage(context.TODO(), request.Unset, map[string]interface{}{
|
||||
return b.Websocket.Conn.SendJSONMessage(context.TODO(), request.Unset, map[string]any{
|
||||
"event": "conf",
|
||||
"flags": bitfinexChecksumFlag + bitfinexWsSequenceFlag,
|
||||
})
|
||||
@@ -1790,7 +1790,7 @@ func (b *Bitfinex) unsubscribeFromChan(subs subscription.List) error {
|
||||
return common.GetTypeAssertError("int", s.Key, "subscription.Key")
|
||||
}
|
||||
|
||||
req := map[string]interface{}{
|
||||
req := map[string]any{
|
||||
"event": "unsubscribe",
|
||||
"chanId": chanID,
|
||||
}
|
||||
@@ -1878,7 +1878,7 @@ func (b *Bitfinex) WsNewOrder(data *WsNewOrderRequest) (string, error) {
|
||||
if resp == nil {
|
||||
return "", errors.New(b.Name + " - Order message not returned")
|
||||
}
|
||||
var respData []interface{}
|
||||
var respData []any
|
||||
err = json.Unmarshal(resp, &respData)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1887,7 +1887,7 @@ func (b *Bitfinex) WsNewOrder(data *WsNewOrderRequest) (string, error) {
|
||||
if len(respData) < 3 {
|
||||
return "", errors.New("unexpected respData length")
|
||||
}
|
||||
responseDataDetail, ok := respData[2].([]interface{})
|
||||
responseDataDetail, ok := respData[2].([]any)
|
||||
if !ok {
|
||||
return "", errors.New("unable to type assert respData")
|
||||
}
|
||||
@@ -1896,7 +1896,7 @@ func (b *Bitfinex) WsNewOrder(data *WsNewOrderRequest) (string, error) {
|
||||
return "", errors.New("invalid responseDataDetail length")
|
||||
}
|
||||
|
||||
responseOrderDetail, ok := responseDataDetail[4].([]interface{})
|
||||
responseOrderDetail, ok := responseDataDetail[4].([]any)
|
||||
if !ok {
|
||||
return "", errors.New("unable to type assert responseOrderDetail")
|
||||
}
|
||||
@@ -1936,7 +1936,7 @@ func (b *Bitfinex) WsModifyOrder(data *WsUpdateOrderRequest) error {
|
||||
return errors.New(b.Name + " - Order message not returned")
|
||||
}
|
||||
|
||||
var responseData []interface{}
|
||||
var responseData []any
|
||||
err = json.Unmarshal(resp, &responseData)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1944,7 +1944,7 @@ func (b *Bitfinex) WsModifyOrder(data *WsUpdateOrderRequest) error {
|
||||
if len(responseData) < 3 {
|
||||
return errors.New("unexpected responseData length")
|
||||
}
|
||||
responseOrderData, ok := responseData[2].([]interface{})
|
||||
responseOrderData, ok := responseData[2].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert responseOrderData")
|
||||
}
|
||||
@@ -1989,7 +1989,7 @@ func (b *Bitfinex) WsCancelOrder(orderID int64) error {
|
||||
if resp == nil {
|
||||
return fmt.Errorf("%v - Order %v failed to cancel", b.Name, orderID)
|
||||
}
|
||||
var responseData []interface{}
|
||||
var responseData []any
|
||||
err = json.Unmarshal(resp, &responseData)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1997,7 +1997,7 @@ func (b *Bitfinex) WsCancelOrder(orderID int64) error {
|
||||
if len(responseData) < 3 {
|
||||
return errors.New("unexpected responseData length")
|
||||
}
|
||||
responseOrderData, ok := responseData[2].([]interface{})
|
||||
responseOrderData, ok := responseData[2].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert responseOrderData")
|
||||
}
|
||||
@@ -2046,7 +2046,7 @@ func (b *Bitfinex) WsCancelOffer(orderID int64) error {
|
||||
if resp == nil {
|
||||
return fmt.Errorf("%v - Order %v failed to cancel", b.Name, orderID)
|
||||
}
|
||||
var responseData []interface{}
|
||||
var responseData []any
|
||||
err = json.Unmarshal(resp, &responseData)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -2054,7 +2054,7 @@ func (b *Bitfinex) WsCancelOffer(orderID int64) error {
|
||||
if len(responseData) < 3 {
|
||||
return errors.New("unexpected responseData length")
|
||||
}
|
||||
responseOrderData, ok := responseData[2].([]interface{})
|
||||
responseOrderData, ok := responseData[2].([]any)
|
||||
if !ok {
|
||||
return errors.New("unable to type assert responseOrderData")
|
||||
}
|
||||
@@ -2078,8 +2078,8 @@ func (b *Bitfinex) WsCancelOffer(orderID int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeRequestInterface(channelName string, data interface{}) []interface{} {
|
||||
return []interface{}{0, channelName, nil, data}
|
||||
func makeRequestInterface(channelName string, data any) []any {
|
||||
return []any{0, channelName, nil, data}
|
||||
}
|
||||
|
||||
func validateCRC32(book *orderbook.Base, token uint32) error {
|
||||
@@ -2185,7 +2185,7 @@ func subToMap(s *subscription.Subscription, a asset.Item, p currency.Pair) map[s
|
||||
if name, ok := subscriptionNames[s.Channel]; ok {
|
||||
c = name
|
||||
}
|
||||
req := map[string]interface{}{
|
||||
req := map[string]any{
|
||||
"channel": c,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user