xmaker: use margin order to hedge positions

This commit is contained in:
c9s 2024-08-23 16:57:29 +08:00
parent c2679b4ae1
commit 9f510da78b
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -572,11 +572,12 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
bbgo.Notify("Submitting %s hedge order %s %v", s.Symbol, side.String(), quantity) bbgo.Notify("Submitting %s hedge order %s %v", s.Symbol, side.String(), quantity)
orderExecutor := &bbgo.ExchangeOrderExecutor{Session: s.sourceSession} orderExecutor := &bbgo.ExchangeOrderExecutor{Session: s.sourceSession}
returnOrders, err := orderExecutor.SubmitOrders(ctx, types.SubmitOrder{ returnOrders, err := orderExecutor.SubmitOrders(ctx, types.SubmitOrder{
Market: s.sourceMarket, Market: s.sourceMarket,
Symbol: s.Symbol, Symbol: s.Symbol,
Type: types.OrderTypeMarket, Type: types.OrderTypeMarket,
Side: side, Side: side,
Quantity: quantity, Quantity: quantity,
MarginSideEffect: types.SideEffectTypeMarginBuy,
}) })
if err != nil { if err != nil {