mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
linter: Enable gofumpt and run against codebase (#1848)
* linter: Enable gofumpt and run against codebase * Address shazbert's nits * gofumpt: Fix issues after rebase
This commit is contained in:
@@ -162,7 +162,8 @@ func TestLoadDataAPI(t *testing.T) {
|
||||
APIData: &config.APIData{
|
||||
StartDate: time.Now().Truncate(gctkline.OneMin.Duration()).Add(-time.Minute * 5),
|
||||
EndDate: time.Now().Truncate(gctkline.OneMin.Duration()),
|
||||
}},
|
||||
},
|
||||
},
|
||||
StrategySettings: config.StrategySettings{
|
||||
Name: dollarcostaverage.Name,
|
||||
CustomSettings: map[string]interface{}{
|
||||
@@ -183,7 +184,8 @@ func TestLoadDataAPI(t *testing.T) {
|
||||
Enabled: currency.Pairs{cp},
|
||||
AssetEnabled: true,
|
||||
ConfigFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true}}
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
}
|
||||
|
||||
_, err = bt.loadData(cfg, exch, cp, asset.Spot, false)
|
||||
if err != nil {
|
||||
@@ -216,7 +218,8 @@ func TestLoadDataCSV(t *testing.T) {
|
||||
Interval: gctkline.OneMin,
|
||||
CSVData: &config.CSVData{
|
||||
FullPath: "test",
|
||||
}},
|
||||
},
|
||||
},
|
||||
StrategySettings: config.StrategySettings{
|
||||
Name: dollarcostaverage.Name,
|
||||
CustomSettings: map[string]interface{}{
|
||||
@@ -237,7 +240,8 @@ func TestLoadDataCSV(t *testing.T) {
|
||||
Enabled: currency.Pairs{cp},
|
||||
AssetEnabled: true,
|
||||
ConfigFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true}}
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
}
|
||||
_, err = bt.loadData(cfg, exch, cp, asset.Spot, false)
|
||||
if err != nil &&
|
||||
!strings.Contains(err.Error(), "The system cannot find the file specified.") &&
|
||||
@@ -281,7 +285,8 @@ func TestLoadDataDatabase(t *testing.T) {
|
||||
StartDate: time.Now().Add(-time.Minute),
|
||||
EndDate: time.Now(),
|
||||
InclusiveEndDate: true,
|
||||
}},
|
||||
},
|
||||
},
|
||||
StrategySettings: config.StrategySettings{
|
||||
Name: dollarcostaverage.Name,
|
||||
CustomSettings: map[string]interface{}{
|
||||
@@ -302,7 +307,8 @@ func TestLoadDataDatabase(t *testing.T) {
|
||||
Enabled: currency.Pairs{cp},
|
||||
AssetEnabled: true,
|
||||
ConfigFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true}}
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
}
|
||||
bt.databaseManager, err = engine.SetupDatabaseConnectionManager(&cfg.DataSettings.DatabaseData.Config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -357,7 +363,8 @@ func TestLoadDataLive(t *testing.T) {
|
||||
},
|
||||
},
|
||||
RealOrders: true,
|
||||
}},
|
||||
},
|
||||
},
|
||||
StrategySettings: config.StrategySettings{
|
||||
Name: dollarcostaverage.Name,
|
||||
CustomSettings: map[string]interface{}{
|
||||
@@ -385,7 +392,8 @@ func TestLoadDataLive(t *testing.T) {
|
||||
Enabled: currency.Pairs{cp},
|
||||
AssetEnabled: true,
|
||||
ConfigFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true}}
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
}
|
||||
_, err = bt.loadData(cfg, exch, cp, asset.Spot, false)
|
||||
if !errors.Is(err, gctkline.ErrCannotConstructInterval) {
|
||||
t.Errorf("received: %v, expected: %v", err, gctkline.ErrCannotConstructInterval)
|
||||
@@ -717,9 +725,11 @@ func TestTriggerLiquidationsForExchange(t *testing.T) {
|
||||
a := asset.USDTMarginedFutures
|
||||
expectedError = gctcommon.ErrNilPointer
|
||||
ev := &evkline.Kline{
|
||||
Base: &event.Base{Exchange: testExchange,
|
||||
Base: &event.Base{
|
||||
Exchange: testExchange,
|
||||
AssetType: a,
|
||||
CurrencyPair: cp},
|
||||
CurrencyPair: cp,
|
||||
},
|
||||
}
|
||||
err = bt.triggerLiquidationsForExchange(ev, nil)
|
||||
if !errors.Is(err, expectedError) {
|
||||
@@ -885,9 +895,11 @@ func TestProcessSignalEvent(t *testing.T) {
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
a := asset.USDTMarginedFutures
|
||||
de := &evkline.Kline{
|
||||
Base: &event.Base{Exchange: testExchange,
|
||||
Base: &event.Base{
|
||||
Exchange: testExchange,
|
||||
AssetType: a,
|
||||
CurrencyPair: cp},
|
||||
CurrencyPair: cp,
|
||||
},
|
||||
}
|
||||
err := bt.Statistic.SetEventForOffset(de)
|
||||
if !errors.Is(err, expectedError) {
|
||||
@@ -951,9 +963,11 @@ func TestProcessOrderEvent(t *testing.T) {
|
||||
cp := currency.NewPair(currency.BTC, currency.USDT)
|
||||
a := asset.USDTMarginedFutures
|
||||
de := &evkline.Kline{
|
||||
Base: &event.Base{Exchange: testExchange,
|
||||
Base: &event.Base{
|
||||
Exchange: testExchange,
|
||||
AssetType: a,
|
||||
CurrencyPair: cp},
|
||||
CurrencyPair: cp,
|
||||
},
|
||||
}
|
||||
err = bt.Statistic.SetEventForOffset(de)
|
||||
if !errors.Is(err, expectedError) {
|
||||
@@ -1186,7 +1200,8 @@ func TestProcessFuturesFillEvent(t *testing.T) {
|
||||
Base: &event.Base{
|
||||
Exchange: testExchange,
|
||||
AssetType: a,
|
||||
CurrencyPair: cp},
|
||||
CurrencyPair: cp,
|
||||
},
|
||||
}
|
||||
err := bt.Statistic.SetEventForOffset(de)
|
||||
if !errors.Is(err, expectedError) {
|
||||
|
||||
@@ -123,7 +123,6 @@ func (f fakeReport) UseDarkMode(bool) {}
|
||||
type fakeStats struct{}
|
||||
|
||||
func (f *fakeStats) SetStrategyName(string) {
|
||||
|
||||
}
|
||||
|
||||
func (f *fakeStats) SetEventForOffset(common.Event) error {
|
||||
@@ -169,29 +168,30 @@ func (f fakeDataHolder) SetDataForCurrency(string, asset.Item, currency.Pair, da
|
||||
|
||||
func (f fakeDataHolder) GetAllData() ([]data.Handler, error) {
|
||||
cp := currency.NewPair(currency.BTC, currency.USD)
|
||||
return []data.Handler{&kline.DataFromKline{
|
||||
Base: &data.Base{},
|
||||
Item: &gctkline.Item{
|
||||
Exchange: testExchange,
|
||||
Pair: cp,
|
||||
UnderlyingPair: cp,
|
||||
Asset: asset.Spot,
|
||||
Interval: gctkline.OneMin,
|
||||
Candles: []gctkline.Candle{
|
||||
{
|
||||
Time: time.Now(),
|
||||
Open: 1337,
|
||||
High: 1337,
|
||||
Low: 1337,
|
||||
Close: 1337,
|
||||
Volume: 1337,
|
||||
return []data.Handler{
|
||||
&kline.DataFromKline{
|
||||
Base: &data.Base{},
|
||||
Item: &gctkline.Item{
|
||||
Exchange: testExchange,
|
||||
Pair: cp,
|
||||
UnderlyingPair: cp,
|
||||
Asset: asset.Spot,
|
||||
Interval: gctkline.OneMin,
|
||||
Candles: []gctkline.Candle{
|
||||
{
|
||||
Time: time.Now(),
|
||||
Open: 1337,
|
||||
High: 1337,
|
||||
Low: 1337,
|
||||
Close: 1337,
|
||||
Volume: 1337,
|
||||
},
|
||||
},
|
||||
SourceJobID: uuid.UUID{},
|
||||
ValidationJobID: uuid.UUID{},
|
||||
},
|
||||
SourceJobID: uuid.UUID{},
|
||||
ValidationJobID: uuid.UUID{},
|
||||
RangeHolder: &gctkline.IntervalRangeHolder{},
|
||||
},
|
||||
RangeHolder: &gctkline.IntervalRangeHolder{},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,8 @@ func (s *GRPCServer) StartRPCRESTProxy() error {
|
||||
}
|
||||
|
||||
mux := runtime.NewServeMux()
|
||||
opts := []grpc.DialOption{grpc.WithTransportCredentials(creds),
|
||||
opts := []grpc.DialOption{
|
||||
grpc.WithTransportCredentials(creds),
|
||||
grpc.WithPerRPCCredentials(auth.BasicAuth{
|
||||
Username: s.config.GRPC.Username,
|
||||
Password: s.config.GRPC.Password,
|
||||
|
||||
@@ -21,8 +21,10 @@ import (
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
var dcaConfigPath = filepath.Join("..", "config", "strategyexamples", "dca-api-candles.strat")
|
||||
var dbConfigPath = filepath.Join("..", "config", "strategyexamples", "dca-database-candles.strat")
|
||||
var (
|
||||
dcaConfigPath = filepath.Join("..", "config", "strategyexamples", "dca-api-candles.strat")
|
||||
dbConfigPath = filepath.Join("..", "config", "strategyexamples", "dca-database-candles.strat")
|
||||
)
|
||||
|
||||
func TestExecuteStrategyFromFile(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -663,7 +663,8 @@ func getFees(ctx context.Context, exch gctexchange.IBotExchange, fPair currency.
|
||||
return decimal.Zero, decimal.Zero, currency.ErrCurrencyPairEmpty
|
||||
}
|
||||
fTakerFee, err := exch.GetFeeByType(ctx,
|
||||
&gctexchange.FeeBuilder{FeeType: gctexchange.OfflineTradeFee,
|
||||
&gctexchange.FeeBuilder{
|
||||
FeeType: gctexchange.OfflineTradeFee,
|
||||
Pair: fPair,
|
||||
IsMaker: false,
|
||||
PurchasePrice: 1,
|
||||
|
||||
Reference in New Issue
Block a user