mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
emacross, scmaker: fix strategy initialization
This commit is contained in:
parent
6abb320bce
commit
3dd93b65db
|
@ -46,12 +46,18 @@ func (s *Strategy) InstanceID() string {
|
|||
return fmt.Sprintf("%s:%s:%s:%d-%d", ID, s.Symbol, s.Interval, s.FastWindow, s.SlowWindow)
|
||||
}
|
||||
|
||||
func (s *Strategy) Initialize() error {
|
||||
if s.Strategy == nil {
|
||||
s.Strategy = &common.Strategy{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
|
||||
session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: s.Interval})
|
||||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
s.Strategy.Initialize(ctx, s.Environment, session, s.Market, ID, s.InstanceID())
|
||||
|
||||
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval5m, func(k types.KLine) {
|
||||
|
|
|
@ -70,7 +70,9 @@ type Strategy struct {
|
|||
}
|
||||
|
||||
func (s *Strategy) Initialize() error {
|
||||
s.Strategy = &common.Strategy{}
|
||||
if s.Strategy == nil {
|
||||
s.Strategy = &common.Strategy{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user