mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
bollmaker: replace bollinger indicator with v2 indicator
This commit is contained in:
parent
f91a4c2979
commit
e3be2a8af6
|
@ -1,9 +1,10 @@
|
|||
package bollmaker
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"math"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/indicator"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
|
@ -27,7 +28,7 @@ type DynamicSpreadSettings struct {
|
|||
}
|
||||
|
||||
// Initialize dynamic spreads and preload SMAs
|
||||
func (ds *DynamicSpreadSettings) Initialize(symbol string, session *bbgo.ExchangeSession, neutralBoll, defaultBoll *indicator.BOLL) {
|
||||
func (ds *DynamicSpreadSettings) Initialize(symbol string, session *bbgo.ExchangeSession, neutralBoll, defaultBoll *indicator.BOLLStream) {
|
||||
switch {
|
||||
case ds.AmpSpreadSettings != nil:
|
||||
ds.AmpSpreadSettings.initialize(symbol, session)
|
||||
|
@ -163,11 +164,10 @@ type DynamicSpreadBollWidthRatioSettings struct {
|
|||
// A positive number. The greater factor, the sharper weighting function. Default set to 1.0 .
|
||||
Sensitivity float64 `json:"sensitivity"`
|
||||
|
||||
neutralBoll *indicator.BOLL
|
||||
defaultBoll *indicator.BOLL
|
||||
defaultBoll, neutralBoll *indicator.BOLLStream
|
||||
}
|
||||
|
||||
func (ds *DynamicSpreadBollWidthRatioSettings) initialize(neutralBoll, defaultBoll *indicator.BOLL) {
|
||||
func (ds *DynamicSpreadBollWidthRatioSettings) initialize(neutralBoll, defaultBoll *indicator.BOLLStream) {
|
||||
ds.neutralBoll = neutralBoll
|
||||
ds.defaultBoll = defaultBoll
|
||||
if ds.Sensitivity <= 0. {
|
||||
|
|
|
@ -158,10 +158,10 @@ type Strategy struct {
|
|||
groupID uint32
|
||||
|
||||
// defaultBoll is the BOLLINGER indicator we used for predicting the price.
|
||||
defaultBoll *indicator.BOLL
|
||||
defaultBoll *indicator.BOLLStream
|
||||
|
||||
// neutralBoll is the neutral price section
|
||||
neutralBoll *indicator.BOLL
|
||||
neutralBoll *indicator.BOLLStream
|
||||
|
||||
// StrategyController
|
||||
bbgo.StrategyController
|
||||
|
@ -465,8 +465,8 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
// StrategyController
|
||||
s.Status = types.StrategyStatusRunning
|
||||
|
||||
s.neutralBoll = s.StandardIndicatorSet.BOLL(s.NeutralBollinger.IntervalWindow, s.NeutralBollinger.BandWidth)
|
||||
s.defaultBoll = s.StandardIndicatorSet.BOLL(s.DefaultBollinger.IntervalWindow, s.DefaultBollinger.BandWidth)
|
||||
s.neutralBoll = session.Indicators(s.Symbol).BOLL(s.NeutralBollinger.IntervalWindow, s.NeutralBollinger.BandWidth)
|
||||
s.defaultBoll = session.Indicators(s.Symbol).BOLL(s.DefaultBollinger.IntervalWindow, s.DefaultBollinger.BandWidth)
|
||||
|
||||
// Setup dynamic spread
|
||||
if s.DynamicSpread.IsEnabled() {
|
||||
|
|
|
@ -11,16 +11,16 @@ const (
|
|||
UnknownTrend PriceTrend = "unknown"
|
||||
)
|
||||
|
||||
func detectPriceTrend(inc *indicator.BOLL, price float64) PriceTrend {
|
||||
func detectPriceTrend(inc *indicator.BOLLStream, price float64) PriceTrend {
|
||||
if inBetween(price, inc.DownBand.Last(0), inc.UpBand.Last(0)) {
|
||||
return NeutralTrend
|
||||
}
|
||||
|
||||
if price < inc.LastDownBand() {
|
||||
if price < inc.DownBand.Last(0) {
|
||||
return DownTrend
|
||||
}
|
||||
|
||||
if price > inc.LastUpBand() {
|
||||
if price > inc.UpBand.Last(0) {
|
||||
return UpTrend
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user