init
This commit is contained in:
43
surge/max_vol.go
Normal file
43
surge/max_vol.go
Normal 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)
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user