fix: fine tune drift config. fix atr updating issue

This commit is contained in:
zenix 2022-07-14 14:50:37 +09:00
parent b52208d7b6
commit 9c73aa4adb
2 changed files with 4 additions and 3 deletions

View File

@ -14,10 +14,10 @@ exchangeStrategies:
symbol: ETHUSDT
# kline interval for indicators
interval: 15m
window: 3
window: 2
stoploss: 2%
source: hl2
predictOffset: 5
predictOffset: 8
#exits:
#- roiStopLoss:
# percentage: 0.8%

View File

@ -219,7 +219,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
for _, kline := range *klines {
source := getSource(&kline).Float64()
s.drift.Update(source)
s.atr.Update(kline.High.Float64(), kline.Low.Float64(), kline.Close.Float64())
s.atr.PushK(kline)
}
if s.Environment.IsBackTesting() {
@ -288,6 +288,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
sourcef := source.Float64()
priceLine.Update(sourcef)
s.drift.Update(sourcef)
s.atr.PushK(kline)
drift = s.drift.Array(2)
driftPred = s.drift.Predict(s.PredictOffset)
atr = s.atr.Last()