Skip to content

Commit

Permalink
xdepthmaker: initialize s.CrossExchangeMarketMakingStrategy in Initia…
Browse files Browse the repository at this point in the history
…lize()
  • Loading branch information
c9s committed Dec 18, 2023
1 parent c71152d commit f19ed7a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/strategy/xdepthmaker/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ func (s *Strategy) InstanceID() string {
return fmt.Sprintf("%s:%s", ID, s.Symbol)
}

func (s *Strategy) Initialize() error {
if s.CrossExchangeMarketMakingStrategy == nil {
s.CrossExchangeMarketMakingStrategy = &CrossExchangeMarketMakingStrategy{}
}

s.bidPriceHeartBeat = types.NewPriceHeartBeat(priceUpdateTimeout)
s.askPriceHeartBeat = types.NewPriceHeartBeat(priceUpdateTimeout)
return nil
}

func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) {
makerSession, hedgeSession, err := selectSessions2(sessions, s.MakerExchange, s.HedgeExchange)
if err != nil {
Expand Down Expand Up @@ -325,12 +335,6 @@ func (s *Strategy) Defaults() error {
return nil
}

func (s *Strategy) Initialize() error {
s.bidPriceHeartBeat = types.NewPriceHeartBeat(priceUpdateTimeout)
s.askPriceHeartBeat = types.NewPriceHeartBeat(priceUpdateTimeout)
return nil
}

func (s *Strategy) CrossRun(
ctx context.Context, _ bbgo.OrderExecutionRouter,
sessions map[string]*bbgo.ExchangeSession,
Expand All @@ -340,7 +344,6 @@ func (s *Strategy) CrossRun(
return err
}

s.CrossExchangeMarketMakingStrategy = &CrossExchangeMarketMakingStrategy{}
if err := s.CrossExchangeMarketMakingStrategy.Initialize(ctx, s.Environment, makerSession, hedgeSession, s.Symbol, ID, s.InstanceID()); err != nil {
return err
}
Expand Down

0 comments on commit f19ed7a

Please sign in to comment.