Skip to content

Constraint

QuantConnect.Optimizer.Objectives.Constraint

Constraint()
Constraint(
    target: str,
    operator: ComparisonOperatorTypes,
    target_value: Optional[float],
)

Bases: Objective

A backtest optimization constraint. Allows specifying statistical constraints for the optimization, eg. a backtest can't have a DrawDown less than 10%

Signature descriptions:

  • Empty Constraint constructor

  • Creates a new instance

operator

The target comparison operation, eg. 'Greater'

target

target: str

Target; property of json file we want to track

target_value

target_value: Optional[float]

Target value

old_target_value

old_target_value: Optional[float]

is_met

is_met(json_backtest_result: str) -> bool

Asserts the constraint is met

to_string

to_string() -> str

Pretty representation of a constraint