mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-19 07:26:49 +00:00
* 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
78 lines
1.8 KiB
Go
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)
|
|
}
|
|
}
|