Skip to content

Commit

Permalink
FEATURE: [xalign] add notification when order quote is over alert amount
Browse files Browse the repository at this point in the history
  • Loading branch information
kbearXD committed Oct 24, 2024
1 parent 738cb24 commit 52ec12a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/xalign.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ crossExchangeStrategies:
USDT: 100
USDC: 100
TWD: 3000
alertAmounts:
USDT: 200
USDC: 200
TWD: 6000
11 changes: 11 additions & 0 deletions pkg/strategy/xalign/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Strategy struct {
BalanceToleranceRange fixedpoint.Value `json:"balanceToleranceRange"`
Duration types.Duration `json:"for"`
MaxAmounts map[string]fixedpoint.Value `json:"maxAmounts"`
AlertAmounts map[string]fixedpoint.Value `json:"alertAmounts"`

SlackNotify bool `json:"slackNotify"`
SlackNotifyMentions []string `json:"slackNotifyMentions"`
Expand Down Expand Up @@ -304,6 +305,11 @@ func (s *Strategy) selectSessionForCurrency(
}
}

alertAmount, ok := s.AlertAmounts[market.QuoteCurrency]
if ok && requiredQuoteAmount.Compare(alertAmount) > 0 {
bbgo.Notify("quote amount %s is greater than %s, please check it", requiredQuoteAmount.String(), alertAmount.String())
}

maxAmount, ok := s.MaxAmounts[market.QuoteCurrency]
if ok && requiredQuoteAmount.Compare(maxAmount) > 0 {
log.Infof("adjusted required quote ammount %f %s by max amount %f %s", requiredQuoteAmount.Float64(), market.QuoteCurrency, maxAmount.Float64(), market.QuoteCurrency)
Expand Down Expand Up @@ -349,6 +355,11 @@ func (s *Strategy) selectSessionForCurrency(
continue
}

alertAmount, ok := s.AlertAmounts[market.QuoteCurrency]
if ok && q.Compare(alertAmount) > 0 {
bbgo.Notify("quote amount %s is greater than %s, please check it", q.String(), alertAmount.String())
}

maxAmount, ok := s.MaxAmounts[market.QuoteCurrency]
if ok {
q = bbgo.AdjustQuantityByMaxAmount(q, price, maxAmount)
Expand Down

0 comments on commit 52ec12a

Please sign in to comment.