mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 15:10:59 +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:
@@ -144,7 +144,6 @@ func executeStrategyFromFile(c *cli.Context) error {
|
||||
IntervalOverride: durationpb.New(intervalOverride),
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -171,7 +170,6 @@ func listAllTasks(c *cli.Context) error {
|
||||
c.Context,
|
||||
&btrpc.ListAllTasksRequest{},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -217,7 +215,6 @@ func startTask(c *cli.Context) error {
|
||||
Id: id,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -244,7 +241,6 @@ func startAllTasks(c *cli.Context) error {
|
||||
c.Context,
|
||||
&btrpc.StartAllTasksRequest{},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -291,7 +287,6 @@ func stopTask(c *cli.Context) error {
|
||||
Id: id,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -318,7 +313,6 @@ func stopAllTasks(c *cli.Context) error {
|
||||
c.Context,
|
||||
&btrpc.StopAllTasksRequest{},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -365,7 +359,6 @@ func clearTask(c *cli.Context) error {
|
||||
Id: id,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -392,7 +385,6 @@ func clearAllTasks(c *cli.Context) error {
|
||||
c.Context,
|
||||
&btrpc.ClearAllTasksRequest{},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -623,7 +615,6 @@ func executeStrategyFromConfig(c *cli.Context) error {
|
||||
DoNotStore: dns,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ func setupClient(c *cli.Context) (*grpc.ClientConn, context.CancelFunc, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
opts := []grpc.DialOption{grpc.WithTransportCredentials(creds),
|
||||
opts := []grpc.DialOption{
|
||||
grpc.WithTransportCredentials(creds),
|
||||
grpc.WithPerRPCCredentials(auth.BasicAuth{
|
||||
Username: username,
|
||||
Password: password,
|
||||
|
||||
@@ -16,8 +16,10 @@ import (
|
||||
gctkline "github.com/thrasher-corp/gocryptotrader/exchanges/kline"
|
||||
)
|
||||
|
||||
const exch = "binance"
|
||||
const a = asset.Spot
|
||||
const (
|
||||
exch = "binance"
|
||||
a = asset.Spot
|
||||
)
|
||||
|
||||
var p = currency.NewPair(currency.BTC, currency.USD)
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ func TestLoadCandles(t *testing.T) {
|
||||
Enabled: currency.Pairs{cp},
|
||||
AssetEnabled: true,
|
||||
ConfigFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true}}
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
}
|
||||
tt1 := time.Now().Add(-time.Minute).Round(gctkline.OneMin.Duration())
|
||||
tt2 := time.Now().Round(gctkline.OneMin.Duration())
|
||||
interval := gctkline.OneMin
|
||||
@@ -69,7 +70,8 @@ func TestLoadTrades(t *testing.T) {
|
||||
Enabled: currency.Pairs{cp},
|
||||
AssetEnabled: true,
|
||||
ConfigFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true}}
|
||||
RequestFormat: ¤cy.PairFormat{Uppercase: true},
|
||||
}
|
||||
interval := gctkline.OneMin
|
||||
tt1 := time.Now().Add(-time.Minute * 10).Round(interval.Duration())
|
||||
tt2 := time.Now().Round(interval.Duration())
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -83,6 +83,7 @@ func (f *fakeFund) PairReleaser() (funding.IPairReleaser, error) {
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (f *fakeFund) CollateralReleaser() (funding.ICollateralReleaser, error) {
|
||||
i, err := funding.CreateItem(testExchange, asset.Futures, currency.BTC, decimal.Zero, decimal.Zero)
|
||||
if err != nil {
|
||||
|
||||
@@ -42,7 +42,8 @@ func TestGetSnapshotAtTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := Manager{}
|
||||
tt := time.Now()
|
||||
err := m.AddSnapshot(&Snapshot{Offset: 0,
|
||||
err := m.AddSnapshot(&Snapshot{
|
||||
Offset: 0,
|
||||
Timestamp: tt,
|
||||
Orders: []SnapshotOrder{
|
||||
{
|
||||
|
||||
@@ -8,9 +8,7 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
)
|
||||
|
||||
var (
|
||||
errSnapshotNotFound = errors.New("snapshot not found")
|
||||
)
|
||||
var errSnapshotNotFound = errors.New("snapshot not found")
|
||||
|
||||
// Manager holds a snapshot of all orders at each timeperiod, allowing
|
||||
// study of all changes across time
|
||||
|
||||
@@ -117,12 +117,10 @@ func (h *Holding) update(e fill.Event, f funding.IFundReader) error {
|
||||
return nil
|
||||
}
|
||||
switch direction {
|
||||
case order.Buy,
|
||||
order.Bid:
|
||||
case order.Buy, order.Bid:
|
||||
h.BoughtAmount = h.BoughtAmount.Add(amount)
|
||||
h.CommittedFunds = h.BaseSize.Mul(price)
|
||||
case order.Sell,
|
||||
order.Ask:
|
||||
case order.Sell, order.Ask:
|
||||
h.SoldAmount = h.SoldAmount.Add(amount)
|
||||
h.CommittedFunds = h.BaseSize.Mul(price)
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func (p *Portfolio) OnSignal(ev signal.Event, exchangeSettings *exchange.Setting
|
||||
o.BuyLimit = ev.GetBuyLimit()
|
||||
o.SellLimit = ev.GetSellLimit()
|
||||
var sizingFunds decimal.Decimal
|
||||
var side = ev.GetDirection()
|
||||
side := ev.GetDirection()
|
||||
if ev.GetAssetType() == asset.Spot {
|
||||
if side == gctorder.ClosePosition {
|
||||
side = gctorder.Sell
|
||||
|
||||
@@ -134,7 +134,8 @@ func TestSetHoldings(t *testing.T) {
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Timestamp: tt})
|
||||
Timestamp: tt,
|
||||
})
|
||||
if !errors.Is(err, nil) {
|
||||
t.Errorf("received: %v, expected: %v", err, nil)
|
||||
}
|
||||
@@ -143,7 +144,8 @@ func TestSetHoldings(t *testing.T) {
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Timestamp: tt})
|
||||
Timestamp: tt,
|
||||
})
|
||||
if !errors.Is(err, nil) {
|
||||
t.Errorf("received: %v, expected: %v", err, nil)
|
||||
}
|
||||
@@ -161,7 +163,8 @@ func TestGetLatestHoldingsForAllCurrencies(t *testing.T) {
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Timestamp: tt})
|
||||
Timestamp: tt,
|
||||
})
|
||||
if !errors.Is(err, errNoPortfolioSettings) {
|
||||
t.Errorf("received: %v, expected: %v", err, errNoPortfolioSettings)
|
||||
}
|
||||
@@ -181,7 +184,8 @@ func TestGetLatestHoldingsForAllCurrencies(t *testing.T) {
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Timestamp: tt})
|
||||
Timestamp: tt,
|
||||
})
|
||||
if !errors.Is(err, nil) {
|
||||
t.Errorf("received: %v, expected: %v", err, nil)
|
||||
}
|
||||
@@ -194,7 +198,8 @@ func TestGetLatestHoldingsForAllCurrencies(t *testing.T) {
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Timestamp: tt})
|
||||
Timestamp: tt,
|
||||
})
|
||||
if !errors.Is(err, nil) {
|
||||
t.Errorf("received: %v, expected: %v", err, nil)
|
||||
}
|
||||
@@ -238,7 +243,8 @@ func TestViewHoldingAtTimePeriod(t *testing.T) {
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Timestamp: tt})
|
||||
Timestamp: tt,
|
||||
})
|
||||
if !errors.Is(err, nil) {
|
||||
t.Errorf("received: %v, expected: %v", err, nil)
|
||||
}
|
||||
@@ -247,7 +253,8 @@ func TestViewHoldingAtTimePeriod(t *testing.T) {
|
||||
Exchange: testExchange,
|
||||
Asset: asset.Spot,
|
||||
Pair: currency.NewPair(currency.BTC, currency.USDT),
|
||||
Timestamp: tt.Add(time.Hour)})
|
||||
Timestamp: tt.Add(time.Hour),
|
||||
})
|
||||
if !errors.Is(err, nil) {
|
||||
t.Errorf("received: %v, expected: %v", err, nil)
|
||||
}
|
||||
@@ -1068,7 +1075,7 @@ func TestGetHoldingsForTime(t *testing.T) {
|
||||
func TestGetPositions(t *testing.T) {
|
||||
t.Parallel()
|
||||
p := &Portfolio{}
|
||||
var expectedError = common.ErrNilEvent
|
||||
expectedError := common.ErrNilEvent
|
||||
_, err := p.GetPositions(nil)
|
||||
if !errors.Is(err, expectedError) {
|
||||
t.Fatalf("received '%v' expected '%v'", err, expectedError)
|
||||
@@ -1096,7 +1103,7 @@ func TestGetPositions(t *testing.T) {
|
||||
func TestGetLatestPNLForEvent(t *testing.T) {
|
||||
t.Parallel()
|
||||
p := &Portfolio{}
|
||||
var expectedError = common.ErrNilEvent
|
||||
expectedError := common.ErrNilEvent
|
||||
_, err := p.GetLatestPNLForEvent(nil)
|
||||
if !errors.Is(err, expectedError) {
|
||||
t.Fatalf("received '%v' expected '%v'", err, expectedError)
|
||||
@@ -1349,7 +1356,7 @@ func TestGetDirection(t *testing.T) {
|
||||
|
||||
func TestCannotPurchase(t *testing.T) {
|
||||
t.Parallel()
|
||||
var expectedError = common.ErrNilEvent
|
||||
expectedError := common.ErrNilEvent
|
||||
_, err := cannotPurchase(nil, nil)
|
||||
if !errors.Is(err, expectedError) {
|
||||
t.Fatalf("received '%v' expected '%v'", err, expectedError)
|
||||
|
||||
@@ -104,6 +104,7 @@ func TestMaximumBuySizeEqualZero(t *testing.T) {
|
||||
t.Errorf("expected: %v, received %v, err: %+v", buyLimit, amount, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaximumSellSizeEqualZero(t *testing.T) {
|
||||
t.Parallel()
|
||||
globalMinMax := exchange.MinMax{
|
||||
|
||||
@@ -227,7 +227,7 @@ func sortSignals(d []data.Handler) ([]cashCarrySignals, error) {
|
||||
if len(d) == 0 {
|
||||
return nil, base.ErrNoDataToProcess
|
||||
}
|
||||
var carryMap = make(map[*currency.Item]map[*currency.Item]cashCarrySignals, len(d))
|
||||
carryMap := make(map[*currency.Item]map[*currency.Item]cashCarrySignals, len(d))
|
||||
for i := range d {
|
||||
l, err := d[i].Latest()
|
||||
if err != nil {
|
||||
|
||||
@@ -186,7 +186,7 @@ func TestSortSignals(t *testing.T) {
|
||||
func TestCreateSignals(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := Strategy{}
|
||||
var expectedError = gctcommon.ErrNilPointer
|
||||
expectedError := gctcommon.ErrNilPointer
|
||||
_, err := s.createSignals(nil, nil, nil, decimal.Zero, false)
|
||||
if !errors.Is(err, expectedError) {
|
||||
t.Errorf("received '%v' expected '%v", err, expectedError)
|
||||
|
||||
@@ -116,21 +116,27 @@ type customStrategy struct {
|
||||
func (s *customStrategy) Name() string {
|
||||
return "custom-strategy"
|
||||
}
|
||||
|
||||
func (s *customStrategy) Description() string {
|
||||
return "this is a demonstration of loading strategies via custom plugins"
|
||||
}
|
||||
|
||||
func (s *customStrategy) SupportsSimultaneousProcessing() bool {
|
||||
return s.allowSimultaneousProcessing
|
||||
}
|
||||
|
||||
func (s *customStrategy) OnSignal(d data.Handler, _ funding.IFundingTransferer, _ portfolio.Handler) (signal.Event, error) {
|
||||
return s.createSignal(d)
|
||||
}
|
||||
|
||||
func (s *customStrategy) OnSimultaneousSignals(_ []data.Handler, _ funding.IFundingTransferer, _ portfolio.Handler) ([]signal.Event, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *customStrategy) createSignal(_ data.Handler) (*signal.Signal, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *customStrategy) SetCustomSettings(map[string]interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -160,6 +160,7 @@ func TestGetFillDependentEvent(t *testing.T) {
|
||||
t.Errorf("received '%v' expected '%v'", k.GetFillDependentEvent(), decimal.NewFromInt(1337))
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsClosingPosition(t *testing.T) {
|
||||
t.Parallel()
|
||||
k := Order{
|
||||
|
||||
@@ -27,7 +27,8 @@ func TestCollateralTakeProfit(t *testing.T) {
|
||||
asset: asset.Futures,
|
||||
isCollateral: true,
|
||||
},
|
||||
contract: &Item{asset: asset.Futures,
|
||||
contract: &Item{
|
||||
asset: asset.Futures,
|
||||
available: decimal.NewFromInt(1),
|
||||
},
|
||||
}
|
||||
@@ -287,7 +288,8 @@ func TestCollateralLiquidate(t *testing.T) {
|
||||
isCollateral: true,
|
||||
available: decimal.NewFromInt(1337),
|
||||
},
|
||||
contract: &Item{asset: asset.Futures,
|
||||
contract: &Item{
|
||||
asset: asset.Futures,
|
||||
available: decimal.NewFromInt(1337),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ func (f *FundManager) UpdateAllCollateral(isLive, initialFundsSet bool) error {
|
||||
if usd.IsZero() && exchangeCollateralCalculator.CalculateOffline {
|
||||
continue
|
||||
}
|
||||
var side = gctorder.Buy
|
||||
side := gctorder.Buy
|
||||
if !f.items[y].available.GreaterThan(decimal.Zero) {
|
||||
side = gctorder.Sell
|
||||
}
|
||||
@@ -718,7 +718,7 @@ func (f *FundManager) UpdateCollateralForEvent(ev common.Event, isLive bool) err
|
||||
if usd.IsZero() {
|
||||
continue
|
||||
}
|
||||
var side = gctorder.Buy
|
||||
side := gctorder.Buy
|
||||
if !f.items[i].available.GreaterThan(decimal.Zero) {
|
||||
side = gctorder.Sell
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrNotCollateral is returned when a user requests collateral pair details when it is a funding pair
|
||||
ErrNotCollateral = errors.New("not a collateral pair")
|
||||
)
|
||||
// ErrNotCollateral is returned when a user requests collateral pair details when it is a funding pair
|
||||
var ErrNotCollateral = errors.New("not a collateral pair")
|
||||
|
||||
// BaseInitialFunds returns the initial funds
|
||||
// from the base in a currency pair
|
||||
|
||||
@@ -20,8 +20,10 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/signaler"
|
||||
)
|
||||
|
||||
var singleTaskStrategyPath, templatePath, outputPath, btConfigDir, strategyPluginPath, pprofURL string
|
||||
var printLogo, generateReport, darkReport, colourOutput, logSubHeader, enablePProf bool
|
||||
var (
|
||||
singleTaskStrategyPath, templatePath, outputPath, btConfigDir, strategyPluginPath, pprofURL string
|
||||
printLogo, generateReport, darkReport, colourOutput, logSubHeader, enablePProf bool
|
||||
)
|
||||
|
||||
func main() {
|
||||
wd, err := os.Getwd()
|
||||
|
||||
@@ -50,6 +50,7 @@ func (s *CustomStrategy) SupportsSimultaneousProcessing() bool {
|
||||
func (s *CustomStrategy) OnSignal(d data.Handler, _ funding.IFundingTransferer, _ portfolio.Handler) (signal.Event, error) {
|
||||
return s.createSignal(d)
|
||||
}
|
||||
|
||||
func (s *CustomStrategy) OnSimultaneousSignals(_ []data.Handler, _ funding.IFundingTransferer, _ portfolio.Handler) ([]signal.Event, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user