mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
bollmaker: adjust quantity to met the min notional condition before we submit
This commit is contained in:
parent
fd4a3bb000
commit
898204f5fa
|
@ -353,6 +353,10 @@ func (s *Strategy) placeOrders(ctx context.Context, orderExecutor bbgo.OrderExec
|
|||
if midPrice < s.state.Position.AverageCost.MulFloat64(1.0-s.MinProfitSpread.Float64()) && canBuy {
|
||||
// submitOrders = append(submitOrders, buyOrder)
|
||||
}
|
||||
|
||||
buyOrder = s.adjustOrderQuantity(buyOrder)
|
||||
sellOrder = s.adjustOrderQuantity(sellOrder)
|
||||
|
||||
if canBuy {
|
||||
submitOrders = append(submitOrders, buyOrder)
|
||||
}
|
||||
|
@ -369,6 +373,18 @@ func (s *Strategy) placeOrders(ctx context.Context, orderExecutor bbgo.OrderExec
|
|||
s.activeMakerOrders.Add(createdOrders...)
|
||||
}
|
||||
|
||||
func (s *Strategy) adjustOrderQuantity(submitOrder types.SubmitOrder) types.SubmitOrder {
|
||||
if submitOrder.Quantity*submitOrder.Price < s.market.MinNotional {
|
||||
submitOrder.Quantity = bbgo.AdjustFloatQuantityByMinAmount(submitOrder.Quantity, submitOrder.Price, s.market.MinNotional)
|
||||
}
|
||||
|
||||
if submitOrder.Quantity < s.market.MinQuantity {
|
||||
submitOrder.Quantity = math.Max(submitOrder.Quantity, s.market.MinQuantity)
|
||||
}
|
||||
|
||||
return submitOrder
|
||||
}
|
||||
|
||||
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||
if s.MinProfitSpread == 0 {
|
||||
s.MinProfitSpread = fixedpoint.NewFromFloat(0.001)
|
||||
|
|
Loading…
Reference in New Issue
Block a user