bbgo: introduce ENABLE_MARKET_TRADE_STOP env var

This commit is contained in:
c9s 2023-06-21 18:01:22 +08:00
parent 5afd23b5c7
commit b5f2f57678
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 9 additions and 2 deletions

View File

@ -8,8 +8,17 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/c9s/bbgo/pkg/dynamic" "github.com/c9s/bbgo/pkg/dynamic"
"github.com/c9s/bbgo/pkg/util"
) )
var enableMarketTradeStop = true
func init() {
if v, defined := util.GetEnvVarBool("ENABLE_MARKET_TRADE_STOP"); defined {
enableMarketTradeStop = v
}
}
type ExitMethodSet []ExitMethod type ExitMethodSet []ExitMethod
func (s *ExitMethodSet) SetAndSubscribe(session *ExchangeSession, parent interface{}) { func (s *ExitMethodSet) SetAndSubscribe(session *ExchangeSession, parent interface{}) {

View File

@ -9,8 +9,6 @@ import (
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"
) )
const enableMarketTradeStop = true
// ProtectiveStopLoss provides a way to protect your profit but also keep a room for the price volatility // ProtectiveStopLoss provides a way to protect your profit but also keep a room for the price volatility
// Set ActivationRatio to 1% means if the price is away from your average cost by 1%, we will activate the protective stop loss // Set ActivationRatio to 1% means if the price is away from your average cost by 1%, we will activate the protective stop loss
// and the StopLossRatio is the minimal profit ratio you want to keep for your position. // and the StopLossRatio is the minimal profit ratio you want to keep for your position.