common: Replace StringDataCompare with slices.Contains and cleanup string funcs (#1631)

* common: Replace StringDataCompare with slices.Contains and cleanup string funcs

* common/docs: Update SliceDifference and remove outdated steps from ADD_NEW_EXCHANGE.md

* common: Improve SliceDifference
This commit is contained in:
Adrian Gallagher
2024-09-13 10:43:20 +10:00
committed by GitHub
parent 22cb0eb9b9
commit b8e836d74f
32 changed files with 201 additions and 370 deletions

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"reflect"
"slices"
"strconv"
"strings"
"time"
@@ -1343,7 +1344,7 @@ func (by *Bybit) GetCoinGreeks(ctx context.Context, baseCoin string) (*CoinGreek
// GetFeeRate retrieves the trading fee rate.
func (by *Bybit) GetFeeRate(ctx context.Context, category, symbol, baseCoin string) (*AccountFee, error) {
params := url.Values{}
if !common.StringDataContains(validCategory, category) {
if !slices.Contains(validCategory, category) {
return nil, fmt.Errorf("%w, valid category values are %v", errInvalidCategory, validCategory)
}
if category != "" {
@@ -1470,7 +1471,7 @@ func (by *Bybit) GetCoinExchangeRecords(ctx context.Context, fromCoin, toCoin, c
// GetDeliveryRecord retrieves delivery records of USDC futures and Options, sorted by deliveryTime in descending order
func (by *Bybit) GetDeliveryRecord(ctx context.Context, category, symbol, cursor string, expiryDate time.Time, limit int64) (*DeliveryRecord, error) {
if !common.StringDataContains([]string{cLinear, cOption}, category) {
if !slices.Contains([]string{cLinear, cOption}, category) {
return nil, fmt.Errorf("%w, valid category values are %v", errInvalidCategory, []string{cLinear, cOption})
}
params := url.Values{}
@@ -1493,7 +1494,7 @@ func (by *Bybit) GetDeliveryRecord(ctx context.Context, category, symbol, cursor
// GetUSDCSessionSettlement retrieves session settlement records of USDC perpetual and futures
func (by *Bybit) GetUSDCSessionSettlement(ctx context.Context, category, symbol, cursor string, limit int64) (*SettlementSession, error) {
if !common.StringDataContains([]string{cLinear}, category) {
if category != cLinear {
return nil, fmt.Errorf("%w, valid category value is %v", errInvalidCategory, cLinear)
}
params := url.Values{}