bollmaker: check s.MaxExposurePosition

This commit is contained in:
c9s 2022-01-09 03:03:54 +08:00
parent 0cec652f38
commit cd340bd596

View File

@ -250,7 +250,7 @@ func (s *Strategy) placeOrders(ctx context.Context, orderExecutor bbgo.OrderExec
canSell := hasBaseBalance && baseBalance.Available > s.Quantity canSell := hasBaseBalance && baseBalance.Available > s.Quantity
// adjust quantity for closing position if we over sold or over bought // adjust quantity for closing position if we over sold or over bought
if base.Abs() > s.MaxExposurePosition { if s.MaxExposurePosition > 0 && base.Abs() > s.MaxExposurePosition {
scale := &bbgo.ExponentialScale{ scale := &bbgo.ExponentialScale{
Domain: [2]float64{0, s.MaxExposurePosition.Float64()}, Domain: [2]float64{0, s.MaxExposurePosition.Float64()},
Range: [2]float64{quantity.Float64(), base.Abs().Float64()}, Range: [2]float64{quantity.Float64(), base.Abs().Float64()},