Merge pull request #1809 from c9s/chiahung/xalign/check-large-amount-alert-exist
Some checks are pending
Go / build (1.21, 6.2) (push) Waiting to run
golang-lint / lint (push) Waiting to run

FIX: [xalign] verify LargetAmountAlert is not nil
This commit is contained in:
kbearXD 2024-11-12 16:36:00 +08:00 committed by GitHub
commit 24e33fcdfd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)
}
}
}