Skip to content

Commit

Permalink
FIX: [xalign] verify LargetAmountAlert is not nil
Browse files Browse the repository at this point in the history
  • Loading branch information
kbearXD committed Nov 12, 2024
1 parent b57c54d commit 44ca46c
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions pkg/strategy/xalign/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,27 +593,29 @@ func (s *Strategy) align(ctx context.Context, sessions map[string]*bbgo.Exchange
}
}

if price, ok := s.priceResolver.ResolvePrice(currency, s.LargeAmountAlert.QuoteCurrency); ok {
quantity := q.Abs()
amount := price.Mul(quantity)
if amount.Compare(s.LargeAmountAlert.Amount) > 0 {
alert := &LargeAmountAlert{
QuoteCurrency: s.LargeAmountAlert.QuoteCurrency,
AlertAmount: s.LargeAmountAlert.Amount,
SlackMentions: s.LargeAmountAlert.SlackMentions,
BaseCurrency: currency,
Price: price,
Quantity: quantity,
Amount: amount,
}
if s.LargeAmountAlert != nil {
if price, ok := s.priceResolver.ResolvePrice(currency, s.LargeAmountAlert.QuoteCurrency); ok {
quantity := q.Abs()
amount := price.Mul(quantity)
if amount.Compare(s.LargeAmountAlert.Amount) > 0 {
alert := &LargeAmountAlert{
QuoteCurrency: s.LargeAmountAlert.QuoteCurrency,
AlertAmount: s.LargeAmountAlert.Amount,
SlackMentions: s.LargeAmountAlert.SlackMentions,
BaseCurrency: currency,
Price: price,
Quantity: quantity,
Amount: amount,
}

if q.Sign() > 0 {
alert.Side = types.SideTypeBuy
} else {
alert.Side = types.SideTypeSell
}
if q.Sign() > 0 {
alert.Side = types.SideTypeBuy
} else {
alert.Side = types.SideTypeSell
}

bbgo.Notify(alert)
bbgo.Notify(alert)
}
}
}

Expand Down

0 comments on commit 44ca46c

Please sign in to comment.