From 6e4c28ed1bf7e837de9ecb6d3b5f18d22df2f791 Mon Sep 17 00:00:00 2001 From: c9s Date: Sun, 17 Jul 2022 00:59:35 +0800 Subject: [PATCH] disable marketTrade stop --- pkg/bbgo/exit_protective_stop_loss.go | 4 +++- pkg/bbgo/exit_roi_stop_loss.go | 2 +- pkg/bbgo/exit_trailing_stop.go | 2 +- pkg/strategy/pivotshort/breaklow.go | 7 ------- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/pkg/bbgo/exit_protective_stop_loss.go b/pkg/bbgo/exit_protective_stop_loss.go index 456a9f6bd..5928337ca 100644 --- a/pkg/bbgo/exit_protective_stop_loss.go +++ b/pkg/bbgo/exit_protective_stop_loss.go @@ -9,6 +9,8 @@ import ( "github.com/c9s/bbgo/pkg/types" ) +const enableMarketTradeStop = false + type ProtectiveStopLoss struct { Symbol string `json:"symbol"` @@ -122,7 +124,7 @@ func (s *ProtectiveStopLoss) Bind(session *ExchangeSession, orderExecutor *Gener } }) - if !IsBackTesting { + if !IsBackTesting && enableMarketTradeStop { session.MarketDataStream.OnMarketTrade(func(trade types.Trade) { if trade.Symbol != position.Symbol { return diff --git a/pkg/bbgo/exit_roi_stop_loss.go b/pkg/bbgo/exit_roi_stop_loss.go index 875934f41..4dab15a1c 100644 --- a/pkg/bbgo/exit_roi_stop_loss.go +++ b/pkg/bbgo/exit_roi_stop_loss.go @@ -29,7 +29,7 @@ func (s *RoiStopLoss) Bind(session *ExchangeSession, orderExecutor *GeneralOrder s.checkStopPrice(kline.Close, position) })) - if !IsBackTesting { + if !IsBackTesting && enableMarketTradeStop { session.MarketDataStream.OnMarketTrade(func(trade types.Trade) { if trade.Symbol != position.Symbol { return diff --git a/pkg/bbgo/exit_trailing_stop.go b/pkg/bbgo/exit_trailing_stop.go index 809296df5..c66d031f7 100644 --- a/pkg/bbgo/exit_trailing_stop.go +++ b/pkg/bbgo/exit_trailing_stop.go @@ -58,7 +58,7 @@ func (s *TrailingStop2) Bind(session *ExchangeSession, orderExecutor *GeneralOrd } })) - if !IsBackTesting { + if !IsBackTesting && enableMarketTradeStop { session.MarketDataStream.OnMarketTrade(func(trade types.Trade) { if trade.Symbol != position.Symbol { return diff --git a/pkg/strategy/pivotshort/breaklow.go b/pkg/strategy/pivotshort/breaklow.go index 71ca9a6db..03cf0b36f 100644 --- a/pkg/strategy/pivotshort/breaklow.go +++ b/pkg/strategy/pivotshort/breaklow.go @@ -220,13 +220,6 @@ func (s *BreakLow) Bind(session *bbgo.ExchangeSession, orderExecutor *bbgo.Gener }) } })) - - if !bbgo.IsBackTesting { - // use market trade to submit short order - session.MarketDataStream.OnMarketTrade(func(trade types.Trade) { - - }) - } } func useQuantityOrBaseBalance(session *bbgo.ExchangeSession, market types.Market, price, quantity, leverage fixedpoint.Value) (fixedpoint.Value, error) {