mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-27 17:25:16 +00:00
make the method name clear UpdatePriceFromBalances
This commit is contained in:
parent
c13c33dcbb
commit
e3a2a857cd
|
@ -37,8 +37,8 @@ func NewAccountValueCalculator(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatePrices updates the price index from the existing balances
|
// UpdatePriceFromBalances updates the price index from the existing balances
|
||||||
func (c *AccountValueCalculator) UpdatePrices(ctx context.Context) error {
|
func (c *AccountValueCalculator) UpdatePriceFromBalances(ctx context.Context) error {
|
||||||
balances := c.session.Account.Balances()
|
balances := c.session.Account.Balances()
|
||||||
currencies := balances.Currencies()
|
currencies := balances.Currencies()
|
||||||
markets := c.session.Markets()
|
markets := c.session.Markets()
|
||||||
|
@ -227,7 +227,7 @@ func CalculateBaseQuantity(
|
||||||
} else if len(restBalances) > 1 {
|
} else if len(restBalances) > 1 {
|
||||||
priceSolver := pricesolver.NewSimplePriceResolver(session.Markets())
|
priceSolver := pricesolver.NewSimplePriceResolver(session.Markets())
|
||||||
accountValue := NewAccountValueCalculator(session, priceSolver, "USDT")
|
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
|
return fixedpoint.Zero, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ func CalculateQuoteQuantity(
|
||||||
priceSolver := pricesolver.NewSimplePriceResolver(session.Markets())
|
priceSolver := pricesolver.NewSimplePriceResolver(session.Markets())
|
||||||
|
|
||||||
accountValue := NewAccountValueCalculator(session, priceSolver, quoteCurrency)
|
accountValue := NewAccountValueCalculator(session, priceSolver, quoteCurrency)
|
||||||
if err := accountValue.UpdatePrices(ctx); err != nil {
|
if err := accountValue.UpdatePriceFromBalances(ctx); err != nil {
|
||||||
return fixedpoint.Zero, err
|
return fixedpoint.Zero, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
priceSolver := pricesolver.NewSimplePriceResolver(session.Markets())
|
priceSolver := pricesolver.NewSimplePriceResolver(session.Markets())
|
||||||
priceSolver.BindStream(s.session.MarketDataStream)
|
priceSolver.BindStream(s.session.MarketDataStream)
|
||||||
s.AccountValueCalculator = bbgo.NewAccountValueCalculator(s.session, priceSolver, s.Market.QuoteCurrency)
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
priceSolver.BindStream(session.MarketDataStream)
|
priceSolver.BindStream(session.MarketDataStream)
|
||||||
|
|
||||||
s.AccountValueCalculator = bbgo.NewAccountValueCalculator(s.session, priceSolver, s.Market.QuoteCurrency)
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -389,7 +389,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
|
|
||||||
// AccountValueCalculator
|
// AccountValueCalculator
|
||||||
s.AccountValueCalculator = bbgo.NewAccountValueCalculator(s.session, priceSolver, s.Market.QuoteCurrency)
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1316,7 +1316,7 @@ func (s *Strategy) accountUpdater(ctx context.Context) {
|
||||||
log.WithError(err).Errorf("unable to update account")
|
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")
|
log.WithError(err).Errorf("unable to update account value with prices")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1473,7 +1473,7 @@ func (s *Strategy) CrossRun(
|
||||||
s.priceSolver.BindStream(s.sourceSession.MarketDataStream)
|
s.priceSolver.BindStream(s.sourceSession.MarketDataStream)
|
||||||
|
|
||||||
s.accountValueCalculator = bbgo.NewAccountValueCalculator(s.sourceSession, s.priceSolver, s.sourceMarket.QuoteCurrency)
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user