diff --git a/pkg/bbgo/account_value_calc.go b/pkg/bbgo/account_value_calc.go index a13e565ff..a5b44600d 100644 --- a/pkg/bbgo/account_value_calc.go +++ b/pkg/bbgo/account_value_calc.go @@ -37,8 +37,8 @@ func NewAccountValueCalculator( } } -// UpdatePrices updates the price index from the existing balances -func (c *AccountValueCalculator) UpdatePrices(ctx context.Context) error { +// UpdatePriceFromBalances updates the price index from the existing balances +func (c *AccountValueCalculator) UpdatePriceFromBalances(ctx context.Context) error { balances := c.session.Account.Balances() currencies := balances.Currencies() markets := c.session.Markets() @@ -227,7 +227,7 @@ func CalculateBaseQuantity( } else if len(restBalances) > 1 { priceSolver := pricesolver.NewSimplePriceResolver(session.Markets()) accountValue := NewAccountValueCalculator(session, priceSolver, "USDT") - if err := accountValue.UpdatePrices(context.Background()); err != nil { + if err := accountValue.UpdatePriceFromBalances(context.Background()); err != nil { return fixedpoint.Zero, err } @@ -336,7 +336,7 @@ func CalculateQuoteQuantity( priceSolver := pricesolver.NewSimplePriceResolver(session.Markets()) accountValue := NewAccountValueCalculator(session, priceSolver, quoteCurrency) - if err := accountValue.UpdatePrices(ctx); err != nil { + if err := accountValue.UpdatePriceFromBalances(ctx); err != nil { return fixedpoint.Zero, err } diff --git a/pkg/strategy/harmonic/strategy.go b/pkg/strategy/harmonic/strategy.go index ae7bd2628..fd6383f4d 100644 --- a/pkg/strategy/harmonic/strategy.go +++ b/pkg/strategy/harmonic/strategy.go @@ -263,7 +263,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se priceSolver := pricesolver.NewSimplePriceResolver(session.Markets()) priceSolver.BindStream(s.session.MarketDataStream) s.AccountValueCalculator = bbgo.NewAccountValueCalculator(s.session, priceSolver, s.Market.QuoteCurrency) - if err := s.AccountValueCalculator.UpdatePrices(ctx); err != nil { + if err := s.AccountValueCalculator.UpdatePriceFromBalances(ctx); err != nil { return err } diff --git a/pkg/strategy/irr/strategy.go b/pkg/strategy/irr/strategy.go index 4fd82526b..f2cdabfd5 100644 --- a/pkg/strategy/irr/strategy.go +++ b/pkg/strategy/irr/strategy.go @@ -260,7 +260,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se priceSolver.BindStream(session.MarketDataStream) s.AccountValueCalculator = bbgo.NewAccountValueCalculator(s.session, priceSolver, s.Market.QuoteCurrency) - if err := s.AccountValueCalculator.UpdatePrices(ctx); err != nil { + if err := s.AccountValueCalculator.UpdatePriceFromBalances(ctx); err != nil { return err } diff --git a/pkg/strategy/supertrend/strategy.go b/pkg/strategy/supertrend/strategy.go index 04f9b26b8..f838bb8b7 100644 --- a/pkg/strategy/supertrend/strategy.go +++ b/pkg/strategy/supertrend/strategy.go @@ -389,7 +389,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se // AccountValueCalculator s.AccountValueCalculator = bbgo.NewAccountValueCalculator(s.session, priceSolver, s.Market.QuoteCurrency) - if err := s.AccountValueCalculator.UpdatePrices(ctx); err != nil { + if err := s.AccountValueCalculator.UpdatePriceFromBalances(ctx); err != nil { return err } diff --git a/pkg/strategy/xmaker/strategy.go b/pkg/strategy/xmaker/strategy.go index dc113ee6a..635b24778 100644 --- a/pkg/strategy/xmaker/strategy.go +++ b/pkg/strategy/xmaker/strategy.go @@ -1316,7 +1316,7 @@ func (s *Strategy) accountUpdater(ctx context.Context) { log.WithError(err).Errorf("unable to update account") } - if err := s.accountValueCalculator.UpdatePrices(ctx); err != nil { + if err := s.accountValueCalculator.UpdatePriceFromBalances(ctx); err != nil { log.WithError(err).Errorf("unable to update account value with prices") return } @@ -1473,7 +1473,7 @@ func (s *Strategy) CrossRun( s.priceSolver.BindStream(s.sourceSession.MarketDataStream) s.accountValueCalculator = bbgo.NewAccountValueCalculator(s.sourceSession, s.priceSolver, s.sourceMarket.QuoteCurrency) - if err := s.accountValueCalculator.UpdatePrices(ctx); err != nil { + if err := s.accountValueCalculator.UpdatePriceFromBalances(ctx); err != nil { return err }