xdepthmaker: run profit fixer before s.CrossExchangeMarketMakingStrategy.Initialize

This commit is contained in:
c9s 2024-03-06 12:53:36 +08:00
parent ac43937847
commit 31676cce8e
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -319,19 +319,6 @@ func (s *Strategy) CrossRun(
log.Infof("makerSession: %s hedgeSession: %s", makerSession.Name, hedgeSession.Name) 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 != nil {
if s.ProfitFixerConfig.TradesSince.Time().IsZero() { if s.ProfitFixerConfig.TradesSince.Time().IsZero() {
return errors.New("tradesSince time can not be zero") 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 { if s.RecoverTrade {
go s.runTradeRecover(ctx) go s.runTradeRecover(ctx)
} }