From feb8f11105ae26503dcebfe08e9d5e1c8a1ca6f3 Mon Sep 17 00:00:00 2001 From: kbearXD Date: Tue, 26 Nov 2024 18:17:15 +0800 Subject: [PATCH 1/2] FIX: debug large amount alert --- pkg/strategy/xalign/strategy.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/strategy/xalign/strategy.go b/pkg/strategy/xalign/strategy.go index e22f2d8de6..92d797f69b 100644 --- a/pkg/strategy/xalign/strategy.go +++ b/pkg/strategy/xalign/strategy.go @@ -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() @@ -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, @@ -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") } } From aa21d89b8130063ea0df96b64f376a64091dbef9 Mon Sep 17 00:00:00 2001 From: kbearXD Date: Wed, 27 Nov 2024 16:43:48 +0800 Subject: [PATCH 2/2] FEATURE: [max] add default filters for subscription --- pkg/exchange/max/maxapi/userdata.go | 2 +- pkg/exchange/max/stream.go | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pkg/exchange/max/maxapi/userdata.go b/pkg/exchange/max/maxapi/userdata.go index fe7ae8441d..bb804449c4 100644 --- a/pkg/exchange/max/maxapi/userdata.go +++ b/pkg/exchange/max/maxapi/userdata.go @@ -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": diff --git a/pkg/exchange/max/stream.go b/pkg/exchange/max/stream.go index 9a78732b28..2dc10bfb2c 100644 --- a/pkg/exchange/max/stream.go +++ b/pkg/exchange/max/stream.go @@ -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", + } } }