xmaker: bind price solver with market data stream

This commit is contained in:
c9s 2024-09-27 18:31:18 +08:00
parent e8c063c09b
commit be353c533b
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -1398,7 +1398,6 @@ func (s *Strategy) CrossRun(
// initialize the price resolver
sourceMarkets := s.sourceSession.Markets()
s.priceSolver = pricesolver.NewSimplePriceResolver(sourceMarkets)
makerSession, ok := sessions[s.MakerExchange]
if !ok {
@ -1475,6 +1474,9 @@ func (s *Strategy) CrossRun(
})
}
s.priceSolver = pricesolver.NewSimplePriceResolver(sourceMarkets)
s.priceSolver.BindStream(s.sourceSession.MarketDataStream)
s.sourceSession.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(k types.KLine) {
s.priceSolver.Update(k.Symbol, k.Close)
feeToken := s.sourceSession.Exchange.PlatformFeeCurrency()