Skip to content

Commit

Permalink
fix xalign max amount
Browse files Browse the repository at this point in the history
  • Loading branch information
narumiruna committed Mar 27, 2024
1 parent 5cd68d3 commit 2879913
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pkg/strategy/xalign/strategy.go
Expand Up @@ -185,6 +185,12 @@ func (s *Strategy) selectSessionForCurrency(

log.Infof("%s changeQuantity: %f ticker: %+v market: %+v", symbol, changeQuantity.Float64(), ticker, market)

maxAmount, ok := s.MaxAmounts[market.QuoteCurrency]
if ok {
q = bbgo.AdjustQuantityByMaxAmount(q, ticker.Sell, maxAmount)
log.Infof("adjusted quantity %f %s by max amount %f %s", q.Float64(), market.BaseCurrency, maxAmount.Float64(), market.QuoteCurrency)
}

switch side {

case types.SideTypeBuy:
Expand Down Expand Up @@ -230,12 +236,6 @@ func (s *Strategy) selectSessionForCurrency(
}
}

maxAmount, ok := s.MaxAmounts[market.QuoteCurrency]
if ok {
requiredQuoteAmount = bbgo.AdjustQuantityByMaxAmount(requiredQuoteAmount, price, maxAmount)
log.Infof("adjusted quantity %f %s by max amount %f %s", requiredQuoteAmount.Float64(), market.BaseCurrency, maxAmount.Float64(), market.QuoteCurrency)
}

if quantity, ok := market.GreaterThanMinimalOrderQuantity(side, price, requiredQuoteAmount); ok {
return session, &types.SubmitOrder{
Symbol: symbol,
Expand Down Expand Up @@ -274,12 +274,6 @@ func (s *Strategy) selectSessionForCurrency(
continue
}

maxAmount, ok := s.MaxAmounts[market.QuoteCurrency]
if ok {
q = bbgo.AdjustQuantityByMaxAmount(q, price, maxAmount)
log.Infof("adjusted quantity %f %s by max amount %f %s", q.Float64(), market.BaseCurrency, maxAmount.Float64(), market.QuoteCurrency)
}

if quantity, ok := market.GreaterThanMinimalOrderQuantity(side, price, q); ok {
return session, &types.SubmitOrder{
Symbol: symbol,
Expand Down

0 comments on commit 2879913

Please sign in to comment.