Skip to content

OptionStrategyLegPredicate

QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyLegPredicate

OptionStrategyLegPredicate(
    comparison: BinaryComparison,
    reference: IOptionStrategyLegPredicateReferenceValue,
    predicate: Callable[
        [Sequence[OptionPosition], OptionPosition], bool
    ],
    expression: Any,
)

Bases: Object

Defines a condition under which a particular OptionPosition can be combined with a preceding list of leg (also of type OptionPosition) to achieve a particular option strategy.

Initializes a new instance of the OptionStrategyLegPredicate class

Parameters:

Name Type Description Default
comparison BinaryComparison

The BinaryComparison invoked

required
reference IOptionStrategyLegPredicateReferenceValue

The reference value, such as a strike price, encapsulated within the IOptionStrategyLegPredicateReferenceValue to enable resolving the value from different potential sets.

required
predicate Callable[[Sequence[OptionPosition], OptionPosition], bool]

The compiled predicate expression

required
expression Any

The predicate expression, from which, all other values were derived.

required

is_indexed

is_indexed: bool

Determines whether or not this predicate is able to utilize OptionPositionCollection indexes.

create

create(expression: Any) -> OptionStrategyLegPredicate

Creates a new OptionStrategyLegPredicate from the specified predicate expression

filter

filter(
    legs: Sequence[OptionPosition],
    positions: OptionPositionCollection,
    include_underlying: bool,
) -> OptionPositionCollection

Filters the specified positions by applying this predicate based on the referenced legs.

get_reference_value

get_reference_value() -> (
    IOptionStrategyLegPredicateReferenceValue
)

Gets the underlying IOptionStrategyLegPredicateReferenceValue value used by this predicate.

matches

matches(
    legs: Sequence[OptionPosition], position: OptionPosition
) -> bool

Determines whether or not the provided combination of preceding legs and current position adhere to this predicate's requirements.

to_string

to_string() -> str

Returns a string that represents the current object.

Returns:

Type Description
str

A string that represents the current object.