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: [max] subscription filters not empty #1839

Merged
merged 2 commits into from
Nov 27, 2024
Merged
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
2 changes: 1 addition & 1 deletion pkg/exchange/max/maxapi/userdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func ParseUserEvent(v *fastjson.Value) (interface{}, error) {
case "trade_snapshot", "mwallet_trade_snapshot":
return parseTradeSnapshotEvent(v)

case "trade_update", "mwallet_trade_update":
case "trade_update", "trade_fast_update", "mwallet_trade_update":
return parseTradeUpdateEvent(v)

case "ad_ratio_snapshot", "ad_ratio_update":
Expand Down
22 changes: 15 additions & 7 deletions pkg/exchange/max/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,21 @@ func (s *Stream) handleConnect() {
if len(s.privateChannels) > 0 {
// TODO: maybe check the valid private channels
filters = s.privateChannels
} else if s.MarginSettings.IsMargin {
filters = []string{
"mwallet_order",
"mwallet_trade",
"mwallet_account",
"ad_ratio",
"borrowing",
} else {
if s.MarginSettings.IsMargin {
filters = []string{
"mwallet_order",
"mwallet_trade",
"mwallet_account",
"ad_ratio",
"borrowing",
}
} else {
filters = []string{
"order",
"trade",
"account",
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/strategy/xalign/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
// bind on trade to update price
session.UserDataStream.OnTradeUpdate(s.priceResolver.UpdateFromTrade)
}
log.Infof("large amount alert: %+v", s.LargeAmountAlert)

bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()
Expand Down Expand Up @@ -597,6 +598,7 @@ 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)
log.Infof("resolved price for currency: %s, price: %f, quantity: %f, amount: %f", currency, price.Float64(), quantity.Float64(), amount.Float64())
if amount.Compare(s.LargeAmountAlert.Amount) > 0 {
alert := &LargeAmountAlert{
QuoteCurrency: s.LargeAmountAlert.QuoteCurrency,
Expand All @@ -616,6 +618,8 @@ func (s *Strategy) align(ctx context.Context, sessions map[string]*bbgo.Exchange

bbgo.Notify(alert)
}
} else {
log.Info("price resolver can not resolve price, skip alert checking")
}
}

Expand Down
Loading