mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
strategy/linregmaker: add more trend reverse logs
This commit is contained in:
parent
a6956e50b7
commit
79dcda5f52
|
@ -18,8 +18,8 @@ backtest:
|
|||
# for testing max draw down (MDD) at 03-12
|
||||
# see here for more details
|
||||
# https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp
|
||||
startTime: "2022-05-01"
|
||||
endTime: "2022-10-31"
|
||||
startTime: "2022-03-15"
|
||||
endTime: "2022-03-23"
|
||||
symbols:
|
||||
- BTCUSDT
|
||||
accounts:
|
||||
|
@ -41,7 +41,7 @@ exchangeStrategies:
|
|||
# reverseEMA
|
||||
reverseEMA:
|
||||
interval: 1d
|
||||
window: 5
|
||||
window: 60
|
||||
|
||||
# reverseInterval
|
||||
reverseInterval: 4h
|
||||
|
|
|
@ -657,12 +657,13 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
|
||||
// Trend reversal
|
||||
if s.mainTrendCurrent != s.mainTrendPrevious {
|
||||
log.Infof("%s trend reverse to %v", s.Symbol, s.mainTrendCurrent)
|
||||
// Close on-hand position that is not in the same direction as the new trend
|
||||
if !s.Position.IsDust(closePrice) &&
|
||||
((s.Position.IsLong() && s.mainTrendCurrent == types.DirectionDown) ||
|
||||
(s.Position.IsShort() && s.mainTrendCurrent == types.DirectionUp)) {
|
||||
log.Infof("%s trend reverse to %v. closing on-hand position", s.Symbol, s.mainTrendCurrent)
|
||||
bbgo.Notify("%s trend reverse to %v. closing on-hand position", s.Symbol, s.mainTrendCurrent)
|
||||
log.Infof("%s closing on-hand position due to trend reverse", s.Symbol)
|
||||
bbgo.Notify("%s closing on-hand position due to trend reverse", s.Symbol)
|
||||
if err := s.ClosePosition(ctx, fixedpoint.One); err != nil {
|
||||
log.WithError(err).Errorf("cannot close on-hand position of %s", s.Symbol)
|
||||
bbgo.Notify("cannot close on-hand position of %s", s.Symbol)
|
||||
|
|
Loading…
Reference in New Issue
Block a user