mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 16:55:15 +00:00
support: fix long term ema kline subscription
This commit is contained in:
parent
f97eb8914a
commit
01de2c5f66
|
@ -20,6 +20,8 @@ const stateKey = "state-v1"
|
||||||
|
|
||||||
var log = logrus.WithField("strategy", ID)
|
var log = logrus.WithField("strategy", ID)
|
||||||
|
|
||||||
|
var zeroiw = types.IntervalWindow{}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
bbgo.RegisterStrategy(ID, &Strategy{})
|
bbgo.RegisterStrategy(ID, &Strategy{})
|
||||||
}
|
}
|
||||||
|
@ -98,6 +100,10 @@ func (s *Strategy) Validate() error {
|
||||||
|
|
||||||
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
|
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
|
||||||
session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: string(s.Interval)})
|
session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: string(s.Interval)})
|
||||||
|
|
||||||
|
if s.LongTermMovingAverage != zeroiw {
|
||||||
|
session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: string(s.LongTermMovingAverage.Interval)})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Strategy) SaveState() error {
|
func (s *Strategy) SaveState() error {
|
||||||
|
@ -280,7 +286,6 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
return fmt.Errorf("standardIndicatorSet is nil, symbol %s", s.Symbol)
|
return fmt.Errorf("standardIndicatorSet is nil, symbol %s", s.Symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
var zeroiw = types.IntervalWindow{}
|
|
||||||
if s.LongTermMovingAverage != zeroiw {
|
if s.LongTermMovingAverage != zeroiw {
|
||||||
s.longTermEMA = standardIndicatorSet.EWMA(s.LongTermMovingAverage)
|
s.longTermEMA = standardIndicatorSet.EWMA(s.LongTermMovingAverage)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user