From ac43937847e39e0c50777bfc6e46359883e2c9eb Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 6 Mar 2024 12:48:48 +0800 Subject: [PATCH 1/4] xdepthmaker: add disable hedge option --- pkg/strategy/xdepthmaker/strategy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/xdepthmaker/strategy.go b/pkg/strategy/xdepthmaker/strategy.go index 4ab8027399..b82111c9ed 100644 --- a/pkg/strategy/xdepthmaker/strategy.go +++ b/pkg/strategy/xdepthmaker/strategy.go @@ -181,6 +181,8 @@ type Strategy struct { // MaxExposurePosition defines the unhedged quantity of stop MaxExposurePosition fixedpoint.Value `json:"maxExposurePosition"` + DisableHedge bool `json:"disableHedge"` + NotifyTrade bool `json:"notifyTrade"` // RecoverTrade tries to find the missing trades via the REStful API @@ -441,7 +443,9 @@ func (s *Strategy) CrossRun( uncoverPosition, ) - s.Hedge(ctx, uncoverPosition.Neg()) + if !s.DisableHedge { + s.Hedge(ctx, uncoverPosition.Neg()) + } } } } From 31676cce8e27a91e9b06a612648242d40b04c78a Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 6 Mar 2024 12:53:36 +0800 Subject: [PATCH 2/4] xdepthmaker: run profit fixer before s.CrossExchangeMarketMakingStrategy.Initialize --- pkg/strategy/xdepthmaker/strategy.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/strategy/xdepthmaker/strategy.go b/pkg/strategy/xdepthmaker/strategy.go index b82111c9ed..e1dafdfcbc 100644 --- a/pkg/strategy/xdepthmaker/strategy.go +++ b/pkg/strategy/xdepthmaker/strategy.go @@ -319,19 +319,6 @@ func (s *Strategy) CrossRun( log.Infof("makerSession: %s hedgeSession: %s", makerSession.Name, hedgeSession.Name) - if err := s.CrossExchangeMarketMakingStrategy.Initialize(ctx, s.Environment, makerSession, hedgeSession, s.Symbol, ID, s.InstanceID()); err != nil { - return err - } - - s.pricingBook = types.NewStreamBook(s.Symbol) - s.pricingBook.BindStream(s.hedgeSession.MarketDataStream) - - s.stopC = make(chan struct{}) - - s.authedC = make(chan struct{}, 5) - bindAuthSignal(ctx, s.makerSession.UserDataStream, s.authedC) - bindAuthSignal(ctx, s.hedgeSession.UserDataStream, s.authedC) - if s.ProfitFixerConfig != nil { if s.ProfitFixerConfig.TradesSince.Time().IsZero() { return errors.New("tradesSince time can not be zero") @@ -349,6 +336,19 @@ func (s *Strategy) CrossRun( } } + if err := s.CrossExchangeMarketMakingStrategy.Initialize(ctx, s.Environment, makerSession, hedgeSession, s.Symbol, ID, s.InstanceID()); err != nil { + return err + } + + s.pricingBook = types.NewStreamBook(s.Symbol) + s.pricingBook.BindStream(s.hedgeSession.MarketDataStream) + + s.stopC = make(chan struct{}) + + s.authedC = make(chan struct{}, 5) + bindAuthSignal(ctx, s.makerSession.UserDataStream, s.authedC) + bindAuthSignal(ctx, s.hedgeSession.UserDataStream, s.authedC) + if s.RecoverTrade { go s.runTradeRecover(ctx) } From 1fb7262aaea2c96254ae7dd2c263ff199073601a Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 6 Mar 2024 13:12:57 +0800 Subject: [PATCH 3/4] xdepthmaker: adjust default update interval --- pkg/strategy/xdepthmaker/strategy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/strategy/xdepthmaker/strategy.go b/pkg/strategy/xdepthmaker/strategy.go index e1dafdfcbc..7357f02118 100644 --- a/pkg/strategy/xdepthmaker/strategy.go +++ b/pkg/strategy/xdepthmaker/strategy.go @@ -269,7 +269,7 @@ func (s *Strategy) Validate() error { func (s *Strategy) Defaults() error { if s.UpdateInterval == 0 { - s.UpdateInterval = types.Duration(time.Second) + s.UpdateInterval = types.Duration(5 * time.Second) } if s.FullReplenishInterval == 0 { From ad9163f7da1c2a057a48ab3f4eb344c7fa73211d Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 6 Mar 2024 13:13:18 +0800 Subject: [PATCH 4/4] xdepthmaker: adjust FullReplenishInterval to 10min --- pkg/strategy/xdepthmaker/strategy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/strategy/xdepthmaker/strategy.go b/pkg/strategy/xdepthmaker/strategy.go index 7357f02118..9e2f10d693 100644 --- a/pkg/strategy/xdepthmaker/strategy.go +++ b/pkg/strategy/xdepthmaker/strategy.go @@ -273,7 +273,7 @@ func (s *Strategy) Defaults() error { } if s.FullReplenishInterval == 0 { - s.FullReplenishInterval = types.Duration(15 * time.Minute) + s.FullReplenishInterval = types.Duration(10 * time.Minute) } if s.HedgeInterval == 0 {