mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 02:53:50 +00:00
exits/trailingstop: more logs
This commit is contained in:
parent
1f3579e3ec
commit
afc262da8b
|
@ -93,11 +93,13 @@ func (s *HigherHighLowerLowStop) updateActivated(position *types.Position, close
|
||||||
func (s *HigherHighLowerLowStop) updateHighLowNumber(kline types.KLine) {
|
func (s *HigherHighLowerLowStop) updateHighLowNumber(kline types.KLine) {
|
||||||
s.klines.Truncate(s.Window - 1)
|
s.klines.Truncate(s.Window - 1)
|
||||||
|
|
||||||
if s.klines.Len() > 0 {
|
if s.klines.Len() >= s.Window-1 {
|
||||||
if s.klines.GetHigh().Compare(kline.GetHigh()) < 0 {
|
if s.klines.GetHigh().Compare(kline.GetHigh()) < 0 {
|
||||||
s.highLows = append(s.highLows, types.DirectionUp)
|
s.highLows = append(s.highLows, types.DirectionUp)
|
||||||
|
log.Debugf("[hhllStop] new higher high for %s", s.Symbol)
|
||||||
} else if s.klines.GetLow().Compare(kline.GetLow()) > 0 {
|
} else if s.klines.GetLow().Compare(kline.GetLow()) > 0 {
|
||||||
s.highLows = append(s.highLows, types.DirectionDown)
|
s.highLows = append(s.highLows, types.DirectionDown)
|
||||||
|
log.Debugf("[hhllStop] new lower low for %s", s.Symbol)
|
||||||
} else {
|
} else {
|
||||||
s.highLows = append(s.highLows, types.DirectionNone)
|
s.highLows = append(s.highLows, types.DirectionNone)
|
||||||
}
|
}
|
||||||
|
@ -164,7 +166,7 @@ func (s *HigherHighLowerLowStop) Bind(session *ExchangeSession, orderExecutor *G
|
||||||
s.updateHighLowNumber(kline)
|
s.updateHighLowNumber(kline)
|
||||||
|
|
||||||
// Close position & reset
|
// Close position & reset
|
||||||
if s.activated && s.shouldStop(position) {
|
if s.shouldStop(position) {
|
||||||
err := s.orderExecutor.ClosePosition(context.Background(), fixedpoint.One, "hhllStop")
|
err := s.orderExecutor.ClosePosition(context.Background(), fixedpoint.One, "hhllStop")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Notify("[hhllStop] Stop of %s triggered but failed to close %s position:", s.Symbol, err)
|
Notify("[hhllStop] Stop of %s triggered but failed to close %s position:", s.Symbol, err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user