bbgo_origin/pkg/backtest/stream.go

42 lines
746 B
Go
Raw Permalink Normal View History

package backtest
import (
"context"
"github.com/sirupsen/logrus"
"github.com/c9s/bbgo/pkg/types"
)
var log = logrus.WithField("cmd", "backtest")
type Stream struct {
types.StandardStream
exchange *Exchange
}
func (s *Stream) Connect(ctx context.Context) error {
if s.PublicOnly {
if s.exchange.marketDataStream != nil {
panic("you should not set up more than 1 market data stream in back-test")
}
s.exchange.marketDataStream = s
} else {
// assign user data stream back
if s.exchange.userDataStream != nil {
panic("you should not set up more than 1 user data stream in back-test")
}
s.exchange.userDataStream = s
}
2021-12-25 14:37:38 +00:00
s.EmitConnect()
s.EmitStart()
return nil
}
2020-11-07 12:11:07 +00:00
func (s *Stream) Close() error {
return nil
}