mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
bbgo: add supportTakeProfit method to the core exit methods
This commit is contained in:
parent
11854db51a
commit
fb9a4994c0
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user