adjust max query limiter and sync before running trader

This commit is contained in:
c9s 2021-02-22 16:54:08 +08:00
parent e93b5a1868
commit 21a4669905
3 changed files with 11 additions and 7 deletions

View File

@ -108,6 +108,10 @@ func runConfig(basectx context.Context, userConfig *bbgo.Config, enableApiServer
return err return err
} }
if err := environ.Sync(ctx) ; err != nil {
return err
}
trader := bbgo.NewTrader(environ) trader := bbgo.NewTrader(environ)
if err := trader.Configure(userConfig); err != nil { if err := trader.Configure(userConfig); err != nil {
return err return err

View File

@ -19,9 +19,9 @@ import (
"github.com/c9s/bbgo/pkg/util" "github.com/c9s/bbgo/pkg/util"
) )
var closedOrderQueryLimiter = rate.NewLimiter(rate.Every(10*time.Second), 1) var closedOrderQueryLimiter = rate.NewLimiter(rate.Every(6*time.Second), 1)
var tradeQuerylimiter = rate.NewLimiter(rate.Every(5*time.Second), 1) var tradeQueryLimiter = rate.NewLimiter(rate.Every(4*time.Second), 1)
var accountQuerylimiter = rate.NewLimiter(rate.Every(5*time.Second), 1) var accountQueryLimiter = rate.NewLimiter(rate.Every(5*time.Second), 1)
var marketDataLimiter = rate.NewLimiter(rate.Every(5*time.Second), 1) var marketDataLimiter = rate.NewLimiter(rate.Every(5*time.Second), 1)
var log = logrus.WithField("exchange", "max") var log = logrus.WithField("exchange", "max")
@ -376,7 +376,7 @@ func (e *Exchange) PlatformFeeCurrency() string {
} }
func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) { func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) {
if err := accountQuerylimiter.Wait(ctx) ; err != nil { if err := accountQueryLimiter.Wait(ctx) ; err != nil {
return nil, err return nil, err
} }
@ -521,7 +521,7 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
} }
func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error) { func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error) {
if err := accountQuerylimiter.Wait(ctx) ; err != nil { if err := accountQueryLimiter.Wait(ctx) ; err != nil {
return nil, err return nil, err
} }
@ -544,7 +544,7 @@ func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap,
} }
func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) (trades []types.Trade, err error) { func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) (trades []types.Trade, err error) {
if err := tradeQuerylimiter.Wait(ctx) ; err != nil { if err := tradeQueryLimiter.Wait(ctx) ; err != nil {
return nil, err return nil, err
} }

View File

@ -122,7 +122,7 @@ func (s *Strategy) generateGridBuyOrders(session *bbgo.ExchangeSession) ([]types
} }
if currentPrice > upBand || currentPrice < downBand { if currentPrice > upBand || currentPrice < downBand {
return nil, fmt.Errorf("current price exceed the bollinger band") return nil, fmt.Errorf("current price %f exceed the bollinger band %f <> %f", currentPrice, upBand, downBand)
} }
ema99 := s.StandardIndicatorSet.EWMA(types.IntervalWindow{Interval: s.Interval, Window: 99}) ema99 := s.StandardIndicatorSet.EWMA(types.IntervalWindow{Interval: s.Interval, Window: 99})