mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 07:26:46 +00:00
Tests: Use currency.NewBTCUSD and NewBTCUSDT (#1895)
* Tests: Use currency.NewUSD and NewUSDT Simple refactor to use the provided shortcut methods * Github: Add CI check to ensure NewPair not used Add a step to ensure NewPair(BTC, USD*) isn't used
This commit is contained in:
@@ -203,7 +203,7 @@ func TestUExchangeInfo(t *testing.T) {
|
||||
|
||||
func TestUFuturesOrderbook(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UFuturesOrderbook(t.Context(), currency.NewPair(currency.BTC, currency.USDT), 1000)
|
||||
_, err := b.UFuturesOrderbook(t.Context(), currency.NewBTCUSDT(), 1000)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -211,7 +211,7 @@ func TestUFuturesOrderbook(t *testing.T) {
|
||||
|
||||
func TestURecentTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.URecentTrades(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "", 1000)
|
||||
_, err := b.URecentTrades(t.Context(), currency.NewBTCUSDT(), "", 1000)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -219,7 +219,7 @@ func TestURecentTrades(t *testing.T) {
|
||||
|
||||
func TestUCompressedTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UCompressedTrades(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "", 5, time.Time{}, time.Time{})
|
||||
_, err := b.UCompressedTrades(t.Context(), currency.NewBTCUSDT(), "", 5, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -232,7 +232,7 @@ func TestUCompressedTrades(t *testing.T) {
|
||||
|
||||
func TestUKlineData(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UKlineData(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "1d", 5, time.Time{}, time.Time{})
|
||||
_, err := b.UKlineData(t.Context(), currency.NewBTCUSDT(), "1d", 5, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func TestUKlineData(t *testing.T) {
|
||||
|
||||
func TestUGetMarkPrice(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UGetMarkPrice(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.UGetMarkPrice(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func TestUGetMarkPrice(t *testing.T) {
|
||||
|
||||
func TestUGetFundingHistory(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UGetFundingHistory(t.Context(), currency.NewPair(currency.BTC, currency.USDT), 1, time.Time{}, time.Time{})
|
||||
_, err := b.UGetFundingHistory(t.Context(), currency.NewBTCUSDT(), 1, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func TestUGetFundingHistory(t *testing.T) {
|
||||
|
||||
func TestU24HTickerPriceChangeStats(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.U24HTickerPriceChangeStats(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.U24HTickerPriceChangeStats(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -282,7 +282,7 @@ func TestU24HTickerPriceChangeStats(t *testing.T) {
|
||||
|
||||
func TestUSymbolPriceTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.USymbolPriceTicker(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.USymbolPriceTicker(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -294,7 +294,7 @@ func TestUSymbolPriceTicker(t *testing.T) {
|
||||
|
||||
func TestUSymbolOrderbookTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.USymbolOrderbookTicker(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.USymbolOrderbookTicker(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -306,7 +306,7 @@ func TestUSymbolOrderbookTicker(t *testing.T) {
|
||||
|
||||
func TestUOpenInterest(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UOpenInterest(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.UOpenInterest(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -314,7 +314,7 @@ func TestUOpenInterest(t *testing.T) {
|
||||
|
||||
func TestUOpenInterestStats(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UOpenInterestStats(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "5m", 1, time.Time{}, time.Time{})
|
||||
_, err := b.UOpenInterestStats(t.Context(), currency.NewBTCUSDT(), "5m", 1, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -327,12 +327,12 @@ func TestUOpenInterestStats(t *testing.T) {
|
||||
|
||||
func TestUTopAcccountsLongShortRatio(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UTopAcccountsLongShortRatio(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "5m", 2, time.Time{}, time.Time{})
|
||||
_, err := b.UTopAcccountsLongShortRatio(t.Context(), currency.NewBTCUSDT(), "5m", 2, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
start, end := getTime()
|
||||
_, err = b.UTopAcccountsLongShortRatio(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "5m", 2, start, end)
|
||||
_, err = b.UTopAcccountsLongShortRatio(t.Context(), currency.NewBTCUSDT(), "5m", 2, start, end)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -340,12 +340,12 @@ func TestUTopAcccountsLongShortRatio(t *testing.T) {
|
||||
|
||||
func TestUTopPostionsLongShortRatio(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UTopPostionsLongShortRatio(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "5m", 3, time.Time{}, time.Time{})
|
||||
_, err := b.UTopPostionsLongShortRatio(t.Context(), currency.NewBTCUSDT(), "5m", 3, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
start, end := getTime()
|
||||
_, err = b.UTopPostionsLongShortRatio(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "1d", 0, start, end)
|
||||
_, err = b.UTopPostionsLongShortRatio(t.Context(), currency.NewBTCUSDT(), "1d", 0, start, end)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -353,12 +353,12 @@ func TestUTopPostionsLongShortRatio(t *testing.T) {
|
||||
|
||||
func TestUGlobalLongShortRatio(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.UGlobalLongShortRatio(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "5m", 3, time.Time{}, time.Time{})
|
||||
_, err := b.UGlobalLongShortRatio(t.Context(), currency.NewBTCUSDT(), "5m", 3, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
start, end := getTime()
|
||||
_, err = b.UGlobalLongShortRatio(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "4h", 0, start, end)
|
||||
_, err = b.UGlobalLongShortRatio(t.Context(), currency.NewBTCUSDT(), "4h", 0, start, end)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -367,7 +367,7 @@ func TestUGlobalLongShortRatio(t *testing.T) {
|
||||
func TestUTakerBuySellVol(t *testing.T) {
|
||||
t.Parallel()
|
||||
start, end := getTime()
|
||||
_, err := b.UTakerBuySellVol(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "5m", 10, start, end)
|
||||
_, err := b.UTakerBuySellVol(t.Context(), currency.NewBTCUSDT(), "5m", 10, start, end)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -394,7 +394,7 @@ func TestUFuturesNewOrder(t *testing.T) {
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
_, err := b.UFuturesNewOrder(t.Context(),
|
||||
&UFuturesNewOrderRequest{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Side: "BUY",
|
||||
OrderType: "LIMIT",
|
||||
TimeInForce: "GTC",
|
||||
@@ -428,7 +428,7 @@ func TestUPlaceBatchOrders(t *testing.T) {
|
||||
func TestUGetOrderData(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.UGetOrderData(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "123", "")
|
||||
_, err := b.UGetOrderData(t.Context(), currency.NewBTCUSDT(), "123", "")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -437,7 +437,7 @@ func TestUGetOrderData(t *testing.T) {
|
||||
func TestUCancelOrder(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
_, err := b.UCancelOrder(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "123", "")
|
||||
_, err := b.UCancelOrder(t.Context(), currency.NewBTCUSDT(), "123", "")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -446,7 +446,7 @@ func TestUCancelOrder(t *testing.T) {
|
||||
func TestUCancelAllOpenOrders(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
_, err := b.UCancelAllOpenOrders(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.UCancelAllOpenOrders(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -455,7 +455,7 @@ func TestUCancelAllOpenOrders(t *testing.T) {
|
||||
func TestUCancelBatchOrders(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
_, err := b.UCancelBatchOrders(t.Context(), currency.NewPair(currency.BTC, currency.USDT), []string{"123"}, []string{})
|
||||
_, err := b.UCancelBatchOrders(t.Context(), currency.NewBTCUSDT(), []string{"123"}, []string{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -464,7 +464,7 @@ func TestUCancelBatchOrders(t *testing.T) {
|
||||
func TestUAutoCancelAllOpenOrders(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
_, err := b.UAutoCancelAllOpenOrders(t.Context(), currency.NewPair(currency.BTC, currency.USDT), 30)
|
||||
_, err := b.UAutoCancelAllOpenOrders(t.Context(), currency.NewBTCUSDT(), 30)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -473,7 +473,7 @@ func TestUAutoCancelAllOpenOrders(t *testing.T) {
|
||||
func TestUFetchOpenOrder(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.UFetchOpenOrder(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "123", "")
|
||||
_, err := b.UFetchOpenOrder(t.Context(), currency.NewBTCUSDT(), "123", "")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -482,7 +482,7 @@ func TestUFetchOpenOrder(t *testing.T) {
|
||||
func TestUAllAccountOpenOrders(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.UAllAccountOpenOrders(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.UAllAccountOpenOrders(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -495,7 +495,7 @@ func TestUAllAccountOrders(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = b.UAllAccountOrders(t.Context(), currency.NewPair(currency.BTC, currency.USDT), 0, 5, time.Now().Add(-time.Hour*4), time.Now())
|
||||
_, err = b.UAllAccountOrders(t.Context(), currency.NewBTCUSDT(), 0, 5, time.Now().Add(-time.Hour*4), time.Now())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -522,7 +522,7 @@ func TestUAccountInformationV2(t *testing.T) {
|
||||
func TestUChangeInitialLeverageRequest(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
_, err := b.UChangeInitialLeverageRequest(t.Context(), currency.NewPair(currency.BTC, currency.USDT), 2)
|
||||
_, err := b.UChangeInitialLeverageRequest(t.Context(), currency.NewBTCUSDT(), 2)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -531,7 +531,7 @@ func TestUChangeInitialLeverageRequest(t *testing.T) {
|
||||
func TestUChangeInitialMarginType(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
err := b.UChangeInitialMarginType(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "ISOLATED")
|
||||
err := b.UChangeInitialMarginType(t.Context(), currency.NewBTCUSDT(), "ISOLATED")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -540,7 +540,7 @@ func TestUChangeInitialMarginType(t *testing.T) {
|
||||
func TestUModifyIsolatedPositionMarginReq(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
_, err := b.UModifyIsolatedPositionMarginReq(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "LONG", "add", 5)
|
||||
_, err := b.UModifyIsolatedPositionMarginReq(t.Context(), currency.NewBTCUSDT(), "LONG", "add", 5)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -549,7 +549,7 @@ func TestUModifyIsolatedPositionMarginReq(t *testing.T) {
|
||||
func TestUPositionMarginChangeHistory(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
_, err := b.UPositionMarginChangeHistory(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "add", 5, time.Time{}, time.Time{})
|
||||
_, err := b.UPositionMarginChangeHistory(t.Context(), currency.NewBTCUSDT(), "add", 5, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -558,7 +558,7 @@ func TestUPositionMarginChangeHistory(t *testing.T) {
|
||||
func TestUPositionsInfoV2(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.UPositionsInfoV2(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.UPositionsInfoV2(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -567,7 +567,7 @@ func TestUPositionsInfoV2(t *testing.T) {
|
||||
func TestUAccountTradesHistory(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.UAccountTradesHistory(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "", 5, time.Time{}, time.Time{})
|
||||
_, err := b.UAccountTradesHistory(t.Context(), currency.NewBTCUSDT(), "", 5, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -585,7 +585,7 @@ func TestUAccountIncomeHistory(t *testing.T) {
|
||||
func TestUGetNotionalAndLeverageBrackets(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.UGetNotionalAndLeverageBrackets(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.UGetNotionalAndLeverageBrackets(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -594,7 +594,7 @@ func TestUGetNotionalAndLeverageBrackets(t *testing.T) {
|
||||
func TestUPositionsADLEstimate(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.UPositionsADLEstimate(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.UPositionsADLEstimate(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -603,7 +603,7 @@ func TestUPositionsADLEstimate(t *testing.T) {
|
||||
func TestUAccountForcedOrders(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.UAccountForcedOrders(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "ADL", 5, time.Time{}, time.Time{})
|
||||
_, err := b.UAccountForcedOrders(t.Context(), currency.NewBTCUSDT(), "ADL", 5, time.Time{}, time.Time{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -933,7 +933,7 @@ func TestAutoCancelAllOpenOrders(t *testing.T) {
|
||||
func TestFuturesOpenOrderData(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.FuturesOpenOrderData(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "", "")
|
||||
_, err := b.FuturesOpenOrderData(t.Context(), currency.NewBTCUSDT(), "", "")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -1111,7 +1111,7 @@ func TestGetOrderBook(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetOrderBook(t.Context(),
|
||||
OrderBookDataRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Limit: 1000,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1123,7 +1123,7 @@ func TestGetMostRecentTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetMostRecentTrades(t.Context(),
|
||||
RecentTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Limit: 15,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1145,7 +1145,7 @@ func TestGetAggregatedTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetAggregatedTrades(t.Context(),
|
||||
&AggregatedTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Limit: 5,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1158,7 +1158,7 @@ func TestGetSpotKline(t *testing.T) {
|
||||
start, end := getTime()
|
||||
_, err := b.GetSpotKline(t.Context(),
|
||||
&KlinesRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Interval: kline.FiveMin.Short(),
|
||||
Limit: 24,
|
||||
StartTime: start,
|
||||
@@ -1172,7 +1172,7 @@ func TestGetSpotKline(t *testing.T) {
|
||||
func TestGetAveragePrice(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := b.GetAveragePrice(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.GetAveragePrice(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error("Binance GetAveragePrice() error", err)
|
||||
}
|
||||
@@ -1181,7 +1181,7 @@ func TestGetAveragePrice(t *testing.T) {
|
||||
func TestGetPriceChangeStats(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := b.GetPriceChangeStats(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.GetPriceChangeStats(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error("Binance GetPriceChangeStats() error", err)
|
||||
}
|
||||
@@ -1193,7 +1193,7 @@ func TestGetTickers(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := b.GetTickers(t.Context(),
|
||||
currency.NewPair(currency.BTC, currency.USDT),
|
||||
currency.NewBTCUSDT(),
|
||||
currency.NewPair(currency.ETH, currency.USDT))
|
||||
require.NoError(t, err)
|
||||
require.Len(t, resp, 2)
|
||||
@@ -1202,7 +1202,7 @@ func TestGetTickers(t *testing.T) {
|
||||
func TestGetLatestSpotPrice(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := b.GetLatestSpotPrice(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.GetLatestSpotPrice(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error("Binance GetLatestSpotPrice() error", err)
|
||||
}
|
||||
@@ -1211,7 +1211,7 @@ func TestGetLatestSpotPrice(t *testing.T) {
|
||||
func TestGetBestPrice(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := b.GetBestPrice(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.GetBestPrice(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error("Binance GetBestPrice() error", err)
|
||||
}
|
||||
@@ -1220,7 +1220,7 @@ func TestGetBestPrice(t *testing.T) {
|
||||
func TestQueryOrder(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := b.QueryOrder(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "", 1337)
|
||||
_, err := b.QueryOrder(t.Context(), currency.NewBTCUSDT(), "", 1337)
|
||||
switch {
|
||||
case sharedtestvalues.AreAPICredentialsSet(b) && err != nil:
|
||||
t.Error("QueryOrder() error", err)
|
||||
@@ -1239,7 +1239,7 @@ func TestOpenOrders(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
p := currency.NewPair(currency.BTC, currency.USDT)
|
||||
p := currency.NewBTCUSDT()
|
||||
_, err = b.OpenOrders(t.Context(), p)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@@ -1249,7 +1249,7 @@ func TestOpenOrders(t *testing.T) {
|
||||
func TestAllOrders(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := b.AllOrders(t.Context(), currency.NewPair(currency.BTC, currency.USDT), "", "")
|
||||
_, err := b.AllOrders(t.Context(), currency.NewBTCUSDT(), "", "")
|
||||
switch {
|
||||
case sharedtestvalues.AreAPICredentialsSet(b) && err != nil:
|
||||
t.Error("AllOrders() error", err)
|
||||
@@ -1452,7 +1452,7 @@ func TestNewOrderTest(t *testing.T) {
|
||||
|
||||
func TestGetHistoricTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
p := currency.NewPair(currency.BTC, currency.USDT)
|
||||
p := currency.NewBTCUSDT()
|
||||
start := time.Unix(1577977445, 0) // 2020-01-02 15:04:05
|
||||
end := start.Add(15 * time.Minute) // 2020-01-02 15:19:05
|
||||
result, err := b.GetHistoricTrades(t.Context(), p, asset.Spot, start, end)
|
||||
@@ -1516,7 +1516,7 @@ func TestGetAggregatedTradesBatched(t *testing.T) {
|
||||
name: "mock custom limit with start time set, no end time",
|
||||
mock: true,
|
||||
args: &AggregatedTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
StartTime: start,
|
||||
Limit: 1001,
|
||||
},
|
||||
@@ -1526,7 +1526,7 @@ func TestGetAggregatedTradesBatched(t *testing.T) {
|
||||
{
|
||||
name: "custom limit with start time set, no end time",
|
||||
args: &AggregatedTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
StartTime: time.Date(2020, 11, 18, 23, 0, 28, 921, time.UTC),
|
||||
Limit: 1001,
|
||||
},
|
||||
@@ -1537,7 +1537,7 @@ func TestGetAggregatedTradesBatched(t *testing.T) {
|
||||
name: "mock recent trades",
|
||||
mock: true,
|
||||
args: &AggregatedTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Limit: 3,
|
||||
},
|
||||
numExpected: 3,
|
||||
@@ -1578,14 +1578,14 @@ func TestGetAggregatedTradesErrors(t *testing.T) {
|
||||
{
|
||||
name: "get recent trades does not support custom limit",
|
||||
args: &AggregatedTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Limit: 1001,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "start time and fromId cannot be both set",
|
||||
args: &AggregatedTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
StartTime: start,
|
||||
EndTime: start.Add(75 * time.Minute),
|
||||
FromID: 2,
|
||||
@@ -1594,7 +1594,7 @@ func TestGetAggregatedTradesErrors(t *testing.T) {
|
||||
{
|
||||
name: "can't get most recent 5000 (more than 1000 not allowed)",
|
||||
args: &AggregatedTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Limit: 5000,
|
||||
},
|
||||
},
|
||||
@@ -2383,7 +2383,7 @@ func TestBinance_FormatExchangeKlineInterval(t *testing.T) {
|
||||
|
||||
func TestGetRecentTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
_, err := b.GetRecentTrades(t.Context(),
|
||||
pair, asset.Spot)
|
||||
if err != nil {
|
||||
@@ -2418,7 +2418,7 @@ func TestGetAvailableTransferChains(t *testing.T) {
|
||||
|
||||
func TestSeedLocalCache(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := b.SeedLocalCache(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
err := b.SeedLocalCache(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -2471,7 +2471,7 @@ func TestProcessUpdate(t *testing.T) {
|
||||
b := new(Binance) //nolint:govet // Intentional shadow to avoid future copy/paste mistakes
|
||||
require.NoError(t, testexch.Setup(b), "Test instance Setup must not error")
|
||||
b.setupOrderbookManager()
|
||||
p := currency.NewPair(currency.BTC, currency.USDT)
|
||||
p := currency.NewBTCUSDT()
|
||||
var depth WebsocketDepthStream
|
||||
err := json.Unmarshal(websocketDepthUpdate, &depth)
|
||||
if err != nil {
|
||||
@@ -2586,7 +2586,7 @@ func TestWsOrderExecutionReport(t *testing.T) {
|
||||
AssetType: asset.Spot,
|
||||
Date: time.UnixMilli(1616627567900),
|
||||
LastUpdated: time.UnixMilli(1616627567900),
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
}
|
||||
// empty the channel. otherwise mock_test will fail
|
||||
for len(b.Websocket.DataHandler) > 0 {
|
||||
@@ -2775,7 +2775,7 @@ func TestUpdateOrderExecutionLimits(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := map[asset.Item]currency.Pair{
|
||||
asset.Spot: currency.NewPair(currency.BTC, currency.USDT),
|
||||
asset.Spot: currency.NewBTCUSDT(),
|
||||
asset.Margin: currency.NewPair(currency.ETH, currency.BTC),
|
||||
}
|
||||
for _, a := range []asset.Item{asset.CoinMarginedFutures, asset.USDTMarginedFutures} {
|
||||
@@ -2821,7 +2821,7 @@ func TestGetHistoricalFundingRates(t *testing.T) {
|
||||
s, e := getTime()
|
||||
_, err := b.GetHistoricalFundingRates(t.Context(), &fundingrate.HistoricalRatesRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: s,
|
||||
EndDate: e,
|
||||
IncludePayments: true,
|
||||
@@ -2833,7 +2833,7 @@ func TestGetHistoricalFundingRates(t *testing.T) {
|
||||
|
||||
_, err = b.GetHistoricalFundingRates(t.Context(), &fundingrate.HistoricalRatesRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: s,
|
||||
EndDate: e,
|
||||
PaymentCurrency: currency.DOGE,
|
||||
@@ -2844,7 +2844,7 @@ func TestGetHistoricalFundingRates(t *testing.T) {
|
||||
|
||||
r := &fundingrate.HistoricalRatesRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
StartDate: s,
|
||||
EndDate: e,
|
||||
}
|
||||
@@ -2869,7 +2869,7 @@ func TestGetHistoricalFundingRates(t *testing.T) {
|
||||
|
||||
func TestGetLatestFundingRates(t *testing.T) {
|
||||
t.Parallel()
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
_, err := b.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: cp,
|
||||
@@ -2899,7 +2899,7 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
|
||||
func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
t.Parallel()
|
||||
is, err := b.IsPerpetualFutureCurrency(asset.Binary, currency.NewPair(currency.BTC, currency.USDT))
|
||||
is, err := b.IsPerpetualFutureCurrency(asset.Binary, currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -2907,7 +2907,7 @@ func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
t.Error("expected false")
|
||||
}
|
||||
|
||||
is, err = b.IsPerpetualFutureCurrency(asset.CoinMarginedFutures, currency.NewPair(currency.BTC, currency.USDT))
|
||||
is, err = b.IsPerpetualFutureCurrency(asset.CoinMarginedFutures, currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -2922,7 +2922,7 @@ func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
t.Error("expected true")
|
||||
}
|
||||
|
||||
is, err = b.IsPerpetualFutureCurrency(asset.USDTMarginedFutures, currency.NewPair(currency.BTC, currency.USDT))
|
||||
is, err = b.IsPerpetualFutureCurrency(asset.USDTMarginedFutures, currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -2941,7 +2941,7 @@ func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
func TestGetUserMarginInterestHistory(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
_, err := b.GetUserMarginInterestHistory(t.Context(), currency.USDT, currency.NewPair(currency.BTC, currency.USDT), time.Now().Add(-time.Hour*24), time.Now(), 1, 10, false)
|
||||
_, err := b.GetUserMarginInterestHistory(t.Context(), currency.USDT, currency.NewBTCUSDT(), time.Now().Add(-time.Hour*24), time.Now(), 1, 10, false)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -3106,7 +3106,7 @@ func TestSetMarginType(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
|
||||
|
||||
err := b.SetMarginType(t.Context(), asset.USDTMarginedFutures, currency.NewPair(currency.BTC, currency.USDT), margin.Isolated)
|
||||
err := b.SetMarginType(t.Context(), asset.USDTMarginedFutures, currency.NewBTCUSDT(), margin.Isolated)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -3120,7 +3120,7 @@ func TestSetMarginType(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
err = b.SetMarginType(t.Context(), asset.Spot, currency.NewPair(currency.BTC, currency.USDT), margin.Isolated)
|
||||
err = b.SetMarginType(t.Context(), asset.Spot, currency.NewBTCUSDT(), margin.Isolated)
|
||||
if !errors.Is(err, asset.ErrNotSupported) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user