mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +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"`
|
RoiStopLoss *RoiStopLoss `json:"roiStopLoss"`
|
||||||
ProtectiveStopLoss *ProtectiveStopLoss `json:"protectiveStopLoss"`
|
ProtectiveStopLoss *ProtectiveStopLoss `json:"protectiveStopLoss"`
|
||||||
RoiTakeProfit *RoiTakeProfit `json:"roiTakeProfit"`
|
RoiTakeProfit *RoiTakeProfit `json:"roiTakeProfit"`
|
||||||
|
TrailingStop *TrailingStop2 `json:"trailingStop"`
|
||||||
|
|
||||||
|
// Exit methods for short positions
|
||||||
|
// =================================================
|
||||||
LowerShadowTakeProfit *LowerShadowTakeProfit `json:"lowerShadowTakeProfit"`
|
LowerShadowTakeProfit *LowerShadowTakeProfit `json:"lowerShadowTakeProfit"`
|
||||||
CumulatedVolumeTakeProfit *CumulatedVolumeTakeProfit `json:"cumulatedVolumeTakeProfit"`
|
CumulatedVolumeTakeProfit *CumulatedVolumeTakeProfit `json:"cumulatedVolumeTakeProfit"`
|
||||||
TrailingStop *TrailingStop2 `json:"trailingStop"`
|
SupportTakeProfit []*SupportTakeProfit `json:"supportTakeProfit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e ExitMethod) String() string {
|
func (e ExitMethod) String() string {
|
||||||
|
@ -43,26 +47,37 @@ func (e ExitMethod) String() string {
|
||||||
b, _ := json.Marshal(e.RoiStopLoss)
|
b, _ := json.Marshal(e.RoiStopLoss)
|
||||||
buf.WriteString("roiStopLoss: " + string(b) + ", ")
|
buf.WriteString("roiStopLoss: " + string(b) + ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.ProtectiveStopLoss != nil {
|
if e.ProtectiveStopLoss != nil {
|
||||||
b, _ := json.Marshal(e.ProtectiveStopLoss)
|
b, _ := json.Marshal(e.ProtectiveStopLoss)
|
||||||
buf.WriteString("protectiveStopLoss: " + string(b) + ", ")
|
buf.WriteString("protectiveStopLoss: " + string(b) + ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.RoiTakeProfit != nil {
|
if e.RoiTakeProfit != nil {
|
||||||
b, _ := json.Marshal(e.RoiTakeProfit)
|
b, _ := json.Marshal(e.RoiTakeProfit)
|
||||||
buf.WriteString("rioTakeProft: " + string(b) + ", ")
|
buf.WriteString("rioTakeProft: " + string(b) + ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.LowerShadowTakeProfit != nil {
|
if e.LowerShadowTakeProfit != nil {
|
||||||
b, _ := json.Marshal(e.LowerShadowTakeProfit)
|
b, _ := json.Marshal(e.LowerShadowTakeProfit)
|
||||||
buf.WriteString("lowerShadowTakeProft: " + string(b) + ", ")
|
buf.WriteString("lowerShadowTakeProft: " + string(b) + ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.CumulatedVolumeTakeProfit != nil {
|
if e.CumulatedVolumeTakeProfit != nil {
|
||||||
b, _ := json.Marshal(e.CumulatedVolumeTakeProfit)
|
b, _ := json.Marshal(e.CumulatedVolumeTakeProfit)
|
||||||
buf.WriteString("cumulatedVolumeTakeProfit: " + string(b) + ", ")
|
buf.WriteString("cumulatedVolumeTakeProfit: " + string(b) + ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.TrailingStop != nil {
|
if e.TrailingStop != nil {
|
||||||
b, _ := json.Marshal(e.TrailingStop)
|
b, _ := json.Marshal(e.TrailingStop)
|
||||||
buf.WriteString("trailingStop: " + string(b) + ", ")
|
buf.WriteString("trailingStop: " + string(b) + ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if e.SupportTakeProfit != nil {
|
||||||
|
b, _ := json.Marshal(e.SupportTakeProfit)
|
||||||
|
buf.WriteString("supportTakeProfit: " + string(b) + ", ")
|
||||||
|
}
|
||||||
|
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +128,10 @@ func (m *ExitMethod) Bind(session *ExchangeSession, orderExecutor *GeneralOrderE
|
||||||
m.CumulatedVolumeTakeProfit.Bind(session, orderExecutor)
|
m.CumulatedVolumeTakeProfit.Bind(session, orderExecutor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.SupportTakeProfit != nil {
|
||||||
|
m.SupportTakeProfit.Bind(session, orderExecutor)
|
||||||
|
}
|
||||||
|
|
||||||
if m.TrailingStop != nil {
|
if m.TrailingStop != nil {
|
||||||
m.TrailingStop.Bind(session, orderExecutor)
|
m.TrailingStop.Bind(session, orderExecutor)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user