Files
gocryptotrader/backtester/data/kline/csv/csv_test.go
Gareth Kirwan 3caa149d8e 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
2025-05-07 11:32:06 +10:00

78 lines
1.8 KiB
Go

package csv
import (
"errors"
"path/filepath"
"testing"
"github.com/thrasher-corp/gocryptotrader/backtester/common"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
gctkline "github.com/thrasher-corp/gocryptotrader/exchanges/kline"
)
const testExchange = "binance"
func TestLoadDataCandles(t *testing.T) {
exch := testExchange
a := asset.Spot
p := currency.NewBTCUSDT()
_, err := LoadData(
common.DataCandle,
filepath.Join("..", "..", "..", "..", "testdata", "binance_BTCUSDT_24h_2019_01_01_2020_01_01.csv"),
exch,
gctkline.FifteenMin.Duration(),
p,
a,
false)
if !errors.Is(err, nil) {
t.Errorf("received: %v, expected: %v", err, nil)
}
}
func TestLoadDataTrades(t *testing.T) {
exch := testExchange
a := asset.Spot
p := currency.NewBTCUSDT()
_, err := LoadData(
common.DataTrade,
filepath.Join("..", "..", "..", "..", "testdata", "binance_BTCUSDT_24h-trades_2020_11_16.csv"),
exch,
gctkline.FifteenMin.Duration(),
p,
a,
false)
if !errors.Is(err, nil) {
t.Errorf("received: %v, expected: %v", err, nil)
}
}
func TestLoadDataInvalid(t *testing.T) {
exch := testExchange
a := asset.Spot
p := currency.NewBTCUSDT()
_, err := LoadData(
-1,
filepath.Join("..", "..", "..", "..", "testdata", "binance_BTCUSDT_24h-trades_2020_11_16.csv"),
exch,
gctkline.FifteenMin.Duration(),
p,
a,
false)
if !errors.Is(err, common.ErrInvalidDataType) {
t.Errorf("received: %v, expected: %v", err, common.ErrInvalidDataType)
}
_, err = LoadData(
-1,
filepath.Join("..", "..", "..", "..", "testdata", "binance_BTCUSDT_24h-trades_2020_11_16.csv"),
exch,
gctkline.FifteenMin.Duration(),
p,
a,
true)
if !errors.Is(err, errNoUSDData) {
t.Errorf("received: %v, expected: %v", err, errNoUSDData)
}
}