diff --git a/pkg/bbgo/exit.go b/pkg/bbgo/exit.go index 4c554ce7e..68282cecb 100644 --- a/pkg/bbgo/exit.go +++ b/pkg/bbgo/exit.go @@ -32,9 +32,13 @@ type ExitMethod struct { RoiStopLoss *RoiStopLoss `json:"roiStopLoss"` ProtectiveStopLoss *ProtectiveStopLoss `json:"protectiveStopLoss"` RoiTakeProfit *RoiTakeProfit `json:"roiTakeProfit"` + TrailingStop *TrailingStop2 `json:"trailingStop"` + + // Exit methods for short positions + // ================================================= LowerShadowTakeProfit *LowerShadowTakeProfit `json:"lowerShadowTakeProfit"` CumulatedVolumeTakeProfit *CumulatedVolumeTakeProfit `json:"cumulatedVolumeTakeProfit"` - TrailingStop *TrailingStop2 `json:"trailingStop"` + SupportTakeProfit []*SupportTakeProfit `json:"supportTakeProfit"` } func (e ExitMethod) String() string { @@ -43,26 +47,37 @@ func (e ExitMethod) String() string { b, _ := json.Marshal(e.RoiStopLoss) buf.WriteString("roiStopLoss: " + string(b) + ", ") } + if e.ProtectiveStopLoss != nil { b, _ := json.Marshal(e.ProtectiveStopLoss) buf.WriteString("protectiveStopLoss: " + string(b) + ", ") } + if e.RoiTakeProfit != nil { b, _ := json.Marshal(e.RoiTakeProfit) buf.WriteString("rioTakeProft: " + string(b) + ", ") } + if e.LowerShadowTakeProfit != nil { b, _ := json.Marshal(e.LowerShadowTakeProfit) buf.WriteString("lowerShadowTakeProft: " + string(b) + ", ") } + if e.CumulatedVolumeTakeProfit != nil { b, _ := json.Marshal(e.CumulatedVolumeTakeProfit) buf.WriteString("cumulatedVolumeTakeProfit: " + string(b) + ", ") } + if e.TrailingStop != nil { b, _ := json.Marshal(e.TrailingStop) buf.WriteString("trailingStop: " + string(b) + ", ") } + + if e.SupportTakeProfit != nil { + b, _ := json.Marshal(e.SupportTakeProfit) + buf.WriteString("supportTakeProfit: " + string(b) + ", ") + } + return buf.String() } @@ -113,6 +128,10 @@ func (m *ExitMethod) Bind(session *ExchangeSession, orderExecutor *GeneralOrderE m.CumulatedVolumeTakeProfit.Bind(session, orderExecutor) } + if m.SupportTakeProfit != nil { + m.SupportTakeProfit.Bind(session, orderExecutor) + } + if m.TrailingStop != nil { m.TrailingStop.Bind(session, orderExecutor) }