From 44ca46cbf216669e327606c8595b6e4489029c5c Mon Sep 17 00:00:00 2001 From: kbearXD Date: Tue, 12 Nov 2024 16:24:18 +0800 Subject: [PATCH] FIX: [xalign] verify LargetAmountAlert is not nil --- pkg/strategy/xalign/strategy.go | 40 +++++++++++++++++---------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/pkg/strategy/xalign/strategy.go b/pkg/strategy/xalign/strategy.go index 36c133dfc..e22f2d8de 100644 --- a/pkg/strategy/xalign/strategy.go +++ b/pkg/strategy/xalign/strategy.go @@ -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) + } } }