Skip to content

Commit

Permalink
Merge pull request #1809 from c9s/chiahung/xalign/check-large-amount-…
Browse files Browse the repository at this point in the history
…alert-exist

FIX: [xalign] verify LargetAmountAlert is not nil
  • Loading branch information
kbearXD authored Nov 12, 2024
2 parents 751afdb + 44ca46c commit 24e33fc
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 24e33fc

Please sign in to comment.