strategy/supertrend: fix double dema missing interval

This commit is contained in:
Andy Cheng 2022-07-06 17:05:38 +08:00
parent 6c93c42ef6
commit 8aa5b706b6
2 changed files with 8 additions and 5 deletions

View File

@ -45,7 +45,9 @@ func (dd *DoubleDema) preloadDema(kLineStore *bbgo.MarketDataStore) {
}
// setupDoubleDema initializes double DEMA indicators
func (dd *DoubleDema) setupDoubleDema(kLineStore *bbgo.MarketDataStore) {
func (dd *DoubleDema) setupDoubleDema(kLineStore *bbgo.MarketDataStore, interval types.Interval) {
dd.Interval = interval
// DEMA
if dd.FastDEMAWindow == 0 {
dd.FastDEMAWindow = 144
@ -58,5 +60,6 @@ func (dd *DoubleDema) setupDoubleDema(kLineStore *bbgo.MarketDataStore) {
}
dd.slowDEMA = &indicator.DEMA{IntervalWindow: types.IntervalWindow{Interval: dd.Interval, Window: dd.SlowDEMAWindow}}
dd.slowDEMA.Bind(kLineStore)
dd.preloadDema(kLineStore)
}

View File

@ -56,6 +56,9 @@ type Strategy struct {
// Symbol is the market symbol you want to trade
Symbol string `json:"symbol"`
// Double DEMA
DoubleDema
// Interval is how long do you want to update your order price and quantity
Interval types.Interval `json:"interval"`
@ -67,9 +70,6 @@ type Strategy struct {
// SupertrendMultiplier ATR multiplier for calculation of supertrend
SupertrendMultiplier float64 `json:"supertrendMultiplier"`
// Double DEMA
DoubleDema
// LinearRegression Use linear regression as trend confirmation
LinearRegression *LinGre `json:"linearRegression,omitempty"`
@ -180,7 +180,7 @@ func (s *Strategy) setupIndicators() {
kLineStore, _ := s.session.MarketDataStore(s.Symbol)
// Double DEMA
s.setupDoubleDema(kLineStore)
s.setupDoubleDema(kLineStore, s.Interval)
// Supertrend
if s.SupertrendWindow == 0 {