mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
strategy/supertrend: add ExitMethod
This commit is contained in:
parent
f0dc9d6147
commit
91077ce61d
|
@ -71,3 +71,10 @@ exchangeStrategies:
|
|||
|
||||
# TP/SL by reversed linear regression signal
|
||||
stopByReversedLinGre: false
|
||||
|
||||
exits:
|
||||
# Protective stop loss
|
||||
- protectiveStopLoss:
|
||||
activationRatio: 0.6%
|
||||
stopLossRatio: 1%
|
||||
placeStopOrder: false
|
||||
|
|
|
@ -23,8 +23,7 @@ const stateKey = "state-v1"
|
|||
|
||||
var log = logrus.WithField("strategy", ID)
|
||||
|
||||
// TODO: SL by fixed percentage
|
||||
// TODO: limit order if possible
|
||||
// TODO: limit order for ATR TP
|
||||
|
||||
func init() {
|
||||
// Register the pointer of the strategy struct,
|
||||
|
@ -144,6 +143,9 @@ type Strategy struct {
|
|||
currentTakeProfitPrice fixedpoint.Value
|
||||
currentStopLossPrice fixedpoint.Value
|
||||
|
||||
// ExitMethods Exit methods
|
||||
ExitMethods []bbgo.ExitMethod `json:"exits"`
|
||||
|
||||
// StrategyController
|
||||
bbgo.StrategyController
|
||||
}
|
||||
|
@ -363,6 +365,11 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
// Setup indicators
|
||||
s.setupIndicators()
|
||||
|
||||
// Exit methods
|
||||
for _, method := range s.ExitMethods {
|
||||
method.Bind(session, s.orderExecutor)
|
||||
}
|
||||
|
||||
s.currentStopLossPrice = fixedpoint.Zero
|
||||
s.currentTakeProfitPrice = fixedpoint.Zero
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user