init
This commit is contained in:
43
demo/freqtrade/Strategy004.go
Normal file
43
demo/freqtrade/Strategy004.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package freqtrade
|
||||
|
||||
import (
|
||||
"github.com/banbox/banbot/config"
|
||||
"github.com/banbox/banbot/strat"
|
||||
ta "github.com/banbox/banta"
|
||||
)
|
||||
|
||||
/*
|
||||
Strategy 004
|
||||
author@: Gerald Lonlas
|
||||
github@: https://github.com/freqtrade/freqtrade-strategies/blob/main/user_data/strategies/Strategy004.py
|
||||
*/
|
||||
func Strategy004(p *config.RunPolicyConfig) *strat.TradeStrat {
|
||||
return &strat.TradeStrat{
|
||||
WarmupNum: 100,
|
||||
EachMaxLong: 1,
|
||||
OnBar: func(s *strat.StratJob) {
|
||||
e := s.Env
|
||||
adx := ta.ADX(e.High, e.Low, e.Close, 14).Get(0)
|
||||
adxSlow := ta.ADX(e.High, e.Low, e.Close, 35).Get(0)
|
||||
cci := ta.CCI(e.Close, 14).Get(0)
|
||||
fastD, _, fastK := ta.KDJBy(e.High, e.Low, e.Close, 5, 3, 3, "sma")
|
||||
fastDBig, _, fastKBig := ta.KDJBy(e.High, e.Low, e.Close, 50, 3, 3, "sma")
|
||||
ema := ta.EMA(e.Close, 5).Get(0)
|
||||
KDX := fastK.Cross(fastD)
|
||||
|
||||
adxOk := adx > 50 || adxSlow > 26
|
||||
fastKDOk := fastK.Get(1) < 20 && fastD.Get(1) < 20
|
||||
fastKDBigOk := fastKBig.Get(1) < 30 && fastDBig.Get(1) < 30
|
||||
|
||||
fastKDgt70 := fastK.Get(0) > 70 || fastD.Get(0) > 70
|
||||
if adxOk && cci < -100 && fastKDOk && fastKDBigOk && KDX == 1 {
|
||||
s.OpenOrder(&strat.EnterReq{
|
||||
Tag: "long",
|
||||
StopLossVal: ema * 0.1,
|
||||
})
|
||||
} else if adxSlow < 25 && fastKDgt70 && fastK.Get(1) < fastD.Get(1) && e.Close.Get(0) > ema {
|
||||
s.CloseOrders(&strat.ExitReq{Tag: "exit"})
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
26
demo/freqtrade/Strategy005.go
Normal file
26
demo/freqtrade/Strategy005.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package freqtrade
|
||||
|
||||
/*
|
||||
Strategy 005
|
||||
author@: Gerald Lonlas
|
||||
github@: https://github.com/freqtrade/freqtrade-strategies/blob/main/user_data/strategies/Strategy005.py
|
||||
*/
|
||||
|
||||
//func Strategy005(p *config.RunPolicyConfig) *strat.TradeStrat {
|
||||
// buyVolAvg := int(p.Def("buyVolAvg", 150, core.PNorm(50, 300)))
|
||||
// buyRsi := p.Def("buyRsi", 26, core.PNorm(1, 100))
|
||||
// buyFastD := p.Def("buyFastD", 1, core.PNorm(1, 100))
|
||||
// buyFishNo := p.Def("buyFishNo", 5, core.PNorm(1, 100))
|
||||
// sellRsi := p.Def("sellRsi", 74, core.PNorm(1, 100))
|
||||
// sellMiDi := p.Def("sellMiDi", 4, core.PNorm(1, 100))
|
||||
// sellFiRsiN := p.Def("sellFiRsiN", 30, core.PNorm(1, 100))
|
||||
// return &strat.TradeStrat{
|
||||
// WarmupNum: 100,
|
||||
// OnBar: func(s *strat.StratJob) {
|
||||
// e := s.Env
|
||||
// macdCols := ta.MACD(e.Close, 12, 26, 9).Cols
|
||||
// macd, macdSig := macdCols[0], macdCols[1]
|
||||
//
|
||||
// },
|
||||
// }
|
||||
//}
|
||||
11
demo/freqtrade/common.go
Normal file
11
demo/freqtrade/common.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package freqtrade
|
||||
|
||||
import "github.com/banbox/banbot/strat"
|
||||
|
||||
func init() {
|
||||
strat.AddStratGroup("freqtrade", map[string]strat.FuncMakeStrat{
|
||||
"Strategy001": Strategy001,
|
||||
"Strategy004": Strategy004,
|
||||
|
||||
})
|
||||
}
|
||||
46
demo/freqtrade/strategy001.go
Normal file
46
demo/freqtrade/strategy001.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package freqtrade
|
||||
|
||||
import (
|
||||
"github.com/banbox/banbot/config"
|
||||
"github.com/banbox/banbot/core"
|
||||
"github.com/banbox/banbot/strat"
|
||||
ta "github.com/banbox/banta"
|
||||
)
|
||||
|
||||
/*
|
||||
Strategy 001
|
||||
author@: Gerald Lonlas
|
||||
github@: https://github.com/freqtrade/freqtrade-strategies/blob/main/user_data/strategies/Strategy001.py
|
||||
*/
|
||||
|
||||
func Strategy001(p *config.RunPolicyConfig) *strat.TradeStrat {
|
||||
lenSml := int(p.Def("lenSml", 20, core.PNorm(10, 30)))
|
||||
midRate := p.Def("midRate", 2.5, core.PNorm(1.5, 5))
|
||||
bigRate := p.Def("bigRate", 2, core.PNorm(1.5, 3))
|
||||
lenMid := int(float64(lenSml) * midRate)
|
||||
lenBig := int(float64(lenMid) * bigRate)
|
||||
return &strat.TradeStrat{
|
||||
WarmupNum: 200,
|
||||
EachMaxLong: 1,
|
||||
OnBar: func(s *strat.StratJob) {
|
||||
e := s.Env
|
||||
maSml := ta.EMA(e.Close, lenSml)
|
||||
maMid := ta.EMA(e.Close, lenMid)
|
||||
maBig := ta.EMA(e.Close, lenBig)
|
||||
haO, _, _, haC := ta.HeikinAshi(e)
|
||||
haOpen := haO.Get(0)
|
||||
haClose := haC.Get(0)
|
||||
smlXmid := maSml.Cross(maMid)
|
||||
midXBig := maMid.Cross(maBig)
|
||||
|
||||
if smlXmid == 1 && haClose > maSml.Get(0) && haOpen < haClose {
|
||||
s.OpenOrder(&strat.EnterReq{
|
||||
Tag: "long",
|
||||
StopLossVal: haClose * 0.1,
|
||||
})
|
||||
} else if midXBig == 1 && haClose < maSml.Get(0) && haOpen > haClose {
|
||||
s.CloseOrders(&strat.ExitReq{Tag: "exit"})
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user