mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
strategy: use stop market to tp instead of stop limit
This commit is contained in:
parent
8782104f1a
commit
861fd84fd4
|
@ -108,7 +108,7 @@ func (control *TrailingStopControl) GenerateStopOrder(quantity fixedpoint.Value)
|
||||||
Symbol: control.symbol,
|
Symbol: control.symbol,
|
||||||
Market: control.market,
|
Market: control.market,
|
||||||
Side: types.SideTypeSell,
|
Side: types.SideTypeSell,
|
||||||
Type: types.OrderTypeStopLimit,
|
Type: types.OrderTypeStopMarket,
|
||||||
Quantity: quantity,
|
Quantity: quantity,
|
||||||
MarginSideEffect: control.marginSideEffect,
|
MarginSideEffect: control.marginSideEffect,
|
||||||
TimeInForce: types.TimeInForceGTC,
|
TimeInForce: types.TimeInForceGTC,
|
||||||
|
@ -531,12 +531,14 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
orders, err := s.submitOrders(ctx, orderExecutor, orderForm)
|
orders, err := s.submitOrders(ctx, orderExecutor, orderForm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("submit profit trailing stop order error")
|
log.WithError(err).Error("submit profit trailing stop order error")
|
||||||
|
s.Notify("submit %s profit trailing stop order error", s.Symbol)
|
||||||
} else {
|
} else {
|
||||||
orderIds := orders.IDs()
|
orderIds := orders.IDs()
|
||||||
if len(orderIds) > 0 {
|
if len(orderIds) > 0 {
|
||||||
s.trailingStopControl.OrderID = orderIds[0]
|
s.trailingStopControl.OrderID = orderIds[0]
|
||||||
} else {
|
} else {
|
||||||
log.Error("submit profit trailing stop order error. unknown error")
|
log.Error("submit profit trailing stop order error. unknown error")
|
||||||
|
s.Notify("submit %s profit trailing stop order error", s.Symbol)
|
||||||
s.trailingStopControl.OrderID = 0
|
s.trailingStopControl.OrderID = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,7 +600,8 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
orderForm := s.trailingStopControl.GenerateStopOrder(s.state.Position.Base)
|
orderForm := s.trailingStopControl.GenerateStopOrder(s.state.Position.Base)
|
||||||
orders, err := s.submitOrders(ctx, orderExecutor, orderForm)
|
orders, err := s.submitOrders(ctx, orderExecutor, orderForm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("submit profit trailing stop order error")
|
log.WithError(err).Error("submit %s profit trailing stop order error", s.Symbol)
|
||||||
|
s.Notify("submit %s profit trailing stop order error", s.Symbol)
|
||||||
} else {
|
} else {
|
||||||
s.trailingStopControl.OrderID = orders.IDs()[0]
|
s.trailingStopControl.OrderID = orders.IDs()[0]
|
||||||
}
|
}
|
||||||
|
@ -732,6 +735,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
|
|
||||||
if _, err := s.submitOrders(ctx, orderExecutor, targetOrders...); err != nil {
|
if _, err := s.submitOrders(ctx, orderExecutor, targetOrders...); err != nil {
|
||||||
log.WithError(err).Error("submit profit target order error")
|
log.WithError(err).Error("submit profit target order error")
|
||||||
|
s.Notify("submit %s profit trailing stop order error", s.Symbol)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user