You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
package strategy |
|
|
|
import "sig-pub/pkg/types" |
|
|
|
// SuperTrendRSI 结合super trend和rsi指标策略 |
|
type SuperTrendRSI struct { |
|
} |
|
|
|
func (s *SuperTrendRSI) New() ISigStrategy { |
|
return &SuperTrendRSI{} |
|
} |
|
|
|
func (s *SuperTrendRSI) Meta() StrategyMeta { |
|
return StrategyMeta{ |
|
Name: "SuperTrendRSI", |
|
Desc: "金叉策略", |
|
Input: []types.InputArg{ |
|
{Name: "trendWindow", Type: types.InputTypeUInt, Desc: "SuperTrend ATR周期"}, |
|
{Name: "trendMultipiler", Type: types.InputTypeUInt, Desc: "SuperTrend multipiler"}, |
|
{Name: "rsiWindow", Type: types.InputTypeUInt, Desc: "rsi周期"}, |
|
}, |
|
} |
|
} |
|
|
|
// Init 校验参数, 并根据参数初始化策略 |
|
func (s *SuperTrendRSI) Init(input types.Input) (err error) { |
|
return |
|
} |
|
|
|
func (s *SuperTrendRSI) CandlePeriods(ctx ISingleSigStrategyContext) int16 { |
|
return max( |
|
ctx.Indicator("SuperTrend", types.Input{ |
|
"window": ctx.Input().Int16("trendPeriod"), |
|
"mul": ctx.Input().Int16("trendMultipiler"), |
|
}).CandlePeriods(), |
|
ctx.Indicator("RSI", types.Input{"window": ctx.Input().Int16("rsiWindow")}).CandlePeriods(), |
|
) |
|
} |
|
|
|
func (s *SuperTrendRSI) Update(ctx ISingleSigStrategyContext) (side types.Side) { |
|
superTrend := ctx.Indicator("SuperTrend", types.Input{ |
|
"window": ctx.Input().Int16("trendPeriod"), |
|
"mul": ctx.Input().Int16("trendMultipiler"), |
|
}) |
|
rsi := ctx.Indicator("RSI", types.Input{"window": ctx.Input().Int16("rsiWindow")}) |
|
|
|
_, _ = superTrend, rsi |
|
|
|
return |
|
}
|
|
|