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

43
surge/max_vol.go Normal file
View File

@@ -0,0 +1,43 @@
package surge
import (
"fmt"
"github.com/banbox/banbot/config"
"github.com/banbox/banbot/strat"
ta "github.com/banbox/banta"
)
type volSta struct {
rate float64
}
func goMaxVol(pol *config.RunPolicyConfig) *strat.TradeStrat {
return &strat.TradeStrat{
WarmupNum: 100,
BatchInOut: true,
OnStartUp: func(s *strat.StratJob) {
s.More = &volSta{}
},
OnBar: func(s *strat.StratJob) {
e := s.Env
more, _ := s.More.(*volSta)
bigVolMa := ta.SMA(e.Volume, 100).Get(0)
more.rate = e.Volume.Get(0)/bigVolMa - 1
},
OnBatchJobs: func(jobs []*strat.StratJob) {
var maxIn, maxOut *strat.StratJob
var inVal, outVal float64
for _, j := range jobs {
sta, _ := j.More.(*volSta)
if sta.rate < outVal {
outVal = sta.rate
maxOut = j
} else if sta.rate > inVal {
inVal = sta.rate
maxIn = j
}
}
fmt.Printf("%v %v", maxIn, maxOut)
},
}
}