mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +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:
@@ -142,7 +142,7 @@ func TestLoadDataAPI(t *testing.T) {
|
||||
bt := BackTest{
|
||||
Reports: &report.Data{},
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
cfg := &config.Config{
|
||||
CurrencySettings: []config.CurrencySettings{
|
||||
{
|
||||
@@ -197,7 +197,7 @@ func TestLoadDataCSV(t *testing.T) {
|
||||
bt := BackTest{
|
||||
Reports: &report.Data{},
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
cfg := &config.Config{
|
||||
CurrencySettings: []config.CurrencySettings{
|
||||
{
|
||||
@@ -255,7 +255,7 @@ func TestLoadDataDatabase(t *testing.T) {
|
||||
Reports: &report.Data{},
|
||||
shutdown: make(chan struct{}),
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
cfg := &config.Config{
|
||||
CurrencySettings: []config.CurrencySettings{
|
||||
{
|
||||
@@ -329,7 +329,7 @@ func TestLoadDataLive(t *testing.T) {
|
||||
shutdown: make(chan struct{}),
|
||||
}
|
||||
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
cfg := &config.Config{
|
||||
CurrencySettings: []config.CurrencySettings{
|
||||
{
|
||||
@@ -445,7 +445,7 @@ func TestReset(t *testing.T) {
|
||||
func TestFullCycle(t *testing.T) {
|
||||
t.Parallel()
|
||||
ex := testExchange
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
a := asset.Spot
|
||||
tt := time.Now()
|
||||
|
||||
@@ -579,7 +579,7 @@ func TestStop(t *testing.T) {
|
||||
func TestFullCycleMulti(t *testing.T) {
|
||||
t.Parallel()
|
||||
ex := testExchange
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
a := asset.Spot
|
||||
tt := time.Now()
|
||||
|
||||
@@ -720,7 +720,7 @@ func TestTriggerLiquidationsForExchange(t *testing.T) {
|
||||
t.Errorf("received '%v' expected '%v'", err, expectedError)
|
||||
}
|
||||
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
a := asset.USDTMarginedFutures
|
||||
expectedError = gctcommon.ErrNilPointer
|
||||
ev := &evkline.Kline{
|
||||
@@ -813,7 +813,7 @@ func TestUpdateStatsForDataEvent(t *testing.T) {
|
||||
t.Errorf("received '%v' expected '%v'", err, expectedError)
|
||||
}
|
||||
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
a := asset.Futures
|
||||
ev := &evkline.Kline{
|
||||
Base: &event.Base{
|
||||
@@ -891,7 +891,7 @@ func TestProcessSignalEvent(t *testing.T) {
|
||||
EventQueue: &eventholder.Holder{},
|
||||
shutdown: make(chan struct{}),
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
a := asset.USDTMarginedFutures
|
||||
de := &evkline.Kline{
|
||||
Base: &event.Base{
|
||||
@@ -959,7 +959,7 @@ func TestProcessOrderEvent(t *testing.T) {
|
||||
DataHolder: &data.HandlerHolder{},
|
||||
shutdown: make(chan struct{}),
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
a := asset.USDTMarginedFutures
|
||||
de := &evkline.Kline{
|
||||
Base: &event.Base{
|
||||
@@ -1080,7 +1080,7 @@ func TestProcessFillEvent(t *testing.T) {
|
||||
DataHolder: &data.HandlerHolder{},
|
||||
shutdown: make(chan struct{}),
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
a := asset.Futures
|
||||
tt := time.Now()
|
||||
de := &evkline.Kline{
|
||||
@@ -1193,7 +1193,7 @@ func TestProcessFuturesFillEvent(t *testing.T) {
|
||||
DataHolder: &data.HandlerHolder{},
|
||||
shutdown: make(chan struct{}),
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
a := asset.Futures
|
||||
de := &evkline.Kline{
|
||||
Base: &event.Base{
|
||||
@@ -1347,7 +1347,7 @@ func TestCloseAllPositions(t *testing.T) {
|
||||
dc.dataHolder = bt.DataHolder
|
||||
dc.report = &report.Data{}
|
||||
dc.funding = bt.Funding
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
dc.sourcesToCheck = append(dc.sourcesToCheck, &liveDataSourceDataHandler{
|
||||
exchange: &binance.Binance{},
|
||||
exchangeName: testExchange,
|
||||
@@ -1427,7 +1427,7 @@ func TestRunLive(t *testing.T) {
|
||||
funding: bt.Funding,
|
||||
}
|
||||
bt.LiveDataHandler = dc
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
i := &gctkline.Item{
|
||||
Pair: cp,
|
||||
UnderlyingPair: cp,
|
||||
@@ -1596,7 +1596,7 @@ func TestGetFees(t *testing.T) {
|
||||
_, _, err = getFees(t.Context(), f, currency.EMPTYPAIR)
|
||||
assert.ErrorIs(t, err, currency.ErrCurrencyPairEmpty)
|
||||
|
||||
maker, taker, err := getFees(t.Context(), f, currency.NewPair(currency.BTC, currency.USDT))
|
||||
maker, taker, err := getFees(t.Context(), f, currency.NewBTCUSDT())
|
||||
assert.NoError(t, err, "getFees should not error")
|
||||
assert.NotZero(t, maker, "getFees should return a non-zero maker fee")
|
||||
assert.NotZero(t, taker, "getFees should return a non-zero taker fee")
|
||||
@@ -1914,7 +1914,7 @@ func TestProcessSingleDataEvent(t *testing.T) {
|
||||
if !errors.Is(err, common.ErrNilEvent) {
|
||||
t.Errorf("received '%v' expected '%v'", err, common.ErrNilEvent)
|
||||
}
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
cp := currency.NewBTCUSDT()
|
||||
a := asset.Spot
|
||||
ev := &evkline.Kline{
|
||||
Base: &event.Base{
|
||||
|
||||
@@ -167,7 +167,7 @@ func (f fakeDataHolder) SetDataForCurrency(string, asset.Item, currency.Pair, da
|
||||
}
|
||||
|
||||
func (f fakeDataHolder) GetAllData() ([]data.Handler, error) {
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
cp := currency.NewBTCUSD()
|
||||
return []data.Handler{
|
||||
&kline.DataFromKline{
|
||||
Base: &data.Base{},
|
||||
@@ -321,8 +321,8 @@ func (f fakeStrat) CloseAllPositions([]holdings.Holding, []data.Event) ([]signal
|
||||
Exchange: testExchange,
|
||||
Time: time.Now(),
|
||||
Interval: gctkline.FifteenSecond,
|
||||
CurrencyPair: currency.NewPair(currency.BTC, currency.USD),
|
||||
UnderlyingPair: currency.NewPair(currency.BTC, currency.USD),
|
||||
CurrencyPair: currency.NewBTCUSD(),
|
||||
UnderlyingPair: currency.NewBTCUSD(),
|
||||
AssetType: asset.Spot,
|
||||
},
|
||||
OpenPrice: leet,
|
||||
|
||||
@@ -281,7 +281,7 @@ func TestAppendDataSource(t *testing.T) {
|
||||
t.Errorf("received '%v' expected '%v'", err, currency.ErrCurrencyPairEmpty)
|
||||
}
|
||||
|
||||
setup.pair = currency.NewPair(currency.BTC, currency.USDT)
|
||||
setup.pair = currency.NewBTCUSDT()
|
||||
err = dataHandler.AppendDataSource(setup)
|
||||
if !errors.Is(err, kline.ErrInvalidInterval) {
|
||||
t.Errorf("received '%v' expected '%v'", err, kline.ErrInvalidInterval)
|
||||
@@ -384,7 +384,7 @@ func TestLoadCandleData(t *testing.T) {
|
||||
|
||||
exch := &binanceus.Binanceus{}
|
||||
exch.SetDefaults()
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT).Format(
|
||||
cp := currency.NewBTCUSDT().Format(
|
||||
currency.PairFormat{
|
||||
Uppercase: true,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user