mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xalign: allocate and bind order store
This commit is contained in:
parent
45aaad1629
commit
1fd52f78a9
|
@ -37,6 +37,8 @@ type Strategy struct {
|
||||||
|
|
||||||
sessions map[string]*bbgo.ExchangeSession
|
sessions map[string]*bbgo.ExchangeSession
|
||||||
orderBooks map[string]*bbgo.ActiveOrderBook
|
orderBooks map[string]*bbgo.ActiveOrderBook
|
||||||
|
|
||||||
|
orderStore *bbgo.OrderStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Strategy) ID() string {
|
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.sessions = make(map[string]*bbgo.ExchangeSession)
|
||||||
s.orderBooks = make(map[string]*bbgo.ActiveOrderBook)
|
s.orderBooks = make(map[string]*bbgo.ActiveOrderBook)
|
||||||
|
|
||||||
|
s.orderStore = bbgo.NewOrderStore("")
|
||||||
|
|
||||||
for _, sessionName := range s.PreferredSessions {
|
for _, sessionName := range s.PreferredSessions {
|
||||||
session, ok := sessions[sessionName]
|
session, ok := sessions[sessionName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("incorrect preferred session name: %s is not defined", sessionName)
|
return fmt.Errorf("incorrect preferred session name: %s is not defined", sessionName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.orderStore.BindStream(session.UserDataStream)
|
||||||
|
|
||||||
orderBook := bbgo.NewActiveOrderBook("")
|
orderBook := bbgo.NewActiveOrderBook("")
|
||||||
orderBook.BindStream(session.UserDataStream)
|
orderBook.BindStream(session.UserDataStream)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user