disable marketTrade stop

This commit is contained in:
c9s 2022-07-17 00:59:35 +08:00
parent 2d0fbe4b99
commit 6e4c28ed1b
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
4 changed files with 5 additions and 10 deletions

View File

@ -9,6 +9,8 @@ import (
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"
) )
const enableMarketTradeStop = false
type ProtectiveStopLoss struct { type ProtectiveStopLoss struct {
Symbol string `json:"symbol"` 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) { session.MarketDataStream.OnMarketTrade(func(trade types.Trade) {
if trade.Symbol != position.Symbol { if trade.Symbol != position.Symbol {
return return

View File

@ -29,7 +29,7 @@ func (s *RoiStopLoss) Bind(session *ExchangeSession, orderExecutor *GeneralOrder
s.checkStopPrice(kline.Close, position) s.checkStopPrice(kline.Close, position)
})) }))
if !IsBackTesting { if !IsBackTesting && enableMarketTradeStop {
session.MarketDataStream.OnMarketTrade(func(trade types.Trade) { session.MarketDataStream.OnMarketTrade(func(trade types.Trade) {
if trade.Symbol != position.Symbol { if trade.Symbol != position.Symbol {
return return

View File

@ -58,7 +58,7 @@ func (s *TrailingStop2) Bind(session *ExchangeSession, orderExecutor *GeneralOrd
} }
})) }))
if !IsBackTesting { if !IsBackTesting && enableMarketTradeStop {
session.MarketDataStream.OnMarketTrade(func(trade types.Trade) { session.MarketDataStream.OnMarketTrade(func(trade types.Trade) {
if trade.Symbol != position.Symbol { if trade.Symbol != position.Symbol {
return return

View File

@ -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) { func useQuantityOrBaseBalance(session *bbgo.ExchangeSession, market types.Market, price, quantity, leverage fixedpoint.Value) (fixedpoint.Value, error) {