mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
round down quantity
This commit is contained in:
parent
e7a20db048
commit
0eb3856906
|
@ -136,8 +136,9 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
||||||
// the shutdown handler, you can cancel all orders
|
// the shutdown handler, you can cancel all orders
|
||||||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
_ = s.OrderExecutorMap.GracefulCancel(ctx)
|
if err := s.activeOrderBook.GracefulCancel(ctx, s.Session.Exchange); err != nil {
|
||||||
bbgo.Sync(ctx, s)
|
log.WithError(err).Errorf("failed to cancel orders")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
s.cron = cron.New()
|
s.cron = cron.New()
|
||||||
|
@ -174,7 +175,7 @@ func (s *Strategy) rebalance(ctx context.Context) {
|
||||||
|
|
||||||
createdOrders, err := s.OrderExecutorMap.SubmitOrders(ctx, *order)
|
createdOrders, err := s.OrderExecutorMap.SubmitOrders(ctx, *order)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("failed to submit orders")
|
log.WithError(err).Errorf("failed to submit order: %s", order.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.activeOrderBook.Add(createdOrders...)
|
s.activeOrderBook.Add(createdOrders...)
|
||||||
|
@ -259,6 +260,7 @@ func (s *Strategy) generateOrder(ctx context.Context) (*types.SubmitOrder, error
|
||||||
} else if side == types.SideTypeSell {
|
} else if side == types.SideTypeSell {
|
||||||
quantity = fixedpoint.Min(quantity, balances[market.BaseCurrency].Available)
|
quantity = fixedpoint.Min(quantity, balances[market.BaseCurrency].Available)
|
||||||
}
|
}
|
||||||
|
quantity = market.RoundDownQuantityByPrecision(quantity)
|
||||||
|
|
||||||
price := s.PriceType.Map(ticker, side)
|
price := s.PriceType.Map(ticker, side)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user