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

64
old/s01/v3.go Normal file
View File

@@ -0,0 +1,64 @@
package s01
import (
"github.com/banbox/banbot/config"
"github.com/banbox/banbot/core"
"github.com/banbox/banbot/strat"
ta "github.com/banbox/banta"
"math"
"slices"
)
func MainV3(pol *config.RunPolicyConfig) *strat.TradeStrat {
RsiSml = 100
watchBig := 5
watchSml := 3
threshold := float64(17)
return &strat.TradeStrat{
Version: 1,
WarmupNum: RsiBig,
MinTfScore: 0.75,
//DrawDownExit: true,
OnBar: func(s *strat.StratJob) {
e := s.Env
rsi := ta.RSI(e.Close, RsiSml)
sml := ta.SMA(rsi, watchSml)
big := ta.SMA(rsi, watchBig)
atr := ta.ATR(e.High, e.Low, e.Close, 14).Get(0)
crx := sml.Cross(big)
if crx != 1 && crx != -1 {
return
}
rsiVal := float64(0)
if rsi.Get(watchBig) > 50 {
rsiVal = slices.Max(rsi.Range(0, watchBig*2))
} else {
rsiVal = slices.Min(rsi.Range(0, watchBig*2))
}
if math.Abs(rsiVal-50) < threshold {
return
}
c := e.Close.Get(0)
if crx == -1 {
_ = s.CloseOrders(&strat.ExitReq{
Tag: "x_short",
Dirt: core.OdDirtShort,
})
_ = s.OpenOrder(&strat.EnterReq{
Tag: "long",
StopLoss: c - atr*10,
})
} else if crx == 1 {
_ = s.CloseOrders(&strat.ExitReq{
Tag: "x_long",
Dirt: core.OdDirtLong,
})
_ = s.OpenOrder(&strat.EnterReq{
Tag: "short",
Short: true,
StopLoss: c + atr*10,
})
}
},
}
}