mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-20 23:16:49 +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)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ const (
|
||||
|
||||
var (
|
||||
bi = &Binanceus{}
|
||||
testPairMapping = currency.NewPair(currency.BTC, currency.USDT)
|
||||
testPairMapping = currency.NewBTCUSDT()
|
||||
// this lock guards against orderbook tests race
|
||||
binanceusOrderBookLock = &sync.Mutex{}
|
||||
)
|
||||
@@ -210,7 +210,7 @@ func TestSubmitOrder(t *testing.T) {
|
||||
func TestCancelOrder(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pair := currency.NewPair(currency.BTC, currency.USD)
|
||||
pair := currency.NewBTCUSD()
|
||||
err := bi.CancelOrder(t.Context(), &order.Cancel{
|
||||
AssetType: asset.Spot,
|
||||
OrderID: "1337",
|
||||
@@ -385,7 +385,7 @@ func TestGetFee(t *testing.T) {
|
||||
|
||||
func TestGetHistoricCandles(t *testing.T) {
|
||||
t.Parallel()
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
startTime := time.Date(2020, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
endTime := time.Date(2021, 2, 15, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
@@ -402,7 +402,7 @@ func TestGetHistoricCandles(t *testing.T) {
|
||||
|
||||
func TestGetHistoricCandlesExtended(t *testing.T) {
|
||||
t.Parallel()
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
startTime := time.Date(2020, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
endTime := time.Date(2021, 2, 15, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
@@ -426,7 +426,7 @@ func TestGetHistoricCandlesExtended(t *testing.T) {
|
||||
func TestGetMostRecentTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := bi.GetMostRecentTrades(t.Context(), RecentTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Limit: 15,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -451,7 +451,7 @@ func TestGetAggregateTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := bi.GetAggregateTrades(t.Context(),
|
||||
&AggregatedTradeRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Limit: 5,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -462,7 +462,7 @@ func TestGetAggregateTrades(t *testing.T) {
|
||||
func TestGetOrderBookDepth(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, er := bi.GetOrderBookDepth(t.Context(), &OrderBookDataRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Limit: 1000,
|
||||
})
|
||||
if er != nil {
|
||||
@@ -473,7 +473,7 @@ func TestGetOrderBookDepth(t *testing.T) {
|
||||
func TestGetCandlestickData(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, er := bi.GetSpotKline(t.Context(), &KlinesRequestParams{
|
||||
Symbol: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Symbol: currency.NewBTCUSDT(),
|
||||
Interval: kline.FiveMin.Short(),
|
||||
Limit: 24,
|
||||
StartTime: time.Unix(1577836800, 0),
|
||||
@@ -505,7 +505,7 @@ func TestGetSinglePriceData(t *testing.T) {
|
||||
|
||||
func TestGetAveragePrice(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := bi.GetAveragePrice(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := bi.GetAveragePrice(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error("Binance GetAveragePrice() error", err)
|
||||
}
|
||||
@@ -513,7 +513,7 @@ func TestGetAveragePrice(t *testing.T) {
|
||||
|
||||
func TestGetBestPrice(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := bi.GetBestPrice(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := bi.GetBestPrice(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error("Binanceus GetBestPrice() error", err)
|
||||
}
|
||||
@@ -521,7 +521,7 @@ func TestGetBestPrice(t *testing.T) {
|
||||
|
||||
func TestGetPriceChangeStats(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := bi.GetPriceChangeStats(t.Context(), currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := bi.GetPriceChangeStats(t.Context(), currency.NewBTCUSDT())
|
||||
if err != nil {
|
||||
t.Error("Binance GetPriceChangeStats() error", err)
|
||||
}
|
||||
@@ -1704,7 +1704,7 @@ func TestProcessUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
binanceusOrderBookLock.Lock()
|
||||
defer binanceusOrderBookLock.Unlock()
|
||||
p := currency.NewPair(currency.BTC, currency.USDT)
|
||||
p := currency.NewBTCUSDT()
|
||||
var depth WebsocketDepthStream
|
||||
err := json.Unmarshal(websocketDepthUpdate, &depth)
|
||||
if err != nil {
|
||||
@@ -1742,7 +1742,7 @@ func TestWebsocketOrderExecutionReport(t *testing.T) {
|
||||
AssetType: asset.Spot,
|
||||
Date: time.UnixMilli(1616627567900),
|
||||
LastUpdated: time.UnixMilli(1616627567900),
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
}
|
||||
for len(bi.Websocket.DataHandler) > 0 {
|
||||
<-bi.Websocket.DataHandler
|
||||
|
||||
@@ -39,7 +39,7 @@ const (
|
||||
|
||||
var (
|
||||
b *Bitfinex
|
||||
btcusdPair = currency.NewPair(currency.BTC, currency.USD)
|
||||
btcusdPair = currency.NewBTCUSD()
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -998,7 +998,7 @@ func TestModifyOrder(t *testing.T) {
|
||||
&order.Modify{
|
||||
OrderID: "1337",
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@@ -1179,7 +1179,7 @@ func TestWSSubscribe(t *testing.T) {
|
||||
b := new(Bitfinex) //nolint:govet // Intentional shadow of b to avoid future copy/paste mistakes
|
||||
require.NoError(t, testexch.Setup(b), "TestInstance must not error")
|
||||
testexch.SetupWs(t, b)
|
||||
err := b.Subscribe(subscription.List{{Channel: subscription.TickerChannel, Pairs: currency.Pairs{currency.NewPair(currency.BTC, currency.USD)}, Asset: asset.Spot}})
|
||||
err := b.Subscribe(subscription.List{{Channel: subscription.TickerChannel, Pairs: currency.Pairs{currency.NewBTCUSD()}, Asset: asset.Spot}})
|
||||
require.NoError(t, err, "Subrcribe should not error")
|
||||
catcher := func() (ok bool) {
|
||||
i := <-b.Websocket.ToRoutine
|
||||
@@ -1192,7 +1192,7 @@ func TestWSSubscribe(t *testing.T) {
|
||||
require.NoError(t, err, "GetSubscriptions should not error")
|
||||
require.Len(t, subs, 1, "We should only have 1 subscription; subID subscription should have been Removed by subscribeToChan")
|
||||
|
||||
err = b.Subscribe(subscription.List{{Channel: subscription.TickerChannel, Pairs: currency.Pairs{currency.NewPair(currency.BTC, currency.USD)}, Asset: asset.Spot}})
|
||||
err = b.Subscribe(subscription.List{{Channel: subscription.TickerChannel, Pairs: currency.Pairs{currency.NewBTCUSD()}, Asset: asset.Spot}})
|
||||
require.ErrorContains(t, err, "subscribe: dup (code: 10301)", "Duplicate subscription should error correctly")
|
||||
|
||||
assert.EventuallyWithT(t, func(t *assert.CollectT) {
|
||||
@@ -1218,7 +1218,7 @@ func TestWSSubscribe(t *testing.T) {
|
||||
|
||||
err = b.Subscribe(subscription.List{{
|
||||
Channel: subscription.TickerChannel,
|
||||
Pairs: currency.Pairs{currency.NewPair(currency.BTC, currency.USD)},
|
||||
Pairs: currency.Pairs{currency.NewBTCUSD()},
|
||||
Asset: asset.Spot,
|
||||
Params: map[string]any{"key": "tBTCUSD"},
|
||||
}})
|
||||
@@ -1230,7 +1230,7 @@ func TestSubToMap(t *testing.T) {
|
||||
s := &subscription.Subscription{
|
||||
Channel: subscription.CandlesChannel,
|
||||
Asset: asset.Spot,
|
||||
Pairs: currency.Pairs{currency.NewPair(currency.BTC, currency.USD)},
|
||||
Pairs: currency.Pairs{currency.NewBTCUSD()},
|
||||
Interval: kline.OneMin,
|
||||
}
|
||||
|
||||
|
||||
@@ -973,7 +973,7 @@ func TestGetOrderInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, b)
|
||||
|
||||
_, err := b.GetOrderInfo(t.Context(), "1234", currency.NewPair(currency.BTC, currency.USD), asset.Spot)
|
||||
_, err := b.GetOrderInfo(t.Context(), "1234", currency.NewBTCUSD(), asset.Spot)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -984,7 +984,7 @@ func TestCancelBatchOrders(t *testing.T) {
|
||||
{
|
||||
OrderID: "1234",
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -1009,7 +1009,7 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
IncludePredictedRate: true,
|
||||
})
|
||||
assert.ErrorIs(t, err, common.ErrFunctionNotSupported)
|
||||
@@ -1036,11 +1036,11 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
|
||||
func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
t.Parallel()
|
||||
isPerp, err := b.IsPerpetualFutureCurrency(asset.Futures, currency.NewPair(currency.BTC, currency.USD))
|
||||
isPerp, err := b.IsPerpetualFutureCurrency(asset.Futures, currency.NewBTCUSD())
|
||||
require.NoError(t, err)
|
||||
require.False(t, isPerp)
|
||||
|
||||
isPerp, err = b.IsPerpetualFutureCurrency(asset.PerpetualContract, currency.NewPair(currency.BTC, currency.USD))
|
||||
isPerp, err = b.IsPerpetualFutureCurrency(asset.PerpetualContract, currency.NewBTCUSD())
|
||||
require.NoError(t, err)
|
||||
require.True(t, isPerp)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ const (
|
||||
|
||||
var (
|
||||
b = &Bitstamp{}
|
||||
btcusdPair = currency.NewPair(currency.BTC, currency.USD)
|
||||
btcusdPair = currency.NewBTCUSD()
|
||||
)
|
||||
|
||||
func setFeeBuilder() *exchange.FeeBuilder {
|
||||
@@ -252,7 +252,7 @@ func TestUpdateOrderExecutionLimits(t *testing.T) {
|
||||
tests := map[asset.Item][]limitTest{
|
||||
asset.Spot: {
|
||||
{currency.NewPair(currency.ETH, currency.USDT), 0.01, 20},
|
||||
{currency.NewPair(currency.BTC, currency.USDT), 0.01, 20},
|
||||
{currency.NewBTCUSDT(), 0.01, 20},
|
||||
},
|
||||
}
|
||||
for assetItem, limitTests := range tests {
|
||||
|
||||
@@ -677,7 +677,7 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
IncludePredictedRate: true,
|
||||
})
|
||||
assert.ErrorIs(t, err, asset.ErrNotSupported, "GetLatestFundingRates should error on Margin")
|
||||
@@ -696,7 +696,7 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
|
||||
func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
t.Parallel()
|
||||
isPerp, err := b.IsPerpetualFutureCurrency(asset.CoinMarginedFutures, currency.NewPair(currency.BTC, currency.USD))
|
||||
isPerp, err := b.IsPerpetualFutureCurrency(asset.CoinMarginedFutures, currency.NewBTCUSD())
|
||||
assert.NoError(t, err, "IsPerpetualFutureCurrency should not error")
|
||||
assert.False(t, isPerp, "IsPerpetualFutureCurrency should return true for a Margin pair")
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ func TestGetOrderHistoryWrapper(t *testing.T) {
|
||||
getOrdersRequest := order.MultiOrderRequest{
|
||||
Type: order.AnyType,
|
||||
AssetType: asset.Spot,
|
||||
Pairs: []currency.Pair{currency.NewPair(currency.BTC, currency.USD)},
|
||||
Pairs: []currency.Pair{currency.NewBTCUSD()},
|
||||
Side: order.AnySide,
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, c, canManipulateRealOrders)
|
||||
|
||||
currencyPair := currency.NewPair(currency.BTC, currency.USD)
|
||||
currencyPair := currency.NewBTCUSD()
|
||||
orderCancellation := &order.Cancel{
|
||||
OrderID: "1",
|
||||
AccountID: "1",
|
||||
@@ -1139,7 +1139,7 @@ func TestCancelBatchOrders(t *testing.T) {
|
||||
{
|
||||
OrderID: "1234",
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestCanTradePair(t *testing.T) {
|
||||
t.Fatalf("received: %v, but expected: %v", err, errEmptyCurrency)
|
||||
}
|
||||
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
err = (&States{}).CanTradePair(cp, asset.Empty)
|
||||
if !errors.Is(err, asset.ErrNotSupported) {
|
||||
t.Fatalf("received: %v, but expected: %v", err, asset.ErrNotSupported)
|
||||
|
||||
@@ -3836,7 +3836,7 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := d.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
IncludePredictedRate: true,
|
||||
})
|
||||
require.ErrorIs(t, err, asset.ErrNotSupported)
|
||||
|
||||
@@ -923,7 +923,7 @@ func TestSetPairs(t *testing.T) {
|
||||
}
|
||||
|
||||
pairs := currency.Pairs{
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
}
|
||||
err := b.SetPairs(pairs, asset.Spot, true)
|
||||
if err != nil {
|
||||
@@ -1078,7 +1078,7 @@ func TestUpdatePairs(t *testing.T) {
|
||||
|
||||
pairs := currency.Pairs{
|
||||
currency.NewPair(currency.XRP, currency.USD),
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
currency.NewPair(currency.LTC, currency.USD),
|
||||
currency.NewPair(currency.LTC, currency.USDT),
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ func TestUpdatePairs(t *testing.T) {
|
||||
if uacEnabledPairs.Contains(currency.NewPair(currency.XRP, currency.USD), true) {
|
||||
t.Fatal("expected currency pair not found")
|
||||
}
|
||||
if uacEnabledPairs.Contains(currency.NewPair(currency.BTC, currency.USD), true) {
|
||||
if uacEnabledPairs.Contains(currency.NewBTCUSD(), true) {
|
||||
t.Fatal("expected currency pair not found")
|
||||
}
|
||||
if uacEnabledPairs.Contains(currency.NewPair(currency.LTC, currency.USD), true) {
|
||||
@@ -1308,7 +1308,7 @@ func TestPrintEnabledPairs(t *testing.T) {
|
||||
b.CurrencyPairs.Pairs = make(map[asset.Item]*currency.PairStore)
|
||||
b.CurrencyPairs.Pairs[asset.Spot] = ¤cy.PairStore{
|
||||
Enabled: currency.Pairs{
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1332,7 +1332,7 @@ func TestGetBase(t *testing.T) {
|
||||
|
||||
func TestGetAssetType(t *testing.T) {
|
||||
var b Base
|
||||
p := currency.NewPair(currency.BTC, currency.USD)
|
||||
p := currency.NewBTCUSD()
|
||||
if _, err := b.GetPairAssetType(p); err == nil {
|
||||
t.Fatal("error cannot be nil")
|
||||
}
|
||||
@@ -1340,10 +1340,10 @@ func TestGetAssetType(t *testing.T) {
|
||||
b.CurrencyPairs.Pairs[asset.Spot] = ¤cy.PairStore{
|
||||
AssetEnabled: true,
|
||||
Enabled: currency.Pairs{
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
},
|
||||
Available: currency.Pairs{
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
},
|
||||
ConfigFormat: ¤cy.PairFormat{Delimiter: "-"},
|
||||
}
|
||||
@@ -1378,10 +1378,10 @@ func TestGetFormattedPairAndAssetType(t *testing.T) {
|
||||
b.CurrencyPairs.Pairs[asset.Spot] = ¤cy.PairStore{
|
||||
AssetEnabled: true,
|
||||
Enabled: currency.Pairs{
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
},
|
||||
Available: currency.Pairs{
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
},
|
||||
}
|
||||
p, a, err := b.GetRequestFormattedPairAndAssetType("btc#usd")
|
||||
@@ -2099,7 +2099,7 @@ func TestGetFundingRates(t *testing.T) {
|
||||
func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
t.Parallel()
|
||||
var b Base
|
||||
if _, err := b.IsPerpetualFutureCurrency(asset.Spot, currency.NewPair(currency.BTC, currency.USD)); !errors.Is(err, common.ErrNotYetImplemented) {
|
||||
if _, err := b.IsPerpetualFutureCurrency(asset.Spot, currency.NewBTCUSD()); !errors.Is(err, common.ErrNotYetImplemented) {
|
||||
t.Errorf("received: %v, expected: %v", err, common.ErrNotYetImplemented)
|
||||
}
|
||||
}
|
||||
@@ -2248,7 +2248,7 @@ func TestGetKlineRequest(t *testing.T) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, currency.ErrCurrencyPairEmpty)
|
||||
}
|
||||
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
_, err = b.GetKlineRequest(pair, asset.Empty, 0, time.Time{}, time.Time{}, false)
|
||||
if !errors.Is(err, asset.ErrNotSupported) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, asset.ErrNotSupported)
|
||||
@@ -2412,7 +2412,7 @@ func TestGetKlineExtendedRequest(t *testing.T) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, currency.ErrCurrencyPairEmpty)
|
||||
}
|
||||
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
_, err = b.GetKlineExtendedRequest(pair, asset.Empty, 0, time.Time{}, time.Time{})
|
||||
if !errors.Is(err, asset.ErrNotSupported) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, asset.ErrNotSupported)
|
||||
@@ -2571,7 +2571,7 @@ func TestEnsureOnePairEnabled(t *testing.T) {
|
||||
asset.Spot: {
|
||||
AssetEnabled: true,
|
||||
Available: []currency.Pair{
|
||||
currency.NewPair(currency.BTC, currency.USDT),
|
||||
currency.NewBTCUSDT(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -2640,7 +2640,7 @@ func TestGetStandardConfig(t *testing.T) {
|
||||
func TestMatchSymbolWithAvailablePairs(t *testing.T) {
|
||||
t.Parallel()
|
||||
b := Base{Name: "test"}
|
||||
whatIWant := currency.NewPair(currency.BTC, currency.USDT)
|
||||
whatIWant := currency.NewBTCUSDT()
|
||||
err := b.CurrencyPairs.Store(asset.Spot, ¤cy.PairStore{
|
||||
AssetEnabled: true,
|
||||
Available: []currency.Pair{whatIWant},
|
||||
@@ -2676,7 +2676,7 @@ func TestMatchSymbolWithAvailablePairs(t *testing.T) {
|
||||
func TestMatchSymbolCheckEnabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
b := Base{Name: "test"}
|
||||
whatIWant := currency.NewPair(currency.BTC, currency.USDT)
|
||||
whatIWant := currency.NewBTCUSDT()
|
||||
availButNoEnabled := currency.NewPair(currency.BTC, currency.AUD)
|
||||
err := b.CurrencyPairs.Store(asset.Spot, ¤cy.PairStore{
|
||||
AssetEnabled: true,
|
||||
@@ -2735,7 +2735,7 @@ func TestMatchSymbolCheckEnabled(t *testing.T) {
|
||||
func TestIsPairEnabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
b := Base{Name: "test"}
|
||||
whatIWant := currency.NewPair(currency.BTC, currency.USDT)
|
||||
whatIWant := currency.NewBTCUSDT()
|
||||
availButNoEnabled := currency.NewPair(currency.BTC, currency.AUD)
|
||||
err := b.CurrencyPairs.Store(asset.Spot, ¤cy.PairStore{
|
||||
AssetEnabled: true,
|
||||
@@ -2906,7 +2906,7 @@ func TestCanUseAuthenticatedWebsocketEndpoints(t *testing.T) {
|
||||
func TestGetCachedTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
b := Base{Name: "test"}
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
_, err := b.GetCachedTicker(pair, asset.Spot)
|
||||
assert.ErrorIs(t, err, ticker.ErrTickerNotFound)
|
||||
|
||||
@@ -2921,7 +2921,7 @@ func TestGetCachedTicker(t *testing.T) {
|
||||
func TestGetCachedOrderbook(t *testing.T) {
|
||||
t.Parallel()
|
||||
b := Base{Name: "test"}
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
_, err := b.GetCachedOrderbook(pair, asset.Spot)
|
||||
assert.ErrorIs(t, err, orderbook.ErrOrderbookNotFound)
|
||||
|
||||
@@ -3116,7 +3116,7 @@ func (f *FakeBase) GetFuturesContractDetails(context.Context, asset.Item) ([]fut
|
||||
func TestGetCurrencyTradeURL(t *testing.T) {
|
||||
t.Parallel()
|
||||
b := Base{}
|
||||
_, err := b.GetCurrencyTradeURL(t.Context(), asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
_, err := b.GetCurrencyTradeURL(t.Context(), asset.Spot, currency.NewBTCUSDT())
|
||||
require.ErrorIs(t, err, common.ErrFunctionNotSupported)
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ func TestGetOrderHistory(t *testing.T) {
|
||||
AssetType: asset.Spot,
|
||||
Side: order.AnySide,
|
||||
}
|
||||
currPair := currency.NewPair(currency.BTC, currency.USD)
|
||||
currPair := currency.NewBTCUSD()
|
||||
currPair.Delimiter = "_"
|
||||
getOrdersRequest.Pairs = []currency.Pair{currPair}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ func TestSetupMultiPositionTracker(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
setup.Pair = currency.NewPair(currency.BTC, currency.USDT)
|
||||
setup.Pair = currency.NewBTCUSDT()
|
||||
_, err = SetupMultiPositionTracker(setup)
|
||||
if !errors.Is(err, errEmptyUnderlying) {
|
||||
t.Error(err)
|
||||
@@ -277,7 +277,7 @@ func TestMultiPositionTrackerTrackNewOrder(t *testing.T) {
|
||||
t.Parallel()
|
||||
exch := testExchange
|
||||
item := asset.Futures
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
setup := &MultiPositionTrackerSetup{
|
||||
Asset: item,
|
||||
Pair: pair,
|
||||
@@ -460,7 +460,7 @@ func TestPositionControllerTestTrackNewOrder(t *testing.T) {
|
||||
err = pc.TrackNewOrder(&order.Detail{
|
||||
Date: time.Now(),
|
||||
Exchange: "hi",
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
AssetType: asset.Spot,
|
||||
Side: order.Long,
|
||||
OrderID: "lol",
|
||||
@@ -471,7 +471,7 @@ func TestPositionControllerTestTrackNewOrder(t *testing.T) {
|
||||
|
||||
err = pc.TrackNewOrder(&order.Detail{
|
||||
Date: time.Now(),
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
AssetType: asset.Futures,
|
||||
Side: order.Long,
|
||||
OrderID: "lol",
|
||||
@@ -483,7 +483,7 @@ func TestPositionControllerTestTrackNewOrder(t *testing.T) {
|
||||
err = pc.TrackNewOrder(&order.Detail{
|
||||
Exchange: testExchange,
|
||||
Date: time.Now(),
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
AssetType: asset.Futures,
|
||||
Side: order.Long,
|
||||
OrderID: "lol",
|
||||
@@ -588,7 +588,7 @@ func TestGetPositions(t *testing.T) {
|
||||
func TestGetPositionsForExchange(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &PositionController{}
|
||||
p := currency.NewPair(currency.BTC, currency.USDT)
|
||||
p := currency.NewBTCUSDT()
|
||||
|
||||
_, err := c.GetPositionsForExchange("", asset.Futures, p)
|
||||
if !errors.Is(err, errExchangeNameEmpty) {
|
||||
@@ -677,7 +677,7 @@ func TestGetPositionsForExchange(t *testing.T) {
|
||||
func TestClearPositionsForExchange(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := &PositionController{}
|
||||
p := currency.NewPair(currency.BTC, currency.USDT)
|
||||
p := currency.NewBTCUSDT()
|
||||
err := c.ClearPositionsForExchange("", asset.Futures, p)
|
||||
if !errors.Is(err, errExchangeNameEmpty) {
|
||||
t.Errorf("received '%v' expected '%v", err, errExchangeNameEmpty)
|
||||
@@ -805,7 +805,7 @@ func TestSetupPositionTracker(t *testing.T) {
|
||||
t.Error("expected nil")
|
||||
}
|
||||
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
p, err = SetupPositionTracker(&PositionTrackerSetup{
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Futures,
|
||||
@@ -893,17 +893,17 @@ func TestUpdateOpenPositionUnrealisedPNL(t *testing.T) {
|
||||
t.Parallel()
|
||||
pc := SetupPositionController()
|
||||
|
||||
_, err := pc.UpdateOpenPositionUnrealisedPNL("", asset.Futures, currency.NewPair(currency.BTC, currency.USDT), 2, time.Now())
|
||||
_, err := pc.UpdateOpenPositionUnrealisedPNL("", asset.Futures, currency.NewBTCUSDT(), 2, time.Now())
|
||||
if !errors.Is(err, errExchangeNameEmpty) {
|
||||
t.Errorf("received '%v' expected '%v", err, errExchangeNameEmpty)
|
||||
}
|
||||
|
||||
_, err = pc.UpdateOpenPositionUnrealisedPNL("hi", asset.Futures, currency.NewPair(currency.BTC, currency.USDT), 2, time.Now())
|
||||
_, err = pc.UpdateOpenPositionUnrealisedPNL("hi", asset.Futures, currency.NewBTCUSDT(), 2, time.Now())
|
||||
if !errors.Is(err, ErrPositionNotFound) {
|
||||
t.Errorf("received '%v' expected '%v", err, ErrPositionNotFound)
|
||||
}
|
||||
|
||||
_, err = pc.UpdateOpenPositionUnrealisedPNL("hi", asset.Spot, currency.NewPair(currency.BTC, currency.USDT), 2, time.Now())
|
||||
_, err = pc.UpdateOpenPositionUnrealisedPNL("hi", asset.Spot, currency.NewBTCUSDT(), 2, time.Now())
|
||||
if !errors.Is(err, ErrNotFuturesAsset) {
|
||||
t.Errorf("received '%v' expected '%v", err, ErrNotFuturesAsset)
|
||||
}
|
||||
@@ -911,7 +911,7 @@ func TestUpdateOpenPositionUnrealisedPNL(t *testing.T) {
|
||||
err = pc.TrackNewOrder(&order.Detail{
|
||||
Date: time.Now(),
|
||||
Exchange: "hi",
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
AssetType: asset.Futures,
|
||||
Side: order.Long,
|
||||
OrderID: "lol",
|
||||
@@ -922,12 +922,12 @@ func TestUpdateOpenPositionUnrealisedPNL(t *testing.T) {
|
||||
t.Errorf("received '%v' expected '%v", err, nil)
|
||||
}
|
||||
|
||||
_, err = pc.UpdateOpenPositionUnrealisedPNL("hi2", asset.Futures, currency.NewPair(currency.BTC, currency.USDT), 2, time.Now())
|
||||
_, err = pc.UpdateOpenPositionUnrealisedPNL("hi2", asset.Futures, currency.NewBTCUSDT(), 2, time.Now())
|
||||
if !errors.Is(err, ErrPositionNotFound) {
|
||||
t.Errorf("received '%v' expected '%v", err, ErrPositionNotFound)
|
||||
}
|
||||
|
||||
_, err = pc.UpdateOpenPositionUnrealisedPNL("hi", asset.PerpetualSwap, currency.NewPair(currency.BTC, currency.USDT), 2, time.Now())
|
||||
_, err = pc.UpdateOpenPositionUnrealisedPNL("hi", asset.PerpetualSwap, currency.NewBTCUSDT(), 2, time.Now())
|
||||
if !errors.Is(err, ErrPositionNotFound) {
|
||||
t.Errorf("received '%v' expected '%v", err, ErrPositionNotFound)
|
||||
}
|
||||
@@ -937,7 +937,7 @@ func TestUpdateOpenPositionUnrealisedPNL(t *testing.T) {
|
||||
t.Errorf("received '%v' expected '%v", err, ErrPositionNotFound)
|
||||
}
|
||||
|
||||
pnl, err := pc.UpdateOpenPositionUnrealisedPNL("hi", asset.Futures, currency.NewPair(currency.BTC, currency.USDT), 2, time.Now())
|
||||
pnl, err := pc.UpdateOpenPositionUnrealisedPNL("hi", asset.Futures, currency.NewBTCUSDT(), 2, time.Now())
|
||||
if !errors.Is(err, nil) {
|
||||
t.Errorf("received '%v' expected '%v", err, nil)
|
||||
}
|
||||
@@ -946,7 +946,7 @@ func TestUpdateOpenPositionUnrealisedPNL(t *testing.T) {
|
||||
}
|
||||
|
||||
var nilPC *PositionController
|
||||
_, err = nilPC.UpdateOpenPositionUnrealisedPNL("hi", asset.Futures, currency.NewPair(currency.BTC, currency.USDT), 2, time.Now())
|
||||
_, err = nilPC.UpdateOpenPositionUnrealisedPNL("hi", asset.Futures, currency.NewBTCUSDT(), 2, time.Now())
|
||||
if !errors.Is(err, common.ErrNilPointer) {
|
||||
t.Errorf("received '%v' expected '%v", err, common.ErrNilPointer)
|
||||
}
|
||||
@@ -964,7 +964,7 @@ func TestSetCollateralCurrency(t *testing.T) {
|
||||
if !errors.Is(err, ErrNotFuturesAsset) {
|
||||
t.Errorf("received '%v' expected '%v", err, ErrNotFuturesAsset)
|
||||
}
|
||||
p := currency.NewPair(currency.BTC, currency.USDT)
|
||||
p := currency.NewBTCUSDT()
|
||||
pc.multiPositionTrackers = make(map[key.ExchangePairAsset]*MultiPositionTracker)
|
||||
err = pc.SetCollateralCurrency("hi", asset.Futures, p, currency.DOGE)
|
||||
if !errors.Is(err, ErrPositionNotFound) {
|
||||
@@ -1025,7 +1025,7 @@ func TestSetCollateralCurrency(t *testing.T) {
|
||||
|
||||
func TestMPTUpdateOpenPositionUnrealisedPNL(t *testing.T) {
|
||||
t.Parallel()
|
||||
p := currency.NewPair(currency.BTC, currency.USDT)
|
||||
p := currency.NewBTCUSDT()
|
||||
pc := SetupPositionController()
|
||||
err := pc.TrackNewOrder(&order.Detail{
|
||||
Date: time.Now(),
|
||||
@@ -1578,7 +1578,7 @@ func TestCheckTrackerPrerequisitesLowerExchange(t *testing.T) {
|
||||
if !errors.Is(err, order.ErrPairIsEmpty) {
|
||||
t.Errorf("received '%v' expected '%v", err, order.ErrPairIsEmpty)
|
||||
}
|
||||
lowerExch, err := checkTrackerPrerequisitesLowerExchange(upperExch, asset.Futures, currency.NewPair(currency.BTC, currency.USDT))
|
||||
lowerExch, err := checkTrackerPrerequisitesLowerExchange(upperExch, asset.Futures, currency.NewBTCUSDT())
|
||||
if !errors.Is(err, nil) {
|
||||
t.Errorf("received '%v' expected '%v", err, nil)
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ func TestRepayALoan(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, g)
|
||||
if _, err := g.RepayALoan(t.Context(), "1234", &RepayLoanRequestParam{
|
||||
CurrencyPair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
CurrencyPair: currency.NewBTCUSDT(),
|
||||
Currency: currency.BTC,
|
||||
Mode: "all",
|
||||
}); err != nil {
|
||||
@@ -558,7 +558,7 @@ func TestModifyALoanRecord(t *testing.T) {
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, g)
|
||||
if _, err := g.ModifyALoanRecord(t.Context(), "1234", &ModifyLoanRequestParam{
|
||||
Currency: currency.USDT,
|
||||
CurrencyPair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
CurrencyPair: currency.NewBTCUSDT(),
|
||||
Side: "lend",
|
||||
AutoRenew: true,
|
||||
LoanID: "1234",
|
||||
@@ -1196,7 +1196,7 @@ func TestPlaceFuturesOrder(t *testing.T) {
|
||||
func TestGetFuturesOrders(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, g)
|
||||
_, err := g.GetFuturesOrders(t.Context(), currency.NewPair(currency.BTC, currency.USD), statusOpen, "", currency.BTC, 0, 0, 1)
|
||||
_, err := g.GetFuturesOrders(t.Context(), currency.NewBTCUSD(), statusOpen, "", currency.BTC, 0, 0, 1)
|
||||
assert.NoError(t, err, "GetFuturesOrders should not error")
|
||||
}
|
||||
|
||||
@@ -1947,7 +1947,7 @@ func TestGetUnderlyingFromCurrencyPair(t *testing.T) {
|
||||
t.Parallel()
|
||||
if uly, err := g.GetUnderlyingFromCurrencyPair(currency.Pair{Delimiter: currency.UnderscoreDelimiter, Base: currency.BTC, Quote: currency.NewCode("USDT_LLK")}); err != nil {
|
||||
t.Error(err)
|
||||
} else if !uly.Equal(currency.NewPair(currency.BTC, currency.USDT)) {
|
||||
} else if !uly.Equal(currency.NewBTCUSDT()) {
|
||||
t.Error("unexpected underlying")
|
||||
}
|
||||
}
|
||||
@@ -2615,14 +2615,14 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := g.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
IncludePredictedRate: true,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, err = g.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
Asset: asset.CoinMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -2947,7 +2947,7 @@ func TestDeriveSpotWebsocketOrderResponse(t *testing.T) {
|
||||
Exchange: g.Name,
|
||||
OrderID: "766075454481",
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT).Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Pair: currency.NewBTCUSDT().Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
ClientOrderID: "t-1735720637181634009",
|
||||
Date: time.UnixMilli(1735720637188),
|
||||
LastUpdated: time.UnixMilli(1735720637188),
|
||||
@@ -2990,7 +2990,7 @@ func TestDeriveSpotWebsocketOrderResponses(t *testing.T) {
|
||||
Exchange: g.Name,
|
||||
OrderID: "766075454481",
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT).Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Pair: currency.NewBTCUSDT().Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
ClientOrderID: "t-1735720637181634009",
|
||||
Date: time.UnixMilli(1735720637188),
|
||||
LastUpdated: time.UnixMilli(1735720637188),
|
||||
@@ -3043,7 +3043,7 @@ func TestDeriveSpotWebsocketOrderResponses(t *testing.T) {
|
||||
Exchange: g.Name,
|
||||
OrderID: "766504537761",
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT).Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Pair: currency.NewBTCUSDT().Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
ClientOrderID: "t-1735780321603944400",
|
||||
Date: time.UnixMilli(1735780321729),
|
||||
LastUpdated: time.UnixMilli(1735780321729),
|
||||
@@ -3181,7 +3181,7 @@ func TestDeriveFuturesWebsocketOrderResponses(t *testing.T) {
|
||||
Exchange: g.Name,
|
||||
OrderID: "596746193678",
|
||||
AssetType: asset.Futures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT).Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Pair: currency.NewBTCUSDT().Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Date: time.UnixMilli(1735789790476),
|
||||
LastUpdated: time.UnixMilli(1735789790476),
|
||||
RemainingAmount: 1,
|
||||
@@ -3195,7 +3195,7 @@ func TestDeriveFuturesWebsocketOrderResponses(t *testing.T) {
|
||||
Exchange: g.Name,
|
||||
OrderID: "596748780649",
|
||||
AssetType: asset.Futures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT).Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Pair: currency.NewBTCUSDT().Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Date: time.UnixMilli(1735790222185),
|
||||
LastUpdated: time.UnixMilli(1735790222185),
|
||||
RemainingAmount: 1,
|
||||
@@ -3209,7 +3209,7 @@ func TestDeriveFuturesWebsocketOrderResponses(t *testing.T) {
|
||||
Exchange: g.Name,
|
||||
OrderID: "36028797827161124",
|
||||
AssetType: asset.Futures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT).Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Pair: currency.NewBTCUSDT().Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Date: time.UnixMilli(1740108860761),
|
||||
LastUpdated: time.UnixMilli(1740108860761),
|
||||
Amount: 1,
|
||||
@@ -3223,7 +3223,7 @@ func TestDeriveFuturesWebsocketOrderResponses(t *testing.T) {
|
||||
Exchange: g.Name,
|
||||
OrderID: "36028797827225781",
|
||||
AssetType: asset.Futures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT).Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Pair: currency.NewBTCUSDT().Format(currency.PairFormat{Uppercase: true, Delimiter: "_"}),
|
||||
Date: time.UnixMilli(1740109172060),
|
||||
LastUpdated: time.UnixMilli(1740109172060),
|
||||
Amount: 1,
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestFetchTradablePairs(t *testing.T) {
|
||||
if !pairs.Contains(currency.NewPair(currency.STORJ, currency.USD), false) {
|
||||
t.Error("expected pair STORJ-USD")
|
||||
}
|
||||
if !pairs.Contains(currency.NewPair(currency.BTC, currency.USD), false) {
|
||||
if !pairs.Contains(currency.NewBTCUSD(), false) {
|
||||
t.Error("expected pair BTC-USD")
|
||||
}
|
||||
if !pairs.Contains(currency.NewPair(currency.AAVE, currency.USD), false) {
|
||||
@@ -430,7 +430,7 @@ func TestCancelExchangeOrder(t *testing.T) {
|
||||
orderCancellation := &order.Cancel{
|
||||
OrderID: "266029865",
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
}
|
||||
|
||||
err := g.CancelOrder(t.Context(), orderCancellation)
|
||||
|
||||
@@ -1055,7 +1055,7 @@ func TestGetOrderInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, h)
|
||||
|
||||
_, err := h.GetOrderInfo(t.Context(), "1234", currency.NewPair(currency.BTC, currency.USD), asset.Spot)
|
||||
_, err := h.GetOrderInfo(t.Context(), "1234", currency.NewBTCUSD(), asset.Spot)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ func TestGetOrderHistory(t *testing.T) {
|
||||
updatePairsOnce(t, h)
|
||||
getOrdersRequest := order.MultiOrderRequest{
|
||||
Type: order.AnyType,
|
||||
Pairs: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)},
|
||||
Pairs: []currency.Pair{currency.NewBTCUSDT()},
|
||||
AssetType: asset.Spot,
|
||||
Side: order.AnySide,
|
||||
}
|
||||
@@ -1156,7 +1156,7 @@ func TestGetActiveOrders(t *testing.T) {
|
||||
getOrdersRequest := order.MultiOrderRequest{
|
||||
AssetType: asset.Spot,
|
||||
Type: order.AnyType,
|
||||
Pairs: []currency.Pair{currency.NewPair(currency.BTC, currency.USDT)},
|
||||
Pairs: []currency.Pair{currency.NewBTCUSDT()},
|
||||
Side: order.AnySide,
|
||||
}
|
||||
|
||||
@@ -1680,7 +1680,7 @@ func TestFormatFuturesPair(t *testing.T) {
|
||||
assert.Len(t, r, 9, "Should be an 9 character string")
|
||||
assert.Equal(t, "BTC2", r[0:4], "Should start with btc and a date this millennium")
|
||||
|
||||
r, err = h.formatFuturesPair(currency.NewPair(currency.BTC, currency.USDT), false)
|
||||
r, err = h.formatFuturesPair(currency.NewBTCUSDT(), false)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "BTC-USDT", r)
|
||||
}
|
||||
@@ -1706,7 +1706,7 @@ func TestCancelBatchOrders(t *testing.T) {
|
||||
{
|
||||
OrderID: "1234",
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -1740,19 +1740,19 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
|
||||
_, err := h.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
IncludePredictedRate: true,
|
||||
})
|
||||
require.ErrorIs(t, err, asset.ErrNotSupported)
|
||||
|
||||
_, err = h.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
Asset: asset.CoinMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
IncludePredictedRate: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
err = h.CurrencyPairs.EnablePair(asset.CoinMarginedFutures, currency.NewPair(currency.BTC, currency.USD))
|
||||
err = h.CurrencyPairs.EnablePair(asset.CoinMarginedFutures, currency.NewBTCUSD())
|
||||
require.ErrorIs(t, err, currency.ErrPairAlreadyEnabled)
|
||||
|
||||
_, err = h.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
@@ -1764,11 +1764,11 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
|
||||
func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
t.Parallel()
|
||||
is, err := h.IsPerpetualFutureCurrency(asset.Binary, currency.NewPair(currency.BTC, currency.USDT))
|
||||
is, err := h.IsPerpetualFutureCurrency(asset.Binary, currency.NewBTCUSDT())
|
||||
require.NoError(t, err)
|
||||
assert.False(t, is)
|
||||
|
||||
is, err = h.IsPerpetualFutureCurrency(asset.CoinMarginedFutures, currency.NewPair(currency.BTC, currency.USDT))
|
||||
is, err = h.IsPerpetualFutureCurrency(asset.CoinMarginedFutures, currency.NewBTCUSDT())
|
||||
require.NoError(t, err)
|
||||
assert.True(t, is)
|
||||
}
|
||||
@@ -1896,7 +1896,7 @@ func TestContractOpenInterestUSDT(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, resp)
|
||||
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
resp, err = h.ContractOpenInterestUSDT(t.Context(), cp, currency.EMPTYPAIR, "", "")
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, resp)
|
||||
|
||||
@@ -90,7 +90,7 @@ func TestValidateData(t *testing.T) {
|
||||
func TestCreateKline(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pair := currency.NewPair(currency.BTC, currency.USD)
|
||||
pair := currency.NewBTCUSD()
|
||||
_, err := CreateKline(nil, OneMin, pair, asset.Spot, "Binance")
|
||||
if !errors.Is(err, errInsufficientTradeData) {
|
||||
t.Fatalf("received: '%v' but expected '%v'", err, errInsufficientTradeData)
|
||||
@@ -459,7 +459,7 @@ func TestItem_SortCandlesByTimestamp(t *testing.T) {
|
||||
t.Parallel()
|
||||
tempKline := Item{
|
||||
Exchange: "testExchange",
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
Asset: asset.Spot,
|
||||
Interval: OneDay,
|
||||
}
|
||||
@@ -699,7 +699,7 @@ func genOHCLVData() (out candle.Item, outItem Item, err error) {
|
||||
|
||||
outItem.Interval = OneDay
|
||||
outItem.Asset = asset.Spot
|
||||
outItem.Pair = currency.NewPair(currency.BTC, currency.USDT)
|
||||
outItem.Pair = currency.NewBTCUSDT()
|
||||
outItem.Exchange = testExchanges[0].Name
|
||||
|
||||
for x := range 365 {
|
||||
@@ -913,7 +913,7 @@ func TestConvertToNewInterval(t *testing.T) {
|
||||
|
||||
old := &Item{
|
||||
Exchange: "lol",
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
Asset: asset.Spot,
|
||||
Interval: OneDay,
|
||||
Candles: []Candle{
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestCreateKlineRequest(t *testing.T) {
|
||||
t.Fatalf("received: '%v', but expected '%v'", err, currency.ErrCurrencyPairEmpty)
|
||||
}
|
||||
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
_, err = CreateKlineRequest("name", pair, currency.EMPTYPAIR, 0, 0, 0, time.Time{}, time.Time{}, 0)
|
||||
if !errors.Is(err, currency.ErrCurrencyPairEmpty) {
|
||||
t.Fatalf("received: '%v', but expected '%v'", err, currency.ErrCurrencyPairEmpty)
|
||||
@@ -118,7 +118,7 @@ func TestGetRanges(t *testing.T) {
|
||||
|
||||
start := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
|
||||
var r *Request
|
||||
_, err := r.GetRanges(100)
|
||||
@@ -198,7 +198,7 @@ func TestRequest_ProcessResponse(t *testing.T) {
|
||||
|
||||
start := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
end := start.AddDate(0, 0, 1)
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
|
||||
var r *Request
|
||||
_, err := r.ProcessResponse(nil)
|
||||
@@ -333,7 +333,7 @@ func TestExtendedRequest_ProcessResponse(t *testing.T) {
|
||||
ohc := getOneHour()
|
||||
start := ohc[0].Time
|
||||
end := ohc[len(ohc)-1].Time.Add(OneHour.Duration())
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
|
||||
var rExt *ExtendedRequest
|
||||
_, err := rExt.ProcessResponse(nil)
|
||||
|
||||
@@ -1526,7 +1526,7 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := k.GetLatestFundingRates(t.Context(), &fundingrate.LatestRateRequest{
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
IncludePredictedRate: true,
|
||||
})
|
||||
assert.ErrorIs(t, err, asset.ErrNotSupported, "GetLatestFundingRates should error")
|
||||
@@ -1548,11 +1548,11 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
|
||||
func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
t.Parallel()
|
||||
is, err := k.IsPerpetualFutureCurrency(asset.Binary, currency.NewPair(currency.BTC, currency.USDT))
|
||||
is, err := k.IsPerpetualFutureCurrency(asset.Binary, currency.NewBTCUSDT())
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, is, "IsPerpetualFutureCurrency should return false for a binary asset")
|
||||
|
||||
is, err = k.IsPerpetualFutureCurrency(asset.Futures, currency.NewPair(currency.BTC, currency.USDT))
|
||||
is, err = k.IsPerpetualFutureCurrency(asset.Futures, currency.NewBTCUSDT())
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, is, "IsPerpetualFutureCurrency should return false for a non-perpetual future")
|
||||
|
||||
|
||||
@@ -3110,7 +3110,7 @@ func TestGetLatestFundingRates(t *testing.T) {
|
||||
|
||||
req := &fundingrate.LatestRateRequest{
|
||||
Asset: asset.Futures,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
}
|
||||
_, err = ku.GetLatestFundingRates(t.Context(), req)
|
||||
require.ErrorIs(t, err, futures.ErrNotPerpetualFuture)
|
||||
|
||||
@@ -3326,7 +3326,7 @@ func TestUpdateOrderExecutionLimits(t *testing.T) {
|
||||
tests := map[asset.Item][]currency.Pair{
|
||||
asset.Spot: {
|
||||
currency.NewPair(currency.ETH, currency.USDT),
|
||||
currency.NewPair(currency.BTC, currency.USDT),
|
||||
currency.NewBTCUSDT(),
|
||||
},
|
||||
asset.Margin: {
|
||||
currency.NewPair(currency.ETH, currency.USDT),
|
||||
@@ -3360,7 +3360,7 @@ func TestUpdateOrderExecutionLimits(t *testing.T) {
|
||||
|
||||
func TestUpdateTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
result, err := ok.UpdateTicker(contextGenerate(), currency.NewPair(currency.BTC, currency.USDT), asset.Spot)
|
||||
result, err := ok.UpdateTicker(contextGenerate(), currency.NewBTCUSDT(), asset.Spot)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, result)
|
||||
}
|
||||
@@ -3410,10 +3410,10 @@ func TestGetWithdrawalsHistory(t *testing.T) {
|
||||
|
||||
func TestGetRecentTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
result, err := ok.GetRecentTrades(contextGenerate(), currency.NewPair(currency.BTC, currency.USDT), asset.PerpetualSwap)
|
||||
result, err := ok.GetRecentTrades(contextGenerate(), currency.NewBTCUSDT(), asset.PerpetualSwap)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, result)
|
||||
result, err = ok.GetRecentTrades(contextGenerate(), currency.NewPair(currency.BTC, currency.USDT), asset.Spread)
|
||||
result, err = ok.GetRecentTrades(contextGenerate(), currency.NewBTCUSDT(), asset.Spread)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, result)
|
||||
}
|
||||
@@ -3889,7 +3889,7 @@ func TestValidateAPICredentials(t *testing.T) {
|
||||
|
||||
func TestGetHistoricCandles(t *testing.T) {
|
||||
t.Parallel()
|
||||
pair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
pair := currency.NewBTCUSDT()
|
||||
startTime := time.Date(2021, 2, 1, 0, 0, 0, 0, time.UTC)
|
||||
endTime := startTime.AddDate(0, 0, 100)
|
||||
_, err := ok.GetHistoricCandles(contextGenerate(), pair, asset.Spot, kline.Interval(time.Hour*4), startTime, endTime)
|
||||
@@ -3902,7 +3902,7 @@ func TestGetHistoricCandles(t *testing.T) {
|
||||
|
||||
func TestGetHistoricCandlesExtended(t *testing.T) {
|
||||
t.Parallel()
|
||||
currencyPair := currency.NewPair(currency.BTC, currency.USDT)
|
||||
currencyPair := currency.NewBTCUSDT()
|
||||
result, err := ok.GetHistoricCandlesExtended(contextGenerate(), currencyPair, asset.Spot, kline.OneMin, time.Now().Add(-time.Hour), time.Now())
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, result)
|
||||
@@ -4046,7 +4046,7 @@ func TestPushDataDynamic(t *testing.T) {
|
||||
|
||||
func TestGetHistoricTrades(t *testing.T) {
|
||||
t.Parallel()
|
||||
result, err := ok.GetHistoricTrades(contextGenerate(), currency.NewPair(currency.BTC, currency.USDT), asset.Spot, time.Now().Add(-time.Minute*4), time.Now().Add(-time.Minute*2))
|
||||
result, err := ok.GetHistoricTrades(contextGenerate(), currency.NewBTCUSDT(), asset.Spot, time.Now().Add(-time.Minute*4), time.Now().Add(-time.Minute*2))
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, result)
|
||||
}
|
||||
@@ -4138,15 +4138,15 @@ func TestWSProcessTrades(t *testing.T) {
|
||||
|
||||
func TestInstrumentsSubscription(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := ok.InstrumentsSubscription(contextGenerate(), "subscribe", asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err := ok.InstrumentsSubscription(contextGenerate(), "subscribe", asset.Spot, currency.NewBTCUSDT())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestTickersSubscription(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := ok.TickersSubscription(contextGenerate(), "subscribe", asset.Margin, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err := ok.TickersSubscription(contextGenerate(), "subscribe", asset.Margin, currency.NewBTCUSDT())
|
||||
require.NoError(t, err)
|
||||
err = ok.TickersSubscription(contextGenerate(), "unsubscribe", asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err = ok.TickersSubscription(contextGenerate(), "unsubscribe", asset.Spot, currency.NewBTCUSDT())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -4169,7 +4169,7 @@ func TestCandlesticksSubscription(t *testing.T) {
|
||||
|
||||
func TestTradesSubscription(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := ok.TradesSubscription(contextGenerate(), "subscribe", asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err := ok.TradesSubscription(contextGenerate(), "subscribe", asset.Spot, currency.NewBTCUSDT())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -4275,9 +4275,9 @@ func TestPublicStructureBlockTradesSubscription(t *testing.T) {
|
||||
|
||||
func TestBlockTickerSubscription(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := ok.BlockTickerSubscription(contextGenerate(), "subscribe", asset.Options, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err := ok.BlockTickerSubscription(contextGenerate(), "subscribe", asset.Options, currency.NewBTCUSDT())
|
||||
require.NoError(t, err)
|
||||
err = ok.BlockTickerSubscription(contextGenerate(), "unsubscribe", asset.Options, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err = ok.BlockTickerSubscription(contextGenerate(), "unsubscribe", asset.Options, currency.NewBTCUSDT())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -4294,7 +4294,7 @@ func TestPublicBlockTradesSubscription(t *testing.T) {
|
||||
func TestWsAccountSubscription(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, ok)
|
||||
err := ok.WsAccountSubscription(contextGenerate(), "subscribe", asset.Spot, currency.NewPair(currency.BTC, currency.USDT))
|
||||
err := ok.WsAccountSubscription(contextGenerate(), "subscribe", asset.Spot, currency.NewBTCUSDT())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -4796,7 +4796,7 @@ func TestGetHistoricalFundingRates(t *testing.T) {
|
||||
|
||||
func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
t.Parallel()
|
||||
is, err := ok.IsPerpetualFutureCurrency(asset.Binary, currency.NewPair(currency.BTC, currency.USDT))
|
||||
is, err := ok.IsPerpetualFutureCurrency(asset.Binary, currency.NewBTCUSDT())
|
||||
require.NoError(t, err)
|
||||
require.False(t, is)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
btcusd = currency.NewPair(currency.BTC, currency.USD)
|
||||
btcusd = currency.NewBTCUSD()
|
||||
ltcusd = currency.NewPair(currency.LTC, currency.USD)
|
||||
btcltc = currency.NewPair(currency.BTC, currency.LTC)
|
||||
)
|
||||
|
||||
@@ -635,7 +635,7 @@ func TestFilterOrdersByPairs(t *testing.T) {
|
||||
|
||||
orders := []Detail{
|
||||
{
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
},
|
||||
{
|
||||
Pair: currency.NewPair(currency.LTC, currency.EUR),
|
||||
@@ -647,7 +647,7 @@ func TestFilterOrdersByPairs(t *testing.T) {
|
||||
}
|
||||
|
||||
currencies := []currency.Pair{
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
currency.NewPair(currency.LTC, currency.EUR),
|
||||
currency.NewPair(currency.DOGE, currency.RUB),
|
||||
}
|
||||
@@ -657,7 +657,7 @@ func TestFilterOrdersByPairs(t *testing.T) {
|
||||
}
|
||||
|
||||
currencies = []currency.Pair{
|
||||
currency.NewPair(currency.BTC, currency.USD),
|
||||
currency.NewBTCUSD(),
|
||||
currency.NewPair(currency.LTC, currency.EUR),
|
||||
}
|
||||
FilterOrdersByPairs(&orders, currencies)
|
||||
@@ -665,7 +665,7 @@ func TestFilterOrdersByPairs(t *testing.T) {
|
||||
t.Errorf("Orders failed to be filtered. Expected %v, received %v", 2, len(orders))
|
||||
}
|
||||
|
||||
currencies = []currency.Pair{currency.NewPair(currency.BTC, currency.USD)}
|
||||
currencies = []currency.Pair{currency.NewBTCUSD()}
|
||||
FilterOrdersByPairs(&orders, currencies)
|
||||
if len(orders) != 2 {
|
||||
t.Errorf("Orders failed to be filtered. Expected %v, received %v", 1, len(orders))
|
||||
@@ -690,16 +690,16 @@ func TestFilterOrdersByPairs(t *testing.T) {
|
||||
}
|
||||
|
||||
var filterOrdersByPairsBenchmark = &[]Detail{
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewPair(currency.BTC, currency.USD)},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
{Pair: currency.NewBTCUSD()},
|
||||
}
|
||||
|
||||
// BenchmarkFilterOrdersByPairs benchmark
|
||||
@@ -707,7 +707,7 @@ var filterOrdersByPairsBenchmark = &[]Detail{
|
||||
// 400032 2977 ns/op 15840 B/op 5 allocs/op // PREV
|
||||
// 6977242 172.8 ns/op 0 B/op 0 allocs/op // CURRENT
|
||||
func BenchmarkFilterOrdersByPairs(b *testing.B) {
|
||||
pairs := []currency.Pair{currency.NewPair(currency.BTC, currency.USD)}
|
||||
pairs := []currency.Pair{currency.NewBTCUSD()}
|
||||
for b.Loop() {
|
||||
FilterOrdersByPairs(filterOrdersByPairsBenchmark, pairs)
|
||||
}
|
||||
@@ -1381,7 +1381,7 @@ func TestValidationOnOrderTypes(t *testing.T) {
|
||||
t.Errorf("received '%v' expected '%v'", err, ErrPairIsEmpty)
|
||||
}
|
||||
|
||||
cancelMe.Pair = currency.NewPair(currency.BTC, currency.USDT)
|
||||
cancelMe.Pair = currency.NewBTCUSDT()
|
||||
err = cancelMe.Validate(cancelMe.PairAssetRequired())
|
||||
if err == nil || err.Error() != ErrAssetNotSet.Error() {
|
||||
t.Errorf("received '%v' expected '%v'", err, ErrAssetNotSet)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func testSetup() Base {
|
||||
return Base{
|
||||
Exchange: "a",
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
Asks: []Tranche{
|
||||
{Price: 7000, Amount: 1},
|
||||
{Price: 7001, Amount: 2},
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestSubscribeToExchangeOrderbooks(t *testing.T) {
|
||||
_, err := SubscribeToExchangeOrderbooks("")
|
||||
assert.ErrorIs(t, err, ErrOrderbookNotFound)
|
||||
|
||||
p := currency.NewPair(currency.BTC, currency.USD)
|
||||
p := currency.NewBTCUSD()
|
||||
|
||||
b := Base{
|
||||
Pair: p,
|
||||
@@ -51,7 +51,7 @@ func TestVerify(t *testing.T) {
|
||||
b := Base{
|
||||
Exchange: "TestExchange",
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
VerifyOrderbook: true,
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestSimulate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
o, err := b.UpdateOrderbook(t.Context(),
|
||||
currency.NewPair(currency.BTC, currency.USD), asset.Spot)
|
||||
currency.NewBTCUSD(), asset.Spot)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ func TestModifyOrder(t *testing.T) {
|
||||
OrderID: "1337",
|
||||
Price: 1337,
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Pair: currency.NewBTCUSDT(),
|
||||
})
|
||||
switch {
|
||||
case sharedtestvalues.AreAPICredentialsSet(p) && err != nil && mockTests:
|
||||
@@ -1096,7 +1096,7 @@ func TestCancelBatchOrders(t *testing.T) {
|
||||
{
|
||||
OrderID: "1234",
|
||||
AssetType: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
btcusdtPair = currency.NewPair(currency.BTC, currency.USDT)
|
||||
btcusdtPair = currency.NewBTCUSDT()
|
||||
ethusdcPair = currency.NewPair(currency.ETH, currency.USDC)
|
||||
ltcusdcPair = currency.NewPair(currency.LTC, currency.USDC)
|
||||
)
|
||||
@@ -81,7 +81,7 @@ func TestSubscriptionMarshaling(t *testing.T) {
|
||||
assert.NoError(t, err, "Marshalling should not error")
|
||||
assert.JSONEq(t, `{"enabled":true,"channel":"orderbook","interval":"5m","levels":4}`, string(j), "Marshalling should be clean and concise")
|
||||
|
||||
j, err = json.Marshal(&Subscription{Enabled: true, Channel: OrderbookChannel, Interval: kline.FiveMin, Levels: 4, Pairs: currency.Pairs{currency.NewPair(currency.BTC, currency.USDT)}})
|
||||
j, err = json.Marshal(&Subscription{Enabled: true, Channel: OrderbookChannel, Interval: kline.FiveMin, Levels: 4, Pairs: currency.Pairs{currency.NewBTCUSDT()}})
|
||||
assert.NoError(t, err, "Marshalling should not error")
|
||||
assert.JSONEq(t, `{"enabled":true,"channel":"orderbook","pairs":"BTCUSDT","interval":"5m","levels":4}`, string(j), "Marshalling should be clean and concise")
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestSubscribeTicker(t *testing.T) {
|
||||
t.Error("error cannot be nil")
|
||||
}
|
||||
|
||||
p := currency.NewPair(currency.BTC, currency.USD)
|
||||
p := currency.NewBTCUSD()
|
||||
|
||||
// force error
|
||||
service.mux = nil
|
||||
@@ -104,7 +104,7 @@ func TestSubscribeToExchangeTickers(t *testing.T) {
|
||||
t.Error("error cannot be nil")
|
||||
}
|
||||
|
||||
p := currency.NewPair(currency.BTC, currency.USD)
|
||||
p := currency.NewBTCUSD()
|
||||
|
||||
err = ProcessTicker(&Price{
|
||||
Pair: p,
|
||||
@@ -279,7 +279,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
|
||||
|
||||
err = ProcessTicker(&Price{
|
||||
ExchangeName: "Bitfinex",
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
AssetType: asset.Margin,
|
||||
Bid: 1337,
|
||||
Ask: 1337,
|
||||
@@ -288,7 +288,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
|
||||
|
||||
err = ProcessTicker(&Price{
|
||||
ExchangeName: "Bitfinex",
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
AssetType: asset.Margin,
|
||||
Bid: 1338,
|
||||
Ask: 1336,
|
||||
@@ -299,7 +299,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
|
||||
|
||||
err = ProcessTicker(&Price{
|
||||
ExchangeName: "Bitfinex",
|
||||
Pair: currency.NewPair(currency.BTC, currency.USD),
|
||||
Pair: currency.NewBTCUSD(),
|
||||
AssetType: asset.MarginFunding,
|
||||
Bid: 1338,
|
||||
Ask: 1336,
|
||||
|
||||
@@ -130,7 +130,7 @@ func TestSqlDataToTrade(t *testing.T) {
|
||||
|
||||
func TestTradeToSQLData(t *testing.T) {
|
||||
t.Parallel()
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
sqlData, err := tradeToSQLData(Data{
|
||||
Timestamp: time.Now(),
|
||||
Exchange: "test!",
|
||||
|
||||
@@ -113,7 +113,7 @@ func TestGetOpenOrders(t *testing.T) {
|
||||
func TestGetOrderInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
sharedtestvalues.SkipTestIfCredentialsUnset(t, y)
|
||||
_, err := y.GetOrderInfo(t.Context(), "1337", currency.NewPair(currency.BTC, currency.USD), asset.Spot)
|
||||
_, err := y.GetOrderInfo(t.Context(), "1337", currency.NewBTCUSD(), asset.Spot)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user