diff --git a/pkg/bbgo/config_test.go b/pkg/bbgo/config_test.go index 0b15546a46..f20494c756 100644 --- a/pkg/bbgo/config_test.go +++ b/pkg/bbgo/config_test.go @@ -75,25 +75,16 @@ func TestLoadConfig(t *testing.T) { assert.Equal(t, map[string]interface{}{ "sessions": map[string]interface{}{ "max": map[string]interface{}{ - "exchange": "max", - "envVarPrefix": "MAX", - "takerFeeRate": 0., - "makerFeeRate": 0., - "modifyOrderAmountForFee": false, + "exchange": "max", + "envVarPrefix": "MAX", + "takerFeeRate": 0., + "makerFeeRate": 0., }, "binance": map[string]interface{}{ - "exchange": "binance", - "envVarPrefix": "BINANCE", - "takerFeeRate": 0., - "makerFeeRate": 0., - "modifyOrderAmountForFee": false, - }, - "ftx": map[string]interface{}{ - "exchange": "ftx", - "envVarPrefix": "FTX", - "takerFeeRate": 0., - "makerFeeRate": 0., - "modifyOrderAmountForFee": true, + "exchange": "binance", + "envVarPrefix": "BINANCE", + "takerFeeRate": 0., + "makerFeeRate": 0., }, }, "build": map[string]interface{}{ @@ -155,33 +146,6 @@ func TestLoadConfig(t *testing.T) { assert.NotNil(t, config.Persistence.Json) }, }, - - { - name: "order_executor", - args: args{configFile: "testdata/order_executor.yaml"}, - wantErr: false, - f: func(t *testing.T, config *Config) { - assert.Len(t, config.Sessions, 2) - - session, ok := config.Sessions["max"] - assert.True(t, ok) - assert.NotNil(t, session) - - riskControls := config.RiskControls - assert.NotNil(t, riskControls) - assert.NotNil(t, riskControls.SessionBasedRiskControl) - - conf, ok := riskControls.SessionBasedRiskControl["max"] - assert.True(t, ok) - assert.NotNil(t, conf) - assert.NotNil(t, conf.OrderExecutor) - assert.NotNil(t, conf.OrderExecutor.BySymbol) - - executorConf, ok := conf.OrderExecutor.BySymbol["BTCUSDT"] - assert.True(t, ok) - assert.NotNil(t, executorConf) - }, - }, { name: "backtest", args: args{configFile: "testdata/backtest.yaml"}, @@ -189,9 +153,9 @@ func TestLoadConfig(t *testing.T) { f: func(t *testing.T, config *Config) { assert.Len(t, config.ExchangeStrategies, 1) assert.NotNil(t, config.Backtest) - assert.NotNil(t, config.Backtest.Account) - assert.NotNil(t, config.Backtest.Account["binance"].Balances) - assert.Len(t, config.Backtest.Account["binance"].Balances, 2) + assert.NotNil(t, config.Backtest.Accounts) + assert.NotNil(t, config.Backtest.Accounts["binance"].Balances) + assert.Len(t, config.Backtest.Accounts["binance"].Balances, 2) }, }, } diff --git a/pkg/bbgo/session.go b/pkg/bbgo/session.go index 341846aebd..edf49332ad 100644 --- a/pkg/bbgo/session.go +++ b/pkg/bbgo/session.go @@ -48,10 +48,9 @@ type ExchangeSession struct { SubAccount string `json:"subAccount,omitempty" yaml:"subAccount,omitempty"` // Withdrawal is used for enabling withdrawal functions - Withdrawal bool `json:"withdrawal,omitempty" yaml:"withdrawal,omitempty"` - MakerFeeRate fixedpoint.Value `json:"makerFeeRate" yaml:"makerFeeRate"` - TakerFeeRate fixedpoint.Value `json:"takerFeeRate" yaml:"takerFeeRate"` - ModifyOrderAmountForFee bool `json:"modifyOrderAmountForFee" yaml:"modifyOrderAmountForFee"` + Withdrawal bool `json:"withdrawal,omitempty" yaml:"withdrawal,omitempty"` + MakerFeeRate fixedpoint.Value `json:"makerFeeRate" yaml:"makerFeeRate"` + TakerFeeRate fixedpoint.Value `json:"takerFeeRate" yaml:"takerFeeRate"` // PublicOnly is used for setting the session to public only (without authentication, no private user data) PublicOnly bool `json:"publicOnly,omitempty" yaml:"publicOnly"` @@ -319,16 +318,6 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment) } } - if session.ModifyOrderAmountForFee { - amountProtectExchange, ok := session.Exchange.(types.ExchangeAmountFeeProtect) - if !ok { - return fmt.Errorf("exchange %s does not support order amount protection", session.ExchangeName.String()) - } - - fees := types.ExchangeFee{MakerFeeRate: session.MakerFeeRate, TakerFeeRate: session.TakerFeeRate} - amountProtectExchange.SetModifyOrderAmountForFee(fees) - } - if session.UseHeikinAshi { // replace the existing market data stream session.MarketDataStream = &types.HeikinAshiStream{ diff --git a/pkg/bbgo/testdata/backtest.yaml b/pkg/bbgo/testdata/backtest.yaml index 7c96b81d25..2caced83b5 100644 --- a/pkg/bbgo/testdata/backtest.yaml +++ b/pkg/bbgo/testdata/backtest.yaml @@ -13,7 +13,7 @@ backtest: # see here for more details # https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp startTime: "2020-01-01" - account: + accounts: binance: makerFeeRate: 15 takerFeeRate: 15 diff --git a/pkg/bbgo/testdata/strategy.yaml b/pkg/bbgo/testdata/strategy.yaml index 9c1ecc4829..e04e630e1a 100644 --- a/pkg/bbgo/testdata/strategy.yaml +++ b/pkg/bbgo/testdata/strategy.yaml @@ -5,19 +5,11 @@ sessions: envVarPrefix: MAX takerFeeRate: 0 makerFeeRate: 0 - modifyOrderAmountForFee: false binance: exchange: binance envVarPrefix: BINANCE takerFeeRate: 0 makerFeeRate: 0 - modifyOrderAmountForFee: false - ftx: - exchange: ftx - envVarPrefix: FTX - takerFeeRate: 0 - makerFeeRate: 0 - modifyOrderAmountForFee: true exchangeStrategies: - on: ["binance"] diff --git a/pkg/types/exchange.go b/pkg/types/exchange.go index d4364cad21..6aaa1e8866 100644 --- a/pkg/types/exchange.go +++ b/pkg/types/exchange.go @@ -122,10 +122,6 @@ type ExchangeDefaultFeeRates interface { DefaultFeeRates() ExchangeFee } -type ExchangeAmountFeeProtect interface { - SetModifyOrderAmountForFee(ExchangeFee) -} - //go:generate mockgen -destination=mocks/mock_exchange_trade_history.go -package=mocks . ExchangeTradeHistoryService type ExchangeTradeHistoryService interface { QueryTrades(ctx context.Context, symbol string, options *TradeQueryOptions) ([]Trade, error)