This commit is contained in:
2026-08-24 20:53:21 +08:00
commit 6e78bba16a
287 changed files with 32443 additions and 0 deletions

71
old/s01/v1.go Normal file
View File

@@ -0,0 +1,71 @@
package s01
import (
"github.com/banbox/banbot/config"
"github.com/banbox/banbot/strat"
"github.com/banbox/banexg/log"
ta "github.com/banbox/banta"
"go.uber.org/zap"
"math"
)
/*
此策略对应python原始策略名为PivotRev
*/
func MainV1(pol *config.RunPolicyConfig) *strat.TradeStrat {
RsiBig = 60
RsiSml = 14
ThsBig = 20
ThsSml = 30
AtrLen = 14
return &strat.TradeStrat{
Version: 1,
WarmupNum: RsiBig,
MinTfScore: 0.75,
DrawDownExit: true,
OnBar: func(s *strat.StratJob) {
e := s.Env
ma5 := ta.EMA(e.Close, 5)
ma20 := ta.EMA(e.Close, 20)
maX := ma5.Cross(ma20)
rsiB := ta.RSI(e.Close, RsiBig).Get(0) - 50
rsiS := ta.RSI(e.Close, RsiSml).Get(0) - 50
atr := ta.ATR(e.High, e.Low, e.Close, AtrLen)
basev1AtrLen := int(math.Round(float64(AtrLen) * 4.3))
atrB := ta.Lowest(ta.Highest(atr, AtrLen), basev1AtrLen).Get(0)
if math.Abs(float64(maX)) == 1 {
// 均线交叉,顶底切换,允许开单
s.More = nil
} else if s.More != nil {
// 禁止开单
return
}
if math.Abs(rsiB) <= ThsBig || math.Abs(rsiS) <= ThsSml {
// 未触发阈值,不开单
return
}
s.More = true // 禁止同方向再次开单
isShort := rsiB > 0
odDirt := float64(1)
if isShort {
odDirt = -1
}
stopLoss := e.Close.Get(0) - max(atrB*3, atr.Get(0)*1.5)*odDirt
err := s.OpenOrder(&strat.EnterReq{
Tag: "enter",
Short: isShort,
StopLoss: stopLoss,
})
if err != nil {
log.Error("open order fail", zap.String("pair", s.Symbol.Symbol),
zap.String("stagy", s.Strat.Name), zap.Error(err))
}
},
}
}