init
This commit is contained in:
53
trend/fastio.go
Normal file
53
trend/fastio.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package trend
|
||||
|
||||
import (
|
||||
"github.com/banbox/banbot/config"
|
||||
"github.com/banbox/banbot/orm/ormo"
|
||||
"github.com/banbox/banbot/strat"
|
||||
ta "github.com/banbox/banta"
|
||||
"math"
|
||||
)
|
||||
|
||||
func fastIO(p *config.RunPolicyConfig) *strat.TradeStrat {
|
||||
lenAtr := 15
|
||||
baseAtrLen := int(math.Round(float64(lenAtr) * 4.3))
|
||||
return &strat.TradeStrat{
|
||||
WarmupNum: 100,
|
||||
EachMaxLong: 1,
|
||||
EachMaxShort: 1,
|
||||
DrawDownExit: true,
|
||||
OnBar: func(s *strat.StratJob) {
|
||||
e := s.Env
|
||||
rsi4 := ta.RSI50(e.Close, 4).Get(0)
|
||||
rsi14 := ta.RSI50(e.Close, 14).Get(0)
|
||||
atr := ta.ATR(e.High, e.Low, e.Close, lenAtr)
|
||||
atrBase := ta.Lowest(ta.Highest(atr, lenAtr), baseAtrLen).Get(0)
|
||||
|
||||
if rsi4 > 30 && rsi14 > 25 && rsi14 < 40 {
|
||||
s.OpenOrder(&strat.EnterReq{
|
||||
Tag: "long",
|
||||
StopLossVal: atrBase,
|
||||
TakeProfitVal: atrBase * 2.5,
|
||||
})
|
||||
} else if rsi4 < -30 && rsi14 < -25 && rsi14 > -40 {
|
||||
s.OpenOrder(&strat.EnterReq{
|
||||
Tag: "short",
|
||||
Short: true,
|
||||
StopLossVal: atrBase,
|
||||
TakeProfitVal: atrBase * 2.5,
|
||||
})
|
||||
}
|
||||
},
|
||||
GetDrawDownExitRate: func(s *strat.StratJob, od *ormo.InOutOrder, maxChg float64) float64 {
|
||||
sl := od.GetStopLoss()
|
||||
if sl == nil {
|
||||
return 0
|
||||
}
|
||||
slRate := sl.Range / od.Enter.Average
|
||||
if maxChg > slRate {
|
||||
return 0.63
|
||||
}
|
||||
return 0
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user