diff --git a/exchanges/bitget/bitget.go b/exchanges/bitget/bitget.go index eb35679a90d..a21f6e28581 100644 --- a/exchanges/bitget/bitget.go +++ b/exchanges/bitget/bitget.go @@ -15,6 +15,7 @@ import ( "github.com/buger/jsonparser" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/crypto" + "github.com/thrasher-corp/gocryptotrader/currency" exchange "github.com/thrasher-corp/gocryptotrader/exchanges" "github.com/thrasher-corp/gocryptotrader/exchanges/request" ) @@ -328,15 +329,15 @@ func (bi *Bitget) GetTime(ctx context.Context) (*TimeResp, error) { } // GetTradeRate returns the fees the user would face for trading a given symbol -func (bi *Bitget) GetTradeRate(ctx context.Context, pair, businessType string) (*TradeRateResp, error) { - if pair == "" { +func (bi *Bitget) GetTradeRate(ctx context.Context, pair currency.Pair, businessType string) (*TradeRateResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if businessType == "" { return nil, errBusinessTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("businessType", businessType) var resp struct { TradeRateResp `json:"data"` @@ -345,15 +346,15 @@ func (bi *Bitget) GetTradeRate(ctx context.Context, pair, businessType string) ( } // GetSpotTransactionRecords returns the user's spot transaction records -func (bi *Bitget) GetSpotTransactionRecords(ctx context.Context, currency string, startTime, endTime time.Time, limit, pagination int64) ([]SpotTrResp, error) { +func (bi *Bitget) GetSpotTransactionRecords(ctx context.Context, currency currency.Code, startTime, endTime time.Time, limit, pagination int64) ([]SpotTrResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, false) if err != nil { return nil, err } - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } if limit != 0 { params.Values.Set("limit", strconv.FormatInt(limit, 10)) @@ -368,7 +369,7 @@ func (bi *Bitget) GetSpotTransactionRecords(ctx context.Context, currency string } // GetFuturesTransactionRecords returns the user's futures transaction records -func (bi *Bitget) GetFuturesTransactionRecords(ctx context.Context, productType, currency string, startTime, endTime time.Time, limit, pagination int64) ([]FutureTrResp, error) { +func (bi *Bitget) GetFuturesTransactionRecords(ctx context.Context, productType string, currency currency.Code, startTime, endTime time.Time, limit, pagination int64) ([]FutureTrResp, error) { if productType == "" { return nil, errProductTypeEmpty } @@ -379,7 +380,7 @@ func (bi *Bitget) GetFuturesTransactionRecords(ctx context.Context, productType, return nil, err } params.Values.Set("productType", productType) - params.Values.Set("marginCoin", currency) + params.Values.Set("marginCoin", currency.String()) if limit != 0 { params.Values.Set("limit", strconv.FormatInt(limit, 10)) } @@ -393,7 +394,7 @@ func (bi *Bitget) GetFuturesTransactionRecords(ctx context.Context, productType, } // GetMarginTransactionRecords returns the user's margin transaction records -func (bi *Bitget) GetMarginTransactionRecords(ctx context.Context, marginType, currency string, startTime, endTime time.Time, limit, pagination int64) ([]MarginTrResp, error) { +func (bi *Bitget) GetMarginTransactionRecords(ctx context.Context, marginType string, currency currency.Code, startTime, endTime time.Time, limit, pagination int64) ([]MarginTrResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, false) @@ -401,8 +402,8 @@ func (bi *Bitget) GetMarginTransactionRecords(ctx context.Context, marginType, c return nil, err } params.Values.Set("marginType", marginType) - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } if limit != 0 { params.Values.Set("limit", strconv.FormatInt(limit, 10)) @@ -417,15 +418,15 @@ func (bi *Bitget) GetMarginTransactionRecords(ctx context.Context, marginType, c } // GetP2PTransactionRecords returns the user's P2P transaction records -func (bi *Bitget) GetP2PTransactionRecords(ctx context.Context, currency string, startTime, endTime time.Time, limit, pagination int64) ([]P2PTrResp, error) { +func (bi *Bitget) GetP2PTransactionRecords(ctx context.Context, currency currency.Code, startTime, endTime time.Time, limit, pagination int64) ([]P2PTrResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, false) if err != nil { return nil, err } - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } if limit != 0 { params.Values.Set("limit", strconv.FormatInt(limit, 10)) @@ -464,7 +465,7 @@ func (bi *Bitget) GetMerchantInfo(ctx context.Context) (*P2PMerInfoResp, error) } // GetMerchantP2POrders returns information on the user's P2P orders -func (bi *Bitget) GetMerchantP2POrders(ctx context.Context, startTime, endTime time.Time, limit, pagination, adNum, ordNum int64, status, side, cryptoCurrency, fiatCurrency string) (*P2POrdersResp, error) { +func (bi *Bitget) GetMerchantP2POrders(ctx context.Context, startTime, endTime time.Time, limit, pagination, adNum, ordNum int64, status, side string, cryptoCurrency, fiatCurrency currency.Code) (*P2POrdersResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, true) @@ -481,10 +482,10 @@ func (bi *Bitget) GetMerchantP2POrders(ctx context.Context, startTime, endTime t params.Values.Set("orderNo", strconv.FormatInt(ordNum, 10)) params.Values.Set("status", status) params.Values.Set("side", side) - if cryptoCurrency != "" { - params.Values.Set("coin", cryptoCurrency) + if !cryptoCurrency.IsEmpty() { + params.Values.Set("coin", cryptoCurrency.String()) } - params.Values.Set("fiat", fiatCurrency) + params.Values.Set("fiat", fiatCurrency.String()) var resp struct { P2POrdersResp `json:"data"` } @@ -492,7 +493,7 @@ func (bi *Bitget) GetMerchantP2POrders(ctx context.Context, startTime, endTime t } // GetMerchantAdvertisementList returns information on a variety of merchant advertisements -func (bi *Bitget) GetMerchantAdvertisementList(ctx context.Context, startTime, endTime time.Time, limit, pagination, adNum, payMethodID int64, status, side, cryptoCurrency, fiatCurrency, orderBy, sourceType string) (*P2PAdListResp, error) { +func (bi *Bitget) GetMerchantAdvertisementList(ctx context.Context, startTime, endTime time.Time, limit, pagination, adNum, payMethodID int64, status, side, orderBy, sourceType string, cryptoCurrency, fiatCurrency currency.Code) (*P2PAdListResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, true) @@ -509,10 +510,10 @@ func (bi *Bitget) GetMerchantAdvertisementList(ctx context.Context, startTime, e params.Values.Set("payMethodId", strconv.FormatInt(payMethodID, 10)) params.Values.Set("status", status) params.Values.Set("side", side) - if cryptoCurrency != "" { - params.Values.Set("coin", cryptoCurrency) + if !cryptoCurrency.IsEmpty() { + params.Values.Set("coin", cryptoCurrency.String()) } - params.Values.Set("fiat", fiatCurrency) + params.Values.Set("fiat", fiatCurrency.String()) params.Values.Set("orderBy", orderBy) params.Values.Set("sourceType", sourceType) var resp struct { @@ -522,12 +523,12 @@ func (bi *Bitget) GetMerchantAdvertisementList(ctx context.Context, startTime, e } // GetSpotWhaleNetFlow returns the amount whales have been trading in a specified pair recently -func (bi *Bitget) GetSpotWhaleNetFlow(ctx context.Context, pair string) ([]WhaleNetFlowResp, error) { - if pair == "" { +func (bi *Bitget) GetSpotWhaleNetFlow(ctx context.Context, pair currency.Pair) ([]WhaleNetFlowResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetSpot + bitgetMarket + bitgetWhaleNetFlow var resp struct { WhaleNetFlowResp []WhaleNetFlowResp `json:"data"` @@ -536,12 +537,12 @@ func (bi *Bitget) GetSpotWhaleNetFlow(ctx context.Context, pair string) ([]Whale } // GetFuturesActiveVolume returns the active volume of a specified pair -func (bi *Bitget) GetFuturesActiveVolume(ctx context.Context, pair, period string) ([]ActiveVolumeResp, error) { - if pair == "" { +func (bi *Bitget) GetFuturesActiveVolume(ctx context.Context, pair currency.Pair, period string) ([]ActiveVolumeResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("period", period) path := bitgetMix + bitgetMarket + bitgetTakerBuySell var resp struct { @@ -551,12 +552,12 @@ func (bi *Bitget) GetFuturesActiveVolume(ctx context.Context, pair, period strin } // GetFuturesPositionRatios returns the ratio of long to short positions for a specified pair -func (bi *Bitget) GetFuturesPositionRatios(ctx context.Context, pair, period string) ([]PosRatFutureResp, error) { - if pair == "" { +func (bi *Bitget) GetFuturesPositionRatios(ctx context.Context, pair currency.Pair, period string) ([]PosRatFutureResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("period", period) path := bitgetMix + bitgetMarket + bitgetPositionLongShort var resp struct { @@ -566,12 +567,12 @@ func (bi *Bitget) GetFuturesPositionRatios(ctx context.Context, pair, period str } // GetMarginPositionRatios returns the ratio of long to short positions for a specified pair in margin accounts -func (bi *Bitget) GetMarginPositionRatios(ctx context.Context, pair, period, currency string) ([]PosRatMarginResp, error) { - if pair == "" { +func (bi *Bitget) GetMarginPositionRatios(ctx context.Context, pair currency.Pair, period, currency string) ([]PosRatMarginResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("period", period) vals.Set("coin", currency) path := bitgetMargin + bitgetMarket + bitgetLongShortRatio @@ -582,12 +583,12 @@ func (bi *Bitget) GetMarginPositionRatios(ctx context.Context, pair, period, cur } // GetMarginLoanGrowth returns the growth rate of borrowed funds for a specified pair in margin accounts -func (bi *Bitget) GetMarginLoanGrowth(ctx context.Context, pair, period, currency string) ([]LoanGrowthResp, error) { - if pair == "" { +func (bi *Bitget) GetMarginLoanGrowth(ctx context.Context, pair currency.Pair, period, currency string) ([]LoanGrowthResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("period", period) vals.Set("coin", currency) path := bitgetMargin + bitgetMarket + bitgetLoanGrowth @@ -598,12 +599,12 @@ func (bi *Bitget) GetMarginLoanGrowth(ctx context.Context, pair, period, currenc } // GetIsolatedBorrowingRatio returns the ratio of borrowed funds between base and quote currencies, after converting to USDT, within isolated margin accounts -func (bi *Bitget) GetIsolatedBorrowingRatio(ctx context.Context, pair, period string) ([]BorrowRatioResp, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedBorrowingRatio(ctx context.Context, pair currency.Pair, period string) ([]BorrowRatioResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("period", period) path := bitgetMargin + bitgetMarket + bitgetIsolatedBorrowRate var resp struct { @@ -613,12 +614,12 @@ func (bi *Bitget) GetIsolatedBorrowingRatio(ctx context.Context, pair, period st } // GetFuturesRatios returns the ratio of long to short positions for a specified pair -func (bi *Bitget) GetFuturesRatios(ctx context.Context, pair, period string) ([]RatioResp, error) { - if pair == "" { +func (bi *Bitget) GetFuturesRatios(ctx context.Context, pair currency.Pair, period string) ([]RatioResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("period", period) path := bitgetMix + bitgetMarket + bitgetLongShort var resp struct { @@ -628,12 +629,12 @@ func (bi *Bitget) GetFuturesRatios(ctx context.Context, pair, period string) ([] } // GetSpotFundFlows returns information on volumes and buy/sell ratios for whales, dolphins, and fish for a particular pair -func (bi *Bitget) GetSpotFundFlows(ctx context.Context, pair string) (*FundFlowResp, error) { - if pair == "" { +func (bi *Bitget) GetSpotFundFlows(ctx context.Context, pair currency.Pair) (*FundFlowResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetSpot + bitgetMarket + bitgetFundFlow var resp struct { FundFlowResp `json:"data"` @@ -651,12 +652,12 @@ func (bi *Bitget) GetTradeSupportSymbols(ctx context.Context) (*SymbolsResp, err } // GetSpotWhaleFundFlows returns the amount whales have been trading in a specified pair recently -func (bi *Bitget) GetSpotWhaleFundFlows(ctx context.Context, pair string) ([]WhaleFundFlowResp, error) { - if pair == "" { +func (bi *Bitget) GetSpotWhaleFundFlows(ctx context.Context, pair currency.Pair) ([]WhaleFundFlowResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetSpot + bitgetMarket + bitgetFundNetFlow var resp struct { WhaleFundFlowResp []WhaleFundFlowResp `json:"data"` @@ -665,12 +666,12 @@ func (bi *Bitget) GetSpotWhaleFundFlows(ctx context.Context, pair string) ([]Wha } // GetFuturesAccountRatios returns the ratio of long to short positions for a specified pair -func (bi *Bitget) GetFuturesAccountRatios(ctx context.Context, pair, period string) ([]AccountRatioResp, error) { - if pair == "" { +func (bi *Bitget) GetFuturesAccountRatios(ctx context.Context, pair currency.Pair, period string) ([]AccountRatioResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("period", period) path := bitgetMix + bitgetMarket + bitgetAccountLongShort var resp struct { @@ -823,10 +824,10 @@ func (bi *Bitget) GetAPIKeys(ctx context.Context, subaccountID string) ([]GetAPI } // GetFundingAssets returns the user's assets -func (bi *Bitget) GetFundingAssets(ctx context.Context, currency string) ([]FundingAssetsResp, error) { +func (bi *Bitget) GetFundingAssets(ctx context.Context, currency currency.Code) ([]FundingAssetsResp, error) { vals := url.Values{} - if currency != "" { - vals.Set("coin", currency) + if !currency.IsEmpty() { + vals.Set("coin", currency.String()) } var resp struct { FundingAssetsResp []FundingAssetsResp `json:"data"` @@ -863,16 +864,16 @@ func (bi *Bitget) GetConvertCoins(ctx context.Context) ([]ConvertCoinsResp, erro } // GetQuotedPrice returns the price of a given amount of one currency in terms of another currency, and an ID for this quote, to be used in a subsequent conversion -func (bi *Bitget) GetQuotedPrice(ctx context.Context, fromCurrency, toCurrency string, fromAmount, toAmount float64) (*QuotedPriceResp, error) { - if fromCurrency == "" || toCurrency == "" { +func (bi *Bitget) GetQuotedPrice(ctx context.Context, fromCurrency, toCurrency currency.Code, fromAmount, toAmount float64) (*QuotedPriceResp, error) { + if fromCurrency.IsEmpty() || toCurrency.IsEmpty() { return nil, errCurrencyEmpty } if (fromAmount == 0 && toAmount == 0) || (fromAmount != 0 && toAmount != 0) { return nil, errFromToMutex } vals := url.Values{} - vals.Set("fromCoin", fromCurrency) - vals.Set("toCoin", toCurrency) + vals.Set("fromCoin", fromCurrency.String()) + vals.Set("toCoin", toCurrency.String()) if fromAmount != 0 { vals.Set("fromCoinSize", strconv.FormatFloat(fromAmount, 'f', -1, 64)) } else { @@ -885,8 +886,8 @@ func (bi *Bitget) GetQuotedPrice(ctx context.Context, fromCurrency, toCurrency s } // CommitConversion commits a conversion previously quoted by GetQuotedPrice. This quote has to have been issued within the last 8 seconds. -func (bi *Bitget) CommitConversion(ctx context.Context, fromCurrency, toCurrency, traceID string, fromAmount, toAmount, price float64) (*CommitConvResp, error) { - if fromCurrency == "" || toCurrency == "" { +func (bi *Bitget) CommitConversion(ctx context.Context, fromCurrency, toCurrency currency.Code, traceID string, fromAmount, toAmount, price float64) (*CommitConvResp, error) { + if fromCurrency.IsEmpty() || toCurrency.IsEmpty() { return nil, errCurrencyEmpty } if traceID == "" { @@ -899,8 +900,9 @@ func (bi *Bitget) CommitConversion(ctx context.Context, fromCurrency, toCurrency return nil, errPriceEmpty } req := map[string]any{ - "fromCoin": fromCurrency, - "toCoin": toCurrency, + // Double-check whether functionality would actually be weird if they weren't stringed + "fromCoin": fromCurrency.String(), + "toCoin": toCurrency.String(), "traceId": traceID, "fromCoinSize": strconv.FormatFloat(fromAmount, 'f', -1, 64), "toCoinSize": strconv.FormatFloat(toAmount, 'f', -1, 64), @@ -943,11 +945,12 @@ func (bi *Bitget) GetBGBConvertCoins(ctx context.Context) ([]BGBConvertCoinsResp } // ConvertBGB converts all funds in the listed currencies to BGB -func (bi *Bitget) ConvertBGB(ctx context.Context, currencies []string) ([]ConvertBGBResp, error) { +func (bi *Bitget) ConvertBGB(ctx context.Context, currencies []currency.Code) ([]ConvertBGBResp, error) { if len(currencies) == 0 { return nil, errCurrencyEmpty } req := map[string]any{ + // See whether this breaks and should be reverted back to just strings, or maybe I could just unroll them into strings somewhere "coinList": currencies, } var resp struct { @@ -980,10 +983,10 @@ func (bi *Bitget) GetBGBConvertHistory(ctx context.Context, orderID, limit, pagi } // GetCoinInfo returns information on all supported spot currencies, or a single currency of the user's choice -func (bi *Bitget) GetCoinInfo(ctx context.Context, currency string) ([]CoinInfoResp, error) { +func (bi *Bitget) GetCoinInfo(ctx context.Context, currency currency.Code) ([]CoinInfoResp, error) { vals := url.Values{} - if currency != "" { - vals.Set("coin", currency) + if !currency.IsEmpty() { + vals.Set("coin", currency.String()) } path := bitgetSpot + bitgetPublic + bitgetCoins var resp struct { @@ -993,9 +996,9 @@ func (bi *Bitget) GetCoinInfo(ctx context.Context, currency string) ([]CoinInfoR } // GetSymbolInfo returns information on all supported spot trading pairs, or a single pair of the user's choice -func (bi *Bitget) GetSymbolInfo(ctx context.Context, pair string) ([]SymbolInfoResp, error) { +func (bi *Bitget) GetSymbolInfo(ctx context.Context, pair currency.Pair) ([]SymbolInfoResp, error) { vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetSpot + bitgetPublic + bitgetSymbols var resp struct { SymbolInfoResp []SymbolInfoResp `json:"data"` @@ -1013,9 +1016,9 @@ func (bi *Bitget) GetSpotVIPFeeRate(ctx context.Context) ([]VIPFeeRateResp, erro } // GetSpotTickerInformation returns the ticker information for all trading pairs, or a single pair of the user's choice -func (bi *Bitget) GetSpotTickerInformation(ctx context.Context, pair string) ([]TickerResp, error) { +func (bi *Bitget) GetSpotTickerInformation(ctx context.Context, pair currency.Pair) ([]TickerResp, error) { vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetSpot + bitgetMarket + bitgetTickers var resp struct { TickerResp []TickerResp `json:"data"` @@ -1024,12 +1027,12 @@ func (bi *Bitget) GetSpotTickerInformation(ctx context.Context, pair string) ([] } // GetSpotMergeDepth returns part of the orderbook, with options to merge orders of similar price levels together, and to change how many results are returned. Limit's a string instead of the typical int64 because the API will accept a value of "max" -func (bi *Bitget) GetSpotMergeDepth(ctx context.Context, pair, precision, limit string) (*DepthResp, error) { - if pair == "" { +func (bi *Bitget) GetSpotMergeDepth(ctx context.Context, pair currency.Pair, precision, limit string) (*DepthResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("precision", precision) vals.Set("limit", limit) path := bitgetSpot + bitgetMarket + bitgetMergeDepth @@ -1040,9 +1043,9 @@ func (bi *Bitget) GetSpotMergeDepth(ctx context.Context, pair, precision, limit } // GetOrderbookDepth returns the orderbook for a given trading pair, with options to merge orders of similar price levels together, and to change how many results are returned. -func (bi *Bitget) GetOrderbookDepth(ctx context.Context, pair, step string, limit uint8) (*OrderbookResp, error) { +func (bi *Bitget) GetOrderbookDepth(ctx context.Context, pair currency.Pair, step string, limit uint8) (*OrderbookResp, error) { vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("type", step) vals.Set("limit", strconv.FormatUint(uint64(limit), 10)) path := bitgetSpot + bitgetMarket + bitgetOrderbook @@ -1053,8 +1056,8 @@ func (bi *Bitget) GetOrderbookDepth(ctx context.Context, pair, step string, limi } // GetSpotCandlestickData returns candlestick data for a given trading pair -func (bi *Bitget) GetSpotCandlestickData(ctx context.Context, pair, granularity string, startTime, endTime time.Time, limit uint16, historic bool) (*CandleData, error) { - if pair == "" { +func (bi *Bitget) GetSpotCandlestickData(ctx context.Context, pair currency.Pair, granularity string, startTime, endTime time.Time, limit uint16, historic bool) (*CandleData, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if granularity == "" { @@ -1080,12 +1083,12 @@ func (bi *Bitget) GetSpotCandlestickData(ctx context.Context, pair, granularity } // GetRecentSpotFills returns the most recent trades for a given pair -func (bi *Bitget) GetRecentSpotFills(ctx context.Context, pair string, limit uint16) ([]MarketFillsResp, error) { - if pair == "" { +func (bi *Bitget) GetRecentSpotFills(ctx context.Context, pair currency.Pair, limit uint16) ([]MarketFillsResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("limit", strconv.FormatInt(int64(limit), 10)) path := bitgetSpot + bitgetMarket + bitgetFills var resp struct { @@ -1095,8 +1098,8 @@ func (bi *Bitget) GetRecentSpotFills(ctx context.Context, pair string, limit uin } // GetSpotMarketTrades returns trades for a given pair within a particular time range, and/or before a certain ID -func (bi *Bitget) GetSpotMarketTrades(ctx context.Context, pair string, startTime, endTime time.Time, limit, pagination int64) ([]MarketFillsResp, error) { - if pair == "" { +func (bi *Bitget) GetSpotMarketTrades(ctx context.Context, pair currency.Pair, startTime, endTime time.Time, limit, pagination int64) ([]MarketFillsResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -1105,7 +1108,7 @@ func (bi *Bitget) GetSpotMarketTrades(ctx context.Context, pair string, startTim if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) if limit != 0 { params.Values.Set("limit", strconv.FormatInt(limit, 10)) } @@ -1120,8 +1123,8 @@ func (bi *Bitget) GetSpotMarketTrades(ctx context.Context, pair string, startTim } // PlaceSpotOrder places a spot order on the exchange -func (bi *Bitget) PlaceSpotOrder(ctx context.Context, pair, side, orderType, strategy, clientOrderID, stpMode string, price, amount, triggerPrice, presetTPPrice, executeTPPrice, presetSLPrice, executeSLPrice float64, isCopyTradeLeader bool, acceptableDelay time.Duration) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) PlaceSpotOrder(ctx context.Context, pair currency.Pair, side, orderType, strategy, clientOrderID, stpMode string, price, amount, triggerPrice, presetTPPrice, executeTPPrice, presetSLPrice, executeSLPrice float64, isCopyTradeLeader bool, acceptableDelay time.Duration) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if side == "" { @@ -1140,7 +1143,7 @@ func (bi *Bitget) PlaceSpotOrder(ctx context.Context, pair, side, orderType, str return nil, errAmountEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "side": side, "orderType": orderType, "force": strategy, @@ -1179,8 +1182,8 @@ func (bi *Bitget) PlaceSpotOrder(ctx context.Context, pair, side, orderType, str } // CancelAndPlaceSpotOrder cancels an order and places a new one on the exchange -func (bi *Bitget) CancelAndPlaceSpotOrder(ctx context.Context, pair, oldClientOrderID, newClientOrderID string, price, amount, presetTPPrice, executeTPPrice, presetSLPrice, executeSLPrice float64, orderID int64) (*CancelAndPlaceResp, error) { - if pair == "" { +func (bi *Bitget) CancelAndPlaceSpotOrder(ctx context.Context, pair currency.Pair, oldClientOrderID, newClientOrderID string, price, amount, presetTPPrice, executeTPPrice, presetSLPrice, executeSLPrice float64, orderID int64) (*CancelAndPlaceResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if oldClientOrderID == "" && orderID == 0 { @@ -1190,7 +1193,7 @@ func (bi *Bitget) CancelAndPlaceSpotOrder(ctx context.Context, pair, oldClientOr return nil, errPriceEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "price": strconv.FormatFloat(price, 'f', -1, 64), "size": strconv.FormatFloat(amount, 'f', -1, 64), } @@ -1224,6 +1227,7 @@ func (bi *Bitget) BatchCancelAndPlaceSpotOrders(ctx context.Context, orders []Re return nil, errOrdersEmpty } req := map[string]any{ + // Check whether this breaks with the pair being changed from a string to a currency.Pair "orderList": orders, } path := bitgetSpot + bitgetTrade + bitgetBatchCancelReplaceOrder @@ -1234,15 +1238,15 @@ func (bi *Bitget) BatchCancelAndPlaceSpotOrders(ctx context.Context, orders []Re } // CancelSpotOrderByID cancels an order on the exchange -func (bi *Bitget) CancelSpotOrderByID(ctx context.Context, pair, tpslType, clientOrderID string, orderID int64) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) CancelSpotOrderByID(ctx context.Context, pair currency.Pair, tpslType, clientOrderID string, orderID int64) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if orderID == 0 && clientOrderID == "" { return nil, errOrderClientEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "tpslType": tpslType, } if orderID != 0 { @@ -1259,15 +1263,15 @@ func (bi *Bitget) CancelSpotOrderByID(ctx context.Context, pair, tpslType, clien } // BatchPlaceSpotOrders places up to fifty orders on the exchange -func (bi *Bitget) BatchPlaceSpotOrders(ctx context.Context, pair string, multiCurrencyMode, isCopyTradeLeader bool, orders []PlaceSpotOrderStruct) (*BatchOrderResp, error) { - if pair == "" && !multiCurrencyMode { +func (bi *Bitget) BatchPlaceSpotOrders(ctx context.Context, pair currency.Pair, multiCurrencyMode, isCopyTradeLeader bool, orders []PlaceSpotOrderStruct) (*BatchOrderResp, error) { + if pair.IsEmpty() && !multiCurrencyMode { return nil, errPairEmpty } if len(orders) == 0 { return nil, errOrdersEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "orderList": orders, } if multiCurrencyMode { @@ -1285,15 +1289,15 @@ func (bi *Bitget) BatchPlaceSpotOrders(ctx context.Context, pair string, multiCu } // BatchCancelOrders cancels up to fifty orders on the exchange -func (bi *Bitget) BatchCancelOrders(ctx context.Context, pair string, multiCurrencyMode bool, orderIDs []CancelSpotOrderStruct) (*BatchOrderResp, error) { - if pair == "" && !multiCurrencyMode { +func (bi *Bitget) BatchCancelOrders(ctx context.Context, pair currency.Pair, multiCurrencyMode bool, orderIDs []CancelSpotOrderStruct) (*BatchOrderResp, error) { + if pair.IsEmpty() && !multiCurrencyMode { return nil, errPairEmpty } if len(orderIDs) == 0 { return nil, errOrderIDEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "orderList": orderIDs, } if multiCurrencyMode { @@ -1305,12 +1309,12 @@ func (bi *Bitget) BatchCancelOrders(ctx context.Context, pair string, multiCurre } // CancelOrdersBySymbol cancels orders for a given symbol. Doesn't return information on failures/successes -func (bi *Bitget) CancelOrdersBySymbol(ctx context.Context, pair string) (string, error) { - if pair == "" { +func (bi *Bitget) CancelOrdersBySymbol(ctx context.Context, pair currency.Pair) (string, error) { + if pair.IsEmpty() { return "", errPairEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), } path := bitgetSpot + bitgetTrade + bitgetCancelSymbolOrder var resp struct { @@ -1340,14 +1344,14 @@ func (bi *Bitget) GetSpotOrderDetails(ctx context.Context, orderID int64, client } // GetUnfilledOrders returns information on the user's unfilled orders -func (bi *Bitget) GetUnfilledOrders(ctx context.Context, pair, tpslType string, startTime, endTime time.Time, limit, pagination, orderID int64, acceptableDelay time.Duration) ([]UnfilledOrdersResp, error) { +func (bi *Bitget) GetUnfilledOrders(ctx context.Context, pair currency.Pair, tpslType string, startTime, endTime time.Time, limit, pagination, orderID int64, acceptableDelay time.Duration) ([]UnfilledOrdersResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, true, true) if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("tpslType", tpslType) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) @@ -1366,14 +1370,14 @@ func (bi *Bitget) GetUnfilledOrders(ctx context.Context, pair, tpslType string, } // GetHistoricalSpotOrders returns the user's spot order history -func (bi *Bitget) GetHistoricalSpotOrders(ctx context.Context, pair string, startTime, endTime time.Time, limit, pagination, orderID int64) ([]SpotOrderDetailData, error) { +func (bi *Bitget) GetHistoricalSpotOrders(ctx context.Context, pair currency.Pair, startTime, endTime time.Time, limit, pagination, orderID int64) ([]SpotOrderDetailData, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, true, true) if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } @@ -1386,8 +1390,8 @@ func (bi *Bitget) GetHistoricalSpotOrders(ctx context.Context, pair string, star } // GetSpotFills returns information on the user's fulfilled orders in a certain pair -func (bi *Bitget) GetSpotFills(ctx context.Context, pair string, startTime, endTime time.Time, limit, pagination, orderID int64) ([]SpotFillsResp, error) { - if pair == "" { +func (bi *Bitget) GetSpotFills(ctx context.Context, pair currency.Pair, startTime, endTime time.Time, limit, pagination, orderID int64) ([]SpotFillsResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -1396,7 +1400,7 @@ func (bi *Bitget) GetSpotFills(ctx context.Context, pair string, startTime, endT if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } @@ -1412,8 +1416,8 @@ func (bi *Bitget) GetSpotFills(ctx context.Context, pair string, startTime, endT } // PlacePlanSpotOrder sets up an order to be placed after certain conditions are met -func (bi *Bitget) PlacePlanSpotOrder(ctx context.Context, pair, side, orderType, planType, triggerType, clientOrderID, strategy string, triggerPrice, executePrice, amount float64) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) PlacePlanSpotOrder(ctx context.Context, pair currency.Pair, side, orderType, planType, triggerType, clientOrderID, strategy string, triggerPrice, executePrice, amount float64) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if side == "" { @@ -1435,7 +1439,7 @@ func (bi *Bitget) PlacePlanSpotOrder(ctx context.Context, pair, side, orderType, return nil, errTriggerTypeEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "side": side, "triggerPrice": strconv.FormatFloat(triggerPrice, 'f', -1, 64), "orderType": orderType, @@ -1513,8 +1517,8 @@ func (bi *Bitget) CancelPlanSpotOrder(ctx context.Context, orderID int64, client } // GetCurrentSpotPlanOrders returns the user's current plan orders -func (bi *Bitget) GetCurrentSpotPlanOrders(ctx context.Context, pair string, startTime, endTime time.Time, limit, pagination int64) (*PlanSpotOrderResp, error) { - if pair == "" { +func (bi *Bitget) GetCurrentSpotPlanOrders(ctx context.Context, pair currency.Pair, startTime, endTime time.Time, limit, pagination int64) (*PlanSpotOrderResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -1523,7 +1527,7 @@ func (bi *Bitget) GetCurrentSpotPlanOrders(ctx context.Context, pair string, sta if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } @@ -1552,8 +1556,8 @@ func (bi *Bitget) GetSpotPlanSubOrder(ctx context.Context, orderID string) (*Sub } // GetSpotPlanOrderHistory returns the user's plan order history -func (bi *Bitget) GetSpotPlanOrderHistory(ctx context.Context, pair string, startTime, endTime time.Time, limit, pagination int64) (*PlanSpotOrderResp, error) { - if pair == "" { +func (bi *Bitget) GetSpotPlanOrderHistory(ctx context.Context, pair currency.Pair, startTime, endTime time.Time, limit, pagination int64) (*PlanSpotOrderResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -1562,7 +1566,7 @@ func (bi *Bitget) GetSpotPlanOrderHistory(ctx context.Context, pair string, star if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } @@ -1577,10 +1581,10 @@ func (bi *Bitget) GetSpotPlanOrderHistory(ctx context.Context, pair string, star } // BatchCancelSpotPlanOrders cancels all plan orders, with the option to restrict to only those for particular pairs -func (bi *Bitget) BatchCancelSpotPlanOrders(ctx context.Context, pairs []string) (*BatchOrderResp, error) { +func (bi *Bitget) BatchCancelSpotPlanOrders(ctx context.Context, pairs currency.Pairs) (*BatchOrderResp, error) { req := make(map[string]any) if len(pairs) > 0 { - req["symbolList"] = pairs + req["symbolList"] = pairs.Strings() } path := bitgetSpot + bitgetTrade + bitgetBatchCancelPlanOrder var resp *BatchOrderResp @@ -1597,10 +1601,10 @@ func (bi *Bitget) GetAccountInfo(ctx context.Context) (*AccountInfoResp, error) } // GetAccountAssets returns information on the user's assets -func (bi *Bitget) GetAccountAssets(ctx context.Context, currency, assetType string) ([]AssetData, error) { +func (bi *Bitget) GetAccountAssets(ctx context.Context, currency currency.Code, assetType string) ([]AssetData, error) { vals := url.Values{} - if currency != "" { - vals.Set("coin", currency) + if !currency.IsEmpty() { + vals.Set("coin", currency.String()) } vals.Set("type", assetType) path := bitgetSpot + bitgetAccount + bitgetAssets @@ -1620,15 +1624,15 @@ func (bi *Bitget) GetSpotSubaccountAssets(ctx context.Context) ([]SubaccountAsse } // ModifyDepositAccount changes which account is automatically used for deposits of a particular currency -func (bi *Bitget) ModifyDepositAccount(ctx context.Context, accountType, currency string) (*SuccessBool, error) { +func (bi *Bitget) ModifyDepositAccount(ctx context.Context, accountType string, currency currency.Code) (*SuccessBool, error) { if accountType == "" { return nil, errAccountTypeEmpty } - if currency == "" { + if currency.IsEmpty() { return nil, errCurrencyEmpty } req := map[string]any{ - "coin": currency, + "coin": currency.String(), "accountType": accountType, } path := bitgetSpot + bitgetWallet + bitgetModifyDepositAccount @@ -1639,15 +1643,15 @@ func (bi *Bitget) ModifyDepositAccount(ctx context.Context, accountType, currenc } // GetSpotAccountBills returns a section of the user's billing history -func (bi *Bitget) GetSpotAccountBills(ctx context.Context, currency, groupType, businessType string, startTime, endTime time.Time, limit, pagination int64) ([]SpotAccBillResp, error) { +func (bi *Bitget) GetSpotAccountBills(ctx context.Context, currency currency.Code, groupType, businessType string, startTime, endTime time.Time, limit, pagination int64) ([]SpotAccBillResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, true, true) if err != nil { return nil, err } - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } params.Values.Set("groupType", groupType) params.Values.Set("businessType", businessType) @@ -1665,14 +1669,14 @@ func (bi *Bitget) GetSpotAccountBills(ctx context.Context, currency, groupType, } // TransferAsset transfers a certain amount of a currency or pair between different productType accounts -func (bi *Bitget) TransferAsset(ctx context.Context, fromType, toType, currency, pair, clientOrderID string, amount float64) (*TransferResp, error) { +func (bi *Bitget) TransferAsset(ctx context.Context, fromType, toType, clientOrderID string, currency currency.Code, pair currency.Pair, amount float64) (*TransferResp, error) { if fromType == "" { return nil, errFromTypeEmpty } if toType == "" { return nil, errToTypeEmpty } - if currency == "" && pair == "" { + if currency.IsEmpty() && pair.IsEmpty() { return nil, errCurrencyAndPairEmpty } if amount == 0 { @@ -1682,8 +1686,8 @@ func (bi *Bitget) TransferAsset(ctx context.Context, fromType, toType, currency, "fromType": fromType, "toType": toType, "amount": strconv.FormatFloat(amount, 'f', -1, 64), - "coin": currency, - "symbol": pair, + "coin": currency.String(), + "symbol": pair.String(), } if clientOrderID != "" { req["clientOid"] = clientOrderID @@ -1714,14 +1718,14 @@ func (bi *Bitget) GetTransferableCoinList(ctx context.Context, fromType, toType } // SubaccountTransfer transfers assets between sub-accounts -func (bi *Bitget) SubaccountTransfer(ctx context.Context, fromType, toType, currency, pair, clientOrderID, fromID, toID string, amount float64) (*TransferResp, error) { +func (bi *Bitget) SubaccountTransfer(ctx context.Context, fromType, toType, clientOrderID, fromID, toID string, currency currency.Code, pair currency.Pair, amount float64) (*TransferResp, error) { if fromType == "" { return nil, errFromTypeEmpty } if toType == "" { return nil, errToTypeEmpty } - if currency == "" && pair == "" { + if currency.IsEmpty() && pair.IsEmpty() { return nil, errCurrencyAndPairEmpty } if fromID == "" { @@ -1737,8 +1741,8 @@ func (bi *Bitget) SubaccountTransfer(ctx context.Context, fromType, toType, curr "fromType": fromType, "toType": toType, "amount": strconv.FormatFloat(amount, 'f', -1, 64), - "coin": currency, - "symbol": pair, + "coin": currency.String(), + "symbol": pair.String(), "fromId": fromID, "toId": toID, } @@ -1753,8 +1757,8 @@ func (bi *Bitget) SubaccountTransfer(ctx context.Context, fromType, toType, curr } // WithdrawFunds withdraws funds from the user's account -func (bi *Bitget) WithdrawFunds(ctx context.Context, currency, transferType, address, chain, innerAddressType, areaCode, tag, note, clientOrderID string, amount float64) (*OrderIDStruct, error) { - if currency == "" { +func (bi *Bitget) WithdrawFunds(ctx context.Context, currency currency.Code, transferType, address, chain, innerAddressType, areaCode, tag, note, clientOrderID string, amount float64) (*OrderIDStruct, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } if transferType == "" { @@ -1767,7 +1771,7 @@ func (bi *Bitget) WithdrawFunds(ctx context.Context, currency, transferType, add return nil, errAmountEmpty } req := map[string]any{ - "coin": currency, + "coin": currency.String(), "transferType": transferType, "address": address, "chain": chain, @@ -1788,15 +1792,15 @@ func (bi *Bitget) WithdrawFunds(ctx context.Context, currency, transferType, add } // GetSubaccountTransferRecord returns the user's sub-account transfer history -func (bi *Bitget) GetSubaccountTransferRecord(ctx context.Context, currency, subaccountID, clientOrderID string, startTime, endTime time.Time, limit, pagination int64) ([]SubaccTfrRecResp, error) { +func (bi *Bitget) GetSubaccountTransferRecord(ctx context.Context, currency currency.Code, subaccountID, clientOrderID string, startTime, endTime time.Time, limit, pagination int64) ([]SubaccTfrRecResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, true, true) if err != nil { return nil, err } - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } params.Values.Set("subUid", subaccountID) if clientOrderID != "" { @@ -1816,8 +1820,8 @@ func (bi *Bitget) GetSubaccountTransferRecord(ctx context.Context, currency, sub } // GetTransferRecord returns the user's transfer history -func (bi *Bitget) GetTransferRecord(ctx context.Context, currency, fromType, clientOrderID string, startTime, endTime time.Time, limit, pagination int64) ([]TransferRecResp, error) { - if currency == "" { +func (bi *Bitget) GetTransferRecord(ctx context.Context, currency currency.Code, fromType, clientOrderID string, startTime, endTime time.Time, limit, pagination int64) ([]TransferRecResp, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } if fromType == "" { @@ -1829,7 +1833,7 @@ func (bi *Bitget) GetTransferRecord(ctx context.Context, currency, fromType, cli if err != nil { return nil, err } - params.Values.Set("coin", currency) + params.Values.Set("coin", currency.String()) params.Values.Set("fromType", fromType) if clientOrderID != "" { params.Values.Set("clientOid", clientOrderID) @@ -1863,12 +1867,12 @@ func (bi *Bitget) SwitchBGBDeductionStatus(ctx context.Context, deduct bool) (bo } // GetDepositAddressForCurrency returns the user's deposit address for a particular currency -func (bi *Bitget) GetDepositAddressForCurrency(ctx context.Context, currency, chain string) (*DepositAddressResp, error) { - if currency == "" { +func (bi *Bitget) GetDepositAddressForCurrency(ctx context.Context, currency currency.Code, chain string) (*DepositAddressResp, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } vals := url.Values{} - vals.Set("coin", currency) + vals.Set("coin", currency.String()) vals.Set("chain", chain) path := bitgetSpot + bitgetWallet + bitgetDepositAddress var resp struct { @@ -1878,16 +1882,16 @@ func (bi *Bitget) GetDepositAddressForCurrency(ctx context.Context, currency, ch } // GetSubaccountDepositAddress returns the deposit address for a particular currency and sub-account -func (bi *Bitget) GetSubaccountDepositAddress(ctx context.Context, subaccountID, currency, chain string) (*DepositAddressResp, error) { +func (bi *Bitget) GetSubaccountDepositAddress(ctx context.Context, subaccountID, chain string, currency currency.Code) (*DepositAddressResp, error) { if subaccountID == "" { return nil, errSubaccountEmpty } - if currency == "" { + if currency.IsEmpty() { return nil, errCurrencyEmpty } vals := url.Values{} vals.Set("subUid", subaccountID) - vals.Set("coin", currency) + vals.Set("coin", currency.String()) vals.Set("chain", chain) path := bitgetSpot + bitgetWallet + bitgetSubaccountDepositAddress var resp struct { @@ -1921,7 +1925,7 @@ func (bi *Bitget) CancelWithdrawal(ctx context.Context, orderID string) (*Succes } // GetSubaccountDepositRecords returns the deposit history for a sub-account -func (bi *Bitget) GetSubaccountDepositRecords(ctx context.Context, subaccountID, currency string, orderID, pagination, limit int64, startTime, endTime time.Time) ([]SubaccDepRecResp, error) { +func (bi *Bitget) GetSubaccountDepositRecords(ctx context.Context, subaccountID string, currency currency.Code, orderID, pagination, limit int64, startTime, endTime time.Time) ([]SubaccDepRecResp, error) { if subaccountID == "" { return nil, errSubaccountEmpty } @@ -1932,8 +1936,8 @@ func (bi *Bitget) GetSubaccountDepositRecords(ctx context.Context, subaccountID, return nil, err } params.Values.Set("subUid", subaccountID) - if currency != "" { - params.Values.Set("coin", currency) + if currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) if pagination != 0 { @@ -1950,15 +1954,15 @@ func (bi *Bitget) GetSubaccountDepositRecords(ctx context.Context, subaccountID, } // GetWithdrawalRecords returns the user's withdrawal history -func (bi *Bitget) GetWithdrawalRecords(ctx context.Context, currency, clientOrderID string, startTime, endTime time.Time, pagination, orderID, limit int64) ([]WithdrawRecordsResp, error) { +func (bi *Bitget) GetWithdrawalRecords(ctx context.Context, currency currency.Code, clientOrderID string, startTime, endTime time.Time, pagination, orderID, limit int64) ([]WithdrawRecordsResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, false) if err != nil { return nil, err } - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } params.Values.Set("clientOid", clientOrderID) if pagination != 0 { @@ -1976,15 +1980,15 @@ func (bi *Bitget) GetWithdrawalRecords(ctx context.Context, currency, clientOrde } // GetDepositRecords returns the user's cryptocurrency deposit history -func (bi *Bitget) GetDepositRecords(ctx context.Context, crypto string, orderID, pagination, limit int64, startTime, endTime time.Time) ([]CryptoDepRecResp, error) { +func (bi *Bitget) GetDepositRecords(ctx context.Context, crypto currency.Code, orderID, pagination, limit int64, startTime, endTime time.Time) ([]CryptoDepRecResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, false) if err != nil { return nil, err } - if crypto != "" { - params.Values.Set("coin", crypto) + if !crypto.IsEmpty() { + params.Values.Set("coin", crypto.String()) } if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) @@ -2010,15 +2014,15 @@ func (bi *Bitget) GetFuturesVIPFeeRate(ctx context.Context) ([]VIPFeeRateResp, e } // GetFuturesMergeDepth returns part of the orderbook, with options to merge orders of similar price levels together, and to change how many results are returned. Limit's a string instead of the typical int64 because the API will accept a value of "max" -func (bi *Bitget) GetFuturesMergeDepth(ctx context.Context, pair, productType, precision, limit string) (*DepthResp, error) { - if pair == "" { +func (bi *Bitget) GetFuturesMergeDepth(ctx context.Context, pair currency.Pair, productType, precision, limit string) (*DepthResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) vals.Set("precision", precision) vals.Set("limit", limit) @@ -2030,15 +2034,15 @@ func (bi *Bitget) GetFuturesMergeDepth(ctx context.Context, pair, productType, p } // GetFuturesTicker returns the ticker information for a pair of the user's choice -func (bi *Bitget) GetFuturesTicker(ctx context.Context, pair, productType string) ([]FutureTickerResp, error) { - if pair == "" { +func (bi *Bitget) GetFuturesTicker(ctx context.Context, pair currency.Pair, productType string) ([]FutureTickerResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) path := bitgetMix + bitgetMarket + bitgetTicker var resp struct { @@ -2062,15 +2066,15 @@ func (bi *Bitget) GetAllFuturesTickers(ctx context.Context, productType string) } // GetRecentFuturesFills returns the most recent trades for a given pair -func (bi *Bitget) GetRecentFuturesFills(ctx context.Context, pair, productType string, limit int64) ([]MarketFillsResp, error) { - if pair == "" { +func (bi *Bitget) GetRecentFuturesFills(ctx context.Context, pair currency.Pair, productType string, limit int64) ([]MarketFillsResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) if limit != 0 { vals.Set("limit", strconv.FormatInt(limit, 10)) @@ -2083,8 +2087,8 @@ func (bi *Bitget) GetRecentFuturesFills(ctx context.Context, pair, productType s } // GetFuturesMarketTrades returns trades for a given pair within a particular time range, and/or before a certain ID -func (bi *Bitget) GetFuturesMarketTrades(ctx context.Context, pair, productType string, limit, pagination int64, startTime, endTime time.Time) ([]MarketFillsResp, error) { - if pair == "" { +func (bi *Bitget) GetFuturesMarketTrades(ctx context.Context, pair currency.Pair, productType string, limit, pagination int64, startTime, endTime time.Time) ([]MarketFillsResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { @@ -2096,7 +2100,7 @@ func (bi *Bitget) GetFuturesMarketTrades(ctx context.Context, pair, productType if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("productType", productType) if limit != 0 { params.Values.Set("limit", strconv.FormatInt(limit, 10)) @@ -2112,8 +2116,8 @@ func (bi *Bitget) GetFuturesMarketTrades(ctx context.Context, pair, productType } // GetFuturesCandlestickData returns candlestick data for a given pair within a particular time range -func (bi *Bitget) GetFuturesCandlestickData(ctx context.Context, pair, productType, granularity string, startTime, endTime time.Time, limit uint16, mode CallMode) (*CandleData, error) { - if pair == "" { +func (bi *Bitget) GetFuturesCandlestickData(ctx context.Context, pair currency.Pair, productType, granularity string, startTime, endTime time.Time, limit uint16, mode CallMode) (*CandleData, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { @@ -2144,15 +2148,15 @@ func (bi *Bitget) GetFuturesCandlestickData(ctx context.Context, pair, productTy } // GetOpenPositions returns the total positions of a particular pair -func (bi *Bitget) GetOpenPositions(ctx context.Context, pair, productType string) (*OpenPositionsResp, error) { - if pair == "" { +func (bi *Bitget) GetOpenPositions(ctx context.Context, pair currency.Pair, productType string) (*OpenPositionsResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) path := bitgetMix + bitgetMarket + bitgetOpenInterest var resp struct { @@ -2162,15 +2166,15 @@ func (bi *Bitget) GetOpenPositions(ctx context.Context, pair, productType string } // GetNextFundingTime returns the settlement time and period of a particular contract -func (bi *Bitget) GetNextFundingTime(ctx context.Context, pair, productType string) ([]FundingTimeResp, error) { - if pair == "" { +func (bi *Bitget) GetNextFundingTime(ctx context.Context, pair currency.Pair, productType string) ([]FundingTimeResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) path := bitgetMix + bitgetMarket + bitgetFundingTime var resp struct { @@ -2180,15 +2184,15 @@ func (bi *Bitget) GetNextFundingTime(ctx context.Context, pair, productType stri } // GetFuturesPrices returns the current market, index, and mark prices for a given pair -func (bi *Bitget) GetFuturesPrices(ctx context.Context, pair, productType string) ([]FuturesPriceResp, error) { - if pair == "" { +func (bi *Bitget) GetFuturesPrices(ctx context.Context, pair currency.Pair, productType string) ([]FuturesPriceResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) path := bitgetMix + bitgetMarket + bitgetSymbolPrice var resp struct { @@ -2198,15 +2202,15 @@ func (bi *Bitget) GetFuturesPrices(ctx context.Context, pair, productType string } // GetFundingHistorical returns the historical funding rates for a given pair -func (bi *Bitget) GetFundingHistorical(ctx context.Context, pair, productType string, limit, pagination int64) ([]FundingHistoryResp, error) { - if pair == "" { +func (bi *Bitget) GetFundingHistorical(ctx context.Context, pair currency.Pair, productType string, limit, pagination int64) ([]FundingHistoryResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) if limit != 0 { vals.Set("pageSize", strconv.FormatInt(limit, 10)) @@ -2222,15 +2226,15 @@ func (bi *Bitget) GetFundingHistorical(ctx context.Context, pair, productType st } // GetFundingCurrent returns the current funding rate for a given pair -func (bi *Bitget) GetFundingCurrent(ctx context.Context, pair, productType string) ([]FundingCurrentResp, error) { - if pair == "" { +func (bi *Bitget) GetFundingCurrent(ctx context.Context, pair currency.Pair, productType string) ([]FundingCurrentResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) path := bitgetMix + bitgetMarket + bitgetCurrentFundRate var resp struct { @@ -2240,12 +2244,12 @@ func (bi *Bitget) GetFundingCurrent(ctx context.Context, pair, productType strin } // GetContractConfig returns details for a given contract -func (bi *Bitget) GetContractConfig(ctx context.Context, pair, productType string) ([]ContractConfigResp, error) { +func (bi *Bitget) GetContractConfig(ctx context.Context, pair currency.Pair, productType string) ([]ContractConfigResp, error) { if productType == "" { return nil, errProductTypeEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) path := bitgetMix + bitgetMarket + bitgetContracts var resp struct { @@ -2255,20 +2259,20 @@ func (bi *Bitget) GetContractConfig(ctx context.Context, pair, productType strin } // GetOneFuturesAccount returns details for the account associated with a given pair, margin coin, and product type -func (bi *Bitget) GetOneFuturesAccount(ctx context.Context, pair, productType, marginCoin string) (*OneAccResp, error) { - if pair == "" { +func (bi *Bitget) GetOneFuturesAccount(ctx context.Context, pair currency.Pair, productType string, marginCoin currency.Code) (*OneAccResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) - vals.Set("marginCoin", marginCoin) + vals.Set("marginCoin", marginCoin.String()) path := bitgetMix + bitgetAccount + "/" + bitgetAccount var resp struct { OneAccResp `json:"data"` @@ -2305,14 +2309,14 @@ func (bi *Bitget) GetFuturesSubaccountAssets(ctx context.Context, productType st } // GetEstimatedOpenCount returns the estimated size of open orders for a given pair -func (bi *Bitget) GetEstimatedOpenCount(ctx context.Context, pair, productType, marginCoin string, openAmount, openPrice, leverage float64) (float64, error) { - if pair == "" { +func (bi *Bitget) GetEstimatedOpenCount(ctx context.Context, pair currency.Pair, productType string, marginCoin currency.Code, openAmount, openPrice, leverage float64) (float64, error) { + if pair.IsEmpty() { return 0, errPairEmpty } if productType == "" { return 0, errProductTypeEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return 0, errMarginCoinEmpty } if openAmount == 0 { @@ -2322,9 +2326,9 @@ func (bi *Bitget) GetEstimatedOpenCount(ctx context.Context, pair, productType, return 0, errOpenPriceEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) - vals.Set("marginCoin", marginCoin) + vals.Set("marginCoin", marginCoin.String()) vals.Set("openAmount", strconv.FormatFloat(openAmount, 'f', -1, 64)) vals.Set("openPrice", strconv.FormatFloat(openPrice, 'f', -1, 64)) if leverage != 0 { @@ -2340,23 +2344,23 @@ func (bi *Bitget) GetEstimatedOpenCount(ctx context.Context, pair, productType, } // ChangeLeverage changes the leverage for the given pair and product type -func (bi *Bitget) ChangeLeverage(ctx context.Context, pair, productType, marginCoin, holdSide string, leverage float64) (*LeverageResp, error) { - if pair == "" { +func (bi *Bitget) ChangeLeverage(ctx context.Context, pair currency.Pair, productType, holdSide string, marginCoin currency.Code, leverage float64) (*LeverageResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } if leverage == 0 { return nil, errLeverageEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "productType": productType, - "marginCoin": marginCoin, + "marginCoin": marginCoin.String(), "holdSide": holdSide, "leverage": strconv.FormatFloat(leverage, 'f', -1, 64), } @@ -2368,16 +2372,16 @@ func (bi *Bitget) ChangeLeverage(ctx context.Context, pair, productType, marginC } // AdjustIsolatedAutoMargin adjusts the auto margin for a specified isolated margin account -func (bi *Bitget) AdjustIsolatedAutoMargin(ctx context.Context, pair, marginCoin, holdSide string, autoMargin bool, amount float64) error { - if pair == "" { +func (bi *Bitget) AdjustIsolatedAutoMargin(ctx context.Context, pair currency.Pair, marginCoin currency.Code, holdSide string, autoMargin bool, amount float64) error { + if pair.IsEmpty() { return errPairEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return errMarginCoinEmpty } req := map[string]any{ - "symbol": pair, - "marginCoin": marginCoin, + "symbol": pair.String(), + "marginCoin": marginCoin.String(), "holdSide": holdSide, "amount": strconv.FormatFloat(amount, 'f', -1, 64), } @@ -2391,23 +2395,23 @@ func (bi *Bitget) AdjustIsolatedAutoMargin(ctx context.Context, pair, marginCoin } // AdjustMargin adds or subtracts margin from a position -func (bi *Bitget) AdjustMargin(ctx context.Context, pair, productType, marginCoin, holdSide string, amount float64) error { - if pair == "" { +func (bi *Bitget) AdjustMargin(ctx context.Context, pair currency.Pair, productType, holdSide string, marginCoin currency.Code, amount float64) error { + if pair.IsEmpty() { return errPairEmpty } if productType == "" { return errProductTypeEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return errMarginCoinEmpty } if amount == 0 { return errAmountEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "productType": productType, - "marginCoin": marginCoin, + "marginCoin": marginCoin.String(), "amount": strconv.FormatFloat(amount, 'f', -1, 64), } if holdSide != "" { @@ -2418,23 +2422,23 @@ func (bi *Bitget) AdjustMargin(ctx context.Context, pair, productType, marginCoi } // ChangeMarginMode changes the margin mode for a given pair. Can only be done when there the user has no open positions or orders -func (bi *Bitget) ChangeMarginMode(ctx context.Context, pair, productType, marginCoin, marginMode string) (*LeverageResp, error) { - if pair == "" { +func (bi *Bitget) ChangeMarginMode(ctx context.Context, pair currency.Pair, productType, marginMode string, marginCoin currency.Code) (*LeverageResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } if marginMode == "" { return nil, errMarginModeEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "productType": productType, - "marginCoin": marginCoin, + "marginCoin": marginCoin.String(), "marginMode": marginMode, } path := bitgetMix + bitgetAccount + bitgetSetMarginMode @@ -2466,7 +2470,7 @@ func (bi *Bitget) ChangePositionMode(ctx context.Context, productType, positionM } // GetFuturesAccountBills returns a section of the user's billing history -func (bi *Bitget) GetFuturesAccountBills(ctx context.Context, productType, pair, currency, businessType string, pagination, limit int64, startTime, endTime time.Time) ([]FutureAccBillResp, error) { +func (bi *Bitget) GetFuturesAccountBills(ctx context.Context, productType, businessType string, pair currency.Pair, currency currency.Code, pagination, limit int64, startTime, endTime time.Time) ([]FutureAccBillResp, error) { if productType == "" { return nil, errProductTypeEmpty } @@ -2477,9 +2481,9 @@ func (bi *Bitget) GetFuturesAccountBills(ctx context.Context, productType, pair, return nil, err } params.Values.Set("productType", productType) - params.Values.Set("symbol", pair) - if currency != "" { - params.Values.Set("coin", currency) + params.Values.Set("symbol", pair.String()) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } params.Values.Set("businessType", businessType) if pagination != 0 { @@ -2498,16 +2502,16 @@ func (bi *Bitget) GetFuturesAccountBills(ctx context.Context, productType, pair, } // GetPositionTier returns the position configuration for a given pair -func (bi *Bitget) GetPositionTier(ctx context.Context, productType, pair string) ([]PositionTierResp, error) { +func (bi *Bitget) GetPositionTier(ctx context.Context, productType string, pair currency.Pair) ([]PositionTierResp, error) { if productType == "" { return nil, errProductTypeEmpty } - if pair == "" { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} vals.Set("productType", productType) - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetMix + bitgetMarket + bitgetQueryPositionLever var resp struct { PositionTierResp []PositionTierResp `json:"data"` @@ -2516,20 +2520,20 @@ func (bi *Bitget) GetPositionTier(ctx context.Context, productType, pair string) } // GetSinglePosition returns position details for a given productType, pair, and marginCoin. The exchange recommends using the websocket feed instead, as information from this endpoint may be delayed during settlement or market fluctuations -func (bi *Bitget) GetSinglePosition(ctx context.Context, productType, pair, marginCoin string) ([]PositionResp, error) { +func (bi *Bitget) GetSinglePosition(ctx context.Context, productType string, pair currency.Pair, marginCoin currency.Code) ([]PositionResp, error) { if productType == "" { return nil, errProductTypeEmpty } - if pair == "" { + if pair.IsEmpty() { return nil, errPairEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } vals := url.Values{} vals.Set("productType", productType) - vals.Set("symbol", pair) - vals.Set("marginCoin", marginCoin) + vals.Set("symbol", pair.String()) + vals.Set("marginCoin", marginCoin.String()) path := bitgetMix + bitgetPosition + bitgetSinglePosition var resp struct { PositionResp []PositionResp `json:"data"` @@ -2538,16 +2542,16 @@ func (bi *Bitget) GetSinglePosition(ctx context.Context, productType, pair, marg } // GetAllPositions returns position details for a given productType and marginCoin. The exchange recommends using the websocket feed instead, as information from this endpoint may be delayed during settlement or market fluctuations -func (bi *Bitget) GetAllPositions(ctx context.Context, productType, marginCoin string) ([]PositionResp, error) { +func (bi *Bitget) GetAllPositions(ctx context.Context, productType string, marginCoin currency.Code) ([]PositionResp, error) { if productType == "" { return nil, errProductTypeEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } vals := url.Values{} vals.Set("productType", productType) - vals.Set("marginCoin", marginCoin) + vals.Set("marginCoin", marginCoin.String()) path := bitgetMix + bitgetPosition + bitgetAllPositions var resp struct { PositionResp []PositionResp `json:"data"` @@ -2556,16 +2560,15 @@ func (bi *Bitget) GetAllPositions(ctx context.Context, productType, marginCoin s } // GetHistoricalPositions returns historical position details, up to a maximum of three months ago -func (bi *Bitget) GetHistoricalPositions(ctx context.Context, pair, productType string, pagination, limit int64, startTime, endTime time.Time) (*HistPositionResp, error) { +func (bi *Bitget) GetHistoricalPositions(ctx context.Context, pair currency.Pair, productType string, pagination, limit int64, startTime, endTime time.Time) (*HistPositionResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, true, true) if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("productType", productType) - fmt.Printf("pagination %v\n", pagination) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } @@ -2580,8 +2583,8 @@ func (bi *Bitget) GetHistoricalPositions(ctx context.Context, pair, productType } // PlaceFuturesOrder places a futures order on the exchange -func (bi *Bitget) PlaceFuturesOrder(ctx context.Context, pair, productType, marginMode, marginCoin, side, tradeSide, orderType, strategy, clientOID string, stopSurplusPrice, stopLossPrice, amount, price float64, reduceOnly, isCopyTradeLeader bool) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) PlaceFuturesOrder(ctx context.Context, pair currency.Pair, productType, marginMode, side, tradeSide, orderType, strategy, clientOID string, marginCoin currency.Code, stopSurplusPrice, stopLossPrice, amount, price float64, reduceOnly, isCopyTradeLeader bool) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { @@ -2590,7 +2593,7 @@ func (bi *Bitget) PlaceFuturesOrder(ctx context.Context, pair, productType, marg if marginMode == "" { return nil, errMarginModeEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } if side == "" { @@ -2606,10 +2609,10 @@ func (bi *Bitget) PlaceFuturesOrder(ctx context.Context, pair, productType, marg return nil, errLimitPriceEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "productType": productType, "marginMode": marginMode, - "marginCoin": marginCoin, + "marginCoin": marginCoin.String(), "side": side, "tradeSide": tradeSide, "orderType": orderType, @@ -2641,11 +2644,11 @@ func (bi *Bitget) PlaceFuturesOrder(ctx context.Context, pair, productType, marg } // PlaceReversal attempts to close a position, in part or in whole, and opens a position of corresponding size on the opposite side. This operation may only be done in part under certain margin levels, market conditions, or other unspecified factors. If a reversal is attempted for an amount greater than the current outstanding position, that position will be closed, and a new position will be opened for the amount of the closed position; not the amount specified in the request. The side specified in the parameter should correspond to the side of the position you're attempting to close; if the original is open_long, use close_long; if the original is open_short, use close_short; if the original is sell_single, use buy_single. If the position is sell_single or buy_single, the amount parameter will be ignored, and the entire position will be closed, with a corresponding amount opened on the opposite side. -func (bi *Bitget) PlaceReversal(ctx context.Context, pair, marginCoin, productType, side, tradeSide, clientOID string, amount float64, isCopyTradeLeader bool) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) PlaceReversal(ctx context.Context, pair currency.Pair, marginCoin currency.Code, productType, side, tradeSide, clientOID string, amount float64, isCopyTradeLeader bool) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } if productType == "" { @@ -2655,8 +2658,8 @@ func (bi *Bitget) PlaceReversal(ctx context.Context, pair, marginCoin, productTy return nil, errAmountEmpty } req := map[string]any{ - "symbol": pair, - "marginCoin": marginCoin, + "symbol": pair.String(), + "marginCoin": marginCoin.String(), "productType": productType, "side": side, "tradeSide": tradeSide, @@ -2678,14 +2681,14 @@ func (bi *Bitget) PlaceReversal(ctx context.Context, pair, marginCoin, productTy } // BatchPlaceFuturesOrders places multiple orders at once. Can also be used to modify the take-profit and stop-loss of an open position. -func (bi *Bitget) BatchPlaceFuturesOrders(ctx context.Context, pair, productType, marginCoin, marginMode string, orders []PlaceFuturesOrderStruct, isCopyTradeLeader bool) (*BatchOrderResp, error) { - if pair == "" { +func (bi *Bitget) BatchPlaceFuturesOrders(ctx context.Context, pair currency.Pair, productType, marginMode string, marginCoin currency.Code, orders []PlaceFuturesOrderStruct, isCopyTradeLeader bool) (*BatchOrderResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { return nil, errProductTypeEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } if marginMode == "" { @@ -2695,9 +2698,9 @@ func (bi *Bitget) BatchPlaceFuturesOrders(ctx context.Context, pair, productType return nil, errOrdersEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "productType": productType, - "marginCoin": marginCoin, + "marginCoin": marginCoin.String(), "marginMode": marginMode, "orderList": orders, } @@ -2711,11 +2714,11 @@ func (bi *Bitget) BatchPlaceFuturesOrders(ctx context.Context, pair, productType } // ModifyFuturesOrder can change the size, price, take-profit, and stop-loss of an order. Size and price have to be modified at the same time, or the request will fail. If size and price are altered, the old order will be cancelled, and a new one will be created asynchronously. Due to the asynchronous creation of a new order, a new ClientOrderID must be supplied so it can be tracked. -func (bi *Bitget) ModifyFuturesOrder(ctx context.Context, orderID int64, clientOrderID, pair, productType, newClientOrderID string, newAmount, newPrice, newTakeProfit, newStopLoss float64) (*OrderIDStruct, error) { +func (bi *Bitget) ModifyFuturesOrder(ctx context.Context, orderID int64, clientOrderID, productType, newClientOrderID string, pair currency.Pair, newAmount, newPrice, newTakeProfit, newStopLoss float64) (*OrderIDStruct, error) { if orderID == 0 && clientOrderID == "" { return nil, errOrderClientEmpty } - if pair == "" { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { @@ -2725,7 +2728,7 @@ func (bi *Bitget) ModifyFuturesOrder(ctx context.Context, orderID int64, clientO return nil, errNewClientOrderIDEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "productType": productType, "newClientOid": newClientOrderID, "newPresetStopSurplusPrice": strconv.FormatFloat(newTakeProfit, 'f', -1, 64), @@ -2751,8 +2754,8 @@ func (bi *Bitget) ModifyFuturesOrder(ctx context.Context, orderID int64, clientO } // CancelFuturesOrder cancels an order on the exchange -func (bi *Bitget) CancelFuturesOrder(ctx context.Context, pair, productType, marginCoin, clientOrderID string, orderID int64) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) CancelFuturesOrder(ctx context.Context, pair currency.Pair, productType, clientOrderID string, marginCoin currency.Code, orderID int64) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { @@ -2762,7 +2765,7 @@ func (bi *Bitget) CancelFuturesOrder(ctx context.Context, pair, productType, mar return nil, errOrderClientEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "productType": productType, } if clientOrderID != "" { @@ -2771,8 +2774,8 @@ func (bi *Bitget) CancelFuturesOrder(ctx context.Context, pair, productType, mar if orderID != 0 { req["orderId"] = orderID } - if marginCoin != "" { - req["marginCoin"] = marginCoin + if !marginCoin.IsEmpty() { + req["marginCoin"] = marginCoin.String() } path := bitgetMix + bitgetOrder + bitgetCancelOrder var resp struct { @@ -2782,17 +2785,17 @@ func (bi *Bitget) CancelFuturesOrder(ctx context.Context, pair, productType, mar } // BatchCancelFuturesOrders cancels multiple orders at once -func (bi *Bitget) BatchCancelFuturesOrders(ctx context.Context, orderIDs []OrderIDStruct, pair, productType, marginCoin string) (*BatchOrderResp, error) { +func (bi *Bitget) BatchCancelFuturesOrders(ctx context.Context, orderIDs []OrderIDStruct, pair currency.Pair, productType string, marginCoin currency.Code) (*BatchOrderResp, error) { if productType == "" { return nil, errProductTypeEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "productType": productType, "orderList": orderIDs, } - if marginCoin != "" { - req["marginCoin"] = marginCoin + if marginCoin.IsEmpty() { + req["marginCoin"] = marginCoin.String() } path := bitgetMix + bitgetOrder + bitgetBatchCancelOrders var resp *BatchOrderResp @@ -2800,12 +2803,12 @@ func (bi *Bitget) BatchCancelFuturesOrders(ctx context.Context, orderIDs []Order } // FlashClosePosition attempts to close a position at the best available price -func (bi *Bitget) FlashClosePosition(ctx context.Context, pair, holdSide, productType string) (*BatchOrderResp, error) { +func (bi *Bitget) FlashClosePosition(ctx context.Context, pair currency.Pair, holdSide, productType string) (*BatchOrderResp, error) { if productType == "" { return nil, errProductTypeEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "holdSide": holdSide, "productType": productType, } @@ -2815,8 +2818,8 @@ func (bi *Bitget) FlashClosePosition(ctx context.Context, pair, holdSide, produc } // GetFuturesOrderDetails returns details on a given order -func (bi *Bitget) GetFuturesOrderDetails(ctx context.Context, pair, productType, clientOrderID string, orderID int64) (*FuturesOrderDetailResp, error) { - if pair == "" { +func (bi *Bitget) GetFuturesOrderDetails(ctx context.Context, pair currency.Pair, productType, clientOrderID string, orderID int64) (*FuturesOrderDetailResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { @@ -2826,7 +2829,7 @@ func (bi *Bitget) GetFuturesOrderDetails(ctx context.Context, pair, productType, return nil, errOrderClientEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) vals.Set("productType", productType) if clientOrderID != "" { vals.Set("clientOid", clientOrderID) @@ -2840,7 +2843,7 @@ func (bi *Bitget) GetFuturesOrderDetails(ctx context.Context, pair, productType, } // GetFuturesFills returns fill details -func (bi *Bitget) GetFuturesFills(ctx context.Context, orderID, pagination, limit int64, pair, productType string, startTime, endTime time.Time) (*FuturesFillsResp, error) { +func (bi *Bitget) GetFuturesFills(ctx context.Context, orderID, pagination, limit int64, pair currency.Pair, productType string, startTime, endTime time.Time) (*FuturesFillsResp, error) { if productType == "" { return nil, errProductTypeEmpty } @@ -2852,6 +2855,7 @@ func (bi *Bitget) GetFuturesFills(ctx context.Context, orderID, pagination, limi } params.Values.Set("productType", productType) params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) + params.Values.Set("symbol", pair.String()) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } @@ -2866,7 +2870,7 @@ func (bi *Bitget) GetFuturesFills(ctx context.Context, orderID, pagination, limi } // GetFuturesOrderFillHistory returns historical fill details -func (bi *Bitget) GetFuturesOrderFillHistory(ctx context.Context, pair, productType string, orderID, pagination, limit int64, startTime, endTime time.Time) (*FuturesFillsResp, error) { +func (bi *Bitget) GetFuturesOrderFillHistory(ctx context.Context, pair currency.Pair, productType string, orderID, pagination, limit int64, startTime, endTime time.Time) (*FuturesFillsResp, error) { if productType == "" { return nil, errProductTypeEmpty } @@ -2876,7 +2880,7 @@ func (bi *Bitget) GetFuturesOrderFillHistory(ctx context.Context, pair, productT if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("productType", productType) if orderID != 0 { params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) @@ -2895,7 +2899,7 @@ func (bi *Bitget) GetFuturesOrderFillHistory(ctx context.Context, pair, productT } // GetPendingFuturesOrders returns detailed information on pending futures orders -func (bi *Bitget) GetPendingFuturesOrders(ctx context.Context, orderID, pagination, limit int64, clientOrderID, pair, productType, status string, startTime, endTime time.Time) (*FuturesOrdResp, error) { +func (bi *Bitget) GetPendingFuturesOrders(ctx context.Context, orderID, pagination, limit int64, clientOrderID, productType, status string, pair currency.Pair, startTime, endTime time.Time) (*FuturesOrdResp, error) { if productType == "" { return nil, errProductTypeEmpty } @@ -2911,6 +2915,7 @@ func (bi *Bitget) GetPendingFuturesOrders(ctx context.Context, orderID, paginati } params.Values.Set("clientOid", clientOrderID) params.Values.Set("status", status) + params.Values.Set("symbol", pair.String()) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } @@ -2925,7 +2930,7 @@ func (bi *Bitget) GetPendingFuturesOrders(ctx context.Context, orderID, paginati } // GetHistoricalFuturesOrders returns information on futures orders that are no longer pending -func (bi *Bitget) GetHistoricalFuturesOrders(ctx context.Context, orderID, pagination, limit int64, clientOrderID, pair, productType string, startTime, endTime time.Time) (*FuturesOrdResp, error) { +func (bi *Bitget) GetHistoricalFuturesOrders(ctx context.Context, orderID, pagination, limit int64, clientOrderID, productType string, pair currency.Pair, startTime, endTime time.Time) (*FuturesOrdResp, error) { if productType == "" { return nil, errProductTypeEmpty } @@ -2935,7 +2940,7 @@ func (bi *Bitget) GetHistoricalFuturesOrders(ctx context.Context, orderID, pagin if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("productType", productType) if orderID != 0 { params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) @@ -2955,18 +2960,18 @@ func (bi *Bitget) GetHistoricalFuturesOrders(ctx context.Context, orderID, pagin } // CancelAllFuturesOrders cancels all pending orders -func (bi *Bitget) CancelAllFuturesOrders(ctx context.Context, pair, productType, marginCoin string, acceptableDelay time.Duration) (*BatchOrderResp, error) { +func (bi *Bitget) CancelAllFuturesOrders(ctx context.Context, pair currency.Pair, productType string, marginCoin currency.Code, acceptableDelay time.Duration) (*BatchOrderResp, error) { if productType == "" { return nil, errProductTypeEmpty } req := map[string]any{ "productType": productType, - "symbol": pair, + "symbol": pair.String(), "requestTime": time.Now().UnixMilli(), "receiveWindow": time.Unix(0, 0).Add(acceptableDelay).UnixMilli(), } - if marginCoin != "" { - req["marginCoin"] = marginCoin + if !marginCoin.IsEmpty() { + req["marginCoin"] = marginCoin.String() } path := bitgetMix + bitgetOrder + bitgetCancelAllOrders var resp *BatchOrderResp @@ -2996,14 +3001,14 @@ func (bi *Bitget) GetFuturesTriggerOrderByID(ctx context.Context, planType, prod } // PlaceTPSLFuturesOrder places a take-profit or stop-loss futures order -func (bi *Bitget) PlaceTPSLFuturesOrder(ctx context.Context, marginCoin, productType, pair, planType, triggerType, holdSide, rangeRate, clientOrderID string, triggerPrice, executePrice, amount float64) (*OrderIDStruct, error) { - if marginCoin == "" { +func (bi *Bitget) PlaceTPSLFuturesOrder(ctx context.Context, marginCoin currency.Code, productType, planType, triggerType, holdSide, rangeRate, clientOrderID string, pair currency.Pair, triggerPrice, executePrice, amount float64) (*OrderIDStruct, error) { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } if productType == "" { return nil, errProductTypeEmpty } - if pair == "" { + if pair.IsEmpty() { return nil, errPairEmpty } if planType == "" { @@ -3019,9 +3024,9 @@ func (bi *Bitget) PlaceTPSLFuturesOrder(ctx context.Context, marginCoin, product return nil, errAmountEmpty } req := map[string]any{ - "marginCoin": marginCoin, + "marginCoin": marginCoin.String(), "productType": productType, - "symbol": pair, + "symbol": pair.String(), "planType": planType, "triggerType": triggerType, "holdSide": holdSide, @@ -3041,11 +3046,11 @@ func (bi *Bitget) PlaceTPSLFuturesOrder(ctx context.Context, marginCoin, product } // PlaceTriggerFuturesOrder places a trigger futures order -func (bi *Bitget) PlaceTriggerFuturesOrder(ctx context.Context, planType, pair, productType, marginMode, marginCoin, triggerType, side, tradeSide, orderType, clientOrderID, takeProfitTriggerType, stopLossTriggerType string, amount, executePrice, callbackRatio, triggerPrice, takeProfitTriggerPrice, takeProfitExecutePrice, stopLossTriggerPrice, stopLossExecutePrice float64, reduceOnly bool) (*OrderIDStruct, error) { +func (bi *Bitget) PlaceTriggerFuturesOrder(ctx context.Context, planType, productType, marginMode, triggerType, side, tradeSide, orderType, clientOrderID, takeProfitTriggerType, stopLossTriggerType string, pair currency.Pair, marginCoin currency.Code, amount, executePrice, callbackRatio, triggerPrice, takeProfitTriggerPrice, takeProfitExecutePrice, stopLossTriggerPrice, stopLossExecutePrice float64, reduceOnly bool) (*OrderIDStruct, error) { if planType == "" { return nil, errPlanTypeEmpty } - if pair == "" { + if pair.IsEmpty() { return nil, errPairEmpty } if productType == "" { @@ -3054,7 +3059,7 @@ func (bi *Bitget) PlaceTriggerFuturesOrder(ctx context.Context, planType, pair, if marginMode == "" { return nil, errMarginModeEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } if triggerType == "" { @@ -3083,10 +3088,10 @@ func (bi *Bitget) PlaceTriggerFuturesOrder(ctx context.Context, planType, pair, } req := map[string]any{ "planType": planType, - "symbol": pair, + "symbol": pair.String(), "productType": productType, "marginMode": marginMode, - "marginCoin": marginCoin, + "marginCoin": marginCoin.String(), "triggerType": triggerType, "side": side, "tradeSide": tradeSide, @@ -3120,17 +3125,17 @@ func (bi *Bitget) PlaceTriggerFuturesOrder(ctx context.Context, planType, pair, } // ModifyTPSLFuturesOrder modifies a take-profit or stop-loss futures order -func (bi *Bitget) ModifyTPSLFuturesOrder(ctx context.Context, orderID int64, clientOrderID, marginCoin, productType, pair, triggerType string, triggerPrice, executePrice, amount, rangeRate float64) (*OrderIDStruct, error) { +func (bi *Bitget) ModifyTPSLFuturesOrder(ctx context.Context, orderID int64, clientOrderID, productType, triggerType string, marginCoin currency.Code, pair currency.Pair, triggerPrice, executePrice, amount, rangeRate float64) (*OrderIDStruct, error) { if orderID == 0 && clientOrderID == "" { return nil, errOrderClientEmpty } - if marginCoin == "" { + if marginCoin.IsEmpty() { return nil, errMarginCoinEmpty } if productType == "" { return nil, errProductTypeEmpty } - if pair == "" { + if pair.IsEmpty() { return nil, errPairEmpty } if triggerPrice == 0 { @@ -3142,9 +3147,9 @@ func (bi *Bitget) ModifyTPSLFuturesOrder(ctx context.Context, orderID int64, cli req := map[string]any{ "orderId": orderID, "clientOid": clientOrderID, - "marginCoin": marginCoin, + "marginCoin": marginCoin.String(), "productType": productType, - "symbol": pair, + "symbol": pair.String(), "triggerType": triggerType, "triggerPrice": strconv.FormatFloat(triggerPrice, 'f', -1, 64), "executePrice": strconv.FormatFloat(executePrice, 'f', -1, 64), @@ -3202,7 +3207,7 @@ func (bi *Bitget) ModifyTriggerFuturesOrder(ctx context.Context, orderID int64, } // GetPendingTriggerFuturesOrders returns information on pending trigger orders -func (bi *Bitget) GetPendingTriggerFuturesOrders(ctx context.Context, orderID, pagination, limit int64, clientOrderID, pair, planType, productType string, startTime, endTime time.Time) (*PlanFuturesOrdResp, error) { +func (bi *Bitget) GetPendingTriggerFuturesOrders(ctx context.Context, orderID, pagination, limit int64, clientOrderID, planType, productType string, pair currency.Pair, startTime, endTime time.Time) (*PlanFuturesOrdResp, error) { if planType == "" { return nil, errPlanTypeEmpty } @@ -3215,7 +3220,7 @@ func (bi *Bitget) GetPendingTriggerFuturesOrders(ctx context.Context, orderID, p if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("planType", planType) params.Values.Set("productType", productType) if orderID != 0 { @@ -3236,16 +3241,16 @@ func (bi *Bitget) GetPendingTriggerFuturesOrders(ctx context.Context, orderID, p } // CancelTriggerFuturesOrders cancels trigger futures orders -func (bi *Bitget) CancelTriggerFuturesOrders(ctx context.Context, orderIDList []OrderIDStruct, pair, productType, marginCoin, planType string) (*BatchOrderResp, error) { +func (bi *Bitget) CancelTriggerFuturesOrders(ctx context.Context, orderIDList []OrderIDStruct, pair currency.Pair, productType, planType string, marginCoin currency.Code) (*BatchOrderResp, error) { if productType == "" { return nil, errProductTypeEmpty } req := map[string]any{ "productType": productType, "planType": planType, - "symbol": pair, + "symbol": pair.String(), "orderIdList": orderIDList, - "marginCoin": marginCoin, + "marginCoin": marginCoin.String(), } path := bitgetMix + bitgetOrder + bitgetCancelPlanOrder var resp *BatchOrderResp @@ -3253,7 +3258,7 @@ func (bi *Bitget) CancelTriggerFuturesOrders(ctx context.Context, orderIDList [] } // GetHistoricalTriggerFuturesOrders returns information on historical trigger orders -func (bi *Bitget) GetHistoricalTriggerFuturesOrders(ctx context.Context, orderID, pagination, limit int64, clientOrderID, planType, planStatus, pair, productType string, startTime, endTime time.Time) (*HistTriggerFuturesOrdResp, error) { +func (bi *Bitget) GetHistoricalTriggerFuturesOrders(ctx context.Context, orderID, pagination, limit int64, clientOrderID, planType, planStatus, productType string, pair currency.Pair, startTime, endTime time.Time) (*HistTriggerFuturesOrdResp, error) { if planType == "" { return nil, errPlanTypeEmpty } @@ -3266,7 +3271,7 @@ func (bi *Bitget) GetHistoricalTriggerFuturesOrders(ctx context.Context, orderID if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("planType", planType) params.Values.Set("productType", productType) params.Values.Set("planStatus", planStatus) @@ -3297,7 +3302,7 @@ func (bi *Bitget) GetSupportedCurrencies(ctx context.Context) ([]SupCurrencyResp } // GetCrossBorrowHistory returns the borrowing history for cross margin -func (bi *Bitget) GetCrossBorrowHistory(ctx context.Context, loanID, limit, pagination int64, currency string, startTime, endTime time.Time) (*BorrowHistCross, error) { +func (bi *Bitget) GetCrossBorrowHistory(ctx context.Context, loanID, limit, pagination int64, currency currency.Code, startTime, endTime time.Time) (*BorrowHistCross, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, true) @@ -3313,8 +3318,8 @@ func (bi *Bitget) GetCrossBorrowHistory(ctx context.Context, loanID, limit, pagi if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } path := bitgetMargin + bitgetCrossed + bitgetBorrowHistory var resp struct { @@ -3324,7 +3329,7 @@ func (bi *Bitget) GetCrossBorrowHistory(ctx context.Context, loanID, limit, pagi } // GetCrossRepayHistory returns the repayment history for cross margin -func (bi *Bitget) GetCrossRepayHistory(ctx context.Context, repayID, limit, pagination int64, currency string, startTime, endTime time.Time) (*RepayHistResp, error) { +func (bi *Bitget) GetCrossRepayHistory(ctx context.Context, repayID, limit, pagination int64, currency currency.Code, startTime, endTime time.Time) (*RepayHistResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, true) @@ -3340,8 +3345,8 @@ func (bi *Bitget) GetCrossRepayHistory(ctx context.Context, repayID, limit, pagi if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } path := bitgetMargin + bitgetCrossed + bitgetRepayHistory var resp struct { @@ -3351,7 +3356,7 @@ func (bi *Bitget) GetCrossRepayHistory(ctx context.Context, repayID, limit, pagi } // GetCrossInterestHistory returns the interest history for cross margin -func (bi *Bitget) GetCrossInterestHistory(ctx context.Context, currency string, startTime, endTime time.Time, limit, pagination int64) (*InterHistCross, error) { +func (bi *Bitget) GetCrossInterestHistory(ctx context.Context, currency currency.Code, startTime, endTime time.Time, limit, pagination int64) (*InterHistCross, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, true) @@ -3364,8 +3369,8 @@ func (bi *Bitget) GetCrossInterestHistory(ctx context.Context, currency string, if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } path := bitgetMargin + bitgetCrossed + bitgetInterestHistory var resp struct { @@ -3396,7 +3401,7 @@ func (bi *Bitget) GetCrossLiquidationHistory(ctx context.Context, startTime, end } // GetCrossFinancialHistory returns the financial history for cross margin -func (bi *Bitget) GetCrossFinancialHistory(ctx context.Context, marginType, currency string, startTime, endTime time.Time, limit, pagination int64) (*FinHistCrossResp, error) { +func (bi *Bitget) GetCrossFinancialHistory(ctx context.Context, marginType string, currency currency.Code, startTime, endTime time.Time, limit, pagination int64) (*FinHistCrossResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, true) @@ -3410,8 +3415,8 @@ func (bi *Bitget) GetCrossFinancialHistory(ctx context.Context, marginType, curr params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } params.Values.Set("marginType", marginType) - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } path := bitgetMargin + bitgetCrossed + bitgetFinancialRecords var resp struct { @@ -3421,10 +3426,10 @@ func (bi *Bitget) GetCrossFinancialHistory(ctx context.Context, marginType, curr } // GetCrossAccountAssets returns the account assets for cross margin -func (bi *Bitget) GetCrossAccountAssets(ctx context.Context, currency string) ([]CrossAssetResp, error) { +func (bi *Bitget) GetCrossAccountAssets(ctx context.Context, currency currency.Code) ([]CrossAssetResp, error) { vals := url.Values{} - if currency != "" { - vals.Set("coin", currency) + if !currency.IsEmpty() { + vals.Set("coin", currency.String()) } path := bitgetMargin + bitgetCrossed + "/" + bitgetAccount + bitgetAssets var resp struct { @@ -3434,15 +3439,15 @@ func (bi *Bitget) GetCrossAccountAssets(ctx context.Context, currency string) ([ } // CrossBorrow borrows funds for cross margin -func (bi *Bitget) CrossBorrow(ctx context.Context, currency, clientOrderID string, amount float64) (*BorrowCross, error) { - if currency == "" { +func (bi *Bitget) CrossBorrow(ctx context.Context, currency currency.Code, clientOrderID string, amount float64) (*BorrowCross, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } if amount == 0 { return nil, errAmountEmpty } req := map[string]any{ - "coin": currency, + "coin": currency.String(), "borrowAmount": strconv.FormatFloat(amount, 'f', -1, 64), "clientOid": clientOrderID, } @@ -3454,15 +3459,15 @@ func (bi *Bitget) CrossBorrow(ctx context.Context, currency, clientOrderID strin } // CrossRepay repays funds for cross margin -func (bi *Bitget) CrossRepay(ctx context.Context, currency string, amount float64) (*RepayCross, error) { - if currency == "" { +func (bi *Bitget) CrossRepay(ctx context.Context, currency currency.Code, amount float64) (*RepayCross, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } if amount == 0 { return nil, errAmountEmpty } req := map[string]any{ - "coin": currency, + "coin": currency.String(), "repayAmount": strconv.FormatFloat(amount, 'f', -1, 64), } path := bitgetMargin + bitgetCrossed + "/" + bitgetAccount + bitgetRepay @@ -3484,12 +3489,12 @@ func (bi *Bitget) GetCrossRiskRate(ctx context.Context) (float64, error) { } // GetCrossMaxBorrowable returns the maximum amount that can be borrowed for cross margin -func (bi *Bitget) GetCrossMaxBorrowable(ctx context.Context, currency string) (*MaxBorrowCross, error) { - if currency == "" { +func (bi *Bitget) GetCrossMaxBorrowable(ctx context.Context, currency currency.Code) (*MaxBorrowCross, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } vals := url.Values{} - vals.Set("coin", currency) + vals.Set("coin", currency.String()) path := bitgetMargin + bitgetCrossed + "/" + bitgetAccount + bitgetMaxBorrowableAmount var resp struct { MaxBorrowCross `json:"data"` @@ -3498,12 +3503,12 @@ func (bi *Bitget) GetCrossMaxBorrowable(ctx context.Context, currency string) (* } // GetCrossMaxTransferable returns the maximum amount that can be transferred out of cross margin -func (bi *Bitget) GetCrossMaxTransferable(ctx context.Context, currency string) (*MaxTransferCross, error) { - if currency == "" { +func (bi *Bitget) GetCrossMaxTransferable(ctx context.Context, currency currency.Code) (*MaxTransferCross, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } vals := url.Values{} - vals.Set("coin", currency) + vals.Set("coin", currency.String()) path := bitgetMargin + bitgetCrossed + "/" + bitgetAccount + bitgetMaxTransferOutAmount var resp struct { MaxTransferCross `json:"data"` @@ -3512,12 +3517,12 @@ func (bi *Bitget) GetCrossMaxTransferable(ctx context.Context, currency string) } // GetCrossInterestRateAndMaxBorrowable returns the interest rate and maximum borrowable amount for cross margin -func (bi *Bitget) GetCrossInterestRateAndMaxBorrowable(ctx context.Context, currency string) ([]IntRateMaxBorrowCross, error) { - if currency == "" { +func (bi *Bitget) GetCrossInterestRateAndMaxBorrowable(ctx context.Context, currency currency.Code) ([]IntRateMaxBorrowCross, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } vals := url.Values{} - vals.Set("coin", currency) + vals.Set("coin", currency.String()) path := bitgetMargin + bitgetCrossed + bitgetInterestRateAndLimit var resp struct { IntRateMaxBorrowCross []IntRateMaxBorrowCross `json:"data"` @@ -3526,12 +3531,12 @@ func (bi *Bitget) GetCrossInterestRateAndMaxBorrowable(ctx context.Context, curr } // GetCrossTierConfiguration returns tier information for the user's VIP level -func (bi *Bitget) GetCrossTierConfiguration(ctx context.Context, currency string) ([]TierConfigCross, error) { - if currency == "" { +func (bi *Bitget) GetCrossTierConfiguration(ctx context.Context, currency currency.Code) ([]TierConfigCross, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } vals := url.Values{} - vals.Set("coin", currency) + vals.Set("coin", currency.String()) path := bitgetMargin + bitgetCrossed + bitgetTierData var resp struct { TierConfigCross []TierConfigCross `json:"data"` @@ -3540,9 +3545,9 @@ func (bi *Bitget) GetCrossTierConfiguration(ctx context.Context, currency string } // CrossFlashRepay repays funds for cross margin, with the option to only repay for a particular currency -func (bi *Bitget) CrossFlashRepay(ctx context.Context, currency string) (*FlashRepayCross, error) { +func (bi *Bitget) CrossFlashRepay(ctx context.Context, currency currency.Code) (*FlashRepayCross, error) { req := map[string]any{ - "coin": currency, + "coin": currency.String(), } path := bitgetMargin + bitgetCrossed + "/" + bitgetAccount + bitgetFlashRepay var resp struct { @@ -3567,8 +3572,8 @@ func (bi *Bitget) GetCrossFlashRepayResult(ctx context.Context, idList []int64) } // PlaceCrossOrder places an order using cross margin -func (bi *Bitget) PlaceCrossOrder(ctx context.Context, pair, orderType, loanType, strategy, clientOrderID, side string, price, baseAmount, quoteAmount float64) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) PlaceCrossOrder(ctx context.Context, pair currency.Pair, orderType, loanType, strategy, clientOrderID, side string, price, baseAmount, quoteAmount float64) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if orderType == "" { @@ -3587,7 +3592,7 @@ func (bi *Bitget) PlaceCrossOrder(ctx context.Context, pair, orderType, loanType return nil, errAmountEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "orderType": orderType, "loanType": loanType, "force": strategy, @@ -3609,15 +3614,15 @@ func (bi *Bitget) PlaceCrossOrder(ctx context.Context, pair, orderType, loanType } // BatchPlaceCrossOrders places multiple orders using cross margin -func (bi *Bitget) BatchPlaceCrossOrders(ctx context.Context, pair string, orders []MarginOrderData) (*BatchOrderResp, error) { - if pair == "" { +func (bi *Bitget) BatchPlaceCrossOrders(ctx context.Context, pair currency.Pair, orders []MarginOrderData) (*BatchOrderResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if len(orders) == 0 { return nil, errOrdersEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "orderList": orders, } path := bitgetMargin + bitgetCrossed + bitgetBatchPlaceOrder @@ -3626,15 +3631,15 @@ func (bi *Bitget) BatchPlaceCrossOrders(ctx context.Context, pair string, orders } // CancelCrossOrder cancels an order using cross margin -func (bi *Bitget) CancelCrossOrder(ctx context.Context, pair, clientOrderID string, orderID int64) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) CancelCrossOrder(ctx context.Context, pair currency.Pair, clientOrderID string, orderID int64) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if clientOrderID == "" && orderID == 0 { return nil, errOrderClientEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), } if clientOrderID != "" { req["clientOid"] = clientOrderID @@ -3650,15 +3655,15 @@ func (bi *Bitget) CancelCrossOrder(ctx context.Context, pair, clientOrderID stri } // BatchCancelCrossOrders cancels multiple orders using cross margin -func (bi *Bitget) BatchCancelCrossOrders(ctx context.Context, pair string, orders []OrderIDStruct) (*BatchOrderResp, error) { - if pair == "" { +func (bi *Bitget) BatchCancelCrossOrders(ctx context.Context, pair currency.Pair, orders []OrderIDStruct) (*BatchOrderResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if len(orders) == 0 { return nil, errOrdersEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "orderList": orders, } path := bitgetMargin + bitgetCrossed + bitgetBatchCancelOrder @@ -3667,8 +3672,8 @@ func (bi *Bitget) BatchCancelCrossOrders(ctx context.Context, pair string, order } // GetCrossOpenOrders returns the open orders for cross margin -func (bi *Bitget) GetCrossOpenOrders(ctx context.Context, pair, clientOrderID string, orderID, limit, pagination int64, startTime, endTime time.Time) (*MarginOpenOrds, error) { - if pair == "" { +func (bi *Bitget) GetCrossOpenOrders(ctx context.Context, pair currency.Pair, clientOrderID string, orderID, limit, pagination int64, startTime, endTime time.Time) (*MarginOpenOrds, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -3677,7 +3682,7 @@ func (bi *Bitget) GetCrossOpenOrders(ctx context.Context, pair, clientOrderID st if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("clientOid", clientOrderID) if orderID != 0 { params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) @@ -3696,8 +3701,8 @@ func (bi *Bitget) GetCrossOpenOrders(ctx context.Context, pair, clientOrderID st } // GetCrossHistoricalOrders returns the historical orders for cross margin -func (bi *Bitget) GetCrossHistoricalOrders(ctx context.Context, pair, enterPointSource, clientOrderID string, orderID, limit, pagination int64, startTime, endTime time.Time) (*MarginHistOrds, error) { - if pair == "" { +func (bi *Bitget) GetCrossHistoricalOrders(ctx context.Context, pair currency.Pair, enterPointSource, clientOrderID string, orderID, limit, pagination int64, startTime, endTime time.Time) (*MarginHistOrds, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -3706,7 +3711,7 @@ func (bi *Bitget) GetCrossHistoricalOrders(ctx context.Context, pair, enterPoint if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("enterPointSource", enterPointSource) params.Values.Set("clientOid", clientOrderID) if orderID != 0 { @@ -3726,8 +3731,8 @@ func (bi *Bitget) GetCrossHistoricalOrders(ctx context.Context, pair, enterPoint } // GetCrossOrderFills returns the fills for cross margin orders -func (bi *Bitget) GetCrossOrderFills(ctx context.Context, pair string, orderID, pagination, limit int64, startTime, endTime time.Time) (*MarginOrderFills, error) { - if pair == "" { +func (bi *Bitget) GetCrossOrderFills(ctx context.Context, pair currency.Pair, orderID, pagination, limit int64, startTime, endTime time.Time) (*MarginOrderFills, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -3736,7 +3741,7 @@ func (bi *Bitget) GetCrossOrderFills(ctx context.Context, pair string, orderID, if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) if orderID != 0 { params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) } @@ -3754,7 +3759,7 @@ func (bi *Bitget) GetCrossOrderFills(ctx context.Context, pair string, orderID, } // GetCrossLiquidationOrders returns the liquidation orders for cross margin -func (bi *Bitget) GetCrossLiquidationOrders(ctx context.Context, orderType, pair, fromCoin, toCoin string, startTime, endTime time.Time, limit, pagination int64) (*LiquidationResp, error) { +func (bi *Bitget) GetCrossLiquidationOrders(ctx context.Context, orderType, fromCoin, toCoin string, pair currency.Pair, startTime, endTime time.Time, limit, pagination int64) (*LiquidationResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, true, true) @@ -3762,7 +3767,7 @@ func (bi *Bitget) GetCrossLiquidationOrders(ctx context.Context, orderType, pair return nil, err } params.Values.Set("orderType", orderType) - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("fromCoin", fromCoin) params.Values.Set("toCoin", toCoin) if limit != 0 { @@ -3779,8 +3784,8 @@ func (bi *Bitget) GetCrossLiquidationOrders(ctx context.Context, orderType, pair } // GetIsolatedRepayHistory returns the repayment history for isolated margin -func (bi *Bitget) GetIsolatedRepayHistory(ctx context.Context, pair, currency string, repayID, limit, pagination int64, startTime, endTime time.Time) (*RepayHistResp, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedRepayHistory(ctx context.Context, pair currency.Pair, currency string, repayID, limit, pagination int64, startTime, endTime time.Time) (*RepayHistResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -3798,7 +3803,7 @@ func (bi *Bitget) GetIsolatedRepayHistory(ctx context.Context, pair, currency st if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) if currency != "" { params.Values.Set("coin", currency) } @@ -3810,8 +3815,8 @@ func (bi *Bitget) GetIsolatedRepayHistory(ctx context.Context, pair, currency st } // GetIsolatedBorrowHistory returns the borrowing history for isolated margin -func (bi *Bitget) GetIsolatedBorrowHistory(ctx context.Context, pair, currency string, loanID, limit, pagination int64, startTime, endTime time.Time) (*BorrowHistIso, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedBorrowHistory(ctx context.Context, pair currency.Pair, currency string, loanID, limit, pagination int64, startTime, endTime time.Time) (*BorrowHistIso, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -3829,7 +3834,7 @@ func (bi *Bitget) GetIsolatedBorrowHistory(ctx context.Context, pair, currency s if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) if currency != "" { params.Values.Set("coin", currency) } @@ -3841,8 +3846,8 @@ func (bi *Bitget) GetIsolatedBorrowHistory(ctx context.Context, pair, currency s } // GetIsolatedInterestHistory returns the interest history for isolated margin -func (bi *Bitget) GetIsolatedInterestHistory(ctx context.Context, pair, currency string, startTime, endTime time.Time, limit, pagination int64) (*InterHistIso, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedInterestHistory(ctx context.Context, pair currency.Pair, currency currency.Code, startTime, endTime time.Time, limit, pagination int64) (*InterHistIso, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -3857,9 +3862,9 @@ func (bi *Bitget) GetIsolatedInterestHistory(ctx context.Context, pair, currency if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - params.Values.Set("symbol", pair) - if currency != "" { - params.Values.Set("coin", currency) + params.Values.Set("symbol", pair.String()) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } path := bitgetMargin + bitgetIsolated + bitgetInterestHistory var resp struct { @@ -3869,8 +3874,8 @@ func (bi *Bitget) GetIsolatedInterestHistory(ctx context.Context, pair, currency } // GetIsolatedLiquidationHistory returns the liquidation history for isolated margin -func (bi *Bitget) GetIsolatedLiquidationHistory(ctx context.Context, pair string, startTime, endTime time.Time, limit, pagination int64) (*LiquidHistIso, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedLiquidationHistory(ctx context.Context, pair currency.Pair, startTime, endTime time.Time, limit, pagination int64) (*LiquidHistIso, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -3885,7 +3890,7 @@ func (bi *Bitget) GetIsolatedLiquidationHistory(ctx context.Context, pair string if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) path := bitgetMargin + bitgetIsolated + bitgetLiquidationHistory var resp struct { LiquidHistIso `json:"data"` @@ -3894,8 +3899,8 @@ func (bi *Bitget) GetIsolatedLiquidationHistory(ctx context.Context, pair string } // GetIsolatedFinancialHistory returns the financial history for isolated margin -func (bi *Bitget) GetIsolatedFinancialHistory(ctx context.Context, pair, marginType, currency string, startTime, endTime time.Time, limit, pagination int64) (*FinHistIsoResp, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedFinancialHistory(ctx context.Context, pair currency.Pair, marginType string, currency currency.Code, startTime, endTime time.Time, limit, pagination int64) (*FinHistIsoResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -3910,10 +3915,10 @@ func (bi *Bitget) GetIsolatedFinancialHistory(ctx context.Context, pair, marginT if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("marginType", marginType) - if currency != "" { - params.Values.Set("coin", currency) + if !currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } path := bitgetMargin + bitgetIsolated + bitgetFinancialRecords var resp struct { @@ -3923,9 +3928,9 @@ func (bi *Bitget) GetIsolatedFinancialHistory(ctx context.Context, pair, marginT } // GetIsolatedAccountAssets returns the account assets for isolated margin -func (bi *Bitget) GetIsolatedAccountAssets(ctx context.Context, pair string) ([]IsoAssetResp, error) { +func (bi *Bitget) GetIsolatedAccountAssets(ctx context.Context, pair currency.Pair) ([]IsoAssetResp, error) { vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetMargin + bitgetIsolated + "/" + bitgetAccount + bitgetAssets var resp struct { IsoAssetResp []IsoAssetResp `json:"data"` @@ -3934,19 +3939,19 @@ func (bi *Bitget) GetIsolatedAccountAssets(ctx context.Context, pair string) ([] } // IsolatedBorrow borrows funds for isolated margin -func (bi *Bitget) IsolatedBorrow(ctx context.Context, pair, currency, clientOrderID string, amount float64) (*BorrowIso, error) { - if pair == "" { +func (bi *Bitget) IsolatedBorrow(ctx context.Context, pair currency.Pair, currency currency.Code, clientOrderID string, amount float64) (*BorrowIso, error) { + if pair.IsEmpty() { return nil, errPairEmpty } - if currency == "" { + if currency.IsEmpty() { return nil, errCurrencyEmpty } if amount == 0 { return nil, errAmountEmpty } req := map[string]any{ - "symbol": pair, - "coin": currency, + "symbol": pair.String(), + "coin": currency.String(), "borrowAmount": strconv.FormatFloat(amount, 'f', -1, 64), "clientOid": clientOrderID, } @@ -3958,20 +3963,20 @@ func (bi *Bitget) IsolatedBorrow(ctx context.Context, pair, currency, clientOrde } // IsolatedRepay repays funds for isolated margin -func (bi *Bitget) IsolatedRepay(ctx context.Context, amount float64, currency, pair, clientOrderID string) (*RepayIso, error) { +func (bi *Bitget) IsolatedRepay(ctx context.Context, amount float64, currency currency.Code, pair currency.Pair, clientOrderID string) (*RepayIso, error) { if amount == 0 { return nil, errAmountEmpty } - if currency == "" { + if currency.IsEmpty() { return nil, errCurrencyEmpty } - if pair == "" { + if pair.IsEmpty() { return nil, errPairEmpty } req := map[string]any{ - "coin": currency, + "coin": currency.String(), "repayAmount": strconv.FormatFloat(amount, 'f', -1, 64), - "symbol": pair, + "symbol": pair.String(), "clientOid": clientOrderID, } path := bitgetMargin + bitgetIsolated + "/" + bitgetAccount + bitgetRepay @@ -3982,9 +3987,9 @@ func (bi *Bitget) IsolatedRepay(ctx context.Context, amount float64, currency, p } // GetIsolatedRiskRate returns the risk rate for isolated margin -func (bi *Bitget) GetIsolatedRiskRate(ctx context.Context, pair string, pagination, limit int64) ([]RiskRateIso, error) { +func (bi *Bitget) GetIsolatedRiskRate(ctx context.Context, pair currency.Pair, pagination, limit int64) ([]RiskRateIso, error) { vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) if limit != 0 { vals.Set("pageSize", strconv.FormatInt(limit, 10)) } @@ -3999,12 +4004,12 @@ func (bi *Bitget) GetIsolatedRiskRate(ctx context.Context, pair string, paginati } // GetIsolatedInterestRateAndMaxBorrowable returns the interest rate and maximum borrowable amount for isolated margin -func (bi *Bitget) GetIsolatedInterestRateAndMaxBorrowable(ctx context.Context, pair string) ([]IntRateMaxBorrowIso, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedInterestRateAndMaxBorrowable(ctx context.Context, pair currency.Pair) ([]IntRateMaxBorrowIso, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetMargin + bitgetIsolated + bitgetInterestRateAndLimit var resp struct { IntRateMaxBorrowIso []IntRateMaxBorrowIso `json:"data"` @@ -4013,12 +4018,12 @@ func (bi *Bitget) GetIsolatedInterestRateAndMaxBorrowable(ctx context.Context, p } // GetIsolatedTierConfiguration returns tier information for the user's VIP level -func (bi *Bitget) GetIsolatedTierConfiguration(ctx context.Context, pair string) ([]TierConfigIso, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedTierConfiguration(ctx context.Context, pair currency.Pair) ([]TierConfigIso, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetMargin + bitgetIsolated + bitgetTierData var resp struct { TierConfigIso []TierConfigIso `json:"data"` @@ -4027,12 +4032,12 @@ func (bi *Bitget) GetIsolatedTierConfiguration(ctx context.Context, pair string) } // GetIsolatedMaxBorrowable returns the maximum amount that can be borrowed for isolated margin -func (bi *Bitget) GetIsolatedMaxBorrowable(ctx context.Context, pair string) (*MaxBorrowIso, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedMaxBorrowable(ctx context.Context, pair currency.Pair) (*MaxBorrowIso, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetMargin + bitgetIsolated + "/" + bitgetAccount + bitgetMaxBorrowableAmount var resp struct { MaxBorrowIso `json:"data"` @@ -4041,12 +4046,12 @@ func (bi *Bitget) GetIsolatedMaxBorrowable(ctx context.Context, pair string) (*M } // GetIsolatedMaxTransferable returns the maximum amount that can be transferred out of isolated margin -func (bi *Bitget) GetIsolatedMaxTransferable(ctx context.Context, pair string) (*MaxTransferIso, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedMaxTransferable(ctx context.Context, pair currency.Pair) (*MaxTransferIso, error) { + if pair.IsEmpty() { return nil, errPairEmpty } vals := url.Values{} - vals.Set("symbol", pair) + vals.Set("symbol", pair.String()) path := bitgetMargin + bitgetIsolated + "/" + bitgetAccount + bitgetMaxTransferOutAmount var resp struct { MaxTransferIso `json:"data"` @@ -4055,9 +4060,9 @@ func (bi *Bitget) GetIsolatedMaxTransferable(ctx context.Context, pair string) ( } // IsolatedFlashRepay repays funds for isolated margin, with the option to only repay for a set of up to 100 pairs -func (bi *Bitget) IsolatedFlashRepay(ctx context.Context, pairs []string) ([]FlashRepayIso, error) { +func (bi *Bitget) IsolatedFlashRepay(ctx context.Context, pairs currency.Pairs) ([]FlashRepayIso, error) { req := map[string]any{ - "symbolList": pairs, + "symbolList": pairs.Strings(), } path := bitgetMargin + bitgetIsolated + "/" + bitgetAccount + bitgetFlashRepay var resp struct { @@ -4082,8 +4087,8 @@ func (bi *Bitget) GetIsolatedFlashRepayResult(ctx context.Context, idList []int6 } // PlaceIsolatedOrder places an order using isolated margin -func (bi *Bitget) PlaceIsolatedOrder(ctx context.Context, pair, orderType, loanType, strategy, clientOrderID, side string, price, baseAmount, quoteAmount float64) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) PlaceIsolatedOrder(ctx context.Context, pair currency.Pair, orderType, loanType, strategy, clientOrderID, side string, price, baseAmount, quoteAmount float64) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if orderType == "" { @@ -4102,7 +4107,7 @@ func (bi *Bitget) PlaceIsolatedOrder(ctx context.Context, pair, orderType, loanT return nil, errAmountEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "orderType": orderType, "loanType": loanType, "force": strategy, @@ -4124,15 +4129,15 @@ func (bi *Bitget) PlaceIsolatedOrder(ctx context.Context, pair, orderType, loanT } // BatchPlaceIsolatedOrders places multiple orders using isolated margin -func (bi *Bitget) BatchPlaceIsolatedOrders(ctx context.Context, pair string, orders []MarginOrderData) (*BatchOrderResp, error) { - if pair == "" { +func (bi *Bitget) BatchPlaceIsolatedOrders(ctx context.Context, pair currency.Pair, orders []MarginOrderData) (*BatchOrderResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if len(orders) == 0 { return nil, errOrdersEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "orderList": orders, } path := bitgetMargin + bitgetIsolated + bitgetBatchPlaceOrder @@ -4141,15 +4146,15 @@ func (bi *Bitget) BatchPlaceIsolatedOrders(ctx context.Context, pair string, ord } // CancelIsolatedOrder cancels an order using isolated margin -func (bi *Bitget) CancelIsolatedOrder(ctx context.Context, pair, clientOrderID string, orderID int64) (*OrderIDStruct, error) { - if pair == "" { +func (bi *Bitget) CancelIsolatedOrder(ctx context.Context, pair currency.Pair, clientOrderID string, orderID int64) (*OrderIDStruct, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if clientOrderID == "" && orderID == 0 { return nil, errOrderClientEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), } if clientOrderID != "" { req["clientOid"] = clientOrderID @@ -4165,15 +4170,15 @@ func (bi *Bitget) CancelIsolatedOrder(ctx context.Context, pair, clientOrderID s } // BatchCancelIsolatedOrders cancels multiple orders using isolated margin -func (bi *Bitget) BatchCancelIsolatedOrders(ctx context.Context, pair string, orders []OrderIDStruct) (*BatchOrderResp, error) { - if pair == "" { +func (bi *Bitget) BatchCancelIsolatedOrders(ctx context.Context, pair currency.Pair, orders []OrderIDStruct) (*BatchOrderResp, error) { + if pair.IsEmpty() { return nil, errPairEmpty } if len(orders) == 0 { return nil, errOrdersEmpty } req := map[string]any{ - "symbol": pair, + "symbol": pair.String(), "orderList": orders, } path := bitgetMargin + bitgetIsolated + bitgetBatchCancelOrder @@ -4182,8 +4187,8 @@ func (bi *Bitget) BatchCancelIsolatedOrders(ctx context.Context, pair string, or } // GetIsolatedOpenOrders returns the open orders for isolated margin -func (bi *Bitget) GetIsolatedOpenOrders(ctx context.Context, pair, clientOrderID string, orderID, limit, pagination int64, startTime, endTime time.Time) (*MarginOpenOrds, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedOpenOrders(ctx context.Context, pair currency.Pair, clientOrderID string, orderID, limit, pagination int64, startTime, endTime time.Time) (*MarginOpenOrds, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -4192,7 +4197,7 @@ func (bi *Bitget) GetIsolatedOpenOrders(ctx context.Context, pair, clientOrderID if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("clientOid", clientOrderID) if orderID != 0 { params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) @@ -4211,8 +4216,8 @@ func (bi *Bitget) GetIsolatedOpenOrders(ctx context.Context, pair, clientOrderID } // GetIsolatedHistoricalOrders returns the historical orders for isolated margin -func (bi *Bitget) GetIsolatedHistoricalOrders(ctx context.Context, pair, enterPointSource, clientOrderID string, orderID, limit, pagination int64, startTime, endTime time.Time) (*MarginHistOrds, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedHistoricalOrders(ctx context.Context, pair currency.Pair, enterPointSource, clientOrderID string, orderID, limit, pagination int64, startTime, endTime time.Time) (*MarginHistOrds, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -4221,7 +4226,7 @@ func (bi *Bitget) GetIsolatedHistoricalOrders(ctx context.Context, pair, enterPo if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("enterPointSource", enterPointSource) params.Values.Set("clientOid", clientOrderID) if orderID != 0 { @@ -4241,8 +4246,8 @@ func (bi *Bitget) GetIsolatedHistoricalOrders(ctx context.Context, pair, enterPo } // GetIsolatedOrderFills returns the fills for isolated margin orders -func (bi *Bitget) GetIsolatedOrderFills(ctx context.Context, pair string, orderID, pagination, limit int64, startTime, endTime time.Time) (*MarginOrderFills, error) { - if pair == "" { +func (bi *Bitget) GetIsolatedOrderFills(ctx context.Context, pair currency.Pair, orderID, pagination, limit int64, startTime, endTime time.Time) (*MarginOrderFills, error) { + if pair.IsEmpty() { return nil, errPairEmpty } var params Params @@ -4251,7 +4256,7 @@ func (bi *Bitget) GetIsolatedOrderFills(ctx context.Context, pair string, orderI if err != nil { return nil, err } - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) if orderID != 0 { params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) } @@ -4269,7 +4274,7 @@ func (bi *Bitget) GetIsolatedOrderFills(ctx context.Context, pair string, orderI } // GetIsolatedLiquidationOrders returns the liquidation orders for isolated margin -func (bi *Bitget) GetIsolatedLiquidationOrders(ctx context.Context, orderType, pair, fromCoin, toCoin string, startTime, endTime time.Time, limit, pagination int64) (*LiquidationResp, error) { +func (bi *Bitget) GetIsolatedLiquidationOrders(ctx context.Context, orderType, fromCoin, toCoin string, pair currency.Pair, startTime, endTime time.Time, limit, pagination int64) (*LiquidationResp, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, true, true) @@ -4277,7 +4282,7 @@ func (bi *Bitget) GetIsolatedLiquidationOrders(ctx context.Context, orderType, p return nil, err } params.Values.Set("orderType", orderType) - params.Values.Set("symbol", pair) + params.Values.Set("symbol", pair.String()) params.Values.Set("fromCoin", fromCoin) params.Values.Set("toCoin", toCoin) if limit != 0 { @@ -4294,12 +4299,12 @@ func (bi *Bitget) GetIsolatedLiquidationOrders(ctx context.Context, orderType, p } // GetSavingsProductList returns the list of savings products for a particular currency -func (bi *Bitget) GetSavingsProductList(ctx context.Context, currency, filter string) ([]SavingsProductList, error) { - if currency == "" { +func (bi *Bitget) GetSavingsProductList(ctx context.Context, currency currency.Code, filter string) ([]SavingsProductList, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } vals := url.Values{} - vals.Set("coin", currency) + vals.Set("coin", currency.String()) vals.Set("filter", filter) path := bitgetEarn + bitgetSavings + bitgetProduct var resp struct { @@ -4340,7 +4345,7 @@ func (bi *Bitget) GetSavingsAssets(ctx context.Context, periodType string, start } // GetSavingsRecords returns information on transactions performed over the last three months -func (bi *Bitget) GetSavingsRecords(ctx context.Context, currency, periodType, orderType string, startTime, endTime time.Time, limit, pagination int64) (*SavingsRecords, error) { +func (bi *Bitget) GetSavingsRecords(ctx context.Context, currency currency.Code, periodType, orderType string, startTime, endTime time.Time, limit, pagination int64) (*SavingsRecords, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, true, true) @@ -4353,8 +4358,8 @@ func (bi *Bitget) GetSavingsRecords(ctx context.Context, currency, periodType, o if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - if currency != "" { - params.Values.Set("coin", currency) + if currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } params.Values.Set("periodType", periodType) params.Values.Set("orderType", orderType) @@ -4467,10 +4472,10 @@ func (bi *Bitget) GetSavingsRedemptionResult(ctx context.Context, orderID int64, } // GetEarnAccountAssets returns the assets in the earn account -func (bi *Bitget) GetEarnAccountAssets(ctx context.Context, currency string) ([]EarnAssets, error) { +func (bi *Bitget) GetEarnAccountAssets(ctx context.Context, currency currency.Code) ([]EarnAssets, error) { vals := url.Values{} - if currency != "" { - vals.Set("coin", currency) + if currency.IsEmpty() { + vals.Set("coin", currency.String()) } path := bitgetEarn + bitgetAccount + bitgetAssets var resp struct { @@ -4480,12 +4485,12 @@ func (bi *Bitget) GetEarnAccountAssets(ctx context.Context, currency string) ([] } // GetSharkFinProducts returns information on Shark Fin products -func (bi *Bitget) GetSharkFinProducts(ctx context.Context, currency string, limit, pagination int64) (*SharkFinProductResp, error) { - if currency == "" { +func (bi *Bitget) GetSharkFinProducts(ctx context.Context, currency currency.Code, limit, pagination int64) (*SharkFinProductResp, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } vals := url.Values{} - vals.Set("coin", currency) + vals.Set("coin", currency.String()) if limit != 0 { vals.Set("limit", strconv.FormatInt(limit, 10)) } @@ -4531,7 +4536,7 @@ func (bi *Bitget) GetSharkFinAssets(ctx context.Context, status string, startTim } // GetSharkFinRecords returns information on transactions performed over the last three months for Shark Fin products -func (bi *Bitget) GetSharkFinRecords(ctx context.Context, currency, transactionType string, startTime, endTime time.Time, limit, pagination int64) ([]SharkFinRecords, error) { +func (bi *Bitget) GetSharkFinRecords(ctx context.Context, currency currency.Code, transactionType string, startTime, endTime time.Time, limit, pagination int64) ([]SharkFinRecords, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, true, true) @@ -4544,8 +4549,8 @@ func (bi *Bitget) GetSharkFinRecords(ctx context.Context, currency, transactionT if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } - if currency != "" { - params.Values.Set("coin", currency) + if currency.IsEmpty() { + params.Values.Set("coin", currency.String()) } params.Values.Set("type", transactionType) path := bitgetEarn + bitgetSharkFin + bitgetRecords @@ -4605,12 +4610,12 @@ func (bi *Bitget) GetSharkFinSubscriptionResult(ctx context.Context, orderID int } // GetLoanCurrencyList returns the list of currencies available for loan -func (bi *Bitget) GetLoanCurrencyList(ctx context.Context, currency string) (*LoanCurList, error) { - if currency == "" { +func (bi *Bitget) GetLoanCurrencyList(ctx context.Context, currency currency.Code) (*LoanCurList, error) { + if currency.IsEmpty() { return nil, errCurrencyEmpty } vals := url.Values{} - vals.Set("coin", currency) + vals.Set("coin", currency.String()) path := bitgetEarn + bitgetLoan + "/" + bitgetPublic + bitgetCoinInfos var resp struct { LoanCurList `json:"data"` @@ -4619,11 +4624,11 @@ func (bi *Bitget) GetLoanCurrencyList(ctx context.Context, currency string) (*Lo } // GetEstimatedInterestAndBorrowable returns the estimated interest and borrowable amount for a currency -func (bi *Bitget) GetEstimatedInterestAndBorrowable(ctx context.Context, loanCoin, collateralCoin, term string, collateralAmount float64) (*EstimateInterest, error) { - if loanCoin == "" { +func (bi *Bitget) GetEstimatedInterestAndBorrowable(ctx context.Context, loanCoin, collateralCoin currency.Code, term string, collateralAmount float64) (*EstimateInterest, error) { + if loanCoin.IsEmpty() { return nil, errLoanCoinEmpty } - if collateralCoin == "" { + if collateralCoin.IsEmpty() { return nil, errCollateralCoinEmpty } if term == "" { @@ -4633,8 +4638,8 @@ func (bi *Bitget) GetEstimatedInterestAndBorrowable(ctx context.Context, loanCoi return nil, errCollateralAmountEmpty } vals := url.Values{} - vals.Set("loanCoin", loanCoin) - vals.Set("pledgeCoin", collateralCoin) + vals.Set("loanCoin", loanCoin.String()) + vals.Set("pledgeCoin", collateralCoin.String()) vals.Set("daily", term) vals.Set("pledgeAmount", strconv.FormatFloat(collateralAmount, 'f', -1, 64)) path := bitgetEarn + bitgetLoan + "/" + bitgetPublic + bitgetHourInterest @@ -4645,11 +4650,11 @@ func (bi *Bitget) GetEstimatedInterestAndBorrowable(ctx context.Context, loanCoi } // BorrowFunds borrows funds for a currency, supplying a certain amount of currency as collateral -func (bi *Bitget) BorrowFunds(ctx context.Context, loanCoin, collateralCoin, term string, collateralAmount, loanAmount float64) (*BorrowResp, error) { - if loanCoin == "" { +func (bi *Bitget) BorrowFunds(ctx context.Context, loanCoin, collateralCoin currency.Code, term string, collateralAmount, loanAmount float64) (*BorrowResp, error) { + if loanCoin.IsEmpty() { return nil, errLoanCoinEmpty } - if collateralCoin == "" { + if collateralCoin.IsEmpty() { return nil, errCollateralCoinEmpty } if term == "" { @@ -4659,8 +4664,8 @@ func (bi *Bitget) BorrowFunds(ctx context.Context, loanCoin, collateralCoin, ter return nil, errCollateralLoanMutex } req := map[string]any{ - "loanCoin": loanCoin, - "pledgeCoin": collateralCoin, + "loanCoin": loanCoin.String(), + "pledgeCoin": collateralCoin.String(), "daily": term, "pledgeAmount": strconv.FormatFloat(collateralAmount, 'f', -1, 64), "loanAmount": strconv.FormatFloat(loanAmount, 'f', -1, 64), @@ -4673,13 +4678,13 @@ func (bi *Bitget) BorrowFunds(ctx context.Context, loanCoin, collateralCoin, ter } // GetOngoingLoans returns the ongoing loans, optionally filtered by currency -func (bi *Bitget) GetOngoingLoans(ctx context.Context, orderID int64, loanCoin, collateralCoin string) ([]OngoingLoans, error) { +func (bi *Bitget) GetOngoingLoans(ctx context.Context, orderID int64, loanCoin, collateralCoin currency.Code) ([]OngoingLoans, error) { vals := url.Values{} if orderID != 0 { vals.Set("orderId", strconv.FormatInt(orderID, 10)) } - vals.Set("loanCoin", loanCoin) - vals.Set("pledgeCoin", collateralCoin) + vals.Set("loanCoin", loanCoin.String()) + vals.Set("pledgeCoin", collateralCoin.String()) path := bitgetEarn + bitgetLoan + bitgetOngoingOrders var resp struct { OngoingLoans []OngoingLoans `json:"data"` @@ -4717,7 +4722,7 @@ func (bi *Bitget) RepayLoan(ctx context.Context, orderID int64, amount float64, } // GetLoanRepayHistory returns the repayment records for a loan -func (bi *Bitget) GetLoanRepayHistory(ctx context.Context, orderID, pagination, limit int64, loanCoin, pledgeCoin string, startTime, endTime time.Time) ([]RepayRecords, error) { +func (bi *Bitget) GetLoanRepayHistory(ctx context.Context, orderID, pagination, limit int64, loanCoin, pledgeCoin currency.Code, startTime, endTime time.Time) ([]RepayRecords, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, false) @@ -4725,8 +4730,8 @@ func (bi *Bitget) GetLoanRepayHistory(ctx context.Context, orderID, pagination, return nil, err } params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) - params.Values.Set("loanCoin", loanCoin) - params.Values.Set("pledgeCoin", pledgeCoin) + params.Values.Set("loanCoin", loanCoin.String()) + params.Values.Set("pledgeCoin", pledgeCoin.String()) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } @@ -4741,14 +4746,14 @@ func (bi *Bitget) GetLoanRepayHistory(ctx context.Context, orderID, pagination, } // ModifyPledgeRate modifies the amount of collateral pledged for a loan -func (bi *Bitget) ModifyPledgeRate(ctx context.Context, orderID int64, amount float64, pledgeCoin, reviseType string) (*ModPledgeResp, error) { +func (bi *Bitget) ModifyPledgeRate(ctx context.Context, orderID int64, amount float64, pledgeCoin currency.Code, reviseType string) (*ModPledgeResp, error) { if orderID == 0 { return nil, errOrderIDEmpty } if amount == 0 { return nil, errAmountEmpty } - if pledgeCoin == "" { + if pledgeCoin.IsEmpty() { return nil, errCollateralCoinEmpty } if reviseType == "" { @@ -4757,7 +4762,7 @@ func (bi *Bitget) ModifyPledgeRate(ctx context.Context, orderID int64, amount fl req := map[string]any{ "orderId": orderID, "amount": strconv.FormatFloat(amount, 'f', -1, 64), - "pledgeCoin": pledgeCoin, + "pledgeCoin": pledgeCoin.String(), "reviseType": reviseType, } path := bitgetEarn + bitgetLoan + bitgetRevisePledge @@ -4768,7 +4773,7 @@ func (bi *Bitget) ModifyPledgeRate(ctx context.Context, orderID int64, amount fl } // GetPledgeRateHistory returns the history of pledged rates for loans -func (bi *Bitget) GetPledgeRateHistory(ctx context.Context, orderID, pagination, limit int64, reviseSide, pledgeCoin string, startTime, endTime time.Time) ([]PledgeRateHist, error) { +func (bi *Bitget) GetPledgeRateHistory(ctx context.Context, orderID, pagination, limit int64, reviseSide string, pledgeCoin currency.Code, startTime, endTime time.Time) ([]PledgeRateHist, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, false) @@ -4777,7 +4782,7 @@ func (bi *Bitget) GetPledgeRateHistory(ctx context.Context, orderID, pagination, } params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) params.Values.Set("reviseSide", reviseSide) - params.Values.Set("pledgeCoin", pledgeCoin) + params.Values.Set("pledgeCoin", pledgeCoin.String()) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) } @@ -4792,7 +4797,7 @@ func (bi *Bitget) GetPledgeRateHistory(ctx context.Context, orderID, pagination, } // GetLoanHistory returns the loan history -func (bi *Bitget) GetLoanHistory(ctx context.Context, orderID, pagination, limit int64, loanCoin, pledgeCoin, status string, startTime, endTime time.Time) ([]LoanHistory, error) { +func (bi *Bitget) GetLoanHistory(ctx context.Context, orderID, pagination, limit int64, loanCoin, pledgeCoin currency.Code, status string, startTime, endTime time.Time) ([]LoanHistory, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, false) @@ -4800,8 +4805,8 @@ func (bi *Bitget) GetLoanHistory(ctx context.Context, orderID, pagination, limit return nil, err } params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) - params.Values.Set("loanCoin", loanCoin) - params.Values.Set("pledgeCoin", pledgeCoin) + params.Values.Set("loanCoin", loanCoin.String()) + params.Values.Set("pledgeCoin", pledgeCoin.String()) params.Values.Set("status", status) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) @@ -4826,7 +4831,7 @@ func (bi *Bitget) GetDebts(ctx context.Context) (*DebtsResp, error) { } // GetLiquidationRecords returns the liquidation records -func (bi *Bitget) GetLiquidationRecords(ctx context.Context, orderID, pagination, limit int64, loanCoin, pledgeCoin, status string, startTime, endTime time.Time) ([]LiquidRecs, error) { +func (bi *Bitget) GetLiquidationRecords(ctx context.Context, orderID, pagination, limit int64, loanCoin, pledgeCoin currency.Code, status string, startTime, endTime time.Time) ([]LiquidRecs, error) { var params Params params.Values = make(url.Values) err := params.prepareDateString(startTime, endTime, false, false) @@ -4834,8 +4839,8 @@ func (bi *Bitget) GetLiquidationRecords(ctx context.Context, orderID, pagination return nil, err } params.Values.Set("orderId", strconv.FormatInt(orderID, 10)) - params.Values.Set("loanCoin", loanCoin) - params.Values.Set("pledgeCoin", pledgeCoin) + params.Values.Set("loanCoin", loanCoin.String()) + params.Values.Set("pledgeCoin", pledgeCoin.String()) params.Values.Set("status", status) if pagination != 0 { params.Values.Set("idLessThan", strconv.FormatInt(pagination, 10)) @@ -5073,8 +5078,8 @@ func (e *EmptyInt) MarshalJSON() ([]byte, error) { } // CandlestickHelper pulls out common candlestick functionality to avoid repetition -func (bi *Bitget) candlestickHelper(ctx context.Context, pair, granularity, path string, limit uint16, params Params) (*CandleData, error) { - params.Values.Set("symbol", pair) +func (bi *Bitget) candlestickHelper(ctx context.Context, pair currency.Pair, granularity, path string, limit uint16, params Params) (*CandleData, error) { + params.Values.Set("symbol", pair.String()) params.Values.Set("granularity", granularity) if limit != 0 { params.Values.Set("limit", strconv.FormatUint(uint64(limit), 10)) diff --git a/exchanges/bitget/bitget_test.go b/exchanges/bitget/bitget_test.go index 02acd20a6bf..7a2c96bac72 100644 --- a/exchanges/bitget/bitget_test.go +++ b/exchanges/bitget/bitget_test.go @@ -154,51 +154,51 @@ func TestGetTime(t *testing.T) { func TestGetTradeRate(t *testing.T) { t.Parallel() - _, err := bi.GetTradeRate(context.Background(), "", "") + _, err := bi.GetTradeRate(context.Background(), currency.Pair{}, "") assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetTradeRate(context.Background(), testPair.String(), "") + _, err = bi.GetTradeRate(context.Background(), testPair, "") assert.ErrorIs(t, err, errBusinessTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetTradeRate(context.Background(), testPair.String(), "spot") + resp, err := bi.GetTradeRate(context.Background(), testPair, "spot") require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetSpotTransactionRecords(t *testing.T) { t.Parallel() - _, err := bi.GetSpotTransactionRecords(context.Background(), "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetSpotTransactionRecords(context.Background(), currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSpotTransactionRecords(context.Background(), "", time.Now().Add(-time.Hour*24*30), time.Now(), 5, 1<<62) + _, err = bi.GetSpotTransactionRecords(context.Background(), currency.Code{}, time.Now().Add(-time.Hour*24*30), time.Now(), 5, 1<<62) assert.NoError(t, err) } func TestGetFuturesTransactionRecords(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesTransactionRecords(context.Background(), "", "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetFuturesTransactionRecords(context.Background(), "", currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetFuturesTransactionRecords(context.Background(), "woof", "", time.Time{}, time.Time{}, 0, 0) + _, err = bi.GetFuturesTransactionRecords(context.Background(), "woof", currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetFuturesTransactionRecords(context.Background(), "COIN-FUTURES", "", time.Now().Add(-time.Hour*24*30), time.Now(), 5, 1<<62) + _, err = bi.GetFuturesTransactionRecords(context.Background(), "COIN-FUTURES", currency.Code{}, time.Now().Add(-time.Hour*24*30), time.Now(), 5, 1<<62) assert.NoError(t, err) } func TestGetMarginTransactionRecords(t *testing.T) { t.Parallel() - _, err := bi.GetMarginTransactionRecords(context.Background(), "", "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetMarginTransactionRecords(context.Background(), "", currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetMarginTransactionRecords(context.Background(), "", "", time.Now().Add(-time.Hour*24*30), time.Now(), 5, 1<<62) + _, err = bi.GetMarginTransactionRecords(context.Background(), "", currency.Code{}, time.Now().Add(-time.Hour*24*30), time.Now(), 5, 1<<62) assert.NoError(t, err) } func TestGetP2PTransactionRecords(t *testing.T) { t.Parallel() - _, err := bi.GetP2PTransactionRecords(context.Background(), "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetP2PTransactionRecords(context.Background(), currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetP2PTransactionRecords(context.Background(), "", time.Now().Add(-time.Hour*24*30), time.Now(), 5, 1<<62) + _, err = bi.GetP2PTransactionRecords(context.Background(), currency.Code{}, time.Now().Add(-time.Hour*24*30), time.Now(), 5, 1<<62) assert.NoError(t, err) } @@ -217,85 +217,85 @@ func TestGetMerchantInfo(t *testing.T) { func TestGetMerchantP2POrders(t *testing.T) { t.Parallel() - _, err := bi.GetMerchantP2POrders(context.Background(), time.Time{}, time.Time{}, 0, 0, 0, 0, "", "", "", "") + _, err := bi.GetMerchantP2POrders(context.Background(), time.Time{}, time.Time{}, 0, 0, 0, 0, "", "", currency.Code{}, currency.Code{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) // Can't currently be properly tested due to not knowing any p2p order IDs - _, err = bi.GetMerchantP2POrders(context.Background(), time.Now().Add(-time.Hour*24*7), time.Now(), 5, 0, 0, 0, "", "", "", "") + _, err = bi.GetMerchantP2POrders(context.Background(), time.Now().Add(-time.Hour*24*7), time.Now(), 5, 0, 0, 0, "", "", currency.Code{}, currency.Code{}) assert.NoError(t, err) } func TestGetMerchantAdvertisementList(t *testing.T) { t.Parallel() - _, err := bi.GetMerchantAdvertisementList(context.Background(), time.Time{}, time.Time{}, 0, 0, 0, 0, "", "", "", "", "", "") + _, err := bi.GetMerchantAdvertisementList(context.Background(), time.Time{}, time.Time{}, 0, 0, 0, 0, "", "", "", "", currency.Code{}, currency.Code{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetMerchantAdvertisementList(context.Background(), time.Now().Add(-time.Hour*24*7), time.Now(), 5, 1<<62, 0, 0, "", "sell", "USDT", "", "", "") + _, err = bi.GetMerchantAdvertisementList(context.Background(), time.Now().Add(-time.Hour*24*7), time.Now(), 5, 1<<62, 0, 0, "", "sell", "USDT", "", currency.Code{}, currency.Code{}) assert.NoError(t, err) } func TestGetSpotWhaleNetFlow(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetSpotWhaleNetFlow, "", testPair.String(), errPairEmpty, true, false, false) + testGetOneArg(t, bi.GetSpotWhaleNetFlow, currency.Pair{}, testPair, errPairEmpty, true, false, false) } func TestGetFuturesActiveVolume(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesActiveVolume(context.Background(), "", "") + _, err := bi.GetFuturesActiveVolume(context.Background(), currency.Pair{}, "") assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetFuturesActiveVolume(context.Background(), testPair.String(), "") + resp, err := bi.GetFuturesActiveVolume(context.Background(), testPair, "") require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetFuturesPositionRatios(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesPositionRatios(context.Background(), "", "") + _, err := bi.GetFuturesPositionRatios(context.Background(), currency.Pair{}, "") assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetFuturesPositionRatios(context.Background(), testPair.String(), "") + resp, err := bi.GetFuturesPositionRatios(context.Background(), testPair, "") require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetMarginPositionRatios(t *testing.T) { t.Parallel() - _, err := bi.GetMarginPositionRatios(context.Background(), "", "", "") + _, err := bi.GetMarginPositionRatios(context.Background(), currency.Pair{}, "", "") assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetMarginPositionRatios(context.Background(), testPair.String(), "", "") + resp, err := bi.GetMarginPositionRatios(context.Background(), testPair, "", "") require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetMarginLoanGrowth(t *testing.T) { t.Parallel() - _, err := bi.GetMarginLoanGrowth(context.Background(), "", "", "") + _, err := bi.GetMarginLoanGrowth(context.Background(), currency.Pair{}, "", "") assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetMarginLoanGrowth(context.Background(), testPair.String(), "", "") + resp, err := bi.GetMarginLoanGrowth(context.Background(), testPair, "", "") require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetIsolatedBorrowingRatio(t *testing.T) { t.Parallel() - _, err := bi.GetIsolatedBorrowingRatio(context.Background(), "", "") + _, err := bi.GetIsolatedBorrowingRatio(context.Background(), currency.Pair{}, "") assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetIsolatedBorrowingRatio(context.Background(), testPair.String(), "") + resp, err := bi.GetIsolatedBorrowingRatio(context.Background(), testPair, "") require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetFuturesRatios(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesRatios(context.Background(), "", "") + _, err := bi.GetFuturesRatios(context.Background(), currency.Pair{}, "") assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetFuturesRatios(context.Background(), testPair.String(), "") + resp, err := bi.GetFuturesRatios(context.Background(), testPair, "") require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetSpotFundFlows(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetSpotFundFlows, "", testPair.String(), errPairEmpty, true, false, false) + testGetOneArg(t, bi.GetSpotFundFlows, currency.Pair{}, testPair, errPairEmpty, true, false, false) } func TestGetTradeSupportSymbols(t *testing.T) { @@ -305,14 +305,14 @@ func TestGetTradeSupportSymbols(t *testing.T) { func TestGetSpotWhaleFundFlows(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetSpotWhaleFundFlows, "", testPair.String(), errPairEmpty, true, false, false) + testGetOneArg(t, bi.GetSpotWhaleFundFlows, currency.Pair{}, testPair, errPairEmpty, true, false, false) } func TestGetFuturesAccountRatios(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesAccountRatios(context.Background(), "", "") + _, err := bi.GetFuturesAccountRatios(context.Background(), currency.Pair{}, "") assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetFuturesAccountRatios(context.Background(), testPair.String(), "") + resp, err := bi.GetFuturesAccountRatios(context.Background(), testPair, "") require.NoError(t, err) assert.NotEmpty(t, resp) } @@ -419,7 +419,7 @@ func TestGetAPIKeys(t *testing.T) { func TestGetFundingAssets(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetFundingAssets, "", testCrypto.String(), nil, false, true, true) + testGetOneArg(t, bi.GetFundingAssets, currency.Code{}, testCrypto, nil, false, true, true) } func TestGetBotAccountAssets(t *testing.T) { @@ -441,14 +441,14 @@ func TestGetConvertCoints(t *testing.T) { func TestGetQuotedPrice(t *testing.T) { t.Parallel() - _, err := bi.GetQuotedPrice(context.Background(), "", "", 0, 0) + _, err := bi.GetQuotedPrice(context.Background(), currency.Code{}, currency.Code{}, 0, 0) assert.ErrorIs(t, err, errCurrencyEmpty) - _, err = bi.GetQuotedPrice(context.Background(), "meow", "woof", 0, 0) + _, err = bi.GetQuotedPrice(context.Background(), currency.NewCode("meow"), currency.NewCode("woof"), 0, 0) assert.ErrorIs(t, err, errFromToMutex) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetQuotedPrice(context.Background(), testCrypto.String(), testFiat.String(), 0, 1) + _, err = bi.GetQuotedPrice(context.Background(), testCrypto, testFiat, 0, 1) assert.NoError(t, err) - resp, err := bi.GetQuotedPrice(context.Background(), testCrypto.String(), testFiat.String(), 0.1, 0) + resp, err := bi.GetQuotedPrice(context.Background(), testCrypto, testFiat, 0.1, 0) require.NoError(t, err) assert.NotEmpty(t, resp) } @@ -471,7 +471,7 @@ func TestGetBGBConvertCoins(t *testing.T) { func TestConvertBGB(t *testing.T) { t.Parallel() // No matter what currency I use, this returns the error "currency does not support convert"; possibly a bad error message, with the true issue being lack of funds? - testGetOneArg(t, bi.ConvertBGB, nil, []string{testCrypto3.String()}, errCurrencyEmpty, false, true, canManipulateRealOrders) + testGetOneArg(t, bi.ConvertBGB, nil, []currency.Code{testCrypto3}, errCurrencyEmpty, false, true, canManipulateRealOrders) } func TestGetBGBConvertHistory(t *testing.T) { @@ -485,12 +485,12 @@ func TestGetBGBConvertHistory(t *testing.T) { func TestGetCoinInfo(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetCoinInfo, "", testCrypto.String(), nil, true, false, false) + testGetOneArg(t, bi.GetCoinInfo, currency.Code{}, testCrypto, nil, true, false, false) } func TestGetSymbolInfo(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetSymbolInfo, "", "", nil, true, false, false) + testGetOneArg(t, bi.GetSymbolInfo, currency.Pair{}, currency.Pair{}, nil, true, false, false) } func TestGetSpotVIPFeeRate(t *testing.T) { @@ -500,99 +500,99 @@ func TestGetSpotVIPFeeRate(t *testing.T) { func TestGetSpotTickerInformation(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetSpotTickerInformation, "", testPair.String(), nil, true, false, false) + testGetOneArg(t, bi.GetSpotTickerInformation, currency.Pair{}, testPair, nil, true, false, false) } func TestGetSpotMergeDepth(t *testing.T) { t.Parallel() - _, err := bi.GetSpotMergeDepth(context.Background(), "", "", "") + _, err := bi.GetSpotMergeDepth(context.Background(), currency.Pair{}, "", "") assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetSpotMergeDepth(context.Background(), testPair.String(), "scale3", "5") + resp, err := bi.GetSpotMergeDepth(context.Background(), testPair, "scale3", "5") require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetOrderbookDepth(t *testing.T) { t.Parallel() - resp, err := bi.GetOrderbookDepth(context.Background(), testPair.String(), "", 5) + resp, err := bi.GetOrderbookDepth(context.Background(), testPair, "", 5) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetSpotCandlestickData(t *testing.T) { t.Parallel() - _, err := bi.GetSpotCandlestickData(context.Background(), "", "", time.Time{}, time.Time{}, 0, false) + _, err := bi.GetSpotCandlestickData(context.Background(), currency.Pair{}, "", time.Time{}, time.Time{}, 0, false) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetSpotCandlestickData(context.Background(), "meow", "", time.Time{}, time.Time{}, 0, false) + _, err = bi.GetSpotCandlestickData(context.Background(), testPair, "", time.Time{}, time.Time{}, 0, false) assert.ErrorIs(t, err, errGranEmpty) - _, err = bi.GetSpotCandlestickData(context.Background(), "meow", "woof", time.Time{}, time.Time{}, 5, true) + _, err = bi.GetSpotCandlestickData(context.Background(), testPair, "woof", time.Time{}, time.Time{}, 5, true) assert.ErrorIs(t, err, errEndTimeEmpty) - _, err = bi.GetSpotCandlestickData(context.Background(), "meow", "woof", time.Now().Add(time.Hour), time.Time{}, 0, false) + _, err = bi.GetSpotCandlestickData(context.Background(), testPair, "woof", time.Now().Add(time.Hour), time.Time{}, 0, false) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) - _, err = bi.GetSpotCandlestickData(context.Background(), testPair.String(), "1min", time.Time{}, time.Time{}, 5, false) + _, err = bi.GetSpotCandlestickData(context.Background(), testPair, "1min", time.Time{}, time.Time{}, 5, false) assert.NoError(t, err) - resp, err := bi.GetSpotCandlestickData(context.Background(), testPair.String(), "1min", time.Time{}, time.Now(), 5, true) + resp, err := bi.GetSpotCandlestickData(context.Background(), testPair, "1min", time.Time{}, time.Now(), 5, true) require.NoError(t, err) assert.NotEmpty(t, resp.SpotCandles) } func TestGetRecentSpotFills(t *testing.T) { t.Parallel() - _, err := bi.GetRecentSpotFills(context.Background(), "", 0) + _, err := bi.GetRecentSpotFills(context.Background(), currency.Pair{}, 0) assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetRecentSpotFills(context.Background(), testPair.String(), 5) + resp, err := bi.GetRecentSpotFills(context.Background(), testPair, 5) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetSpotMarketTrades(t *testing.T) { t.Parallel() - _, err := bi.GetSpotMarketTrades(context.Background(), "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetSpotMarketTrades(context.Background(), currency.Pair{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetSpotMarketTrades(context.Background(), "meow", time.Now().Add(time.Hour), time.Time{}, 0, 0) + _, err = bi.GetSpotMarketTrades(context.Background(), testPair, time.Now().Add(time.Hour), time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) - resp, err := bi.GetSpotMarketTrades(context.Background(), testPair.String(), time.Time{}, time.Time{}, 5, 1<<62) + resp, err := bi.GetSpotMarketTrades(context.Background(), testPair, time.Time{}, time.Time{}, 5, 1<<62) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestPlaceSpotOrder(t *testing.T) { t.Parallel() - _, err := bi.PlaceSpotOrder(context.Background(), "", "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) + _, err := bi.PlaceSpotOrder(context.Background(), currency.Pair{}, "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.PlaceSpotOrder(context.Background(), testPair.String(), "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) + _, err = bi.PlaceSpotOrder(context.Background(), testPair, "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) assert.ErrorIs(t, err, errSideEmpty) - _, err = bi.PlaceSpotOrder(context.Background(), testPair.String(), "sell", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) + _, err = bi.PlaceSpotOrder(context.Background(), testPair, "sell", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) assert.ErrorIs(t, err, errOrderTypeEmpty) - _, err = bi.PlaceSpotOrder(context.Background(), testPair.String(), "sell", "limit", "", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) + _, err = bi.PlaceSpotOrder(context.Background(), testPair, "sell", "limit", "", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) assert.ErrorIs(t, err, errStrategyEmpty) - _, err = bi.PlaceSpotOrder(context.Background(), testPair.String(), "sell", "limit", "IOC", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) + _, err = bi.PlaceSpotOrder(context.Background(), testPair, "sell", "limit", "IOC", "", "", 0, 0, 0, 0, 0, 0, 0, false, 0) assert.ErrorIs(t, err, errLimitPriceEmpty) - _, err = bi.PlaceSpotOrder(context.Background(), testPair.String(), "sell", "limit", "IOC", "", "", testPrice, 0, 0, 0, 0, 0, 0, false, 0) + _, err = bi.PlaceSpotOrder(context.Background(), testPair, "sell", "limit", "IOC", "", "", testPrice, 0, 0, 0, 0, 0, 0, false, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.PlaceSpotOrder(context.Background(), testPair.String(), "sell", "limit", "IOC", "", "", testPrice, testAmount, 0, testPrice-1, testPrice-2, testPrice+1, testPrice+2, true, 0) + _, err = bi.PlaceSpotOrder(context.Background(), testPair, "sell", "limit", "IOC", "", "", testPrice, testAmount, 0, testPrice-1, testPrice-2, testPrice+1, testPrice+2, true, 0) assert.NoError(t, err) - _, err = bi.PlaceSpotOrder(context.Background(), testPair.String(), "sell", "limit", "IOC", "", "", testPrice, testAmount, testPrice/10, 0, 0, 0, 0, false, time.Minute) + _, err = bi.PlaceSpotOrder(context.Background(), testPair, "sell", "limit", "IOC", "", "", testPrice, testAmount, testPrice/10, 0, 0, 0, 0, false, time.Minute) assert.NoError(t, err) } func TestCancelAndPlaceSpotOrder(t *testing.T) { t.Parallel() - _, err := bi.CancelAndPlaceSpotOrder(context.Background(), "", "", "", 0, 0, 0, 0, 0, 0, 0) + _, err := bi.CancelAndPlaceSpotOrder(context.Background(), currency.Pair{}, "", "", 0, 0, 0, 0, 0, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.CancelAndPlaceSpotOrder(context.Background(), testPair.String(), "", "", 0, 0, 0, 0, 0, 0, 0) + _, err = bi.CancelAndPlaceSpotOrder(context.Background(), testPair, "", "", 0, 0, 0, 0, 0, 0, 0) assert.ErrorIs(t, err, errOrderClientEmpty) - _, err = bi.CancelAndPlaceSpotOrder(context.Background(), testPair.String(), "meow", "", 0, 0, 0, 0, 0, 0, 0) + _, err = bi.CancelAndPlaceSpotOrder(context.Background(), testPair, "meow", "", 0, 0, 0, 0, 0, 0, 0) assert.ErrorIs(t, err, errPriceEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetUnfilledOrders(context.Background(), testPair.String(), "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) + resp, err := bi.GetUnfilledOrders(context.Background(), testPair, "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) require.NoError(t, err) if len(resp) == 0 { t.Skip(skipInsufficientOrders) } cID := clientIDGenerator() - _, err = bi.CancelAndPlaceSpotOrder(context.Background(), testPair.String(), resp[0].ClientOrderID, cID, testPrice, testAmount, testPrice-1, testPrice-2, testPrice+1, testPrice+2, int64(resp[0].OrderID)) + _, err = bi.CancelAndPlaceSpotOrder(context.Background(), testPair, resp[0].ClientOrderID, cID, testPrice, testAmount, testPrice-1, testPrice-2, testPrice+1, testPrice+2, int64(resp[0].OrderID)) assert.NoError(t, err) } @@ -602,17 +602,19 @@ func TestBatchCancelAndPlaceSpotOrders(t *testing.T) { _, err := bi.BatchCancelAndPlaceSpotOrders(context.Background(), req) assert.ErrorIs(t, err, errOrdersEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetUnfilledOrders(context.Background(), testPair.String(), "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) + resp, err := bi.GetUnfilledOrders(context.Background(), testPair, "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) require.NoError(t, err) if len(resp) == 0 { t.Skip(skipInsufficientOrders) } + newPair, err := currency.NewPairFromString(resp[0].Symbol) + require.NoError(t, err) req = append(req, ReplaceSpotOrderStruct{ OrderID: int64(resp[0].OrderID), OldClientOrderID: resp[0].ClientOrderID, Price: testPrice, Amount: testAmount, - Pair: resp[0].Symbol, + Pair: newPair, }) _, err = bi.BatchCancelAndPlaceSpotOrders(context.Background(), req) assert.NoError(t, err) @@ -620,26 +622,26 @@ func TestBatchCancelAndPlaceSpotOrders(t *testing.T) { func TestCancelSpotOrderByID(t *testing.T) { t.Parallel() - _, err := bi.CancelSpotOrderByID(context.Background(), "", "", "", 0) + _, err := bi.CancelSpotOrderByID(context.Background(), currency.Pair{}, "", "", 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.CancelSpotOrderByID(context.Background(), testPair.String(), "", "", 0) + _, err = bi.CancelSpotOrderByID(context.Background(), testPair, "", "", 0) assert.ErrorIs(t, err, errOrderClientEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetUnfilledOrders(context.Background(), testPair.String(), "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) + resp, err := bi.GetUnfilledOrders(context.Background(), testPair, "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) require.NoError(t, err) if len(resp) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.CancelSpotOrderByID(context.Background(), testPair.String(), "", resp[0].ClientOrderID, int64(resp[0].OrderID)) + _, err = bi.CancelSpotOrderByID(context.Background(), testPair, "", resp[0].ClientOrderID, int64(resp[0].OrderID)) assert.NoError(t, err) } func TestBatchPlaceSpotOrders(t *testing.T) { t.Parallel() var req []PlaceSpotOrderStruct - _, err := bi.BatchPlaceSpotOrders(context.Background(), "", false, false, req) + _, err := bi.BatchPlaceSpotOrders(context.Background(), currency.Pair{}, false, false, req) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.BatchPlaceSpotOrders(context.Background(), "meow", false, false, req) + _, err = bi.BatchPlaceSpotOrders(context.Background(), testPair, false, false, req) assert.ErrorIs(t, err, errOrdersEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) req = append(req, PlaceSpotOrderStruct{ @@ -650,7 +652,7 @@ func TestBatchPlaceSpotOrders(t *testing.T) { Size: testAmount, Pair: testPair.String(), }) - resp, err := bi.BatchPlaceSpotOrders(context.Background(), testPair.String(), true, true, req) + resp, err := bi.BatchPlaceSpotOrders(context.Background(), testPair, true, true, req) require.NoError(t, err) assert.NotEmpty(t, resp) } @@ -658,12 +660,12 @@ func TestBatchPlaceSpotOrders(t *testing.T) { func TestBatchCancelOrders(t *testing.T) { t.Parallel() var req []CancelSpotOrderStruct - _, err := bi.BatchCancelOrders(context.Background(), "", false, req) + _, err := bi.BatchCancelOrders(context.Background(), currency.Pair{}, false, req) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.BatchCancelOrders(context.Background(), "meow", false, req) + _, err = bi.BatchCancelOrders(context.Background(), testPair, false, req) assert.ErrorIs(t, err, errOrderIDEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetUnfilledOrders(context.Background(), testPair.String(), "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) + resp, err := bi.GetUnfilledOrders(context.Background(), testPair, "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) require.NoError(t, err) if len(resp) == 0 { t.Skip(skipInsufficientOrders) @@ -673,14 +675,14 @@ func TestBatchCancelOrders(t *testing.T) { ClientOrderID: resp[0].ClientOrderID, Pair: resp[0].Symbol, }) - resp2, err := bi.BatchCancelOrders(context.Background(), testPair.String(), true, req) + resp2, err := bi.BatchCancelOrders(context.Background(), testPair, true, req) assert.NoError(t, err) assert.NotEmpty(t, resp2) } func TestCancelOrderBySymbol(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.CancelOrdersBySymbol, "", testPair.String(), errPairEmpty, true, true, canManipulateRealOrders) + testGetOneArg(t, bi.CancelOrdersBySymbol, currency.Pair{}, testPair, errPairEmpty, true, true, canManipulateRealOrders) } func TestGetSpotOrderDetails(t *testing.T) { @@ -695,63 +697,63 @@ func TestGetSpotOrderDetails(t *testing.T) { func TestGetUnfilledOrders(t *testing.T) { t.Parallel() - _, err := bi.GetUnfilledOrders(context.Background(), "", "", time.Now().Add(time.Hour), time.Time{}, 0, 0, 0, 0) + _, err := bi.GetUnfilledOrders(context.Background(), currency.Pair{}, "", time.Now().Add(time.Hour), time.Time{}, 0, 0, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetUnfilledOrders(context.Background(), "", "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) + _, err = bi.GetUnfilledOrders(context.Background(), currency.Pair{}, "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) assert.NoError(t, err) } func TestGetHistoricalSpotOrders(t *testing.T) { t.Parallel() - _, err := bi.GetHistoricalSpotOrders(context.Background(), "", time.Now().Add(time.Hour), time.Time{}, 0, 0, 0) + _, err := bi.GetHistoricalSpotOrders(context.Background(), currency.Pair{}, time.Now().Add(time.Hour), time.Time{}, 0, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetHistoricalSpotOrders(context.Background(), "", time.Time{}, time.Time{}, 5, 1<<62, 0) + _, err = bi.GetHistoricalSpotOrders(context.Background(), currency.Pair{}, time.Time{}, time.Time{}, 5, 1<<62, 0) assert.NoError(t, err) } func TestGetSpotFills(t *testing.T) { t.Parallel() - _, err := bi.GetSpotFills(context.Background(), "", time.Time{}, time.Time{}, 0, 0, 0) + _, err := bi.GetSpotFills(context.Background(), currency.Pair{}, time.Time{}, time.Time{}, 0, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetSpotFills(context.Background(), "meow", time.Now().Add(time.Hour), time.Time{}, 0, 0, 0) + _, err = bi.GetSpotFills(context.Background(), testPair, time.Now().Add(time.Hour), time.Time{}, 0, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSpotFills(context.Background(), testPair.String(), time.Time{}, time.Time{}, 5, 1<<62, 0) + _, err = bi.GetSpotFills(context.Background(), testPair, time.Time{}, time.Time{}, 5, 1<<62, 0) assert.NoError(t, err) } func TestPlacePlanSpotOrder(t *testing.T) { t.Parallel() - _, err := bi.PlacePlanSpotOrder(context.Background(), "", "", "", "", "", "", "", 0, 0, 0) + _, err := bi.PlacePlanSpotOrder(context.Background(), currency.Pair{}, "", "", "", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.PlacePlanSpotOrder(context.Background(), "meow", "", "", "", "", "", "", 0, 0, 0) + _, err = bi.PlacePlanSpotOrder(context.Background(), testPair, "", "", "", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errSideEmpty) - _, err = bi.PlacePlanSpotOrder(context.Background(), "meow", "woof", "", "", "", "", "", 0, 0, 0) + _, err = bi.PlacePlanSpotOrder(context.Background(), testPair, "woof", "", "", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errTriggerPriceEmpty) - _, err = bi.PlacePlanSpotOrder(context.Background(), "meow", "woof", "", "", "", "", "", 1, 0, 0) + _, err = bi.PlacePlanSpotOrder(context.Background(), testPair, "woof", "", "", "", "", "", 1, 0, 0) assert.ErrorIs(t, err, errOrderTypeEmpty) - _, err = bi.PlacePlanSpotOrder(context.Background(), "meow", "woof", "limit", "", "", "", "", 1, 0, 0) + _, err = bi.PlacePlanSpotOrder(context.Background(), testPair, "woof", "limit", "", "", "", "", 1, 0, 0) assert.ErrorIs(t, err, errLimitPriceEmpty) - _, err = bi.PlacePlanSpotOrder(context.Background(), "meow", "woof", "neigh", "", "", "", "", 1, 0, 0) + _, err = bi.PlacePlanSpotOrder(context.Background(), testPair, "woof", "neigh", "", "", "", "", 1, 0, 0) assert.ErrorIs(t, err, errAmountEmpty) - _, err = bi.PlacePlanSpotOrder(context.Background(), "meow", "woof", "neigh", "", "", "", "", 1, 0, 1) + _, err = bi.PlacePlanSpotOrder(context.Background(), currency.NewPairWithDelimiter("meow", "woof", ""), "neigh", "oink", "", "", "", "", 1, 0, 1) assert.ErrorIs(t, err, errTriggerTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.PlacePlanSpotOrder(context.Background(), testPair.String(), "sell", "limit", "", "fill_price", clientIDGenerator(), "ioc", testPrice, testPrice, testAmount) + resp, err := bi.PlacePlanSpotOrder(context.Background(), testPair, "sell", "limit", "", "fill_price", clientIDGenerator(), "ioc", testPrice, testPrice, testAmount) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetCurrentSpotPlanOrders(t *testing.T) { t.Parallel() - _, err := bi.GetCurrentSpotPlanOrders(context.Background(), "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetCurrentSpotPlanOrders(context.Background(), currency.Pair{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetCurrentSpotPlanOrders(context.Background(), "meow", time.Now().Add(time.Hour), time.Time{}, 0, 0) + _, err = bi.GetCurrentSpotPlanOrders(context.Background(), testPair, time.Now().Add(time.Hour), time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair.String(), time.Time{}, time.Time{}, 5, 1<<62) + resp, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair, time.Time{}, time.Time{}, 5, 1<<62) require.NoError(t, err) assert.NotEmpty(t, resp) } @@ -769,18 +771,18 @@ func TestSpotGetPlanSubOrder(t *testing.T) { func TestGetSpotPlanOrderHistory(t *testing.T) { t.Parallel() - _, err := bi.GetSpotPlanOrderHistory(context.Background(), "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetSpotPlanOrderHistory(context.Background(), currency.Pair{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetSpotPlanOrderHistory(context.Background(), "meow", time.Time{}, time.Time{}, 0, 0) + _, err = bi.GetSpotPlanOrderHistory(context.Background(), testPair, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSpotPlanOrderHistory(context.Background(), testPair.String(), time.Now().Add(-time.Hour*24*90), time.Now().Add(-time.Minute), 2, 1<<62) + _, err = bi.GetSpotPlanOrderHistory(context.Background(), testPair, time.Now().Add(-time.Hour*24*90), time.Now().Add(-time.Minute), 2, 1<<62) assert.NoError(t, err) } func TestBatchCancelSpotPlanOrders(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.BatchCancelSpotPlanOrders, nil, []string{testPair.String()}, nil, false, true, canManipulateRealOrders) + testGetOneArg(t, bi.BatchCancelSpotPlanOrders, nil, currency.Pairs{testPair}, nil, false, true, canManipulateRealOrders) } func TestGetAccountInfo(t *testing.T) { @@ -796,7 +798,7 @@ func TestGetAccountInfo(t *testing.T) { func TestGetAccountAssets(t *testing.T) { t.Parallel() sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err := bi.GetAccountAssets(context.Background(), "", "") + _, err := bi.GetAccountAssets(context.Background(), currency.Code{}, "") assert.NoError(t, err) } @@ -808,37 +810,37 @@ func TestGetSpotSubaccountAssets(t *testing.T) { func TestModifyDepositAccount(t *testing.T) { t.Parallel() - _, err := bi.ModifyDepositAccount(context.Background(), "", "") + _, err := bi.ModifyDepositAccount(context.Background(), "", currency.Code{}) assert.ErrorIs(t, err, errAccountTypeEmpty) - _, err = bi.ModifyDepositAccount(context.Background(), "meow", "") + _, err = bi.ModifyDepositAccount(context.Background(), "meow", currency.Code{}) assert.ErrorIs(t, err, errCurrencyEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.ModifyDepositAccount(context.Background(), "spot", testFiat.String()) + resp, err := bi.ModifyDepositAccount(context.Background(), "spot", testFiat) assert.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetAccountBills(t *testing.T) { t.Parallel() - _, err := bi.GetSpotAccountBills(context.Background(), "", "", "", time.Now().Add(time.Hour), time.Time{}, 0, 0) + _, err := bi.GetSpotAccountBills(context.Background(), currency.Code{}, "", "", time.Now().Add(time.Hour), time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSpotAccountBills(context.Background(), testCrypto.String(), "", "", time.Time{}, time.Time{}, 3, 1<<62) + _, err = bi.GetSpotAccountBills(context.Background(), testCrypto, "", "", time.Time{}, time.Time{}, 3, 1<<62) assert.NoError(t, err) } func TestTransferAsset(t *testing.T) { t.Parallel() - _, err := bi.TransferAsset(context.Background(), "", "", "", "", "", 0) + _, err := bi.TransferAsset(context.Background(), "", "", "", currency.Code{}, currency.Pair{}, 0) assert.ErrorIs(t, err, errFromTypeEmpty) - _, err = bi.TransferAsset(context.Background(), "meow", "", "", "", "", 0) + _, err = bi.TransferAsset(context.Background(), "meow", "", "", currency.Code{}, currency.Pair{}, 0) assert.ErrorIs(t, err, errToTypeEmpty) - _, err = bi.TransferAsset(context.Background(), "meow", "woof", "", "", "", 0) + _, err = bi.TransferAsset(context.Background(), "meow", "woof", "", currency.Code{}, currency.Pair{}, 0) assert.ErrorIs(t, err, errCurrencyAndPairEmpty) - _, err = bi.TransferAsset(context.Background(), "meow", "woof", "neigh", "", "", 0) + _, err = bi.TransferAsset(context.Background(), "meow", "woof", "neigh", currency.Code{}, currency.Pair{}, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.TransferAsset(context.Background(), "spot", "p2p", testCrypto.String(), testPair.String(), clientIDGenerator(), testAmount) + _, err = bi.TransferAsset(context.Background(), "spot", "p2p", clientIDGenerator(), testCrypto, testPair, testAmount) assert.NoError(t, err) } @@ -856,59 +858,59 @@ func TestGetTransferableCoinList(t *testing.T) { func TestSubaccountTransfer(t *testing.T) { t.Parallel() - _, err := bi.SubaccountTransfer(context.Background(), "", "", "", "", "", "", "", 0) + _, err := bi.SubaccountTransfer(context.Background(), "", "", "", "", "", currency.Code{}, currency.Pair{}, 0) assert.ErrorIs(t, err, errFromTypeEmpty) - _, err = bi.SubaccountTransfer(context.Background(), "meow", "", "", "", "", "", "", 0) + _, err = bi.SubaccountTransfer(context.Background(), "meow", "", "", "", "", currency.Code{}, currency.Pair{}, 0) assert.ErrorIs(t, err, errToTypeEmpty) - _, err = bi.SubaccountTransfer(context.Background(), "meow", "woof", "", "", "", "", "", 0) + _, err = bi.SubaccountTransfer(context.Background(), "meow", "woof", "", "", "", currency.Code{}, currency.Pair{}, 0) assert.ErrorIs(t, err, errCurrencyAndPairEmpty) - _, err = bi.SubaccountTransfer(context.Background(), "meow", "woof", "neigh", "", "", "", "", 0) + _, err = bi.SubaccountTransfer(context.Background(), "meow", "woof", "neigh", "", "", currency.Code{}, currency.Pair{}, 0) assert.ErrorIs(t, err, errFromIDEmpty) - _, err = bi.SubaccountTransfer(context.Background(), "meow", "woof", "neigh", "", "", "oink", "", 0) + _, err = bi.SubaccountTransfer(context.Background(), "meow", "woof", "neigh", "", "", testCrypto, currency.Pair{}, 0) assert.ErrorIs(t, err, errToIDEmpty) - _, err = bi.SubaccountTransfer(context.Background(), "meow", "woof", "neigh", "", "", "oink", "quack", 0) + _, err = bi.SubaccountTransfer(context.Background(), "meow", "woof", "neigh", "", "", testCrypto, testPair, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) fromID := subAccTestHelper(t, "", strings.ToLower(string(testSubaccountName[:3]))+"****@virtual-bitget.com") toID := subAccTestHelper(t, strings.ToLower(string(testSubaccountName[:3]))+"****@virtual-bitget.com", "") - _, err = bi.SubaccountTransfer(context.Background(), "spot", "p2p", testCrypto.String(), testPair.String(), clientIDGenerator(), fromID, toID, testAmount) + _, err = bi.SubaccountTransfer(context.Background(), "spot", "p2p", clientIDGenerator(), fromID, toID, testCrypto, testPair, testAmount) assert.NoError(t, err) } func TestWithdrawFunds(t *testing.T) { t.Parallel() - _, err := bi.WithdrawFunds(context.Background(), "", "", "", "", "", "", "", "", "", 0) + _, err := bi.WithdrawFunds(context.Background(), currency.Code{}, "", "", "", "", "", "", "", "", 0) assert.ErrorIs(t, err, errCurrencyEmpty) - _, err = bi.WithdrawFunds(context.Background(), "meow", "", "", "", "", "", "", "", "", 0) + _, err = bi.WithdrawFunds(context.Background(), testCrypto, "", "", "", "", "", "", "", "", 0) assert.ErrorIs(t, err, errTransferTypeEmpty) - _, err = bi.WithdrawFunds(context.Background(), "meow", "woof", "", "", "", "", "", "", "", 0) + _, err = bi.WithdrawFunds(context.Background(), testCrypto, "woof", "", "", "", "", "", "", "", 0) assert.ErrorIs(t, err, errAddressEmpty) - _, err = bi.WithdrawFunds(context.Background(), "meow", "woof", "neigh", "", "", "", "", "", "", 0) + _, err = bi.WithdrawFunds(context.Background(), testCrypto, "woof", "neigh", "", "", "", "", "", "", 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.WithdrawFunds(context.Background(), testCrypto.String(), "on_chain", testAddress, testCrypto.String(), "", "", "", "", clientIDGenerator(), testAmount) + _, err = bi.WithdrawFunds(context.Background(), testCrypto, "on_chain", testAddress, testCrypto.String(), "", "", "", "", clientIDGenerator(), testAmount) assert.NoError(t, err) } func TestGetSubaccountTransferRecord(t *testing.T) { t.Parallel() - _, err := bi.GetSubaccountTransferRecord(context.Background(), "", "", "", time.Now().Add(time.Hour), time.Time{}, 0, 0) + _, err := bi.GetSubaccountTransferRecord(context.Background(), currency.Code{}, "", "", time.Now().Add(time.Hour), time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSubaccountTransferRecord(context.Background(), "", "", "meow", time.Time{}, time.Time{}, 3, 1<<62) + _, err = bi.GetSubaccountTransferRecord(context.Background(), currency.Code{}, "", "meow", time.Time{}, time.Time{}, 3, 1<<62) assert.NoError(t, err) } func TestGetTransferRecord(t *testing.T) { t.Parallel() - _, err := bi.GetTransferRecord(context.Background(), "", "", "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetTransferRecord(context.Background(), currency.Code{}, "", "", time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errCurrencyEmpty) - _, err = bi.GetTransferRecord(context.Background(), "meow", "", "", time.Time{}, time.Time{}, 0, 0) + _, err = bi.GetTransferRecord(context.Background(), testCrypto, "", "", time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errFromTypeEmpty) - _, err = bi.GetTransferRecord(context.Background(), "meow", "woof", "", time.Now().Add(time.Hour), time.Time{}, 0, 0) + _, err = bi.GetTransferRecord(context.Background(), testCrypto, "woof", "", time.Now().Add(time.Hour), time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetTransferRecord(context.Background(), testCrypto.String(), "spot", "meow", time.Time{}, time.Time{}, 3, 1<<62) + _, err = bi.GetTransferRecord(context.Background(), testCrypto, "spot", "meow", time.Time{}, time.Time{}, 3, 1<<62) assert.NoError(t, err) } @@ -920,22 +922,22 @@ func TestSwitchBGBDeductionStatus(t *testing.T) { func TestGetDepositAddressForCurrency(t *testing.T) { t.Parallel() - _, err := bi.GetDepositAddressForCurrency(context.Background(), "", "") + _, err := bi.GetDepositAddressForCurrency(context.Background(), currency.Code{}, "") assert.ErrorIs(t, err, errCurrencyEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetDepositAddressForCurrency(context.Background(), testCrypto.String(), "") + resp, err := bi.GetDepositAddressForCurrency(context.Background(), testCrypto, "") require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetSubaccountDepositAddress(t *testing.T) { t.Parallel() - _, err := bi.GetSubaccountDepositAddress(context.Background(), "", "", "") + _, err := bi.GetSubaccountDepositAddress(context.Background(), "", "", currency.Code{}) assert.ErrorIs(t, err, errSubaccountEmpty) - _, err = bi.GetSubaccountDepositAddress(context.Background(), "meow", "", "") + _, err = bi.GetSubaccountDepositAddress(context.Background(), "meow", "", currency.Code{}) assert.ErrorIs(t, err, errCurrencyEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetSubaccountDepositAddress(context.Background(), deposSubaccID, testCrypto.String(), "") + resp, err := bi.GetSubaccountDepositAddress(context.Background(), deposSubaccID, "", testCrypto) // Getting the error "The business of this account has been restricted", don't think this was happening // last week. require.NoError(t, err) @@ -950,41 +952,41 @@ func TestGetBGBDeductionStatus(t *testing.T) { func TestGetSubaccountDepositRecords(t *testing.T) { t.Parallel() - _, err := bi.GetSubaccountDepositRecords(context.Background(), "", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetSubaccountDepositRecords(context.Background(), "", currency.Code{}, 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errSubaccountEmpty) - _, err = bi.GetSubaccountDepositRecords(context.Background(), "meow", "", 0, 0, 0, time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetSubaccountDepositRecords(context.Background(), "meow", currency.Code{}, 0, 0, 0, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) tarID := subAccTestHelper(t, "", "") - _, err = bi.GetSubaccountDepositRecords(context.Background(), tarID, "", 0, 1<<62, 2, time.Time{}, time.Time{}) + _, err = bi.GetSubaccountDepositRecords(context.Background(), tarID, currency.Code{}, 0, 1<<62, 2, time.Time{}, time.Time{}) assert.NoError(t, err) } func TestGetWithdrawalRecords(t *testing.T) { t.Parallel() - _, err := bi.GetWithdrawalRecords(context.Background(), "", "", time.Time{}, time.Time{}, 0, 0, 0) + _, err := bi.GetWithdrawalRecords(context.Background(), currency.Code{}, "", time.Time{}, time.Time{}, 0, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetWithdrawalRecords(context.Background(), "", "", time.Now().Add(-time.Hour*24*90), time.Now(), 1<<62, 0, 5) + _, err = bi.GetWithdrawalRecords(context.Background(), currency.Code{}, "", time.Now().Add(-time.Hour*24*90), time.Now(), 1<<62, 0, 5) assert.NoError(t, err) } func TestGetDepositRecords(t *testing.T) { t.Parallel() - _, err := bi.GetDepositRecords(context.Background(), "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetDepositRecords(context.Background(), currency.Code{}, 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetDepositRecords(context.Background(), testCrypto.String(), 0, 1<<62, 2, time.Now().Add(-time.Hour*24*90), time.Now()) + _, err = bi.GetDepositRecords(context.Background(), testCrypto, 0, 1<<62, 2, time.Now().Add(-time.Hour*24*90), time.Now()) assert.NoError(t, err) } func TestGetFuturesMergeDepth(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesMergeDepth(context.Background(), "", "", "", "") + _, err := bi.GetFuturesMergeDepth(context.Background(), currency.Pair{}, "", "", "") assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetFuturesMergeDepth(context.Background(), "meow", "", "", "") + _, err = bi.GetFuturesMergeDepth(context.Background(), testPair, "", "", "") assert.ErrorIs(t, err, errProductTypeEmpty) - resp, err := bi.GetFuturesMergeDepth(context.Background(), testPair.String(), "USDT-FUTURES", "scale3", "5") + resp, err := bi.GetFuturesMergeDepth(context.Background(), testPair, "USDT-FUTURES", "scale3", "5") require.NoError(t, err) assert.NotEmpty(t, resp) } @@ -1006,48 +1008,48 @@ func TestGetAllFuturesTickers(t *testing.T) { func TestGetRecentFuturesFills(t *testing.T) { t.Parallel() - _, err := bi.GetRecentFuturesFills(context.Background(), "", "", 0) + _, err := bi.GetRecentFuturesFills(context.Background(), currency.Pair{}, "", 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetRecentFuturesFills(context.Background(), "meow", "", 0) + _, err = bi.GetRecentFuturesFills(context.Background(), testPair, "", 0) assert.ErrorIs(t, err, errProductTypeEmpty) - resp, err := bi.GetRecentFuturesFills(context.Background(), testPair.String(), "USDT-FUTURES", 5) + resp, err := bi.GetRecentFuturesFills(context.Background(), testPair, "USDT-FUTURES", 5) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetFuturesMarketTrades(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesMarketTrades(context.Background(), "", "", 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetFuturesMarketTrades(context.Background(), currency.Pair{}, "", 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetFuturesMarketTrades(context.Background(), "meow", "", 0, 0, time.Time{}, time.Time{}) + _, err = bi.GetFuturesMarketTrades(context.Background(), testPair, "", 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetFuturesMarketTrades(context.Background(), "meow", "woof", 0, 0, time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetFuturesMarketTrades(context.Background(), testPair, "woof", 0, 0, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) - resp, err := bi.GetFuturesMarketTrades(context.Background(), testPair.String(), "USDT-FUTURES", 5, 1<<62, time.Time{}, time.Time{}) + resp, err := bi.GetFuturesMarketTrades(context.Background(), testPair, "USDT-FUTURES", 5, 1<<62, time.Time{}, time.Time{}) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetFuturesCandlestickData(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesCandlestickData(context.Background(), "", "", "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetFuturesCandlestickData(context.Background(), currency.Pair{}, "", "", time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetFuturesCandlestickData(context.Background(), "meow", "", "", time.Time{}, time.Time{}, 0, 0) + _, err = bi.GetFuturesCandlestickData(context.Background(), testPair, "", "", time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetFuturesCandlestickData(context.Background(), "meow", "woof", "", time.Time{}, time.Time{}, 0, 0) + _, err = bi.GetFuturesCandlestickData(context.Background(), testPair, "woof", "", time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errGranEmpty) - _, err = bi.GetFuturesCandlestickData(context.Background(), "meow", "woof", "neigh", time.Now().Add(time.Hour), time.Time{}, 0, 0) + _, err = bi.GetFuturesCandlestickData(context.Background(), testPair, "woof", "neigh", time.Now().Add(time.Hour), time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) - resp, err := bi.GetFuturesCandlestickData(context.Background(), testPair.String(), "USDT-FUTURES", "1m", time.Time{}, time.Time{}, 5, CallModeNormal) + resp, err := bi.GetFuturesCandlestickData(context.Background(), testPair, "USDT-FUTURES", "1m", time.Time{}, time.Time{}, 5, CallModeNormal) assert.NoError(t, err) assert.NotEmpty(t, resp.FuturesCandles) - resp, err = bi.GetFuturesCandlestickData(context.Background(), testPair.String(), "COIN-FUTURES", "1m", time.Time{}, time.Time{}, 5, CallModeHistory) + resp, err = bi.GetFuturesCandlestickData(context.Background(), testPair, "COIN-FUTURES", "1m", time.Time{}, time.Time{}, 5, CallModeHistory) assert.NoError(t, err) assert.NotEmpty(t, resp.FuturesCandles) - resp, err = bi.GetFuturesCandlestickData(context.Background(), testPair.String(), "USDC-FUTURES", "1m", time.Time{}, time.Now(), 5, CallModeIndex) + resp, err = bi.GetFuturesCandlestickData(context.Background(), testPair, "USDC-FUTURES", "1m", time.Time{}, time.Now(), 5, CallModeIndex) assert.NoError(t, err) assert.NotEmpty(t, resp.FuturesCandles) - resp, err = bi.GetFuturesCandlestickData(context.Background(), testPair.String(), "USDT-FUTURES", "1m", time.Time{}, time.Now(), 5, CallModeMark) + resp, err = bi.GetFuturesCandlestickData(context.Background(), testPair, "USDT-FUTURES", "1m", time.Time{}, time.Now(), 5, CallModeMark) assert.NoError(t, err) assert.NotEmpty(t, resp.FuturesCandles) } @@ -1069,11 +1071,11 @@ func TestGetFuturesPrices(t *testing.T) { func TestGetFundingHistorical(t *testing.T) { t.Parallel() - _, err := bi.GetFundingHistorical(context.Background(), "", "", 0, 0) + _, err := bi.GetFundingHistorical(context.Background(), currency.Pair{}, "", 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetFundingHistorical(context.Background(), "meow", "", 0, 0) + _, err = bi.GetFundingHistorical(context.Background(), testPair, "", 0, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - resp, err := bi.GetFundingHistorical(context.Background(), testPair.String(), "USDT-FUTURES", 5, 1) + resp, err := bi.GetFundingHistorical(context.Background(), testPair, "USDT-FUTURES", 5, 1) require.NoError(t, err) assert.NotEmpty(t, resp) } @@ -1085,22 +1087,22 @@ func TestGetFundingCurrent(t *testing.T) { func TestGetContractConfig(t *testing.T) { t.Parallel() - _, err := bi.GetContractConfig(context.Background(), "", "") + _, err := bi.GetContractConfig(context.Background(), currency.Pair{}, "") assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetContractConfig(context.Background(), "", prodTypes[0]) + _, err = bi.GetContractConfig(context.Background(), currency.Pair{}, prodTypes[0]) assert.NoError(t, err) } func TestGetOneFuturesAccount(t *testing.T) { t.Parallel() - _, err := bi.GetOneFuturesAccount(context.Background(), "", "", "") + _, err := bi.GetOneFuturesAccount(context.Background(), currency.Pair{}, "", currency.Code{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetOneFuturesAccount(context.Background(), "meow", "", "") + _, err = bi.GetOneFuturesAccount(context.Background(), testPair, "", currency.Code{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetOneFuturesAccount(context.Background(), "meow", "woof", "") + _, err = bi.GetOneFuturesAccount(context.Background(), testPair, "woof", currency.Code{}) assert.ErrorIs(t, err, errMarginCoinEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetOneFuturesAccount(context.Background(), testPair.String(), "USDT-FUTURES", "USDT") + resp, err := bi.GetOneFuturesAccount(context.Background(), testPair, "USDT-FUTURES", testFiat) require.NoError(t, err) assert.NotEmpty(t, resp) } @@ -1117,79 +1119,79 @@ func TestGetFuturesSubaccountAssets(t *testing.T) { func TestGetEstimatedOpenCount(t *testing.T) { t.Parallel() - _, err := bi.GetEstimatedOpenCount(context.Background(), "", "", "", 0, 0, 0) + _, err := bi.GetEstimatedOpenCount(context.Background(), currency.Pair{}, "", currency.Code{}, 0, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetEstimatedOpenCount(context.Background(), "meow", "", "", 0, 0, 0) + _, err = bi.GetEstimatedOpenCount(context.Background(), testPair, "", currency.Code{}, 0, 0, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetEstimatedOpenCount(context.Background(), "meow", "woof", "", 0, 0, 0) + _, err = bi.GetEstimatedOpenCount(context.Background(), testPair, "woof", currency.Code{}, 0, 0, 0) assert.ErrorIs(t, err, errMarginCoinEmpty) - _, err = bi.GetEstimatedOpenCount(context.Background(), "meow", "woof", "neigh", 0, 0, 0) + _, err = bi.GetEstimatedOpenCount(context.Background(), testPair, "woof", testFiat, 0, 0, 0) assert.ErrorIs(t, err, errOpenAmountEmpty) - _, err = bi.GetEstimatedOpenCount(context.Background(), "meow", "woof", "neigh", 1, 0, 0) + _, err = bi.GetEstimatedOpenCount(context.Background(), testPair, "woof", testFiat, 1, 0, 0) assert.ErrorIs(t, err, errOpenPriceEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetEstimatedOpenCount(context.Background(), testPair.String(), "USDT-FUTURES", "USDT", testPrice, testAmount, 20) + resp, err := bi.GetEstimatedOpenCount(context.Background(), testPair, "USDT-FUTURES", testFiat, testPrice, testAmount, 20) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestChangeLeverage(t *testing.T) { t.Parallel() - _, err := bi.ChangeLeverage(context.Background(), "", "", "", "", 0) + _, err := bi.ChangeLeverage(context.Background(), currency.Pair{}, "", "", currency.Code{}, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.ChangeLeverage(context.Background(), "meow", "", "", "", 0) + _, err = bi.ChangeLeverage(context.Background(), testPair, "", "", currency.Code{}, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.ChangeLeverage(context.Background(), "meow", "woof", "", "", 0) + _, err = bi.ChangeLeverage(context.Background(), testPair, "woof", "", currency.Code{}, 0) assert.ErrorIs(t, err, errMarginCoinEmpty) - _, err = bi.ChangeLeverage(context.Background(), "meow", "woof", "neigh", "", 0) + _, err = bi.ChangeLeverage(context.Background(), testPair, "woof", "neigh", currency.Code{}, 0) assert.ErrorIs(t, err, errLeverageEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.ChangeLeverage(context.Background(), testPair.String(), "USDT-FUTURES", "USDT", "", 20) + resp, err := bi.ChangeLeverage(context.Background(), testPair, "USDT-FUTURES", "USDT", currency.Code{}, 20) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestAdjustIsolatedAutoMargin(t *testing.T) { t.Parallel() - err := bi.AdjustIsolatedAutoMargin(context.Background(), "", "", "", false, 0) + err := bi.AdjustIsolatedAutoMargin(context.Background(), currency.Pair{}, currency.Code{}, "", false, 0) assert.ErrorIs(t, err, errPairEmpty) - err = bi.AdjustIsolatedAutoMargin(context.Background(), "meow", "", "", false, 0) + err = bi.AdjustIsolatedAutoMargin(context.Background(), testPair2, currency.Code{}, "", false, 0) assert.ErrorIs(t, err, errMarginCoinEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - err = bi.AdjustIsolatedAutoMargin(context.Background(), testPair2.String(), testFiat2.String(), "long", false, 0) + err = bi.AdjustIsolatedAutoMargin(context.Background(), testPair2, testFiat2, "long", false, 0) assert.NoError(t, err) - err = bi.AdjustIsolatedAutoMargin(context.Background(), testPair2.String(), testFiat2.String(), "long", true, 0.01) + err = bi.AdjustIsolatedAutoMargin(context.Background(), testPair2, testFiat2, "long", true, 0.01) assert.NoError(t, err) } func TestAdjustMargin(t *testing.T) { t.Parallel() - err := bi.AdjustMargin(context.Background(), "", "", "", "", 0) + err := bi.AdjustMargin(context.Background(), currency.Pair{}, "", "", currency.Code{}, 0) assert.ErrorIs(t, err, errPairEmpty) - err = bi.AdjustMargin(context.Background(), "meow", "", "", "", 0) + err = bi.AdjustMargin(context.Background(), testPair2, "", "", currency.Code{}, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - err = bi.AdjustMargin(context.Background(), "meow", "woof", "", "", 0) + err = bi.AdjustMargin(context.Background(), testPair2, "woof", "", currency.Code{}, 0) assert.ErrorIs(t, err, errMarginCoinEmpty) - err = bi.AdjustMargin(context.Background(), "meow", "woof", "neigh", "", 0) + err = bi.AdjustMargin(context.Background(), testPair2, "woof", "neigh", currency.Code{}, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) // This is getting the error "verification exception margin mode == FIXED", and I can't find a way to skirt around that - err = bi.AdjustMargin(context.Background(), testPair2.String(), testFiat2.String()+"-FUTURES", testFiat2.String(), "long", -testAmount) + err = bi.AdjustMargin(context.Background(), testPair2, testFiat2.String()+"-FUTURES", "long", testFiat2, -testAmount) assert.NoError(t, err) } func TestChangeMarginMode(t *testing.T) { t.Parallel() - _, err := bi.ChangeMarginMode(context.Background(), "", "", "", "") + _, err := bi.ChangeMarginMode(context.Background(), currency.Pair{}, "", "", currency.Code{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.ChangeMarginMode(context.Background(), "meow", "", "", "") + _, err = bi.ChangeMarginMode(context.Background(), testPair2, "", "", currency.Code{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.ChangeMarginMode(context.Background(), "meow", "woof", "", "") + _, err = bi.ChangeMarginMode(context.Background(), testPair2, "woof", "", currency.Code{}) assert.ErrorIs(t, err, errMarginCoinEmpty) - _, err = bi.ChangeMarginMode(context.Background(), "meow", "woof", "neigh", "") + _, err = bi.ChangeMarginMode(context.Background(), testPair2, "woof", "neigh", currency.Code{}) assert.ErrorIs(t, err, errMarginModeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.ChangeMarginMode(context.Background(), testPair2.String(), testFiat2.String()+"-FUTURES", testFiat2.String(), "crossed") + _, err = bi.ChangeMarginMode(context.Background(), testPair2, testFiat2.String()+"-FUTURES", "crossed", testFiat2) if err != nil { if strings.Contains(err.Error(), errCurrentlyHoldingPositionPartial) { t.Log(err) @@ -1213,109 +1215,109 @@ func TestChangePositionMode(t *testing.T) { func TestGetFuturesAccountBills(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesAccountBills(context.Background(), "", "", "", "", 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetFuturesAccountBills(context.Background(), "", "", currency.Pair{}, currency.Code{}, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetFuturesAccountBills(context.Background(), "meow", "", "", "", 0, 0, time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetFuturesAccountBills(context.Background(), "meow", "", currency.Pair{}, currency.Code{}, 0, 0, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetFuturesAccountBills(context.Background(), testFiat2.String()+"-FUTURES", "", "", "", 0, 0, time.Time{}, time.Time{}) + _, err = bi.GetFuturesAccountBills(context.Background(), testFiat2.String()+"-FUTURES", "", currency.Pair{}, currency.Code{}, 0, 0, time.Time{}, time.Time{}) assert.NoError(t, err) } func TestGetPositionTier(t *testing.T) { t.Parallel() - _, err := bi.GetPositionTier(context.Background(), "", "") + _, err := bi.GetPositionTier(context.Background(), "", currency.Pair{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetPositionTier(context.Background(), "meow", "") + _, err = bi.GetPositionTier(context.Background(), "meow", currency.Pair{}) assert.ErrorIs(t, err, errPairEmpty) - resp, err := bi.GetPositionTier(context.Background(), testFiat2.String()+"-FUTURES", testPair2.String()) + resp, err := bi.GetPositionTier(context.Background(), testFiat2.String()+"-FUTURES", testPair2) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestGetSinglePosition(t *testing.T) { t.Parallel() - _, err := bi.GetSinglePosition(context.Background(), "", "", "") + _, err := bi.GetSinglePosition(context.Background(), "", currency.Pair{}, currency.Code{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetSinglePosition(context.Background(), "meow", "", "") + _, err = bi.GetSinglePosition(context.Background(), "meow", currency.Pair{}, currency.Code{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetSinglePosition(context.Background(), "meow", "woof", "") + _, err = bi.GetSinglePosition(context.Background(), "meow", testPair2, currency.Code{}) assert.ErrorIs(t, err, errMarginCoinEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSinglePosition(context.Background(), testFiat2.String()+"-FUTURES", testPair2.String(), testFiat2.String()) + _, err = bi.GetSinglePosition(context.Background(), testFiat2.String()+"-FUTURES", testPair2, testFiat2) assert.NoError(t, err) } func TestGetAllPositions(t *testing.T) { t.Parallel() - _, err := bi.GetAllPositions(context.Background(), "", "") + _, err := bi.GetAllPositions(context.Background(), "", currency.Code{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetAllPositions(context.Background(), "meow", "") + _, err = bi.GetAllPositions(context.Background(), "meow", currency.Code{}) assert.ErrorIs(t, err, errMarginCoinEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetAllPositions(context.Background(), testFiat2.String()+"-FUTURES", testFiat2.String()) + _, err = bi.GetAllPositions(context.Background(), testFiat2.String()+"-FUTURES", testFiat2) assert.NoError(t, err) } func TestGetHistoricalPositions(t *testing.T) { t.Parallel() - _, err := bi.GetHistoricalPositions(context.Background(), "", "", 0, 0, time.Now().Add(time.Hour), time.Time{}) + _, err := bi.GetHistoricalPositions(context.Background(), currency.Pair{}, "", 0, 0, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetHistoricalPositions(context.Background(), "", "", 1<<62, 5, time.Time{}, time.Time{}) + _, err = bi.GetHistoricalPositions(context.Background(), currency.Pair{}, "", 1<<62, 5, time.Time{}, time.Time{}) assert.NoError(t, err) } func TestPlaceFuturesOrder(t *testing.T) { t.Parallel() - _, err := bi.PlaceFuturesOrder(context.Background(), "", "", "", "", "", "", "", "", "", 0, 0, 0, 0, false, false) + _, err := bi.PlaceFuturesOrder(context.Background(), currency.Pair{}, "", "", "", "", "", "", "", currency.Code{}, 0, 0, 0, 0, false, false) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.PlaceFuturesOrder(context.Background(), "meow", "", "", "", "", "", "", "", "", 0, 0, 0, 0, false, false) + _, err = bi.PlaceFuturesOrder(context.Background(), testPair2, "", "", "", "", "", "", "", currency.Code{}, 0, 0, 0, 0, false, false) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.PlaceFuturesOrder(context.Background(), "meow", "woof", "", "", "", "", "", "", "", 0, 0, 0, 0, false, false) + _, err = bi.PlaceFuturesOrder(context.Background(), testPair2, "woof", "", "", "", "", "", "", currency.Code{}, 0, 0, 0, 0, false, false) assert.ErrorIs(t, err, errMarginModeEmpty) - _, err = bi.PlaceFuturesOrder(context.Background(), "meow", "woof", "neigh", "", "", "", "", "", "", 0, 0, 0, 0, false, false) + _, err = bi.PlaceFuturesOrder(context.Background(), testPair2, "woof", "neigh", "", "", "", "", "", currency.Code{}, 0, 0, 0, 0, false, false) assert.ErrorIs(t, err, errMarginCoinEmpty) - _, err = bi.PlaceFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "", "", "", "", 0, 0, 0, 0, false, false) + _, err = bi.PlaceFuturesOrder(context.Background(), testPair2, "woof", "neigh", "oink", "", "", "", "", currency.Code{}, 0, 0, 0, 0, false, false) assert.ErrorIs(t, err, errSideEmpty) - _, err = bi.PlaceFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "", "", "", 0, 0, 0, 0, false, false) + _, err = bi.PlaceFuturesOrder(context.Background(), testPair2, "woof", "neigh", "oink", "quack", "", "", "", currency.Code{}, 0, 0, 0, 0, false, false) assert.ErrorIs(t, err, errOrderTypeEmpty) - _, err = bi.PlaceFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "limit", "", "", 0, 0, 0, 0, false, false) + _, err = bi.PlaceFuturesOrder(context.Background(), testPair2, "woof", "neigh", "oink", "quack", "", "limit", "", currency.Code{}, 0, 0, 0, 0, false, false) assert.ErrorIs(t, err, errAmountEmpty) - _, err = bi.PlaceFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "limit", "", "", 0, 0, 1, 0, false, false) + _, err = bi.PlaceFuturesOrder(context.Background(), testPair2, "woof", "neigh", "oink", "quack", "", "limit", "", currency.Code{}, 0, 0, 1, 0, false, false) assert.ErrorIs(t, err, errLimitPriceEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.PlaceFuturesOrder(context.Background(), testPair2.String(), testFiat2.String()+"-FUTURES", "isolated", testFiat2.String(), "buy", "open", "limit", "GTC", clientIDGenerator(), testPrice2+1, testPrice2-1, testAmount2, testPrice2, true, true) + resp, err := bi.PlaceFuturesOrder(context.Background(), testPair2, testFiat2.String()+"-FUTURES", "isolated", "buy", "open", "limit", "GTC", clientIDGenerator(), testFiat2, testPrice2+1, testPrice2-1, testAmount2, testPrice2, true, true) assert.NoError(t, err) assert.NotEmpty(t, resp) } func TestPlaceReversal(t *testing.T) { t.Parallel() - _, err := bi.PlaceReversal(context.Background(), "", "", "", "", "", "", 0, false) + _, err := bi.PlaceReversal(context.Background(), currency.Pair{}, currency.Code{}, "", "", "", "", 0, false) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.PlaceReversal(context.Background(), "meow", "", "", "", "", "", 0, false) + _, err = bi.PlaceReversal(context.Background(), testPair2, currency.Code{}, "", "", "", "", 0, false) assert.ErrorIs(t, err, errMarginCoinEmpty) - _, err = bi.PlaceReversal(context.Background(), "meow", "woof", "", "", "", "", 0, false) + _, err = bi.PlaceReversal(context.Background(), testPair2, testFiat2, "", "", "", "", 0, false) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.PlaceReversal(context.Background(), "meow", "woof", "neigh", "", "", "", 0, false) + _, err = bi.PlaceReversal(context.Background(), testPair2, testFiat2, "neigh", "", "", "", 0, false) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.PlaceReversal(context.Background(), testPair2.String(), testFiat2.String(), testFiat2.String()+"-FUTURES", "Buy", "Open", clientIDGenerator(), testAmount, true) + _, err = bi.PlaceReversal(context.Background(), testPair2, testFiat2, testFiat2.String()+"-FUTURES", "Buy", "Open", clientIDGenerator(), testAmount, true) assert.NoError(t, err) } func TestBatchPlaceFuturesOrders(t *testing.T) { t.Parallel() - _, err := bi.BatchPlaceFuturesOrders(context.Background(), "", "", "", "", nil, false) + _, err := bi.BatchPlaceFuturesOrders(context.Background(), currency.Pair{}, "", "", currency.Code{}, nil, false) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.BatchPlaceFuturesOrders(context.Background(), "meow", "", "", "", nil, false) + _, err = bi.BatchPlaceFuturesOrders(context.Background(), testPair2, "", "", currency.Code{}, nil, false) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.BatchPlaceFuturesOrders(context.Background(), "meow", "woof", "", "", nil, false) + _, err = bi.BatchPlaceFuturesOrders(context.Background(), testPair2, "woof", "", currency.Code{}, nil, false) assert.ErrorIs(t, err, errMarginCoinEmpty) - _, err = bi.BatchPlaceFuturesOrders(context.Background(), "meow", "woof", "neigh", "", nil, false) + _, err = bi.BatchPlaceFuturesOrders(context.Background(), testPair2, "woof", "neigh", currency.Code{}, nil, false) assert.ErrorIs(t, err, errMarginModeEmpty) - _, err = bi.BatchPlaceFuturesOrders(context.Background(), "meow", "woof", "neigh", "oink", nil, false) + _, err = bi.BatchPlaceFuturesOrders(context.Background(), testPair2, "woof", "neigh", testFiat2, nil, false) assert.ErrorIs(t, err, errOrdersEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) orders := []PlaceFuturesOrderStruct{ @@ -1328,81 +1330,81 @@ func TestBatchPlaceFuturesOrders(t *testing.T) { Strategy: "FOK", }, } - _, err = bi.BatchPlaceFuturesOrders(context.Background(), testPair2.String(), testFiat2.String()+"-FUTURES", testFiat2.String(), "isolated", orders, true) + _, err = bi.BatchPlaceFuturesOrders(context.Background(), testPair2, testFiat2.String()+"-FUTURES", "isolated", testFiat2, orders, true) assert.NoError(t, err) } func TestGetFuturesOrderDetails(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesOrderDetails(context.Background(), "", "", "", 0) + _, err := bi.GetFuturesOrderDetails(context.Background(), currency.Pair{}, "", "", 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetFuturesOrderDetails(context.Background(), "meow", "", "", 0) + _, err = bi.GetFuturesOrderDetails(context.Background(), testPair2, "", "", 0) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetFuturesOrderDetails(context.Background(), "meow", "woof", "", 0) + _, err = bi.GetFuturesOrderDetails(context.Background(), testPair2, "woof", "", 0) assert.ErrorIs(t, err, errOrderClientEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) oID := getFuturesOrdIDHelper(t, false, true) - _, err = bi.GetFuturesOrderDetails(context.Background(), testPair2.String(), testFiat2.String()+"-FUTURES", oID.ClientOrderID, int64(oID.OrderID)) + _, err = bi.GetFuturesOrderDetails(context.Background(), testPair2, testFiat2.String()+"-FUTURES", oID.ClientOrderID, int64(oID.OrderID)) assert.NoError(t, err) } func TestGetFuturesFills(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesFills(context.Background(), 0, 0, 0, "", "", time.Time{}, time.Time{}) + _, err := bi.GetFuturesFills(context.Background(), 0, 0, 0, currency.Pair{}, "", time.Time{}, time.Time{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetFuturesFills(context.Background(), 0, 0, 0, "", "meow", time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetFuturesFills(context.Background(), 0, 0, 0, currency.Pair{}, "meow", time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetFuturesFills(context.Background(), 0, 1<<62, 5, "", testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + _, err = bi.GetFuturesFills(context.Background(), 0, 1<<62, 5, currency.Pair{}, testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) assert.NoError(t, err) } func TestGetFuturesOrderFillHistory(t *testing.T) { t.Parallel() - _, err := bi.GetFuturesOrderFillHistory(context.Background(), "", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetFuturesOrderFillHistory(context.Background(), currency.Pair{}, "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetFuturesOrderFillHistory(context.Background(), "", "meow", 0, 0, 0, time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetFuturesOrderFillHistory(context.Background(), currency.Pair{}, "meow", 0, 0, 0, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) // Keeps getting "Parameter verification failed" error and I can't figure out why - resp, err := bi.GetFuturesOrderFillHistory(context.Background(), "", testFiat2.String()+"-FUTURES", 0, 1<<62, 5, time.Time{}, time.Time{}) + resp, err := bi.GetFuturesOrderFillHistory(context.Background(), currency.Pair{}, testFiat2.String()+"-FUTURES", 0, 1<<62, 5, time.Time{}, time.Time{}) require.NoError(t, err) if len(resp.FillList) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetFuturesOrderFillHistory(context.Background(), "", testFiat2.String()+"-FUTURES", resp.FillList[0].OrderID, 1<<62, 5, time.Time{}, time.Time{}) + _, err = bi.GetFuturesOrderFillHistory(context.Background(), currency.Pair{}, testFiat2.String()+"-FUTURES", resp.FillList[0].OrderID, 1<<62, 5, time.Time{}, time.Time{}) assert.NoError(t, err) } func TestGetPendingFuturesOrders(t *testing.T) { t.Parallel() - _, err := bi.GetPendingFuturesOrders(context.Background(), 0, 0, 0, "", "", "", "", time.Time{}, time.Time{}) + _, err := bi.GetPendingFuturesOrders(context.Background(), 0, 0, 0, "", "", "", currency.Pair{}, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetPendingFuturesOrders(context.Background(), 0, 0, 0, "", "", "meow", "", time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetPendingFuturesOrders(context.Background(), 0, 0, 0, "", "", "meow", currency.Pair{}, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetPendingFuturesOrders(context.Background(), 0, 1<<62, 5, "", testPair2.String(), testFiat2.String()+"-FUTURES", "", time.Now().Add(-time.Hour*24*90), time.Now()) + resp, err := bi.GetPendingFuturesOrders(context.Background(), 0, 1<<62, 5, "", testFiat2.String()+"-FUTURES", "", testPair2, time.Now().Add(-time.Hour*24*90), time.Now()) require.NoError(t, err) if len(resp.EntrustedList) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetPendingFuturesOrders(context.Background(), resp.EntrustedList[0].OrderID, 1<<62, 5, "", testPair2.String(), testFiat2.String()+"-FUTURES", "", time.Time{}, time.Time{}) + _, err = bi.GetPendingFuturesOrders(context.Background(), resp.EntrustedList[0].OrderID, 1<<62, 5, "", testFiat2.String()+"-FUTURES", "", testPair2, time.Time{}, time.Time{}) assert.NoError(t, err) } func TestGetHistoricalFuturesOrders(t *testing.T) { t.Parallel() - _, err := bi.GetHistoricalFuturesOrders(context.Background(), 0, 0, 0, "", "", "", time.Time{}, time.Time{}) + _, err := bi.GetHistoricalFuturesOrders(context.Background(), 0, 0, 0, "", "", currency.Pair{}, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetHistoricalFuturesOrders(context.Background(), 0, 0, 0, "", "", "meow", time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetHistoricalFuturesOrders(context.Background(), 0, 0, 0, "", "", testPair2, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetHistoricalFuturesOrders(context.Background(), 0, 1<<62, 5, "", testPair2.String(), testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + resp, err := bi.GetHistoricalFuturesOrders(context.Background(), 0, 1<<62, 5, "", testFiat2.String()+"-FUTURES", testPair2, time.Time{}, time.Time{}) require.NoError(t, err) if len(resp.EntrustedList) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetHistoricalFuturesOrders(context.Background(), resp.EntrustedList[0].OrderID, 1<<62, 5, "", testPair2.String(), testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + _, err = bi.GetHistoricalFuturesOrders(context.Background(), resp.EntrustedList[0].OrderID, 1<<62, 5, "", testFiat2.String()+"-FUTURES", testPair2, time.Time{}, time.Time{}) assert.NoError(t, err) } @@ -1415,7 +1417,7 @@ func TestGetFuturesTriggerOrderByID(t *testing.T) { _, err = bi.GetFuturesTriggerOrderByID(context.Background(), "meow", "woof", 0) assert.ErrorIs(t, err, errPlanOrderIDEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 1<<62, 5, "", "normal_plan", "", testPair2.String(), testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + resp, err := bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 1<<62, 5, "", "normal_plan", "", testFiat2.String()+"-FUTURES", testPair2, time.Time{}, time.Time{}) require.NoError(t, err) if len(resp.EntrustedList) == 0 { t.Skip(skipInsufficientOrders) @@ -1426,79 +1428,79 @@ func TestGetFuturesTriggerOrderByID(t *testing.T) { func TestPlaceTPSLFuturesOrder(t *testing.T) { t.Parallel() - _, err := bi.PlaceTPSLFuturesOrder(context.Background(), "", "", "", "", "", "", "", "", 0, 0, 0) + _, err := bi.PlaceTPSLFuturesOrder(context.Background(), currency.Code{}, "", "", "", "", "", "", currency.Pair{}, 0, 0, 0) assert.ErrorIs(t, err, errMarginCoinEmpty) - _, err = bi.PlaceTPSLFuturesOrder(context.Background(), "meow", "", "", "", "", "", "", "", 0, 0, 0) + _, err = bi.PlaceTPSLFuturesOrder(context.Background(), testFiat2, "", "", "", "", "", "", currency.Pair{}, 0, 0, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.PlaceTPSLFuturesOrder(context.Background(), "meow", "woof", "", "", "", "", "", "", 0, 0, 0) + _, err = bi.PlaceTPSLFuturesOrder(context.Background(), testFiat2, "woof", "", "", "", "", "", currency.Pair{}, 0, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.PlaceTPSLFuturesOrder(context.Background(), "meow", "woof", "neigh", "", "", "", "", "", 0, 0, 0) + _, err = bi.PlaceTPSLFuturesOrder(context.Background(), testFiat2, "woof", "", "", "", "", "", testPair2, 0, 0, 0) assert.ErrorIs(t, err, errPlanTypeEmpty) - _, err = bi.PlaceTPSLFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "", "", "", 0, 0, 0) + _, err = bi.PlaceTPSLFuturesOrder(context.Background(), testFiat2, "woof", "neigh", "", "", "", "", testPair2, 0, 0, 0) assert.ErrorIs(t, err, errHoldSideEmpty) - _, err = bi.PlaceTPSLFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "quack", "", "", 0, 0, 0) + _, err = bi.PlaceTPSLFuturesOrder(context.Background(), testFiat2, "woof", "neigh", "", "", "quack", "", testPair2, 0, 0, 0) assert.ErrorIs(t, err, errTriggerPriceEmpty) - _, err = bi.PlaceTPSLFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "quack", "", "", 1, 0, 0) + _, err = bi.PlaceTPSLFuturesOrder(context.Background(), testFiat2, "woof", "neigh", "", "", "quack", "", testPair2, 1, 0, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) cID := clientIDGenerator() - resp, err := bi.PlaceTPSLFuturesOrder(context.Background(), testFiat2.String(), testFiat2.String()+"-FUTURES", testPair2.String(), "profit_plan", "", "short", "", cID, testPrice2+2, 0, testAmount2) + resp, err := bi.PlaceTPSLFuturesOrder(context.Background(), testFiat2, testFiat2.String()+"-FUTURES", "profit_plan", "", "short", "", cID, testPair2, testPrice2+2, 0, testAmount2) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestPlaceTriggerFuturesOrder(t *testing.T) { t.Parallel() - _, err := bi.PlaceTriggerFuturesOrder(context.Background(), "", "", "", "", "", "", "", "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, false) + _, err := bi.PlaceTriggerFuturesOrder(context.Background(), "", "", "", "", "", "", "", "", "", "", currency.Pair{}, currency.Code{}, 0, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errPlanTypeEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "", "", "", "", "", "", "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "", "", "", "", "", "", "", "", "", currency.Pair{}, currency.Code{}, 0, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "", "", "", "", "", "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "", "", "", "", "", "", "", "", "", testPair2, currency.Code{}, 0, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "", "", "", "", "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "", "", "", "", "", "", "", "", testPair2, currency.Code{}, 0, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errMarginModeEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "", "", "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "", "", "", "", "", "", "", testPair2, currency.Code{}, 0, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errMarginCoinEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "", "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "", "", "", "", "", "", "", testPair2, testFiat2, 0, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errTriggerTypeEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "baa", "", "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "", "", "", "", "", testPair2, testFiat2, 0, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errSideEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "baa", "moo", "", "", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "", "", "", "", testPair2, testFiat2, 0, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errOrderTypeEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "baa", "moo", "", "cluck", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "", "", "cluck", "", testPair2, testFiat2, 0, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errAmountEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "baa", "moo", "", "cluck", "", "", "", 1, 0, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "", "", "cluck", "", testPair2, testFiat2, 1, 0, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errExecutePriceEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "baa", "moo", "", "cluck", "", "", "", 1, 1, 0, 0, 0, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "", "", "cluck", "", testPair2, testFiat2, 1, 1, 0, 0, 0, 0, 0, 0, false) assert.ErrorIs(t, err, errTriggerPriceEmpty) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "baa", "moo", "", "cluck", "", "", "", 1, 1, 0, 1, 1, 0, 0, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "", "", "cluck", "", testPair2, testFiat2, 1, 1, 0, 1, 1, 0, 0, 0, false) assert.ErrorIs(t, err, errTakeProfitParamsInconsistency) - _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "baa", "moo", "", "cluck", "", "", "", 1, 1, 0, 1, 0, 0, 1, 0, false) + _, err = bi.PlaceTriggerFuturesOrder(context.Background(), "meow", "woof", "neigh", "oink", "quack", "", "", "", "cluck", "", testPair2, testFiat2, 1, 1, 0, 1, 0, 0, 1, 0, false) assert.ErrorIs(t, err, errStopLossParamsInconsistency) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) // This returns the error "The parameter does not meet the specification d delegateType is error". The documentation doesn't mention that parameter anywhere, nothing seems similar to it, and attempts to send that parameter with various values, or to tweak other parameters, yielded no difference - resp, err := bi.PlaceTriggerFuturesOrder(context.Background(), "normal_plan", testPair2.String(), testFiat2.String()+"-FUTURES", "isolated", testFiat2.String(), "mark_price", "Sell", "", "limit", clientIDGenerator(), "", "", testAmount2*1000, testPrice2+2, 0, testPrice2+1, 0, 0, 0, 0, false) + resp, err := bi.PlaceTriggerFuturesOrder(context.Background(), "normal_plan", testFiat2.String()+"-FUTURES", "isolated", "mark_price", "Sell", "", "limit", clientIDGenerator(), "", "", testPair2, testFiat2, testAmount2*1000, testPrice2+2, 0, testPrice2+1, 0, 0, 0, 0, false) require.NoError(t, err) assert.NotEmpty(t, resp) } func TestModifyTPSLFuturesOrder(t *testing.T) { t.Parallel() - _, err := bi.ModifyTPSLFuturesOrder(context.Background(), 0, "", "", "", "", "", 0, 0, 0, 0) + _, err := bi.ModifyTPSLFuturesOrder(context.Background(), 0, "", "", "", currency.Code{}, currency.Pair{}, 0, 0, 0, 0) assert.ErrorIs(t, err, errOrderClientEmpty) - _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "", "", "", "", 0, 0, 0, 0) + _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "", "", currency.Code{}, currency.Pair{}, 0, 0, 0, 0) assert.ErrorIs(t, err, errMarginCoinEmpty) - _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "meow", "", "", "", 0, 0, 0, 0) + _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "", "", testFiat2, currency.Pair{}, 0, 0, 0, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "meow", "woof", "", "", 0, 0, 0, 0) + _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "meow", "", testFiat2, currency.Pair{}, 0, 0, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "meow", "woof", "neigh", "", 0, 0, 0, 0) + _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "meow", "", testFiat2, testPair2, 0, 0, 0, 0) assert.ErrorIs(t, err, errTriggerPriceEmpty) - _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "meow", "woof", "neigh", "", 1, 0, 0, 0) + _, err = bi.ModifyTPSLFuturesOrder(context.Background(), 1, "", "meow", "", testFiat2, testPair2, 1, 0, 0, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) ID := getTrigOrdIDHelper(t, []string{"profit_loss"}) - resp, err := bi.ModifyTPSLFuturesOrder(context.Background(), int64(ID.OrderID), ID.ClientOrderID, testFiat2.String(), testFiat2.String()+"-FUTURES", testPair2.String(), "", testPrice2-1, testPrice2+2, testAmount2, 0.1) + resp, err := bi.ModifyTPSLFuturesOrder(context.Background(), int64(ID.OrderID), ID.ClientOrderID, testFiat2.String()+"-FUTURES", "", testFiat2, testPair2, testPrice2-1, testPrice2+2, testAmount2, 0.1) require.NoError(t, err) assert.NotEmpty(t, resp) } @@ -1516,37 +1518,37 @@ func TestModifyTriggerFuturesOrder(t *testing.T) { func TestGetPendingTriggerFuturesOrders(t *testing.T) { t.Parallel() - _, err := bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "", "", "", time.Time{}, time.Time{}) + _, err := bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "", "", currency.Pair{}, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPlanTypeEmpty) - _, err = bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "", "meow", "", time.Time{}, time.Time{}) + _, err = bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "meow", "", currency.Pair{}, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "", "meow", "woof", time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "meow", "woof", currency.Pair{}, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 1<<62, 5, "", testPair2.String(), "profit_loss", testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + resp, err := bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 1<<62, 5, "", "profit_loss", testFiat2.String()+"-FUTURES", testPair2, time.Time{}, time.Time{}) require.NoError(t, err) if len(resp.EntrustedList) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetPendingTriggerFuturesOrders(context.Background(), resp.EntrustedList[0].OrderID, 1<<62, 5, "", testPair2.String(), "profit_loss", testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + _, err = bi.GetPendingTriggerFuturesOrders(context.Background(), resp.EntrustedList[0].OrderID, 1<<62, 5, "", "profit_loss", testFiat2.String()+"-FUTURES", testPair2, time.Time{}, time.Time{}) assert.NoError(t, err) } func TestGetHistoricalTriggerFuturesOrders(t *testing.T) { t.Parallel() - _, err := bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "", "", "", "", time.Time{}, time.Time{}) + _, err := bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "", "", "", testPair2, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPlanTypeEmpty) - _, err = bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "meow", "", "", "", time.Time{}, time.Time{}) + _, err = bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "meow", "", "", testPair2, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "meow", "", "", "woof", time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 0, 0, "", "meow", "", "woof", testPair2, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 1<<62, 5, "", "normal_plan", "", testPair2.String(), testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + resp, err := bi.GetHistoricalTriggerFuturesOrders(context.Background(), 0, 1<<62, 5, "", "normal_plan", "", testFiat2.String()+"-FUTURES", testPair2, time.Time{}, time.Time{}) require.NoError(t, err) if len(resp.EntrustedList) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetHistoricalTriggerFuturesOrders(context.Background(), resp.EntrustedList[0].OrderID, 1<<62, 5, "", "normal_plan", "", testPair2.String(), testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + _, err = bi.GetHistoricalTriggerFuturesOrders(context.Background(), resp.EntrustedList[0].OrderID, 1<<62, 5, "", "normal_plan", "", testFiat2.String()+"-FUTURES", testPair2, time.Time{}, time.Time{}) assert.NoError(t, err) } @@ -1564,37 +1566,32 @@ func TestGetSupportedCurrencies(t *testing.T) { } } } - fmt.Print(curMax) -} - -func TestLen(t *testing.T) { - fmt.Print(int(1)/int(47), int(50)/47, int(94)/47) } func TestGetCrossBorrowHistory(t *testing.T) { t.Parallel() - _, err := bi.GetCrossBorrowHistory(context.Background(), 0, 0, 0, "", time.Time{}, time.Time{}) + _, err := bi.GetCrossBorrowHistory(context.Background(), 0, 0, 0, currency.Code{}, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetCrossBorrowHistory(context.Background(), 1, 2, 1<<62, "", time.Now().Add(-time.Hour*24*85), time.Time{}) + _, err = bi.GetCrossBorrowHistory(context.Background(), 1, 2, 1<<62, currency.Code{}, time.Now().Add(-time.Hour*24*85), time.Time{}) assert.NoError(t, err) } func TestGetCrossRepayHistory(t *testing.T) { t.Parallel() - _, err := bi.GetCrossRepayHistory(context.Background(), 0, 0, 0, "", time.Time{}, time.Time{}) + _, err := bi.GetCrossRepayHistory(context.Background(), 0, 0, 0, currency.Code{}, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetCrossRepayHistory(context.Background(), 1, 2, 1<<62, "", time.Now().Add(-time.Hour*24*85), time.Time{}) + _, err = bi.GetCrossRepayHistory(context.Background(), 1, 2, 1<<62, currency.Code{}, time.Now().Add(-time.Hour*24*85), time.Time{}) assert.NoError(t, err) } func TestGetCrossInterestHistory(t *testing.T) { t.Parallel() - _, err := bi.GetCrossInterestHistory(context.Background(), "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetCrossInterestHistory(context.Background(), currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetCrossInterestHistory(context.Background(), "", time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) + _, err = bi.GetCrossInterestHistory(context.Background(), currency.Code{}, time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) assert.NoError(t, err) } @@ -1609,37 +1606,37 @@ func TestGetCrossLiquidationHistory(t *testing.T) { func TestGetCrossFinancialHistory(t *testing.T) { t.Parallel() - _, err := bi.GetCrossFinancialHistory(context.Background(), "", "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetCrossFinancialHistory(context.Background(), "", currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetCrossFinancialHistory(context.Background(), "", "", time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) + _, err = bi.GetCrossFinancialHistory(context.Background(), "", currency.Code{}, time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) assert.NoError(t, err) } func TestGetCrossAccountAssets(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetCrossAccountAssets, "", "", nil, false, true, true) + testGetOneArg(t, bi.GetCrossAccountAssets, currency.Code{}, currency.Code{}, nil, false, true, true) } func TestCrossBorrow(t *testing.T) { t.Parallel() - _, err := bi.CrossBorrow(context.Background(), "", "", 0) + _, err := bi.CrossBorrow(context.Background(), currency.Code{}, "", 0) assert.ErrorIs(t, err, errCurrencyEmpty) - _, err = bi.CrossBorrow(context.Background(), "meow", "", 0) + _, err = bi.CrossBorrow(context.Background(), testFiat, "", 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.CrossBorrow(context.Background(), testFiat.String(), clientIDGenerator(), testAmount) + _, err = bi.CrossBorrow(context.Background(), testFiat, clientIDGenerator(), testAmount) assert.NoError(t, err) } func TestCrossRepay(t *testing.T) { t.Parallel() - _, err := bi.CrossRepay(context.Background(), "", 0) + _, err := bi.CrossRepay(context.Background(), currency.Code{}, 0) assert.ErrorIs(t, err, errCurrencyEmpty) - _, err = bi.CrossRepay(context.Background(), "meow", 0) + _, err = bi.CrossRepay(context.Background(), testFiat, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.CrossRepay(context.Background(), testFiat.String(), testAmount) + _, err = bi.CrossRepay(context.Background(), testFiat, testAmount) assert.NoError(t, err) } @@ -1651,27 +1648,27 @@ func TestGetCrossRiskRate(t *testing.T) { func TestGetCrossMaxBorrowable(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetCrossMaxBorrowable, "", testFiat.String(), errCurrencyEmpty, false, true, true) + testGetOneArg(t, bi.GetCrossMaxBorrowable, currency.Code{}, testFiat, errCurrencyEmpty, false, true, true) } func TestGetCrossMaxTransferable(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetCrossMaxTransferable, "", testFiat.String(), errCurrencyEmpty, false, true, true) + testGetOneArg(t, bi.GetCrossMaxTransferable, currency.Code{}, testFiat, errCurrencyEmpty, false, true, true) } func TestGetCrossInterestRateAndMaxBorrowable(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetCrossInterestRateAndMaxBorrowable, "", testFiat.String(), errCurrencyEmpty, false, true, true) + testGetOneArg(t, bi.GetCrossInterestRateAndMaxBorrowable, currency.Code{}, testFiat, errCurrencyEmpty, false, true, true) } func TestGetCrossTierConfiguration(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetCrossTierConfiguration, "", testFiat.String(), errCurrencyEmpty, false, true, true) + testGetOneArg(t, bi.GetCrossTierConfiguration, currency.Code{}, testFiat, errCurrencyEmpty, false, true, true) } func TestCrossFlashRepay(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.CrossFlashRepay, "", testFiat.String(), nil, false, true, canManipulateRealOrders) + testGetOneArg(t, bi.CrossFlashRepay, currency.Code{}, testFiat, nil, false, true, canManipulateRealOrders) } func TestGetCrossFlashRepayResult(t *testing.T) { @@ -1680,7 +1677,7 @@ func TestGetCrossFlashRepayResult(t *testing.T) { assert.ErrorIs(t, err, errIDListEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) // This must be done, as this is the only way to get a repayment ID - resp, err := bi.CrossFlashRepay(context.Background(), testFiat.String()) + resp, err := bi.CrossFlashRepay(context.Background(), testFiat) require.NoError(t, err) require.NotEmpty(t, resp) _, err = bi.GetCrossFlashRepayResult(context.Background(), []int64{resp.RepayID}) @@ -1689,29 +1686,29 @@ func TestGetCrossFlashRepayResult(t *testing.T) { func TestPlaceCrossOrder(t *testing.T) { t.Parallel() - _, err := bi.PlaceCrossOrder(context.Background(), "", "", "", "", "", "", 0, 0, 0) + _, err := bi.PlaceCrossOrder(context.Background(), currency.Pair{}, "", "", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.PlaceCrossOrder(context.Background(), "meow", "", "", "", "", "", 0, 0, 0) + _, err = bi.PlaceCrossOrder(context.Background(), testPair, "", "", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errOrderTypeEmpty) - _, err = bi.PlaceCrossOrder(context.Background(), "meow", "woof", "", "", "", "", 0, 0, 0) + _, err = bi.PlaceCrossOrder(context.Background(), testPair, "woof", "", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errLoanTypeEmpty) - _, err = bi.PlaceCrossOrder(context.Background(), "meow", "woof", "neigh", "", "", "", 0, 0, 0) + _, err = bi.PlaceCrossOrder(context.Background(), testPair, "woof", "neigh", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errStrategyEmpty) - _, err = bi.PlaceCrossOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "", 0, 0, 0) + _, err = bi.PlaceCrossOrder(context.Background(), testPair, "woof", "neigh", "oink", "", "", 0, 0, 0) assert.ErrorIs(t, err, errSideEmpty) - _, err = bi.PlaceCrossOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "quack", 0, 0, 0) + _, err = bi.PlaceCrossOrder(context.Background(), testPair, "woof", "neigh", "oink", "", "quack", 0, 0, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.PlaceCrossOrder(context.Background(), testPair.String(), "limit", "normal", "GTC", "", "Buy", + _, err = bi.PlaceCrossOrder(context.Background(), testPair, "limit", "normal", "GTC", "", "Buy", testPrice2, testAmount2, 0) assert.NoError(t, err) } func TestBatchPlaceCrossOrders(t *testing.T) { t.Parallel() - _, err := bi.BatchPlaceCrossOrders(context.Background(), "", nil) + _, err := bi.BatchPlaceCrossOrders(context.Background(), currency.Pair{}, nil) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.BatchPlaceCrossOrders(context.Background(), "meow", nil) + _, err = bi.BatchPlaceCrossOrders(context.Background(), testPair, nil) assert.ErrorIs(t, err, errOrdersEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) orders := []MarginOrderData{ @@ -1724,173 +1721,173 @@ func TestBatchPlaceCrossOrders(t *testing.T) { Side: "Buy", }, } - _, err = bi.BatchPlaceCrossOrders(context.Background(), testPair.String(), orders) + _, err = bi.BatchPlaceCrossOrders(context.Background(), testPair, orders) assert.NoError(t, err) } func TestGetCrossOpenOrders(t *testing.T) { t.Parallel() - _, err := bi.GetCrossOpenOrders(context.Background(), "", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetCrossOpenOrders(context.Background(), currency.Pair{}, "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetCrossOpenOrders(context.Background(), "meow", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err = bi.GetCrossOpenOrders(context.Background(), testPair, "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) resp := getCrossOrdIDHelper(t, true) - _, err = bi.GetCrossOpenOrders(context.Background(), testPair.String(), "", int64(resp.OrderID), 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + _, err = bi.GetCrossOpenOrders(context.Background(), testPair, "", int64(resp.OrderID), 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) assert.NoError(t, err) } func TestGetCrossHistoricalorders(t *testing.T) { t.Parallel() - _, err := bi.GetCrossHistoricalOrders(context.Background(), "", "", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetCrossHistoricalOrders(context.Background(), currency.Pair{}, "", "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetCrossHistoricalOrders(context.Background(), "meow", "", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err = bi.GetCrossHistoricalOrders(context.Background(), testPair, "", "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetCrossHistoricalOrders(context.Background(), testPair.String(), "", "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + resp, err := bi.GetCrossHistoricalOrders(context.Background(), testPair, "", "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) require.NoError(t, err) if len(resp.OrderList) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetCrossHistoricalOrders(context.Background(), testPair.String(), "", "", resp.OrderList[0].OrderID, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + _, err = bi.GetCrossHistoricalOrders(context.Background(), testPair, "", "", resp.OrderList[0].OrderID, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) assert.NoError(t, err) } func TestGetCrossOrderFills(t *testing.T) { t.Parallel() - _, err := bi.GetCrossOrderFills(context.Background(), "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetCrossOrderFills(context.Background(), currency.Pair{}, 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetCrossOrderFills(context.Background(), "meow", 0, 0, 0, time.Time{}, time.Time{}) + _, err = bi.GetCrossOrderFills(context.Background(), testPair, 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetCrossOrderFills(context.Background(), testPair.String(), 0, 1<<62, 5, time.Now().Add(-time.Hour*24*85), time.Time{}) + resp, err := bi.GetCrossOrderFills(context.Background(), testPair, 0, 1<<62, 5, time.Now().Add(-time.Hour*24*85), time.Time{}) require.NoError(t, err) if len(resp.Fills) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetCrossOrderFills(context.Background(), testPair.String(), resp.Fills[0].OrderID, 1<<62, 5, time.Now().Add(-time.Hour*24*85), time.Time{}) + _, err = bi.GetCrossOrderFills(context.Background(), testPair, resp.Fills[0].OrderID, 1<<62, 5, time.Now().Add(-time.Hour*24*85), time.Time{}) assert.NoError(t, err) } func TestGetCrossLiquidationOrders(t *testing.T) { t.Parallel() - _, err := bi.GetCrossLiquidationOrders(context.Background(), "", "", "", "", time.Now().Add(time.Hour), time.Time{}, 5, 1<<62) + _, err := bi.GetCrossLiquidationOrders(context.Background(), "", "", "", currency.Pair{}, time.Now().Add(time.Hour), time.Time{}, 5, 1<<62) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetCrossLiquidationOrders(context.Background(), "", "", "", "", time.Time{}, time.Time{}, 5, 1<<62) + _, err = bi.GetCrossLiquidationOrders(context.Background(), "", "", "", currency.Pair{}, time.Time{}, time.Time{}, 5, 1<<62) assert.NoError(t, err) } func TestGetIsolatedRepayHistory(t *testing.T) { t.Parallel() - _, err := bi.GetIsolatedRepayHistory(context.Background(), "", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetIsolatedRepayHistory(context.Background(), currency.Pair{}, "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetIsolatedRepayHistory(context.Background(), "meow", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err = bi.GetIsolatedRepayHistory(context.Background(), testPair, "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetIsolatedRepayHistory(context.Background(), testPair.String(), "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + resp, err := bi.GetIsolatedRepayHistory(context.Background(), testPair, "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) require.NoError(t, err) if len(resp.ResultList) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetIsolatedRepayHistory(context.Background(), testPair.String(), "", resp.ResultList[0].RepayID, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + _, err = bi.GetIsolatedRepayHistory(context.Background(), testPair, "", resp.ResultList[0].RepayID, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) assert.NoError(t, err) } func TestGetIsolatedInterestHistory(t *testing.T) { t.Parallel() - _, err := bi.GetIsolatedInterestHistory(context.Background(), "", "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetIsolatedInterestHistory(context.Background(), currency.Pair{}, currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetIsolatedInterestHistory(context.Background(), "meow", "", time.Time{}, time.Time{}, 0, 0) + _, err = bi.GetIsolatedInterestHistory(context.Background(), testPair, currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetIsolatedInterestHistory(context.Background(), testPair.String(), "", time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) + _, err = bi.GetIsolatedInterestHistory(context.Background(), testPair, currency.Code{}, time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) assert.NoError(t, err) } func TestGetIsolatedLiquidationHistory(t *testing.T) { t.Parallel() - _, err := bi.GetIsolatedLiquidationHistory(context.Background(), "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetIsolatedLiquidationHistory(context.Background(), currency.Pair{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetIsolatedLiquidationHistory(context.Background(), "meow", time.Time{}, time.Time{}, 0, 0) + _, err = bi.GetIsolatedLiquidationHistory(context.Background(), testPair, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetIsolatedLiquidationHistory(context.Background(), testPair.String(), time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) + _, err = bi.GetIsolatedLiquidationHistory(context.Background(), testPair, time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) assert.NoError(t, err) } func TestGetIsolatedFinancialHistory(t *testing.T) { t.Parallel() - _, err := bi.GetIsolatedFinancialHistory(context.Background(), "", "", "", time.Time{}, time.Time{}, 0, 0) + _, err := bi.GetIsolatedFinancialHistory(context.Background(), currency.Pair{}, "", currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetIsolatedFinancialHistory(context.Background(), "meow", "", "", time.Time{}, time.Time{}, 0, 0) + _, err = bi.GetIsolatedFinancialHistory(context.Background(), testPair, "", currency.Code{}, time.Time{}, time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetIsolatedFinancialHistory(context.Background(), testPair.String(), "", "", time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) + _, err = bi.GetIsolatedFinancialHistory(context.Background(), testPair, "", currency.Code{}, time.Now().Add(-time.Hour*24*85), time.Time{}, 2, 1<<62) assert.NoError(t, err) } func TestGetIsolatedAccountAssets(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetIsolatedAccountAssets, "", "", nil, false, true, true) + testGetOneArg(t, bi.GetIsolatedAccountAssets, currency.Pair{}, currency.Pair{}, nil, false, true, true) } func TestIsolatedBorrow(t *testing.T) { t.Parallel() - _, err := bi.IsolatedBorrow(context.Background(), "", "", "", 0) + _, err := bi.IsolatedBorrow(context.Background(), currency.Pair{}, currency.Code{}, "", 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.IsolatedBorrow(context.Background(), "meow", "", "", 0) + _, err = bi.IsolatedBorrow(context.Background(), testPair, currency.Code{}, "", 0) assert.ErrorIs(t, err, errCurrencyEmpty) - _, err = bi.IsolatedBorrow(context.Background(), "meow", "woof", "", 0) + _, err = bi.IsolatedBorrow(context.Background(), testPair, testFiat, "", 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.IsolatedBorrow(context.Background(), testPair.String(), testFiat.String(), "", testAmount) + _, err = bi.IsolatedBorrow(context.Background(), testPair, testFiat, "", testAmount) assert.NoError(t, err) } func TestIsolatedRepay(t *testing.T) { t.Parallel() - _, err := bi.IsolatedRepay(context.Background(), 0, "", "", "") + _, err := bi.IsolatedRepay(context.Background(), 0, currency.Code{}, currency.Pair{}, "") assert.ErrorIs(t, err, errAmountEmpty) - _, err = bi.IsolatedRepay(context.Background(), 1, "", "", "") + _, err = bi.IsolatedRepay(context.Background(), 1, currency.Code{}, currency.Pair{}, "") assert.ErrorIs(t, err, errCurrencyEmpty) - _, err = bi.IsolatedRepay(context.Background(), 1, "meow", "", "") + _, err = bi.IsolatedRepay(context.Background(), 1, testFiat, currency.Pair{}, "") assert.ErrorIs(t, err, errPairEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.IsolatedRepay(context.Background(), testAmount, testFiat.String(), testPair.String(), "") + _, err = bi.IsolatedRepay(context.Background(), testAmount, testFiat, testPair, "") assert.NoError(t, err) } func TestGetIsolatedRiskRate(t *testing.T) { t.Parallel() sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err := bi.GetIsolatedRiskRate(context.Background(), "", 1, 5) + _, err := bi.GetIsolatedRiskRate(context.Background(), currency.Pair{}, 1, 5) assert.NoError(t, err) } func TestGetIsolatedInterestRateAndMaxBorrowable(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetIsolatedInterestRateAndMaxBorrowable, "", testPair.String(), errPairEmpty, false, true, true) + testGetOneArg(t, bi.GetIsolatedInterestRateAndMaxBorrowable, currency.Pair{}, testPair, errPairEmpty, false, true, true) } func TestGetIsolatedTierConfiguration(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetIsolatedTierConfiguration, "", testPair.String(), errPairEmpty, false, true, true) + testGetOneArg(t, bi.GetIsolatedTierConfiguration, currency.Pair{}, testPair, errPairEmpty, false, true, true) } func TestGetIsolatedMaxborrowable(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetIsolatedMaxBorrowable, "", testPair.String(), errPairEmpty, false, true, true) + testGetOneArg(t, bi.GetIsolatedMaxBorrowable, currency.Pair{}, testPair, errPairEmpty, false, true, true) } func TestGetIsolatedMaxTransferable(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetIsolatedMaxTransferable, "", testPair.String(), errPairEmpty, false, true, true) + testGetOneArg(t, bi.GetIsolatedMaxTransferable, currency.Pair{}, testPair, errPairEmpty, false, true, true) } func TestIsolatedFlashRepay(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.IsolatedFlashRepay, nil, []string{testPair.String()}, nil, false, true, canManipulateRealOrders) + testGetOneArg(t, bi.IsolatedFlashRepay, nil, currency.Pairs{testPair}, nil, false, true, canManipulateRealOrders) } func TestGetIsolatedFlashRepayResult(t *testing.T) { @@ -1899,7 +1896,7 @@ func TestGetIsolatedFlashRepayResult(t *testing.T) { assert.ErrorIs(t, err, errIDListEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) // This must be done, as this is the only way to get a repayment ID - resp, err := bi.IsolatedFlashRepay(context.Background(), []string{testPair.String()}) + resp, err := bi.IsolatedFlashRepay(context.Background(), currency.Pairs{testPair}) require.NoError(t, err) require.NotEmpty(t, resp) _, err = bi.GetIsolatedFlashRepayResult(context.Background(), []int64{resp[0].RepayID}) @@ -1908,28 +1905,28 @@ func TestGetIsolatedFlashRepayResult(t *testing.T) { func TestPlaceIsolatedOrder(t *testing.T) { t.Parallel() - _, err := bi.PlaceIsolatedOrder(context.Background(), "", "", "", "", "", "", 0, 0, 0) + _, err := bi.PlaceIsolatedOrder(context.Background(), currency.Pair{}, "", "", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.PlaceIsolatedOrder(context.Background(), "meow", "", "", "", "", "", 0, 0, 0) + _, err = bi.PlaceIsolatedOrder(context.Background(), testPair, "", "", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errOrderTypeEmpty) - _, err = bi.PlaceIsolatedOrder(context.Background(), "meow", "woof", "", "", "", "", 0, 0, 0) + _, err = bi.PlaceIsolatedOrder(context.Background(), testPair, "meow", "", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errLoanTypeEmpty) - _, err = bi.PlaceIsolatedOrder(context.Background(), "meow", "woof", "neigh", "", "", "", 0, 0, 0) + _, err = bi.PlaceIsolatedOrder(context.Background(), testPair, "meow", "woof", "", "", "", 0, 0, 0) assert.ErrorIs(t, err, errStrategyEmpty) - _, err = bi.PlaceIsolatedOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "", 0, 0, 0) + _, err = bi.PlaceIsolatedOrder(context.Background(), testPair, "meow", "woof", "neigh", "", "", 0, 0, 0) assert.ErrorIs(t, err, errSideEmpty) - _, err = bi.PlaceIsolatedOrder(context.Background(), "meow", "woof", "neigh", "oink", "", "quack", 0, 0, 0) + _, err = bi.PlaceIsolatedOrder(context.Background(), testPair, "meow", "woof", "neigh", "", "quack", 0, 0, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.PlaceIsolatedOrder(context.Background(), testPair.String(), "limit", "normal", "GTC", "", "Buy", testPrice2, testAmount2, 0) + _, err = bi.PlaceIsolatedOrder(context.Background(), testPair, "limit", "normal", "GTC", "", "Buy", testPrice2, testAmount2, 0) assert.NoError(t, err) } func TestBatchPlaceIsolatedOrders(t *testing.T) { t.Parallel() - _, err := bi.BatchPlaceIsolatedOrders(context.Background(), "", nil) + _, err := bi.BatchPlaceIsolatedOrders(context.Background(), currency.Pair{}, nil) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.BatchPlaceIsolatedOrders(context.Background(), "meow", nil) + _, err = bi.BatchPlaceIsolatedOrders(context.Background(), testPair, nil) assert.ErrorIs(t, err, errOrdersEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) orders := []MarginOrderData{ @@ -1942,69 +1939,69 @@ func TestBatchPlaceIsolatedOrders(t *testing.T) { Side: "Buy", }, } - _, err = bi.BatchPlaceIsolatedOrders(context.Background(), testPair.String(), orders) + _, err = bi.BatchPlaceIsolatedOrders(context.Background(), testPair, orders) assert.NoError(t, err) } func TestGetIsolatedOpenOrders(t *testing.T) { t.Parallel() - _, err := bi.GetIsolatedOpenOrders(context.Background(), "", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetIsolatedOpenOrders(context.Background(), currency.Pair{}, "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetIsolatedOpenOrders(context.Background(), "meow", "", 0, 0, 0, time.Now().Add(time.Hour), time.Time{}) + _, err = bi.GetIsolatedOpenOrders(context.Background(), testPair, "", 0, 0, 0, time.Now().Add(time.Hour), time.Time{}) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) resp := getIsoOrdIDHelper(t, true) - _, err = bi.GetIsolatedOpenOrders(context.Background(), testPair.String(), "", int64(resp.OrderID), 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + _, err = bi.GetIsolatedOpenOrders(context.Background(), testPair, "", int64(resp.OrderID), 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) assert.NoError(t, err) } func TestGetIsolatedHistoricalOrders(t *testing.T) { t.Parallel() - _, err := bi.GetIsolatedHistoricalOrders(context.Background(), "", "", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetIsolatedHistoricalOrders(context.Background(), currency.Pair{}, "", "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetIsolatedHistoricalOrders(context.Background(), "meow", "", "", 0, 0, 0, time.Time{}, time.Time{}) + _, err = bi.GetIsolatedHistoricalOrders(context.Background(), testPair, "", "", 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetIsolatedHistoricalOrders(context.Background(), testPair.String(), "", "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + resp, err := bi.GetIsolatedHistoricalOrders(context.Background(), testPair, "", "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) require.NoError(t, err) if len(resp.OrderList) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetIsolatedHistoricalOrders(context.Background(), testPair.String(), "", "", resp.OrderList[0].OrderID, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + _, err = bi.GetIsolatedHistoricalOrders(context.Background(), testPair, "", "", resp.OrderList[0].OrderID, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) assert.NoError(t, err) } func TestGetIsolatedOrderFills(t *testing.T) { t.Parallel() - _, err := bi.GetIsolatedOrderFills(context.Background(), "", 0, 0, 0, time.Time{}, time.Time{}) + _, err := bi.GetIsolatedOrderFills(context.Background(), currency.Pair{}, 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.GetIsolatedOrderFills(context.Background(), "meow", 0, 0, 0, time.Time{}, time.Time{}) + _, err = bi.GetIsolatedOrderFills(context.Background(), testPair, 0, 0, 0, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetIsolatedOrderFills(context.Background(), testPair.String(), 0, 1<<62, 5, time.Now().Add(-time.Hour*24*85), time.Time{}) + resp, err := bi.GetIsolatedOrderFills(context.Background(), testPair, 0, 1<<62, 5, time.Now().Add(-time.Hour*24*85), time.Time{}) require.NoError(t, err) if len(resp.Fills) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetIsolatedOrderFills(context.Background(), testPair.String(), resp.Fills[0].OrderID, 1<<62, 5, time.Now().Add(-time.Hour*24*85), time.Time{}) + _, err = bi.GetIsolatedOrderFills(context.Background(), testPair, resp.Fills[0].OrderID, 1<<62, 5, time.Now().Add(-time.Hour*24*85), time.Time{}) assert.NoError(t, err) } func TestGetIsolatedLiquidationOrders(t *testing.T) { t.Parallel() - _, err := bi.GetIsolatedLiquidationOrders(context.Background(), "", "", "", "", time.Now().Add(time.Hour), time.Time{}, 5, 1<<62) + _, err := bi.GetIsolatedLiquidationOrders(context.Background(), "", "", "", currency.Pair{}, time.Now().Add(time.Hour), time.Time{}, 5, 1<<62) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetIsolatedLiquidationOrders(context.Background(), "", "", "", "", time.Time{}, time.Time{}, 5, 1<<62) + _, err = bi.GetIsolatedLiquidationOrders(context.Background(), "", "", "", currency.Pair{}, time.Time{}, time.Time{}, 5, 1<<62) assert.NoError(t, err) } func TestGetSavingsProductList(t *testing.T) { t.Parallel() - _, err := bi.GetSavingsProductList(context.Background(), "", "") + _, err := bi.GetSavingsProductList(context.Background(), currency.Code{}, "") assert.ErrorIs(t, err, errCurrencyEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSavingsProductList(context.Background(), testCrypto.String(), "") + _, err = bi.GetSavingsProductList(context.Background(), testCrypto, "") assert.NoError(t, err) } @@ -2025,10 +2022,10 @@ func TestGetSavingsAssets(t *testing.T) { func TestGetSavingsRecords(t *testing.T) { t.Parallel() - _, err := bi.GetSavingsRecords(context.Background(), "", "", "", time.Now().Add(time.Hour), time.Time{}, 0, 0) + _, err := bi.GetSavingsRecords(context.Background(), currency.Code{}, "", "", time.Now().Add(time.Hour), time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSavingsRecords(context.Background(), "", "", "", time.Time{}, time.Time{}, 5, 1<<62) + _, err = bi.GetSavingsRecords(context.Background(), currency.Code{}, "", "", time.Time{}, time.Time{}, 5, 1<<62) assert.NoError(t, err) } @@ -2039,7 +2036,7 @@ func TestGetSavingsSubscriptionDetail(t *testing.T) { _, err = bi.GetSavingsSubscriptionDetail(context.Background(), 1, "") assert.ErrorIs(t, err, errPeriodTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetSavingsProductList(context.Background(), testCrypto.String(), "") + resp, err := bi.GetSavingsProductList(context.Background(), testCrypto, "") require.NoError(t, err) require.NotEmpty(t, resp) _, err = bi.GetSavingsSubscriptionDetail(context.Background(), resp[0].ProductID, resp[0].PeriodType) @@ -2055,7 +2052,7 @@ func TestSubscribeSavings(t *testing.T) { _, err = bi.SubscribeSavings(context.Background(), 1, "meow", 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetSavingsProductList(context.Background(), testCrypto.String(), "") + resp, err := bi.GetSavingsProductList(context.Background(), testCrypto, "") require.NoError(t, err) require.NotEmpty(t, resp) resp2, err := bi.GetSavingsSubscriptionDetail(context.Background(), resp[0].ProductID, resp[0].PeriodType) @@ -2072,7 +2069,7 @@ func TestGetSavingsSubscriptionResult(t *testing.T) { _, err = bi.GetSavingsSubscriptionResult(context.Background(), 1, "") assert.ErrorIs(t, err, errPeriodTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetSavingsRecords(context.Background(), "", "", "", time.Time{}, time.Time{}, 100, 0) + resp, err := bi.GetSavingsRecords(context.Background(), currency.Code{}, "", "", time.Time{}, time.Time{}, 100, 0) require.NoError(t, err) require.NotEmpty(t, resp.ResultList) tarID := -1 @@ -2134,7 +2131,7 @@ func TestGetSavingsRedemptionResult(t *testing.T) { _, err = bi.GetSavingsRedemptionResult(context.Background(), 1, "") assert.ErrorIs(t, err, errPeriodTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetSavingsRecords(context.Background(), "", "", "", time.Time{}, time.Time{}, 100, 0) + resp, err := bi.GetSavingsRecords(context.Background(), currency.Code{}, "", "", time.Time{}, time.Time{}, 100, 0) require.NoError(t, err) require.NotEmpty(t, resp.ResultList) tarID := -1 @@ -2153,15 +2150,15 @@ func TestGetSavingsRedemptionResult(t *testing.T) { func TestGetEarnAccountAssets(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetEarnAccountAssets, "", "", nil, false, true, true) + testGetOneArg(t, bi.GetEarnAccountAssets, currency.Code{}, currency.Code{}, nil, false, true, true) } func TestGetSharkFinProducts(t *testing.T) { t.Parallel() - _, err := bi.GetSharkFinProducts(context.Background(), "", 0, 0) + _, err := bi.GetSharkFinProducts(context.Background(), currency.Code{}, 0, 0) assert.ErrorIs(t, err, errCurrencyEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSharkFinProducts(context.Background(), testCrypto.String(), 5, 1<<62) + _, err = bi.GetSharkFinProducts(context.Background(), testCrypto, 5, 1<<62) assert.NoError(t, err) } @@ -2182,10 +2179,10 @@ func TestGetSharkFinAssets(t *testing.T) { func TestGetSharkFinRecords(t *testing.T) { t.Parallel() - _, err := bi.GetSharkFinRecords(context.Background(), "", "", time.Now().Add(time.Hour), time.Time{}, 0, 0) + _, err := bi.GetSharkFinRecords(context.Background(), currency.Code{}, "", time.Now().Add(time.Hour), time.Time{}, 0, 0) assert.ErrorIs(t, err, common.ErrStartAfterTimeNow) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetSharkFinRecords(context.Background(), "", "", time.Time{}, time.Time{}, 5, 1<<62) + _, err = bi.GetSharkFinRecords(context.Background(), currency.Code{}, "", time.Time{}, time.Time{}, 5, 1<<62) assert.NoError(t, err) } @@ -2194,7 +2191,7 @@ func TestGetSharkFinSubscriptionDetail(t *testing.T) { _, err := bi.GetSharkFinSubscriptionDetail(context.Background(), 0) assert.ErrorIs(t, err, errProductIDEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetSharkFinProducts(context.Background(), testCrypto.String(), 5, 1<<62) + resp, err := bi.GetSharkFinProducts(context.Background(), testCrypto, 5, 1<<62) require.NoError(t, err) require.NotEmpty(t, resp) _, err = bi.GetSharkFinSubscriptionDetail(context.Background(), resp.ResultList[0].ProductID) @@ -2208,7 +2205,7 @@ func TestSubscribeSharkFin(t *testing.T) { _, err = bi.SubscribeSharkFin(context.Background(), 1, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetSharkFinProducts(context.Background(), testCrypto.String(), 5, 1<<62) + resp, err := bi.GetSharkFinProducts(context.Background(), testCrypto, 5, 1<<62) require.NoError(t, err) require.NotEmpty(t, resp) _, err = bi.SubscribeSharkFin(context.Background(), resp.ResultList[0].ProductID, resp.ResultList[0].MinAmount) @@ -2220,7 +2217,7 @@ func TestGetSharkFinSubscriptionResult(t *testing.T) { _, err := bi.GetSharkFinSubscriptionResult(context.Background(), 0) assert.ErrorIs(t, err, errOrderIDEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetSharkFinRecords(context.Background(), "", "", time.Time{}, time.Time{}, 100, 0) + resp, err := bi.GetSharkFinRecords(context.Background(), currency.Code{}, "", time.Time{}, time.Time{}, 100, 0) require.NoError(t, err) require.NotEmpty(t, resp) tarID := -1 @@ -2239,94 +2236,94 @@ func TestGetSharkFinSubscriptionResult(t *testing.T) { func TestGetLoanCurrencyList(t *testing.T) { t.Parallel() - testGetOneArg(t, bi.GetLoanCurrencyList, "", testFiat.String(), errCurrencyEmpty, false, true, true) + testGetOneArg(t, bi.GetLoanCurrencyList, currency.Code{}, testFiat, errCurrencyEmpty, false, true, true) } func TestGetEstimatedInterestAndBorrowable(t *testing.T) { t.Parallel() - _, err := bi.GetEstimatedInterestAndBorrowable(context.Background(), "", "", "", 0) + _, err := bi.GetEstimatedInterestAndBorrowable(context.Background(), currency.Code{}, currency.Code{}, "", 0) assert.ErrorIs(t, err, errLoanCoinEmpty) - _, err = bi.GetEstimatedInterestAndBorrowable(context.Background(), "meow", "", "", 0) + _, err = bi.GetEstimatedInterestAndBorrowable(context.Background(), testCrypto, currency.Code{}, "", 0) assert.ErrorIs(t, err, errCollateralCoinEmpty) - _, err = bi.GetEstimatedInterestAndBorrowable(context.Background(), "meow", "woof", "", 0) + _, err = bi.GetEstimatedInterestAndBorrowable(context.Background(), testCrypto, testFiat, "", 0) assert.ErrorIs(t, err, errTermEmpty) - _, err = bi.GetEstimatedInterestAndBorrowable(context.Background(), "meow", "woof", "neigh", 0) + _, err = bi.GetEstimatedInterestAndBorrowable(context.Background(), testCrypto, testFiat, "neigh", 0) assert.ErrorIs(t, err, errCollateralAmountEmpty) - _, err = bi.GetEstimatedInterestAndBorrowable(context.Background(), testCrypto.String(), testFiat.String(), "SEVEN", testPrice) + _, err = bi.GetEstimatedInterestAndBorrowable(context.Background(), testCrypto, testFiat, "SEVEN", testPrice) assert.NoError(t, err) } func TestBorrowFunds(t *testing.T) { t.Parallel() - _, err := bi.BorrowFunds(context.Background(), "", "", "", 0, 0) + _, err := bi.BorrowFunds(context.Background(), currency.Code{}, currency.Code{}, "", 0, 0) assert.ErrorIs(t, err, errLoanCoinEmpty) - _, err = bi.BorrowFunds(context.Background(), "meow", "", "", 0, 0) + _, err = bi.BorrowFunds(context.Background(), testCrypto, currency.Code{}, "", 0, 0) assert.ErrorIs(t, err, errCollateralCoinEmpty) - _, err = bi.BorrowFunds(context.Background(), "meow", "woof", "", 0, 0) + _, err = bi.BorrowFunds(context.Background(), testCrypto, testFiat, "", 0, 0) assert.ErrorIs(t, err, errTermEmpty) - _, err = bi.BorrowFunds(context.Background(), "meow", "woof", "neigh", 0, 0) + _, err = bi.BorrowFunds(context.Background(), testCrypto, testFiat, "neigh", 0, 0) assert.ErrorIs(t, err, errCollateralLoanMutex) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.BorrowFunds(context.Background(), testCrypto.String(), testFiat.String(), "SEVEN", testAmount, 0) + _, err = bi.BorrowFunds(context.Background(), testCrypto, testFiat, "SEVEN", testAmount, 0) assert.NoError(t, err) } func TestGetOngoingLoans(t *testing.T) { t.Parallel() sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - resp, err := bi.GetOngoingLoans(context.Background(), 0, "", "") + resp, err := bi.GetOngoingLoans(context.Background(), 0, currency.Code{}, currency.Code{}) require.NoError(t, err) if len(resp) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.GetOngoingLoans(context.Background(), resp[0].OrderID, "", "") + _, err = bi.GetOngoingLoans(context.Background(), resp[0].OrderID, currency.Code{}, currency.Code{}) assert.NoError(t, err) } func TestGetLoanRepayHistory(t *testing.T) { t.Parallel() - _, err := bi.GetLoanRepayHistory(context.Background(), 0, 0, 0, "", "", time.Time{}, time.Time{}) + _, err := bi.GetLoanRepayHistory(context.Background(), 0, 0, 0, currency.Code{}, currency.Code{}, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetLoanRepayHistory(context.Background(), 0, 1, 5, "", "", time.Now().Add(-time.Hour*24*85), time.Now()) + _, err = bi.GetLoanRepayHistory(context.Background(), 0, 1, 5, currency.Code{}, currency.Code{}, time.Now().Add(-time.Hour*24*85), time.Now()) assert.NoError(t, err) } func TestModifyPledgeRate(t *testing.T) { t.Parallel() - _, err := bi.ModifyPledgeRate(context.Background(), 0, 0, "", "") + _, err := bi.ModifyPledgeRate(context.Background(), 0, 0, currency.Code{}, "") assert.ErrorIs(t, err, errOrderIDEmpty) - _, err = bi.ModifyPledgeRate(context.Background(), 1, 0, "", "") + _, err = bi.ModifyPledgeRate(context.Background(), 1, 0, currency.Code{}, "") assert.ErrorIs(t, err, errAmountEmpty) - _, err = bi.ModifyPledgeRate(context.Background(), 1, 1, "", "") + _, err = bi.ModifyPledgeRate(context.Background(), 1, 1, currency.Code{}, "") assert.ErrorIs(t, err, errCollateralCoinEmpty) - _, err = bi.ModifyPledgeRate(context.Background(), 1, 1, "meow", "") + _, err = bi.ModifyPledgeRate(context.Background(), 1, 1, currency.NewCode("meow"), "") assert.ErrorIs(t, err, errReviseTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetOngoingLoans(context.Background(), 0, "", "") + resp, err := bi.GetOngoingLoans(context.Background(), 0, currency.Code{}, currency.Code{}) require.NoError(t, err) if len(resp) == 0 { t.Skip(skipInsufficientOrders) } - _, err = bi.ModifyPledgeRate(context.Background(), resp[0].OrderID, testAmount, testFiat.String(), "IN") + _, err = bi.ModifyPledgeRate(context.Background(), resp[0].OrderID, testAmount, testFiat, "IN") assert.NoError(t, err) } func TestGetPledgeRateHistory(t *testing.T) { t.Parallel() - _, err := bi.GetPledgeRateHistory(context.Background(), 0, 0, 0, "", "", time.Time{}, time.Time{}) + _, err := bi.GetPledgeRateHistory(context.Background(), 0, 0, 0, "", currency.Code{}, time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetPledgeRateHistory(context.Background(), 0, 1, 5, "", "", time.Now().Add(-time.Hour*24*85), time.Now()) + _, err = bi.GetPledgeRateHistory(context.Background(), 0, 1, 5, "", currency.Code{}, time.Now().Add(-time.Hour*24*85), time.Now()) assert.NoError(t, err) } func TestGetLoanHistory(t *testing.T) { t.Parallel() - _, err := bi.GetLoanHistory(context.Background(), 0, 0, 0, "", "", "", time.Time{}, time.Time{}) + _, err := bi.GetLoanHistory(context.Background(), 0, 0, 0, currency.Code{}, currency.Code{}, "", time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetLoanHistory(context.Background(), 0, 1, 5, "", "", "", time.Now().Add(-time.Hour*24*85), time.Now()) + _, err = bi.GetLoanHistory(context.Background(), 0, 1, 5, currency.Code{}, currency.Code{}, "", time.Now().Add(-time.Hour*24*85), time.Now()) assert.NoError(t, err) } @@ -2340,10 +2337,10 @@ func TestGetDebts(t *testing.T) { func TestGetLiquidationRecords(t *testing.T) { t.Parallel() - _, err := bi.GetLiquidationRecords(context.Background(), 0, 0, 0, "", "", "", time.Time{}, time.Time{}) + _, err := bi.GetLiquidationRecords(context.Background(), 0, 0, 0, currency.Code{}, currency.Code{}, "", time.Time{}, time.Time{}) assert.ErrorIs(t, err, common.ErrDateUnset) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi) - _, err = bi.GetLiquidationRecords(context.Background(), 0, 1, 5, "", "", "", time.Now().Add(-time.Hour*24*85), time.Now()) + _, err = bi.GetLiquidationRecords(context.Background(), 0, 1, 5, currency.Code{}, currency.Code{}, "", time.Now().Add(-time.Hour*24*85), time.Now()) assert.NoError(t, err) } @@ -2553,7 +2550,7 @@ func TestGetOrderInfo(t *testing.T) { _, err = bi.GetOrderInfo(context.Background(), strconv.FormatInt(int64(oID.OrderID), 10), testPair2, asset.CrossMargin) assert.NoError(t, err) } - resp, err := bi.GetUnfilledOrders(context.Background(), testPair.String(), "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) + resp, err := bi.GetUnfilledOrders(context.Background(), testPair, "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) require.NoError(t, err) if len(resp) != 0 { _, err = bi.GetOrderInfo(context.Background(), strconv.FormatInt(int64(resp[0].OrderID), 10), testPair, asset.Spot) @@ -2892,7 +2889,7 @@ func TestModifyPlanSpotOrder(t *testing.T) { _, err = bi.ModifyPlanSpotOrder(context.Background(), 0, "meow", "woof", 1, 0, 0) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - ordID, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair.String(), time.Time{}, time.Time{}, 5, 1<<62) + ordID, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair, time.Time{}, time.Time{}, 5, 1<<62) assert.NoError(t, err) if len(ordID.OrderList) == 0 { t.Skip(skipInsufficientOrders) @@ -2906,7 +2903,7 @@ func TestCancelPlanSpotOrder(t *testing.T) { _, err := bi.CancelPlanSpotOrder(context.Background(), 0, "") assert.ErrorIs(t, err, errOrderClientEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - ordID, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair.String(), time.Time{}, time.Time{}, 5, 1<<62) + ordID, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair, time.Time{}, time.Time{}, 5, 1<<62) assert.NoError(t, err) require.NotNil(t, ordID) if len(ordID.OrderList) == 0 { @@ -2935,7 +2932,7 @@ func TestModifyOrder(t *testing.T) { _, err = bi.ModifyOrder(context.Background(), ord) assert.ErrorIs(t, err, errOrderClientEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - ordID, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair.String(), time.Time{}, time.Time{}, 5, 1<<62) + ordID, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair, time.Time{}, time.Time{}, 5, 1<<62) assert.NoError(t, err) if len(ordID.OrderList) == 0 { t.Skip(skipInsufficientOrders) @@ -2952,29 +2949,29 @@ func TestModifyOrder(t *testing.T) { } func TestCommitConversion(t *testing.T) { - _, err := bi.CommitConversion(context.Background(), "", "", "", 0, 0, 0) + _, err := bi.CommitConversion(context.Background(), currency.Code{}, currency.Code{}, "", 0, 0, 0) assert.ErrorIs(t, err, errCurrencyEmpty) - _, err = bi.CommitConversion(context.Background(), testCrypto.String(), testFiat.String(), "", 0, 0, 0) + _, err = bi.CommitConversion(context.Background(), testCrypto, testFiat, "", 0, 0, 0) assert.ErrorIs(t, err, errTraceIDEmpty) - _, err = bi.CommitConversion(context.Background(), testCrypto.String(), testFiat.String(), "1", 0, 0, 0) + _, err = bi.CommitConversion(context.Background(), testCrypto, testFiat, "1", 0, 0, 0) assert.ErrorIs(t, err, errAmountEmpty) - _, err = bi.CommitConversion(context.Background(), testCrypto.String(), testFiat.String(), "1", 1, 1, 0) + _, err = bi.CommitConversion(context.Background(), testCrypto, testFiat, "1", 1, 1, 0) assert.ErrorIs(t, err, errPriceEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetQuotedPrice(context.Background(), testCrypto.String(), testFiat.String(), testAmount, 0) + resp, err := bi.GetQuotedPrice(context.Background(), testCrypto, testFiat, testAmount, 0) require.NoError(t, err) - _, err = bi.CommitConversion(context.Background(), testCrypto.String(), testFiat.String(), resp.TraceID, resp.FromCoinSize, resp.ToCoinSize, resp.ConvertPrice) + _, err = bi.CommitConversion(context.Background(), testCrypto, testFiat, resp.TraceID, resp.FromCoinSize, resp.ToCoinSize, resp.ConvertPrice) assert.NoError(t, err) } func TestCancelTriggerFuturesOrders(t *testing.T) { var ordList []OrderIDStruct - _, err := bi.CancelTriggerFuturesOrders(context.Background(), ordList, "", "", "", "") + _, err := bi.CancelTriggerFuturesOrders(context.Background(), ordList, currency.Pair{}, "", "", currency.Code{}) assert.ErrorIs(t, err, errProductTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) oID := getTrigOrdIDHelper(t, []string{"profit_loss", "normal_plan", "track_plan"}) ordList = append(ordList, *oID) - resp, err := bi.CancelTriggerFuturesOrders(context.Background(), ordList, testPair2.String(), testFiat2.String()+"-FUTURES", "", "") + resp, err := bi.CancelTriggerFuturesOrders(context.Background(), ordList, testPair2, testFiat2.String()+"-FUTURES", "", currency.Code{}) require.NoError(t, err) assert.NotEmpty(t, resp) } @@ -2985,7 +2982,7 @@ func TestRepayLoan(t *testing.T) { _, err = bi.RepayLoan(context.Background(), 1, 0, false, false) assert.ErrorIs(t, err, errAmountEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetOngoingLoans(context.Background(), 0, "", "") + resp, err := bi.GetOngoingLoans(context.Background(), 0, currency.Code{}, currency.Code{}) require.NoError(t, err) if len(resp) == 0 { t.Skip(skipInsufficientOrders) @@ -2996,35 +2993,35 @@ func TestRepayLoan(t *testing.T) { assert.NoError(t, err) } func TestModifyFuturesOrder(t *testing.T) { - _, err := bi.ModifyFuturesOrder(context.Background(), 0, "", "", "", "", 0, 0, 0, 0) + _, err := bi.ModifyFuturesOrder(context.Background(), 0, "", "", "", currency.Pair{}, 0, 0, 0, 0) assert.ErrorIs(t, err, errOrderClientEmpty) - _, err = bi.ModifyFuturesOrder(context.Background(), 1, "", "", "", "", 0, 0, 0, 0) + _, err = bi.ModifyFuturesOrder(context.Background(), 1, "", "", "", currency.Pair{}, 0, 0, 0, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.ModifyFuturesOrder(context.Background(), 1, "", "meow", "", "", 0, 0, 0, 0) + _, err = bi.ModifyFuturesOrder(context.Background(), 1, "", "", "", currency.Pair{}, 0, 0, 0, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.ModifyFuturesOrder(context.Background(), 1, "", "meow", "woof", "", 0, 0, 0, 0) + _, err = bi.ModifyFuturesOrder(context.Background(), 1, "", "meow", "", currency.Pair{}, 0, 0, 0, 0) assert.ErrorIs(t, err, errNewClientOrderIDEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) oID := getFuturesOrdIDHelper(t, true, true) - _, err = bi.ModifyFuturesOrder(context.Background(), int64(oID.OrderID), oID.ClientOrderID, testPair2.String(), testFiat2.String()+"-FUTURES", clientIDGenerator(), 0, 0, testPrice2+1, testPrice2/10) + _, err = bi.ModifyFuturesOrder(context.Background(), int64(oID.OrderID), oID.ClientOrderID, testFiat2.String()+"-FUTURES", clientIDGenerator(), testPair2, 0, 0, testPrice2+1, testPrice2/10) assert.NoError(t, err) } func TestCancelFuturesOrder(t *testing.T) { - _, err := bi.CancelFuturesOrder(context.Background(), "", "", "", "", 0) + _, err := bi.CancelFuturesOrder(context.Background(), currency.Pair{}, "", "", currency.Code{}, 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.CancelFuturesOrder(context.Background(), "meow", "", "", "", 0) + _, err = bi.CancelFuturesOrder(context.Background(), testPair2, "", "", currency.Code{}, 0) assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = bi.CancelFuturesOrder(context.Background(), "meow", "woof", "", "", 0) + _, err = bi.CancelFuturesOrder(context.Background(), testPair2, "woof", "", currency.Code{}, 0) assert.ErrorIs(t, err, errOrderClientEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) oID := getFuturesOrdIDHelper(t, true, true) - _, err = bi.CancelFuturesOrder(context.Background(), testPair2.String(), testFiat2.String()+"-FUTURES", "", "", int64(oID.OrderID)) + _, err = bi.CancelFuturesOrder(context.Background(), testPair2, testFiat2.String()+"-FUTURES", "", currency.Code{}, int64(oID.OrderID)) assert.NoError(t, err) } func TestBatchCancelFuturesOrders(t *testing.T) { - _, err := bi.BatchCancelFuturesOrders(context.Background(), nil, "", "", "") + _, err := bi.BatchCancelFuturesOrders(context.Background(), nil, currency.Pair{}, "", currency.Code{}) assert.ErrorIs(t, err, errProductTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) oID := getFuturesOrdIDHelper(t, true, true) @@ -3033,23 +3030,23 @@ func TestBatchCancelFuturesOrders(t *testing.T) { OrderID: oID.OrderID, }, } - _, err = bi.BatchCancelFuturesOrders(context.Background(), orders, testPair2.String(), testFiat2.String()+"-FUTURES", "") + _, err = bi.BatchCancelFuturesOrders(context.Background(), orders, testPair2, testFiat2.String()+"-FUTURES", currency.Code{}) assert.NoError(t, err) } func TestFlashClosePosition(t *testing.T) { - _, err := bi.FlashClosePosition(context.Background(), "", "", "") + _, err := bi.FlashClosePosition(context.Background(), currency.Pair{}, "", "") assert.ErrorIs(t, err, errProductTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.FlashClosePosition(context.Background(), testPair2.String(), "", testFiat2.String()+"-FUTURES") + _, err = bi.FlashClosePosition(context.Background(), testPair2, "", testFiat2.String()+"-FUTURES") assert.NoError(t, err) } func TestCancelAllFuturesOrders(t *testing.T) { - _, err := bi.CancelAllFuturesOrders(context.Background(), "", "", "", 0) + _, err := bi.CancelAllFuturesOrders(context.Background(), currency.Pair{}, "", currency.Code{}, 0) assert.ErrorIs(t, err, errProductTypeEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - _, err = bi.CancelAllFuturesOrders(context.Background(), "", testFiat2.String()+"-FUTURES", testFiat2.String(), time.Second*60) + _, err = bi.CancelAllFuturesOrders(context.Background(), currency.Pair{}, testFiat2.String()+"-FUTURES", testFiat2, time.Second*60) assert.NoError(t, err) } @@ -3070,7 +3067,7 @@ func TestCancelOrder(t *testing.T) { err = bi.CancelOrder(context.Background(), ord) assert.ErrorIs(t, err, errPairEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) - resp, err := bi.GetUnfilledOrders(context.Background(), testPair.String(), "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) + resp, err := bi.GetUnfilledOrders(context.Background(), testPair, "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) require.NoError(t, err) if len(resp) == 0 { t.Skip(skipInsufficientOrders) @@ -3116,24 +3113,24 @@ func TestCancelAllOrders(t *testing.T) { assert.NoError(t, err) } func TestCancelCrossOrder(t *testing.T) { - _, err := bi.CancelCrossOrder(context.Background(), "", "", 0) + _, err := bi.CancelCrossOrder(context.Background(), currency.Pair{}, "", 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.CancelCrossOrder(context.Background(), "meow", "", 0) + _, err = bi.CancelCrossOrder(context.Background(), testPair, "", 0) assert.ErrorIs(t, err, errOrderClientEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) oID := getCrossOrdIDHelper(t, true) - _, err = bi.CancelCrossOrder(context.Background(), testPair.String(), oID.ClientOrderID, int64(oID.OrderID)) + _, err = bi.CancelCrossOrder(context.Background(), testPair, oID.ClientOrderID, int64(oID.OrderID)) assert.NoError(t, err) } func TestBatchCancelCrossOrders(t *testing.T) { - _, err := bi.BatchCancelCrossOrders(context.Background(), "", nil) + _, err := bi.BatchCancelCrossOrders(context.Background(), currency.Pair{}, nil) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.BatchCancelCrossOrders(context.Background(), "meow", nil) + _, err = bi.BatchCancelCrossOrders(context.Background(), testPair, nil) assert.ErrorIs(t, err, errOrdersEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) oID := getCrossOrdIDHelper(t, true) - _, err = bi.BatchCancelCrossOrders(context.Background(), testPair.String(), []OrderIDStruct{*oID}) + _, err = bi.BatchCancelCrossOrders(context.Background(), testPair, []OrderIDStruct{*oID}) assert.NoError(t, err) } @@ -3149,7 +3146,7 @@ func TestCancelBatchOrders(t *testing.T) { assert.ErrorIs(t, err, asset.ErrNotSupported) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) orders = nil - resp, err := bi.GetUnfilledOrders(context.Background(), testPair.String(), "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) + resp, err := bi.GetUnfilledOrders(context.Background(), testPair, "", time.Time{}, time.Time{}, 5, 1<<62, 0, time.Minute) require.NoError(t, err) if len(resp) != 0 { orders = append(orders, order.Cancel{ @@ -3193,24 +3190,24 @@ func TestCancelBatchOrders(t *testing.T) { assert.NoError(t, err) } func TestCancelIsolatedOrder(t *testing.T) { - _, err := bi.CancelIsolatedOrder(context.Background(), "", "", 0) + _, err := bi.CancelIsolatedOrder(context.Background(), currency.Pair{}, "", 0) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.CancelIsolatedOrder(context.Background(), "meow", "", 0) + _, err = bi.CancelIsolatedOrder(context.Background(), testPair2, "", 0) assert.ErrorIs(t, err, errOrderClientEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) oID := getIsoOrdIDHelper(t, true) - _, err = bi.CancelIsolatedOrder(context.Background(), testPair2.String(), oID.ClientOrderID, int64(oID.OrderID)) + _, err = bi.CancelIsolatedOrder(context.Background(), testPair2, oID.ClientOrderID, int64(oID.OrderID)) assert.NoError(t, err) } func TestBatchCancelIsolatedOrders(t *testing.T) { - _, err := bi.BatchCancelIsolatedOrders(context.Background(), "", nil) + _, err := bi.BatchCancelIsolatedOrders(context.Background(), currency.Pair{}, nil) assert.ErrorIs(t, err, errPairEmpty) - _, err = bi.BatchCancelIsolatedOrders(context.Background(), "meow", nil) + _, err = bi.BatchCancelIsolatedOrders(context.Background(), testPair2, nil) assert.ErrorIs(t, err, errOrdersEmpty) sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders) oID := getIsoOrdIDHelper(t, true) - _, err = bi.BatchCancelIsolatedOrders(context.Background(), testPair2.String(), []OrderIDStruct{*oID}) + _, err = bi.BatchCancelIsolatedOrders(context.Background(), testPair2, []OrderIDStruct{*oID}) assert.NoError(t, err) } @@ -3586,7 +3583,7 @@ type getOneArgResp interface { } type getOneArgParam interface { - string | []string | bool | asset.Item | *fundingrate.LatestRateRequest | currency.Code | *margin.RateHistoryRequest | *fundingrate.HistoricalRatesRequest | *futures.PositionsRequest | *withdraw.Request | *margin.PositionChangeRequest + string | []string | bool | asset.Item | *fundingrate.LatestRateRequest | currency.Code | *margin.RateHistoryRequest | *fundingrate.HistoricalRatesRequest | *futures.PositionsRequest | *withdraw.Request | *margin.PositionChangeRequest | currency.Pair | []currency.Code | currency.Pairs } type getOneArgGen[R getOneArgResp, P getOneArgParam] func(context.Context, P) (R, error) @@ -3611,15 +3608,15 @@ type getTwoArgsResp interface { []FutureTickerResp | *OpenPositionsResp | []FundingTimeResp | []FuturesPriceResp | []FundingCurrentResp | []ContractConfigResp } -type getTwoArgsPairProduct[G getTwoArgsResp] func(context.Context, string, string) (G, error) +type getTwoArgsPairProduct[G getTwoArgsResp] func(context.Context, currency.Pair, string) (G, error) func testGetTwoArgs[G getTwoArgsResp](t *testing.T, f getTwoArgsPairProduct[G]) { t.Helper() - _, err := f(context.Background(), "", "") + _, err := f(context.Background(), currency.Pair{}, "") assert.ErrorIs(t, err, errPairEmpty) - _, err = f(context.Background(), "meow", "") + _, err = f(context.Background(), currency.NewPairWithDelimiter("meow", "woof", ""), "") assert.ErrorIs(t, err, errProductTypeEmpty) - _, err = f(context.Background(), testPair2.String(), testFiat2.String()+"-FUTURES") + _, err = f(context.Background(), testPair2, testFiat2.String()+"-FUTURES") assert.NoError(t, err) } @@ -3649,7 +3646,7 @@ func subAccTestHelper(t *testing.T, compString, ignoreString string) string { func getPlanOrdIDHelper(t *testing.T, mustBeTriggered bool) *OrderIDStruct { t.Helper() ordIDs := new(OrderIDStruct) - resp, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair.String(), time.Time{}, time.Time{}, 100, 1<<62) + resp, err := bi.GetCurrentSpotPlanOrders(context.Background(), testPair, time.Time{}, time.Time{}, 100, 1<<62) if err == nil && len(resp.OrderList) != 0 { for i := range resp.OrderList { if resp.OrderList[i].ClientOrderID == url.QueryEscape(resp.OrderList[i].ClientOrderID) && !(mustBeTriggered && resp.OrderList[i].Status == "not_trigger") { @@ -3666,7 +3663,7 @@ func getPlanOrdIDHelper(t *testing.T, mustBeTriggered bool) *OrderIDStruct { func getFuturesOrdIDHelper(t *testing.T, live, skip bool) *OrderIDStruct { t.Helper() - resp, err := bi.GetPendingFuturesOrders(context.Background(), 0, 1<<62, 5, "", testPair2.String(), testFiat2.String()+"-FUTURES", "", time.Now().Add(-time.Hour*24*90), time.Now()) + resp, err := bi.GetPendingFuturesOrders(context.Background(), 0, 1<<62, 5, "", testFiat2.String()+"-FUTURES", "", testPair2, time.Now().Add(-time.Hour*24*90), time.Now()) assert.NoError(t, err) if resp != nil { if len(resp.EntrustedList) != 0 { @@ -3677,7 +3674,7 @@ func getFuturesOrdIDHelper(t *testing.T, live, skip bool) *OrderIDStruct { } } if !live { - resp, err := bi.GetHistoricalFuturesOrders(context.Background(), 0, 1<<62, 5, "", testPair2.String(), testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + resp, err := bi.GetHistoricalFuturesOrders(context.Background(), 0, 1<<62, 5, "", testFiat2.String()+"-FUTURES", testPair2, time.Time{}, time.Time{}) assert.NoError(t, err) if resp != nil { if len(resp.EntrustedList) != 0 { @@ -3700,7 +3697,7 @@ func getFuturesOrdIDHelper(t *testing.T, live, skip bool) *OrderIDStruct { func getTrigOrdIDHelper(t *testing.T, planTypes []string) *OrderIDStruct { t.Helper() for i := range planTypes { - resp, err := bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 1<<62, 5, "", testPair2.String(), planTypes[i], testFiat2.String()+"-FUTURES", time.Time{}, time.Time{}) + resp, err := bi.GetPendingTriggerFuturesOrders(context.Background(), 0, 1<<62, 5, "", planTypes[i], testFiat2.String()+"-FUTURES", testPair2, time.Time{}, time.Time{}) assert.NoError(t, err) if resp != nil { if len(resp.EntrustedList) != 0 { @@ -3720,7 +3717,7 @@ func getTrigOrdIDHelper(t *testing.T, planTypes []string) *OrderIDStruct { func getCrossOrdIDHelper(t *testing.T, skip bool) *OrderIDStruct { t.Helper() - resp, err := bi.GetCrossOpenOrders(context.Background(), testPair.String(), "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + resp, err := bi.GetCrossOpenOrders(context.Background(), testPair, "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) require.NoError(t, err) if len(resp.OrderList) != 0 { return &OrderIDStruct{ @@ -3739,7 +3736,7 @@ func getCrossOrdIDHelper(t *testing.T, skip bool) *OrderIDStruct { func getIsoOrdIDHelper(t *testing.T, skip bool) *OrderIDStruct { t.Helper() - resp, err := bi.GetIsolatedOpenOrders(context.Background(), testPair.String(), "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) + resp, err := bi.GetIsolatedOpenOrders(context.Background(), testPair, "", 0, 5, 1<<62, time.Now().Add(-time.Hour*24*85), time.Time{}) require.NoError(t, err) if len(resp.OrderList) != 0 { return &OrderIDStruct{ diff --git a/exchanges/bitget/bitget_types.go b/exchanges/bitget/bitget_types.go index ed756caee5d..fd5c3b75160 100644 --- a/exchanges/bitget/bitget_types.go +++ b/exchanges/bitget/bitget_types.go @@ -5,6 +5,7 @@ import ( "net/url" "time" + "github.com/thrasher-corp/gocryptotrader/currency" "github.com/thrasher-corp/gocryptotrader/types" ) @@ -805,16 +806,16 @@ type CancelAndPlaceResp struct { // ReplaceSpotOrderStruct contains information on an order to be replaced type ReplaceSpotOrderStruct struct { - Pair string `json:"symbol"` - Price float64 `json:"price,string"` - Amount float64 `json:"size,string"` - OldClientOrderID string `json:"clientOid,omitempty"` - OrderID int64 `json:"orderId,string,omitempty"` - NewClientOrderID string `json:"newClientOid,omitempty"` - PresetTakeProfitPrice float64 `json:"presetTakeProfitPrice,string,omitempty"` - ExecuteTakeProfitPrice float64 `json:"executeTakeProfitPrice,string,omitempty"` - PresetStopLossPrice float64 `json:"presetStopLossPrice,string,omitempty"` - ExecuteStopLossPrice float64 `json:"executeStopLossPrice,string,omitempty"` + Pair currency.Pair `json:"symbol"` + Price float64 `json:"price,string"` + Amount float64 `json:"size,string"` + OldClientOrderID string `json:"clientOid,omitempty"` + OrderID int64 `json:"orderId,string,omitempty"` + NewClientOrderID string `json:"newClientOid,omitempty"` + PresetTakeProfitPrice float64 `json:"presetTakeProfitPrice,string,omitempty"` + ExecuteTakeProfitPrice float64 `json:"executeTakeProfitPrice,string,omitempty"` + PresetStopLossPrice float64 `json:"presetStopLossPrice,string,omitempty"` + ExecuteStopLossPrice float64 `json:"executeStopLossPrice,string,omitempty"` } // PlanSpotOrder is a sub-struct that contains information on a planned order diff --git a/exchanges/bitget/bitget_wrapper.go b/exchanges/bitget/bitget_wrapper.go index 7aa1e12a2c9..3d4eb593a82 100644 --- a/exchanges/bitget/bitget_wrapper.go +++ b/exchanges/bitget/bitget_wrapper.go @@ -199,7 +199,7 @@ func (bi *Bitget) Setup(exch *config.Exchange) error { func (bi *Bitget) FetchTradablePairs(ctx context.Context, a asset.Item) (currency.Pairs, error) { switch a { case asset.Spot: - resp, err := bi.GetSymbolInfo(ctx, "") + resp, err := bi.GetSymbolInfo(ctx, currency.Pair{}) if err != nil { return nil, err } @@ -277,7 +277,7 @@ func (bi *Bitget) UpdateTicker(ctx context.Context, p currency.Pair, assetType a } switch assetType { case asset.Spot, asset.Margin, asset.CrossMargin: - tick, err := bi.GetSpotTickerInformation(ctx, p.String()) + tick, err := bi.GetSpotTickerInformation(ctx, p) if err != nil { return nil, err } @@ -293,7 +293,7 @@ func (bi *Bitget) UpdateTicker(ctx context.Context, p currency.Pair, assetType a LastUpdated: tick[0].Timestamp.Time(), } case asset.Futures: - tick, err := bi.GetFuturesTicker(ctx, p.String(), getProductType(p)) + tick, err := bi.GetFuturesTicker(ctx, p, getProductType(p)) if err != nil { return nil, err } @@ -326,7 +326,7 @@ func (bi *Bitget) UpdateTicker(ctx context.Context, p currency.Pair, assetType a func (bi *Bitget) UpdateTickers(ctx context.Context, assetType asset.Item) error { switch assetType { case asset.Spot, asset.Margin, asset.CrossMargin: - tick, err := bi.GetSpotTickerInformation(ctx, "") + tick, err := bi.GetSpotTickerInformation(ctx, currency.Pair{}) if err != nil { return err } @@ -423,7 +423,7 @@ func (bi *Bitget) UpdateOrderbook(ctx context.Context, pair currency.Pair, asset } switch assetType { case asset.Spot, asset.Margin, asset.CrossMargin: - orderbookNew, err := bi.GetOrderbookDepth(ctx, pair.String(), "", 150) + orderbookNew, err := bi.GetOrderbookDepth(ctx, pair, "", 150) if err != nil { return book, err } @@ -438,7 +438,7 @@ func (bi *Bitget) UpdateOrderbook(ctx context.Context, pair currency.Pair, asset book.Asks[x].Price = orderbookNew.Asks[x][0].Float64() } case asset.Futures: - orderbookNew, err := bi.GetFuturesMergeDepth(ctx, pair.String(), getProductType(pair), "", "max") + orderbookNew, err := bi.GetFuturesMergeDepth(ctx, pair, getProductType(pair), "", "max") if err != nil { return book, err } @@ -473,7 +473,7 @@ func (bi *Bitget) UpdateAccountInfo(ctx context.Context, assetType asset.Item) ( } switch assetType { case asset.Spot: - resp, err := bi.GetAccountAssets(ctx, "", "") + resp, err := bi.GetAccountAssets(ctx, currency.Code{}, "") if err != nil { return acc, err } @@ -501,7 +501,7 @@ func (bi *Bitget) UpdateAccountInfo(ctx context.Context, assetType asset.Item) ( } } case asset.Margin: - resp, err := bi.GetIsolatedAccountAssets(ctx, "") + resp, err := bi.GetIsolatedAccountAssets(ctx, currency.Pair{}) if err != nil { return acc, err } @@ -515,7 +515,7 @@ func (bi *Bitget) UpdateAccountInfo(ctx context.Context, assetType asset.Item) ( acc.Accounts[0].Currencies[x].Borrowed = resp[x].Borrow } case asset.CrossMargin: - resp, err := bi.GetCrossAccountAssets(ctx, "") + resp, err := bi.GetCrossAccountAssets(ctx, currency.Code{}) if err != nil { return acc, err } @@ -563,7 +563,7 @@ func (bi *Bitget) FetchAccountInfo(ctx context.Context, assetType asset.Item) (a // withdrawals func (bi *Bitget) GetAccountFundingHistory(ctx context.Context) ([]exchange.FundingHistory, error) { // This exchange only allows requests covering the last 90 days - resp, err := bi.withdrawalHistGrabber(ctx, "") + resp, err := bi.withdrawalHistGrabber(ctx, currency.Code{}) if err != nil { return nil, err } @@ -588,7 +588,7 @@ func (bi *Bitget) GetAccountFundingHistory(ctx context.Context) ([]exchange.Fund var pagination int64 pagination = 0 for { - resp, err := bi.GetDepositRecords(ctx, "", 0, pagination, 100, time.Now().Add(-time.Hour*24*90), time.Now()) + resp, err := bi.GetDepositRecords(ctx, currency.Code{}, 0, pagination, 100, time.Now().Add(-time.Hour*24*90), time.Now()) if err != nil { return nil, err } @@ -623,7 +623,7 @@ func (bi *Bitget) GetAccountFundingHistory(ctx context.Context) ([]exchange.Fund // GetWithdrawalsHistory returns previous withdrawals data func (bi *Bitget) GetWithdrawalsHistory(ctx context.Context, c currency.Code, _ asset.Item) ([]exchange.WithdrawalHistory, error) { // This exchange only allows requests covering the last 90 days - resp, err := bi.withdrawalHistGrabber(ctx, c.String()) + resp, err := bi.withdrawalHistGrabber(ctx, c) if err != nil { return nil, err } @@ -654,7 +654,7 @@ func (bi *Bitget) GetRecentTrades(ctx context.Context, p currency.Pair, assetTyp } switch assetType { case asset.Spot, asset.Margin, asset.CrossMargin: - resp, err := bi.GetRecentSpotFills(ctx, p.String(), 500) + resp, err := bi.GetRecentSpotFills(ctx, p, 500) if err != nil { return nil, err } @@ -673,7 +673,7 @@ func (bi *Bitget) GetRecentTrades(ctx context.Context, p currency.Pair, assetTyp } return trades, nil case asset.Futures: - resp, err := bi.GetRecentFuturesFills(ctx, p.String(), getProductType(p), 100) + resp, err := bi.GetRecentFuturesFills(ctx, p, getProductType(p), 100) if err != nil { return nil, err } @@ -700,7 +700,7 @@ func (bi *Bitget) GetHistoricTrades(ctx context.Context, p currency.Pair, assetT // This exchange only allows requests covering the last 7 days switch assetType { case asset.Spot, asset.Margin, asset.CrossMargin: - resp, err := bi.GetSpotMarketTrades(ctx, p.String(), timestampStart, timestampEnd, 1000, 0) + resp, err := bi.GetSpotMarketTrades(ctx, p, timestampStart, timestampEnd, 1000, 0) if err != nil { return nil, err } @@ -719,7 +719,7 @@ func (bi *Bitget) GetHistoricTrades(ctx context.Context, p currency.Pair, assetT } return trades, nil case asset.Futures: - resp, err := bi.GetFuturesMarketTrades(ctx, p.String(), getProductType(p), 1000, 0, timestampStart, timestampEnd) + resp, err := bi.GetFuturesMarketTrades(ctx, p, getProductType(p), 1000, 0, timestampStart, timestampEnd) if err != nil { return nil, err } @@ -764,18 +764,18 @@ func (bi *Bitget) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Subm } switch s.AssetType { case asset.Spot: - IDs, err = bi.PlaceSpotOrder(ctx, s.Pair.String(), s.Side.String(), s.Type.Lower(), strat, cID.String(), "", s.Price, s.Amount, s.TriggerPrice, 0, 0, 0, 0, false, 0) + IDs, err = bi.PlaceSpotOrder(ctx, s.Pair, s.Side.String(), s.Type.Lower(), strat, cID.String(), "", s.Price, s.Amount, s.TriggerPrice, 0, 0, 0, 0, false, 0) case asset.Futures: - IDs, err = bi.PlaceFuturesOrder(ctx, s.Pair.String(), getProductType(s.Pair), marginStringer(s.MarginType), s.Pair.Quote.String(), sideEncoder(s.Side, false), "", s.Type.Lower(), strat, cID.String(), 0, 0, s.Amount, s.Price, s.ReduceOnly, false) + IDs, err = bi.PlaceFuturesOrder(ctx, s.Pair, getProductType(s.Pair), marginStringer(s.MarginType), s.Pair.Quote.String(), sideEncoder(s.Side, false), s.Type.Lower(), strat, cID.String(), currency.Code{}, 0, 0, s.Amount, s.Price, s.ReduceOnly, false) case asset.Margin, asset.CrossMargin: loanType := "normal" if s.AutoBorrow { loanType = "autoLoan" } if s.AssetType == asset.Margin { - IDs, err = bi.PlaceIsolatedOrder(ctx, s.Pair.String(), s.Type.Lower(), loanType, strat, cID.String(), s.Side.String(), s.Price, s.Amount, s.QuoteAmount) + IDs, err = bi.PlaceIsolatedOrder(ctx, s.Pair, s.Type.Lower(), loanType, strat, cID.String(), s.Side.String(), s.Price, s.Amount, s.QuoteAmount) } else { - IDs, err = bi.PlaceCrossOrder(ctx, s.Pair.String(), s.Type.Lower(), loanType, strat, cID.String(), s.Side.String(), s.Price, s.Amount, s.QuoteAmount) + IDs, err = bi.PlaceCrossOrder(ctx, s.Pair, s.Type.Lower(), loanType, strat, cID.String(), s.Side.String(), s.Price, s.Amount, s.QuoteAmount) } default: return nil, asset.ErrNotSupported @@ -812,8 +812,7 @@ func (bi *Bitget) ModifyOrder(ctx context.Context, action *order.Modify) (*order if err != nil { return nil, err } - IDs, err = bi.ModifyFuturesOrder(ctx, originalID, action.ClientOrderID, action.Pair.String(), getProductType(action.Pair), cID.String(), action.Amount, action.Price, 0, 0) - fmt.Printf("Error: %v\n", err) + IDs, err = bi.ModifyFuturesOrder(ctx, originalID, action.ClientOrderID, getProductType(action.Pair), cID.String(), action.Pair, action.Amount, action.Price, 0, 0) default: return nil, asset.ErrNotSupported } @@ -841,13 +840,13 @@ func (bi *Bitget) CancelOrder(ctx context.Context, ord *order.Cancel) error { } switch ord.AssetType { case asset.Spot: - _, err = bi.CancelSpotOrderByID(ctx, ord.Pair.String(), ord.ClientOrderID, "", originalID) + _, err = bi.CancelSpotOrderByID(ctx, ord.Pair, ord.ClientOrderID, "", originalID) case asset.Futures: - _, err = bi.CancelFuturesOrder(ctx, ord.Pair.String(), getProductType(ord.Pair), ord.Pair.Quote.String(), ord.ClientOrderID, originalID) + _, err = bi.CancelFuturesOrder(ctx, ord.Pair, getProductType(ord.Pair), ord.ClientOrderID, ord.Pair.Quote, originalID) case asset.Margin: - _, err = bi.CancelIsolatedOrder(ctx, ord.Pair.String(), ord.ClientOrderID, originalID) + _, err = bi.CancelIsolatedOrder(ctx, ord.Pair, ord.ClientOrderID, originalID) case asset.CrossMargin: - _, err = bi.CancelCrossOrder(ctx, ord.Pair.String(), ord.ClientOrderID, originalID) + _, err = bi.CancelCrossOrder(ctx, ord.Pair, ord.ClientOrderID, originalID) default: return asset.ErrNotSupported } @@ -882,13 +881,13 @@ func (bi *Bitget) CancelBatchOrders(ctx context.Context, orders []order.Cancel) ClientOrderID: batch[i].ClientOrderID, } } - status, err = bi.BatchCancelOrders(ctx, pair.String(), false, batchConv) + status, err = bi.BatchCancelOrders(ctx, pair, false, batchConv) case asset.Futures: - status, err = bi.BatchCancelFuturesOrders(ctx, batch, pair.String(), getProductType(pair), pair.Quote.String()) + status, err = bi.BatchCancelFuturesOrders(ctx, batch, pair, getProductType(pair), pair.Quote) case asset.Margin: - status, err = bi.BatchCancelIsolatedOrders(ctx, pair.String(), batch) + status, err = bi.BatchCancelIsolatedOrders(ctx, pair, batch) case asset.CrossMargin: - status, err = bi.BatchCancelCrossOrders(ctx, pair.String(), batch) + status, err = bi.BatchCancelCrossOrders(ctx, pair, batch) default: return nil, asset.ErrNotSupported } @@ -910,13 +909,12 @@ func (bi *Bitget) CancelAllOrders(ctx context.Context, orderCancellation *order. } switch orderCancellation.AssetType { case asset.Spot: - _, err = bi.CancelOrdersBySymbol(ctx, orderCancellation.Pair.String()) + _, err = bi.CancelOrdersBySymbol(ctx, orderCancellation.Pair) if err != nil { return resp, err } case asset.Futures: - resp2, err := bi.CancelAllFuturesOrders(ctx, orderCancellation.Pair.String(), - getProductType(orderCancellation.Pair), orderCancellation.Pair.Quote.String(), time.Second*60) + resp2, err := bi.CancelAllFuturesOrders(ctx, orderCancellation.Pair, getProductType(orderCancellation.Pair), orderCancellation.Pair.Quote, time.Second*60) if err != nil { return resp, err } @@ -974,7 +972,7 @@ func (bi *Bitget) GetOrderInfo(ctx context.Context, orderID string, pair currenc break } } - fillInfo, err := bi.GetSpotFills(ctx, pair.String(), time.Time{}, time.Time{}, 0, 0, ordID) + fillInfo, err := bi.GetSpotFills(ctx, pair, time.Time{}, time.Time{}, 0, 0, ordID) if err != nil { return nil, err } @@ -992,7 +990,7 @@ func (bi *Bitget) GetOrderInfo(ctx context.Context, orderID string, pair currenc } } case asset.Futures: - ordInfo, err := bi.GetFuturesOrderDetails(ctx, pair.String(), getProductType(pair), "", ordID) + ordInfo, err := bi.GetFuturesOrderDetails(ctx, pair, getProductType(pair), "", ordID) if err != nil { return nil, err } @@ -1014,7 +1012,7 @@ func (bi *Bitget) GetOrderInfo(ctx context.Context, orderID string, pair currenc resp.ReduceOnly = bool(ordInfo.ReduceOnly) resp.Date = ordInfo.CreationTime.Time() resp.LastUpdated = ordInfo.UpdateTime.Time() - fillInfo, err := bi.GetFuturesFills(ctx, ordID, 0, 100, pair.String(), getProductType(pair), time.Time{}, time.Time{}) + fillInfo, err := bi.GetFuturesFills(ctx, ordID, 0, 100, pair, getProductType(pair), time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -1039,17 +1037,17 @@ func (bi *Bitget) GetOrderInfo(ctx context.Context, orderID string, pair currenc var ordInfo *MarginOpenOrds var fillInfo *MarginOrderFills if assetType == asset.Margin { - ordInfo, err = bi.GetIsolatedOpenOrders(ctx, pair.String(), "", ordID, 2, 0, time.Time{}, time.Time{}) + ordInfo, err = bi.GetIsolatedOpenOrders(ctx, pair, "", ordID, 2, 0, time.Time{}, time.Time{}) if err != nil { return nil, err } - fillInfo, err = bi.GetIsolatedOrderFills(ctx, pair.String(), ordID, 0, 500, time.Now().Add(-time.Hour*24*90), time.Now()) + fillInfo, err = bi.GetIsolatedOrderFills(ctx, pair, ordID, 0, 500, time.Now().Add(-time.Hour*24*90), time.Now()) } else { - ordInfo, err = bi.GetCrossOpenOrders(ctx, pair.String(), "", ordID, 2, 0, time.Time{}, time.Time{}) + ordInfo, err = bi.GetCrossOpenOrders(ctx, pair, "", ordID, 2, 0, time.Time{}, time.Time{}) if err != nil { return nil, err } - fillInfo, err = bi.GetCrossOrderFills(ctx, pair.String(), ordID, 0, 500, time.Now().Add(-time.Hour*24*90), time.Now()) + fillInfo, err = bi.GetCrossOrderFills(ctx, pair, ordID, 0, 500, time.Now().Add(-time.Hour*24*90), time.Now()) } if err != nil { return nil, err @@ -1088,7 +1086,7 @@ func (bi *Bitget) GetOrderInfo(ctx context.Context, orderID string, pair currenc // GetDepositAddress returns a deposit address for a specified currency func (bi *Bitget) GetDepositAddress(ctx context.Context, c currency.Code, _ string, chain string) (*deposit.Address, error) { - resp, err := bi.GetDepositAddressForCurrency(ctx, c.String(), chain) + resp, err := bi.GetDepositAddressForCurrency(ctx, c, chain) if err != nil { return nil, err } @@ -1107,7 +1105,7 @@ func (bi *Bitget) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawReque if err != nil { return nil, err } - resp, err := bi.WithdrawFunds(ctx, withdrawRequest.Currency.String(), "on_chain", withdrawRequest.Crypto.Address, withdrawRequest.Crypto.Chain, "", "", withdrawRequest.Crypto.AddressTag, withdrawRequest.Description, "", withdrawRequest.Amount) + resp, err := bi.WithdrawFunds(ctx, withdrawRequest.Currency, "on_chain", withdrawRequest.Crypto.Address, withdrawRequest.Crypto.Chain, "", "", withdrawRequest.Crypto.AddressTag, withdrawRequest.Description, "", withdrawRequest.Amount) if err != nil { return nil, err } @@ -1135,22 +1133,19 @@ func (bi *Bitget) GetActiveOrders(ctx context.Context, getOrdersRequest *order.M if err != nil { return nil, err } - pairs := make([]string, len(getOrdersRequest.Pairs)) for x := range getOrdersRequest.Pairs { - form, _ := bi.GetPairFormat(asset.Spot, true) - getOrdersRequest.Pairs[x] = getOrdersRequest.Pairs[x].Format(form) - pairs[x] = getOrdersRequest.Pairs[x].String() + getOrdersRequest.Pairs[x], err = bi.FormatExchangeCurrency(getOrdersRequest.Pairs[x], asset.Spot) } - if len(pairs) == 0 { - pairs = append(pairs, "") + if len(getOrdersRequest.Pairs) == 0 { + getOrdersRequest.Pairs = append(getOrdersRequest.Pairs, currency.Pair{}) } var resp order.FilteredOrders - for x := range pairs { + for x := range getOrdersRequest.Pairs { switch getOrdersRequest.AssetType { case asset.Spot: var pagination int64 for { - genOrds, err := bi.GetUnfilledOrders(ctx, pairs[x], "", time.Time{}, time.Time{}, 100, pagination, 0, time.Minute) + genOrds, err := bi.GetUnfilledOrders(ctx, getOrdersRequest.Pairs[x], "", time.Time{}, time.Time{}, 100, pagination, 0, time.Minute) if err != nil { return nil, err } @@ -1177,7 +1172,7 @@ func (bi *Bitget) GetActiveOrders(ctx context.Context, getOrdersRequest *order.M Date: genOrds[i].CreationTime.Time(), LastUpdated: genOrds[i].UpdateTime.Time(), } - if pairs[x] != "" { + if !getOrdersRequest.Pairs[x].IsEmpty() { tempOrds[i].Pair = getOrdersRequest.Pairs[x] } else { tempOrds[i].Pair, err = pairFromStringHelper(genOrds[i].Symbol) @@ -1188,8 +1183,8 @@ func (bi *Bitget) GetActiveOrders(ctx context.Context, getOrdersRequest *order.M } resp = append(resp, tempOrds...) } - if pairs[x] != "" { - resp, err = bi.spotCurrentPlanOrdersHelper(ctx, pairs[x], getOrdersRequest.Pairs[x], resp) + if !getOrdersRequest.Pairs[x].IsEmpty() { + resp, err = bi.spotCurrentPlanOrdersHelper(ctx, getOrdersRequest.Pairs[x], resp) if err != nil { return nil, err } @@ -1203,7 +1198,7 @@ func (bi *Bitget) GetActiveOrders(ctx context.Context, getOrdersRequest *order.M if err != nil { return nil, err } - resp, err = bi.spotCurrentPlanOrdersHelper(ctx, callStr.String(), newPairs[y], resp) + resp, err = bi.spotCurrentPlanOrdersHelper(ctx, callStr, resp) if err != nil { return nil, err } @@ -1211,14 +1206,14 @@ func (bi *Bitget) GetActiveOrders(ctx context.Context, getOrdersRequest *order.M } case asset.Futures: - if pairs[x] != "" { - resp, err = bi.activeFuturesOrderHelper(ctx, pairs[x], getProductType(getOrdersRequest.Pairs[x]), getOrdersRequest.Pairs[x], resp) + if !getOrdersRequest.Pairs[x].IsEmpty() { + resp, err = bi.activeFuturesOrderHelper(ctx, getProductType(getOrdersRequest.Pairs[x]), getOrdersRequest.Pairs[x], resp) if err != nil { return nil, err } } else { for y := range prodTypes { - resp, err = bi.activeFuturesOrderHelper(ctx, "", prodTypes[y], currency.Pair{}, resp) + resp, err = bi.activeFuturesOrderHelper(ctx, prodTypes[y], currency.Pair{}, resp) if err != nil { return nil, err } @@ -1229,9 +1224,9 @@ func (bi *Bitget) GetActiveOrders(ctx context.Context, getOrdersRequest *order.M var genOrds *MarginOpenOrds for { if getOrdersRequest.AssetType == asset.Margin { - genOrds, err = bi.GetIsolatedOpenOrders(ctx, pairs[x], "", 0, 500, pagination, time.Now().Add(-time.Hour*24*90), time.Time{}) + genOrds, err = bi.GetIsolatedOpenOrders(ctx, getOrdersRequest.Pairs[x], "", 0, 500, pagination, time.Now().Add(-time.Hour*24*90), time.Time{}) } else { - genOrds, err = bi.GetCrossOpenOrders(ctx, pairs[x], "", 0, 500, pagination, time.Now().Add(-time.Hour*24*90), time.Time{}) + genOrds, err = bi.GetCrossOpenOrders(ctx, getOrdersRequest.Pairs[x], "", 0, 500, pagination, time.Now().Add(-time.Hour*24*90), time.Time{}) } if err != nil { return nil, err @@ -1256,7 +1251,7 @@ func (bi *Bitget) GetActiveOrders(ctx context.Context, getOrdersRequest *order.M Date: genOrds.OrderList[i].CreationTime.Time(), LastUpdated: genOrds.OrderList[i].UpdateTime.Time(), } - if pairs[x] != "" { + if !getOrdersRequest.Pairs[x].IsEmpty() { tempOrds[i].Pair = getOrdersRequest.Pairs[x] } else { tempOrds[i].Pair, err = pairFromStringHelper(genOrds.OrderList[i].Symbol) @@ -1282,25 +1277,24 @@ func (bi *Bitget) GetOrderHistory(ctx context.Context, getOrdersRequest *order.M if err != nil { return nil, err } - pairs := make([]string, len(getOrdersRequest.Pairs)) for x := range getOrdersRequest.Pairs { - pairs[x] = getOrdersRequest.Pairs[x].String() + getOrdersRequest.Pairs[x], err = bi.FormatExchangeCurrency(getOrdersRequest.Pairs[x], asset.Spot) } - if len(pairs) == 0 { - pairs = append(pairs, "") + if len(getOrdersRequest.Pairs) == 0 { + getOrdersRequest.Pairs = append(getOrdersRequest.Pairs, currency.Pair{}) } var resp order.FilteredOrders - for x := range pairs { + for x := range getOrdersRequest.Pairs { switch getOrdersRequest.AssetType { case asset.Spot: fillMap := make(map[int64][]order.TradeHistory) var pagination int64 - if pairs[x] != "" { - err = bi.spotFillsHelper(ctx, pairs[x], fillMap) + if !getOrdersRequest.Pairs[x].IsEmpty() { + err = bi.spotFillsHelper(ctx, getOrdersRequest.Pairs[x], fillMap) if err != nil { return nil, err } - resp, err = bi.spotHistoricPlanOrdersHelper(ctx, pairs[x], getOrdersRequest.Pairs[x], resp, fillMap) + resp, err = bi.spotHistoricPlanOrdersHelper(ctx, getOrdersRequest.Pairs[x], resp, fillMap) if err != nil { return nil, err } @@ -1314,18 +1308,18 @@ func (bi *Bitget) GetOrderHistory(ctx context.Context, getOrdersRequest *order.M if err != nil { return nil, err } - err = bi.spotFillsHelper(ctx, callStr.String(), fillMap) + err = bi.spotFillsHelper(ctx, callStr, fillMap) if err != nil { return nil, err } - resp, err = bi.spotHistoricPlanOrdersHelper(ctx, callStr.String(), newPairs[y], resp, fillMap) + resp, err = bi.spotHistoricPlanOrdersHelper(ctx, callStr, resp, fillMap) if err != nil { return nil, err } } } for { - genOrds, err := bi.GetHistoricalSpotOrders(ctx, pairs[x], time.Time{}, time.Time{}, 100, pagination, 0) + genOrds, err := bi.GetHistoricalSpotOrders(ctx, getOrdersRequest.Pairs[x], time.Time{}, time.Time{}, 100, pagination, 0) if err != nil { return nil, err } @@ -1351,7 +1345,7 @@ func (bi *Bitget) GetOrderHistory(ctx context.Context, getOrdersRequest *order.M Date: genOrds[i].CreationTime.Time(), LastUpdated: genOrds[i].UpdateTime.Time(), } - if pairs[x] != "" { + if !getOrdersRequest.Pairs[x].IsEmpty() { tempOrds[i].Pair = getOrdersRequest.Pairs[x] } else { tempOrds[i].Pair, err = pairFromStringHelper(genOrds[i].Symbol) @@ -1370,14 +1364,14 @@ func (bi *Bitget) GetOrderHistory(ctx context.Context, getOrdersRequest *order.M resp = append(resp, tempOrds...) } case asset.Futures: - if pairs[x] != "" { - resp, err = bi.historicalFuturesOrderHelper(ctx, pairs[x], getProductType(getOrdersRequest.Pairs[x]), getOrdersRequest.Pairs[x], resp) + if !getOrdersRequest.Pairs[x].IsEmpty() { + resp, err = bi.historicalFuturesOrderHelper(ctx, getProductType(getOrdersRequest.Pairs[x]), getOrdersRequest.Pairs[x], resp) if err != nil { return nil, err } } else { for y := range prodTypes { - resp, err = bi.historicalFuturesOrderHelper(ctx, "", prodTypes[y], currency.Pair{}, resp) + resp, err = bi.historicalFuturesOrderHelper(ctx, prodTypes[y], currency.Pair{}, resp) if err != nil { return nil, err } @@ -1389,9 +1383,9 @@ func (bi *Bitget) GetOrderHistory(ctx context.Context, getOrdersRequest *order.M fillMap := make(map[int64][]order.TradeHistory) for { if getOrdersRequest.AssetType == asset.Margin { - genFills, err = bi.GetIsolatedOrderFills(ctx, pairs[x], 0, pagination, 500, time.Now().Add(-time.Hour*24*90), time.Now()) + genFills, err = bi.GetIsolatedOrderFills(ctx, getOrdersRequest.Pairs[x], 0, pagination, 500, time.Now().Add(-time.Hour*24*90), time.Now()) } else { - genFills, err = bi.GetCrossOrderFills(ctx, pairs[x], 0, pagination, 500, time.Now().Add(-time.Hour*24*90), time.Now()) + genFills, err = bi.GetCrossOrderFills(ctx, getOrdersRequest.Pairs[x], 0, pagination, 500, time.Now().Add(-time.Hour*24*90), time.Now()) } if err != nil { return nil, err @@ -1417,9 +1411,9 @@ func (bi *Bitget) GetOrderHistory(ctx context.Context, getOrdersRequest *order.M var genOrds *MarginHistOrds for { if getOrdersRequest.AssetType == asset.Margin { - genOrds, err = bi.GetIsolatedHistoricalOrders(ctx, pairs[x], "", "", 0, 500, pagination, time.Now().Add(-time.Hour*24*90), time.Time{}) + genOrds, err = bi.GetIsolatedHistoricalOrders(ctx, getOrdersRequest.Pairs[x], "", "", 0, 500, pagination, time.Now().Add(-time.Hour*24*90), time.Time{}) } else { - genOrds, err = bi.GetCrossHistoricalOrders(ctx, pairs[x], "", "", 0, 500, pagination, time.Now().Add(-time.Hour*24*90), time.Time{}) + genOrds, err = bi.GetCrossHistoricalOrders(ctx, getOrdersRequest.Pairs[x], "", "", 0, 500, pagination, time.Now().Add(-time.Hour*24*90), time.Time{}) } if err != nil { return nil, err @@ -1445,7 +1439,7 @@ func (bi *Bitget) GetOrderHistory(ctx context.Context, getOrdersRequest *order.M Date: genOrds.OrderList[i].CreationTime.Time(), LastUpdated: genOrds.OrderList[i].UpdateTime.Time(), } - if pairs[x] != "" { + if !getOrdersRequest.Pairs[x].IsEmpty() { tempOrds[i].Pair = getOrdersRequest.Pairs[x] } else { tempOrds[i].Pair, err = pairFromStringHelper(genOrds.OrderList[i].Symbol) @@ -1472,7 +1466,7 @@ func (bi *Bitget) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuil if feeBuilder == nil { return 0, fmt.Errorf("%T %w", feeBuilder, common.ErrNilPointer) } - fee, err := bi.GetTradeRate(ctx, feeBuilder.Pair.String(), "spot") + fee, err := bi.GetTradeRate(ctx, feeBuilder.Pair, "spot") if err != nil { return 0, err } @@ -1497,7 +1491,7 @@ func (bi *Bitget) GetHistoricCandles(ctx context.Context, pair currency.Pair, a var resp []kline.Candle switch a { case asset.Spot, asset.Margin, asset.CrossMargin: - cndl, err := bi.GetSpotCandlestickData(ctx, req.RequestFormatted.String(), formatExchangeKlineIntervalSpot(req.ExchangeInterval), req.Start, req.End, 200, true) + cndl, err := bi.GetSpotCandlestickData(ctx, req.RequestFormatted, formatExchangeKlineIntervalSpot(req.ExchangeInterval), req.Start, req.End, 200, true) if err != nil { return nil, err } @@ -1513,7 +1507,7 @@ func (bi *Bitget) GetHistoricCandles(ctx context.Context, pair currency.Pair, a } } case asset.Futures: - cndl, err := bi.GetFuturesCandlestickData(ctx, req.RequestFormatted.String(), getProductType(pair), formatExchangeKlineIntervalFutures(req.ExchangeInterval), req.Start, req.End, 200, CallModeHistory) + cndl, err := bi.GetFuturesCandlestickData(ctx, req.RequestFormatted, getProductType(pair), formatExchangeKlineIntervalFutures(req.ExchangeInterval), req.Start, req.End, 200, CallModeHistory) if err != nil { return nil, err } @@ -1544,7 +1538,7 @@ func (bi *Bitget) GetHistoricCandlesExtended(ctx context.Context, pair currency. for x := range req.RangeHolder.Ranges { switch a { case asset.Spot, asset.Margin, asset.CrossMargin: - cndl, err := bi.GetSpotCandlestickData(ctx, req.RequestFormatted.String(), formatExchangeKlineIntervalSpot(req.ExchangeInterval), req.RangeHolder.Ranges[x].Start.Time, req.RangeHolder.Ranges[x].End.Time, 200, true) + cndl, err := bi.GetSpotCandlestickData(ctx, req.RequestFormatted, formatExchangeKlineIntervalSpot(req.ExchangeInterval), req.RangeHolder.Ranges[x].Start.Time, req.RangeHolder.Ranges[x].End.Time, 200, true) if err != nil { return nil, err } @@ -1561,7 +1555,7 @@ func (bi *Bitget) GetHistoricCandlesExtended(ctx context.Context, pair currency. } resp = append(resp, temp...) case asset.Futures: - cndl, err := bi.GetFuturesCandlestickData(ctx, req.RequestFormatted.String(), getProductType(pair), formatExchangeKlineIntervalFutures(req.ExchangeInterval), req.RangeHolder.Ranges[x].Start.Time, req.RangeHolder.Ranges[x].End.Time, 200, CallModeHistory) + cndl, err := bi.GetFuturesCandlestickData(ctx, req.RequestFormatted, getProductType(pair), formatExchangeKlineIntervalFutures(req.ExchangeInterval), req.RangeHolder.Ranges[x].Start.Time, req.RangeHolder.Ranges[x].End.Time, 200, CallModeHistory) if err != nil { return nil, err } @@ -1588,7 +1582,7 @@ func (bi *Bitget) GetHistoricCandlesExtended(ctx context.Context, pair currency. func (bi *Bitget) GetFuturesContractDetails(ctx context.Context, _ asset.Item) ([]futures.Contract, error) { var contracts []futures.Contract for i := range prodTypes { - resp, err := bi.GetContractConfig(ctx, "", prodTypes[i]) + resp, err := bi.GetContractConfig(ctx, currency.Pair{}, prodTypes[i]) if err != nil { return nil, err } @@ -1628,11 +1622,11 @@ func (bi *Bitget) GetLatestFundingRates(ctx context.Context, req *fundingrate.La if err != nil { return nil, err } - curRate, err := bi.GetFundingCurrent(ctx, fPair.String(), getProductType(fPair)) + curRate, err := bi.GetFundingCurrent(ctx, fPair, getProductType(fPair)) if err != nil { return nil, err } - nextTime, err := bi.GetNextFundingTime(ctx, fPair.String(), getProductType(fPair)) + nextTime, err := bi.GetNextFundingTime(ctx, fPair, getProductType(fPair)) if err != nil { return nil, err } @@ -1654,7 +1648,7 @@ func (bi *Bitget) UpdateOrderExecutionLimits(ctx context.Context, a asset.Item) var limits []order.MinMaxLevel switch a { case asset.Spot: - resp, err := bi.GetSymbolInfo(ctx, "") + resp, err := bi.GetSymbolInfo(ctx, currency.Pair{}) if err != nil { return err } @@ -1673,7 +1667,7 @@ func (bi *Bitget) UpdateOrderExecutionLimits(ctx context.Context, a asset.Item) } case asset.Futures: for i := range prodTypes { - resp, err := bi.GetContractConfig(ctx, "", prodTypes[i]) + resp, err := bi.GetContractConfig(ctx, currency.Pair{}, prodTypes[i]) if err != nil { return err } @@ -1714,7 +1708,7 @@ func (bi *Bitget) UpdateOrderExecutionLimits(ctx context.Context, a asset.Item) // UpdateCurrencyStates updates currency states func (bi *Bitget) UpdateCurrencyStates(ctx context.Context, a asset.Item) error { payload := make(map[currency.Code]currencystate.Options) - resp, err := bi.GetCoinInfo(ctx, "") + resp, err := bi.GetCoinInfo(ctx, currency.Code{}) if err != nil { return err } @@ -1748,7 +1742,7 @@ func (bi *Bitget) GetAvailableTransferChains(ctx context.Context, cur currency.C if cur.IsEmpty() { return nil, errCurrencyEmpty } - resp, err := bi.GetCoinInfo(ctx, cur.String()) + resp, err := bi.GetCoinInfo(ctx, cur) if err != nil { return nil, err } @@ -1773,7 +1767,7 @@ loop: for { switch req.Asset { case asset.Margin: - resp, err := bi.GetIsolatedInterestHistory(ctx, req.Pair.String(), req.Currency.String(), req.StartDate, req.EndDate, 500, pagination) + resp, err := bi.GetIsolatedInterestHistory(ctx, req.Pair, req.Currency, req.StartDate, req.EndDate, 500, pagination) if err != nil { return nil, err } @@ -1788,7 +1782,7 @@ loop: }) } case asset.CrossMargin: - resp, err := bi.GetCrossInterestHistory(ctx, req.Currency.String(), req.StartDate, req.EndDate, 500, pagination) + resp, err := bi.GetCrossInterestHistory(ctx, req.Currency, req.StartDate, req.EndDate, 500, pagination) if err != nil { return nil, err } @@ -1814,7 +1808,7 @@ func (bi *Bitget) GetFuturesPositionSummary(ctx context.Context, req *futures.Po if req == nil { return nil, fmt.Errorf("%T %w", req, common.ErrNilPointer) } - resp, err := bi.GetSinglePosition(ctx, getProductType(req.Pair), req.Pair.String(), req.Pair.Quote.String()) + resp, err := bi.GetSinglePosition(ctx, getProductType(req.Pair), req.Pair, req.Pair.Quote) if err != nil { return nil, err } @@ -1848,7 +1842,7 @@ func (bi *Bitget) GetFuturesPositions(ctx context.Context, req *futures.Position var resp []futures.PositionDetails // This exchange needs pairs to be passed through, since a MarginCoin has to be provided for i := range req.Pairs { - temp, err := bi.GetAllPositions(ctx, getProductType(req.Pairs[i]), req.Pairs[i].Quote.String()) + temp, err := bi.GetAllPositions(ctx, getProductType(req.Pairs[i]), req.Pairs[i].Quote) if err != nil { return nil, err } @@ -1899,13 +1893,13 @@ func (bi *Bitget) GetFuturesPositionOrders(ctx context.Context, req *futures.Pos var err error for x := range pairs { if pairs[x] != "" { - resp, err = bi.allFuturesOrderHelper(ctx, pairs[x], getProductType(req.Pairs[x]), req.Pairs[x], resp) + resp, err = bi.allFuturesOrderHelper(ctx, getProductType(req.Pairs[x]), req.Pairs[x], resp) if err != nil { return nil, err } } else { for y := range prodTypes { - resp, err = bi.allFuturesOrderHelper(ctx, "", prodTypes[y], currency.Pair{}, resp) + resp, err = bi.allFuturesOrderHelper(ctx, prodTypes[y], currency.Pair{}, resp) if err != nil { return nil, err } @@ -1920,7 +1914,7 @@ func (bi *Bitget) GetHistoricalFundingRates(ctx context.Context, req *fundingrat if req == nil { return nil, fmt.Errorf("%T %w", req, common.ErrNilPointer) } - resp, err := bi.GetFundingHistorical(ctx, req.Pair.String(), getProductType(req.Pair), 100, 0) + resp, err := bi.GetFundingHistorical(ctx, req.Pair, getProductType(req.Pair), 100, 0) if err != nil { return nil, err } @@ -1970,7 +1964,7 @@ func (bi *Bitget) SetMarginType(ctx context.Context, a asset.Item, p currency.Pa case margin.Multi: str = "crossed" } - _, err := bi.ChangeMarginMode(ctx, p.String(), getProductType(p), p.Quote.String(), str) + _, err := bi.ChangeMarginMode(ctx, p, getProductType(p), str, p.Quote) if err != nil { return err } @@ -1989,7 +1983,7 @@ func (bi *Bitget) ChangePositionMargin(_ context.Context, _ *margin.PositionChan func (bi *Bitget) SetLeverage(ctx context.Context, a asset.Item, p currency.Pair, _ margin.Type, f float64, s order.Side) error { switch a { case asset.Futures: - _, err := bi.ChangeLeverage(ctx, p.String(), getProductType(p), p.Quote.String(), sideEncoder(s, true), f) + _, err := bi.ChangeLeverage(ctx, p, getProductType(p), sideEncoder(s, true), p.Quote, f) if err != nil { return err } @@ -2004,7 +1998,7 @@ func (bi *Bitget) GetLeverage(ctx context.Context, a asset.Item, p currency.Pair lev := -1.1 switch a { case asset.Futures: - resp, err := bi.GetOneFuturesAccount(ctx, p.String(), getProductType(p), p.Quote.String()) + resp, err := bi.GetOneFuturesAccount(ctx, p, getProductType(p), p.Quote) if err != nil { return lev, err } @@ -2024,7 +2018,7 @@ func (bi *Bitget) GetLeverage(ctx context.Context, a asset.Item, p currency.Pair return lev, margin.ErrMarginTypeUnsupported } case asset.Margin: - resp, err := bi.GetIsolatedInterestRateAndMaxBorrowable(ctx, p.String()) + resp, err := bi.GetIsolatedInterestRateAndMaxBorrowable(ctx, p) if err != nil { return lev, err } @@ -2033,7 +2027,7 @@ func (bi *Bitget) GetLeverage(ctx context.Context, a asset.Item, p currency.Pair } lev = resp[0].Leverage case asset.CrossMargin: - resp, err := bi.GetCrossInterestRateAndMaxBorrowable(ctx, p.Quote.String()) + resp, err := bi.GetCrossInterestRateAndMaxBorrowable(ctx, p.Quote) if err != nil { return lev, err } @@ -2051,7 +2045,7 @@ func (bi *Bitget) GetLeverage(ctx context.Context, a asset.Item, p currency.Pair func (bi *Bitget) GetOpenInterest(ctx context.Context, pairs ...key.PairAsset) ([]futures.OpenInterest, error) { openInterest := make([]futures.OpenInterest, len(pairs)) for i := range pairs { - resp, err := bi.GetOpenPositions(ctx, pairs[i].Pair().String(), getProductType(pairs[i].Pair())) + resp, err := bi.GetOpenPositions(ctx, pairs[i].Pair(), getProductType(pairs[i].Pair())) if err != nil { return nil, err } @@ -2225,7 +2219,7 @@ func typeDecoder(s string) order.Type { } // WithdrawalHistGrabber is a helper function that repeatedly calls GetWithdrawalRecords and returns all data -func (bi *Bitget) withdrawalHistGrabber(ctx context.Context, currency string) ([]WithdrawRecordsResp, error) { +func (bi *Bitget) withdrawalHistGrabber(ctx context.Context, currency currency.Code) ([]WithdrawRecordsResp, error) { var allData []WithdrawRecordsResp var pagination int64 for { @@ -2262,10 +2256,10 @@ func pairFromStringHelper(s string) (currency.Pair, error) { } // SpotPlanOrdersHelper is a helper function that repeatedly calls GetCurrentSpotPlanOrders and returns all data -func (bi *Bitget) spotCurrentPlanOrdersHelper(ctx context.Context, pairStr string, pairCan currency.Pair, resp []order.Detail) ([]order.Detail, error) { +func (bi *Bitget) spotCurrentPlanOrdersHelper(ctx context.Context, pairCan currency.Pair, resp []order.Detail) ([]order.Detail, error) { var pagination int64 for { - genOrds, err := bi.GetCurrentSpotPlanOrders(ctx, pairStr, time.Time{}, time.Time{}, 100, pagination) + genOrds, err := bi.GetCurrentSpotPlanOrders(ctx, pairCan, time.Time{}, time.Time{}, 100, pagination) if err != nil { return nil, err } @@ -2312,10 +2306,10 @@ func marginDecoder(s string) margin.Type { // ActiveFuturesOrderHelper is a helper function that repeatedly calls GetPendingFuturesOrders and // GetPendingFuturesTriggerOrders, returning the data formatted appropriately -func (bi *Bitget) activeFuturesOrderHelper(ctx context.Context, pairStr, productType string, pairCan currency.Pair, resp []order.Detail) ([]order.Detail, error) { +func (bi *Bitget) activeFuturesOrderHelper(ctx context.Context, productType string, pairCan currency.Pair, resp []order.Detail) ([]order.Detail, error) { var pagination int64 for { - genOrds, err := bi.GetPendingFuturesOrders(ctx, 0, pagination, 100, "", pairStr, productType, "", time.Time{}, time.Time{}) + genOrds, err := bi.GetPendingFuturesOrders(ctx, 0, pagination, 100, "", productType, "", pairCan, time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -2346,7 +2340,7 @@ func (bi *Bitget) activeFuturesOrderHelper(ctx context.Context, pairStr, product LimitPriceUpper: float64(genOrds.EntrustedList[i].PresetStopSurplusPrice), LimitPriceLower: float64(genOrds.EntrustedList[i].PresetStopLossPrice), } - if pairStr != "" { + if !pairCan.IsEmpty() { tempOrds[i].Pair = pairCan } else { tempOrds[i].Pair, err = pairFromStringHelper(genOrds.EntrustedList[i].Symbol) @@ -2361,7 +2355,7 @@ func (bi *Bitget) activeFuturesOrderHelper(ctx context.Context, pairStr, product for y := range planTypes { pagination = 0 for { - genOrds, err := bi.GetPendingTriggerFuturesOrders(ctx, 0, pagination, 100, "", pairStr, planTypes[y], productType, time.Time{}, time.Time{}) + genOrds, err := bi.GetPendingTriggerFuturesOrders(ctx, 0, pagination, 100, "", planTypes[y], productType, pairCan, time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -2389,7 +2383,7 @@ func (bi *Bitget) activeFuturesOrderHelper(ctx context.Context, pairStr, product LimitPriceUpper: float64(genOrds.EntrustedList[i].PresetTakeProfitPrice), LimitPriceLower: float64(genOrds.EntrustedList[i].PresetStopLossPrice), } - if pairStr != "" { + if !pairCan.IsEmpty() { tempOrds[i].Pair = pairCan } else { tempOrds[i].Pair, err = pairFromStringHelper(genOrds.EntrustedList[i].Symbol) @@ -2406,10 +2400,10 @@ func (bi *Bitget) activeFuturesOrderHelper(ctx context.Context, pairStr, product // SpotHistoricPlanOrdersHelper is a helper function that repeatedly calls GetHistoricalSpotOrders and returns // all data formatted appropriately -func (bi *Bitget) spotHistoricPlanOrdersHelper(ctx context.Context, pairStr string, pairCan currency.Pair, resp []order.Detail, fillMap map[int64][]order.TradeHistory) ([]order.Detail, error) { +func (bi *Bitget) spotHistoricPlanOrdersHelper(ctx context.Context, pairCan currency.Pair, resp []order.Detail, fillMap map[int64][]order.TradeHistory) ([]order.Detail, error) { var pagination int64 for { - genOrds, err := bi.GetSpotPlanOrderHistory(ctx, pairStr, time.Now().Add(-time.Hour*24*90), time.Now(), 100, pagination) + genOrds, err := bi.GetSpotPlanOrderHistory(ctx, pairCan, time.Now().Add(-time.Hour*24*90), time.Now(), 100, pagination) if err != nil { return nil, err } @@ -2448,11 +2442,11 @@ func (bi *Bitget) spotHistoricPlanOrdersHelper(ctx context.Context, pairStr stri // HistoricalFuturesOrderHelper is a helper function that repeatedly calls GetFuturesFills, // GetHistoricalFuturesOrders, and GetHistoricalTriggerFuturesOrders, returning the data formatted appropriately -func (bi *Bitget) historicalFuturesOrderHelper(ctx context.Context, pairStr, productType string, pairCan currency.Pair, resp []order.Detail) ([]order.Detail, error) { +func (bi *Bitget) historicalFuturesOrderHelper(ctx context.Context, productType string, pairCan currency.Pair, resp []order.Detail) ([]order.Detail, error) { var pagination int64 fillMap := make(map[int64][]order.TradeHistory) for { - fillOrds, err := bi.GetFuturesFills(ctx, 0, pagination, 100, pairStr, productType, time.Time{}, time.Time{}) + fillOrds, err := bi.GetFuturesFills(ctx, 0, pagination, 100, pairCan, productType, time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -2477,7 +2471,7 @@ func (bi *Bitget) historicalFuturesOrderHelper(ctx context.Context, pairStr, pro } pagination = 0 for { - genOrds, err := bi.GetHistoricalFuturesOrders(ctx, 0, pagination, 100, "", pairStr, productType, time.Time{}, time.Time{}) + genOrds, err := bi.GetHistoricalFuturesOrders(ctx, 0, pagination, 100, "", productType, pairCan, time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -2508,7 +2502,7 @@ func (bi *Bitget) historicalFuturesOrderHelper(ctx context.Context, pairStr, pro LimitPriceUpper: float64(genOrds.EntrustedList[i].PresetStopSurplusPrice), LimitPriceLower: float64(genOrds.EntrustedList[i].PresetStopLossPrice), } - if pairStr != "" { + if !pairCan.IsEmpty() { tempOrds[i].Pair = pairCan } else { tempOrds[i].Pair, err = pairFromStringHelper(genOrds.EntrustedList[i].Symbol) @@ -2526,7 +2520,7 @@ func (bi *Bitget) historicalFuturesOrderHelper(ctx context.Context, pairStr, pro for y := range planTypes { pagination = 0 for { - genOrds, err := bi.GetHistoricalTriggerFuturesOrders(ctx, 0, pagination, 100, "", planTypes[y], "", pairStr, productType, time.Time{}, time.Time{}) + genOrds, err := bi.GetHistoricalTriggerFuturesOrders(ctx, 0, pagination, 100, "", planTypes[y], "", productType, pairCan, time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -2555,7 +2549,7 @@ func (bi *Bitget) historicalFuturesOrderHelper(ctx context.Context, pairStr, pro LimitPriceUpper: float64(genOrds.EntrustedList[i].PresetTakeProfitPrice), LimitPriceLower: float64(genOrds.EntrustedList[i].PresetStopLossPrice), } - if pairStr != "" { + if !pairCan.IsEmpty() { tempOrds[i].Pair = pairCan } else { tempOrds[i].Pair, err = pairFromStringHelper(genOrds.EntrustedList[i].Symbol) @@ -2574,10 +2568,10 @@ func (bi *Bitget) historicalFuturesOrderHelper(ctx context.Context, pairStr, pro } // SpotFillsHelper is a helper function that repeatedly calls GetSpotFills, directly altering the supplied map with that data -func (bi *Bitget) spotFillsHelper(ctx context.Context, pairStr string, fillMap map[int64][]order.TradeHistory) error { +func (bi *Bitget) spotFillsHelper(ctx context.Context, pair currency.Pair, fillMap map[int64][]order.TradeHistory) error { var pagination int64 for { - genFills, err := bi.GetSpotFills(ctx, pairStr, time.Time{}, time.Time{}, 100, pagination, 0) + genFills, err := bi.GetSpotFills(ctx, pair, time.Time{}, time.Time{}, 100, pagination, 0) if err != nil { return err } @@ -2698,7 +2692,7 @@ func contractTypeDecoder(s string) futures.ContractType { // AllFuturesOrderHelper is a helper function that repeatedly calls GetPendingFuturesOrders and // GetPendingFuturesTriggerOrders, returning the data formatted appropriately -func (bi *Bitget) allFuturesOrderHelper(ctx context.Context, pairStr, productType string, pairCan currency.Pair, resp []futures.PositionResponse) ([]futures.PositionResponse, error) { +func (bi *Bitget) allFuturesOrderHelper(ctx context.Context, productType string, pairCan currency.Pair, resp []futures.PositionResponse) ([]futures.PositionResponse, error) { var pagination1 int64 var pagination2 int64 var breakbool1 bool @@ -2708,7 +2702,7 @@ func (bi *Bitget) allFuturesOrderHelper(ctx context.Context, pairStr, productTyp var genOrds *FuturesOrdResp var err error if !breakbool1 { - genOrds, err = bi.GetPendingFuturesOrders(ctx, 0, pagination1, 100, "", pairStr, productType, "", time.Time{}, time.Time{}) + genOrds, err = bi.GetPendingFuturesOrders(ctx, 0, pagination1, 100, "", productType, "", pairCan, time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -2720,7 +2714,7 @@ func (bi *Bitget) allFuturesOrderHelper(ctx context.Context, pairStr, productTyp } } if !breakbool2 { - genOrds2, err := bi.GetHistoricalFuturesOrders(ctx, 0, pagination2, 100, "", pairStr, productType, time.Time{}, time.Time{}) + genOrds2, err := bi.GetHistoricalFuturesOrders(ctx, 0, pagination2, 100, "", productType, pairCan, time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -2739,7 +2733,7 @@ func (bi *Bitget) allFuturesOrderHelper(ctx context.Context, pairStr, productTyp } for i := range genOrds.EntrustedList { var thisPair currency.Pair - if pairStr != "" { + if !pairCan.IsEmpty() { thisPair = pairCan } else { thisPair, err = pairFromStringHelper(genOrds.EntrustedList[i].Symbol) @@ -2778,7 +2772,7 @@ func (bi *Bitget) allFuturesOrderHelper(ctx context.Context, pairStr, productTyp for y := range planTypes { pagination1 = 0 for { - genOrds, err := bi.GetPendingTriggerFuturesOrders(ctx, 0, pagination1, 100, "", pairStr, planTypes[y], productType, time.Time{}, time.Time{}) + genOrds, err := bi.GetPendingTriggerFuturesOrders(ctx, 0, pagination1, 100, "", planTypes[y], productType, pairCan, time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -2788,7 +2782,7 @@ func (bi *Bitget) allFuturesOrderHelper(ctx context.Context, pairStr, productTyp pagination1 = int64(genOrds.EndID) for i := range genOrds.EntrustedList { var thisPair currency.Pair - if pairStr != "" { + if !pairCan.IsEmpty() { thisPair = pairCan } else { thisPair, err = pairFromStringHelper(genOrds.EntrustedList[i].Symbol) @@ -2819,7 +2813,7 @@ func (bi *Bitget) allFuturesOrderHelper(ctx context.Context, pairStr, productTyp } pagination1 = 0 for { - genOrds, err := bi.GetHistoricalTriggerFuturesOrders(ctx, 0, pagination1, 100, "", planTypes[y], "", pairStr, productType, time.Time{}, time.Time{}) + genOrds, err := bi.GetHistoricalTriggerFuturesOrders(ctx, 0, pagination1, 100, "", planTypes[y], "", productType, pairCan, time.Time{}, time.Time{}) if err != nil { return nil, err } @@ -2829,7 +2823,7 @@ func (bi *Bitget) allFuturesOrderHelper(ctx context.Context, pairStr, productTyp pagination1 = int64(genOrds.EndID) for i := range genOrds.EntrustedList { var thisPair currency.Pair - if pairStr != "" { + if !pairCan.IsEmpty() { thisPair = pairCan } else { thisPair, err = pairFromStringHelper(genOrds.EntrustedList[i].Symbol)