xdepthmaker: improve HedgeMaxOrderQuantity check

This commit is contained in:
c9s 2024-09-25 16:24:34 +08:00
parent 42cd3cba1e
commit f4e905833c
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -604,7 +604,7 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) error {
quantity := pos.Abs()
if s.HedgeMaxOrderQuantity.Sign() > 0 {
if s.HedgeMaxOrderQuantity.Sign() > 0 && quantity.Compare(s.HedgeMaxOrderQuantity) > 0 {
s.logger.Infof("hedgeMaxOrderQuantity is set to %s, limiting the given quantity %s", s.HedgeMaxOrderQuantity.String(), quantity.String())
quantity = fixedpoint.Min(s.HedgeMaxOrderQuantity, quantity)
}