mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +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
|
# TP/SL by reversed linear regression signal
|
||||||
stopByReversedLinGre: false
|
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)
|
var log = logrus.WithField("strategy", ID)
|
||||||
|
|
||||||
// TODO: SL by fixed percentage
|
// TODO: limit order for ATR TP
|
||||||
// TODO: limit order if possible
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Register the pointer of the strategy struct,
|
// Register the pointer of the strategy struct,
|
||||||
|
@ -144,6 +143,9 @@ type Strategy struct {
|
||||||
currentTakeProfitPrice fixedpoint.Value
|
currentTakeProfitPrice fixedpoint.Value
|
||||||
currentStopLossPrice fixedpoint.Value
|
currentStopLossPrice fixedpoint.Value
|
||||||
|
|
||||||
|
// ExitMethods Exit methods
|
||||||
|
ExitMethods []bbgo.ExitMethod `json:"exits"`
|
||||||
|
|
||||||
// StrategyController
|
// StrategyController
|
||||||
bbgo.StrategyController
|
bbgo.StrategyController
|
||||||
}
|
}
|
||||||
|
@ -363,6 +365,11 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
// Setup indicators
|
// Setup indicators
|
||||||
s.setupIndicators()
|
s.setupIndicators()
|
||||||
|
|
||||||
|
// Exit methods
|
||||||
|
for _, method := range s.ExitMethods {
|
||||||
|
method.Bind(session, s.orderExecutor)
|
||||||
|
}
|
||||||
|
|
||||||
s.currentStopLossPrice = fixedpoint.Zero
|
s.currentStopLossPrice = fixedpoint.Zero
|
||||||
s.currentTakeProfitPrice = fixedpoint.Zero
|
s.currentTakeProfitPrice = fixedpoint.Zero
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user