xalign: allocate and bind order store

This commit is contained in:
c9s 2023-06-13 23:23:41 +08:00
parent 45aaad1629
commit 1fd52f78a9
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -37,6 +37,8 @@ type Strategy struct {
sessions map[string]*bbgo.ExchangeSession
orderBooks map[string]*bbgo.ActiveOrderBook
orderStore *bbgo.OrderStore
}
func (s *Strategy) ID() string {
@ -222,12 +224,16 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
s.sessions = make(map[string]*bbgo.ExchangeSession)
s.orderBooks = make(map[string]*bbgo.ActiveOrderBook)
s.orderStore = bbgo.NewOrderStore("")
for _, sessionName := range s.PreferredSessions {
session, ok := sessions[sessionName]
if !ok {
return fmt.Errorf("incorrect preferred session name: %s is not defined", sessionName)
}
s.orderStore.BindStream(session.UserDataStream)
orderBook := bbgo.NewActiveOrderBook("")
orderBook.BindStream(session.UserDataStream)