grid2: handle grid orders submission

This commit is contained in:
c9s 2022-11-24 16:35:31 +08:00
parent e3c735b700
commit 020e7c8604
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -374,6 +374,9 @@ func (s *Strategy) setupGridOrders(ctx context.Context, session *bbgo.ExchangeSe
Side: types.SideTypeSell,
Price: price,
Quantity: quantity,
Market: s.Market,
TimeInForce: types.TimeInForceGTC,
Tag: "grid",
})
usedBase = usedBase.Add(quantity)
} else if i > 0 {
@ -386,30 +389,38 @@ func (s *Strategy) setupGridOrders(ctx context.Context, session *bbgo.ExchangeSe
Side: types.SideTypeBuy,
Price: nextPrice,
Quantity: quantity,
Market: s.Market,
TimeInForce: types.TimeInForceGTC,
Tag: "grid",
})
quoteQuantity := quantity.Mul(price)
usedQuote = usedQuote.Add(quoteQuantity)
buyPlacedPrice = nextPrice
}
} else {
if price.Compare(buyPlacedPrice) >= 0 {
continue
}
/*
createdOrders, err2 := s.orderExecutor.SubmitOrders(ctx, types.SubmitOrder{
submitOrders = append(submitOrders, types.SubmitOrder{
Symbol: s.Symbol,
Type: types.OrderTypeLimitMaker,
Side: types.SideTypeBuy,
Type: types.OrderTypeLimit,
Quantity: quantity,
Price: price,
Quantity: quantity,
Market: s.Market,
TimeInForce: types.TimeInForceGTC,
Tag: "grid",
})
if err2 != nil {
return err2
quoteQuantity := quantity.Mul(price)
usedQuote = usedQuote.Add(quoteQuantity)
}
*/
createdOrders, err2 := s.orderExecutor.SubmitOrders(ctx, submitOrders...)
if err2 != nil {
return err
}
_ = createdOrders
}
return nil