Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: [xalign] add notification when order quote is over alert amount #1791

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to add a quoteCurrency config so that we can convert BTC, ETH into the quote currency

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and use a single field like slackAlertQuoteAmount as the threshold

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need a field named like slackAlertMentions

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check pkg/strategy/autoborrow/strategy.go for example.

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
Loading