Skip to content

CompositeRiskManagementModel

QuantConnect.Algorithm.Framework.Risk.CompositeRiskManagementModel

CompositeRiskManagementModel(
    *risk_management_models: Union[
        IRiskManagementModel, Iterable[IRiskManagementModel]
    ]
)
CompositeRiskManagementModel(
    risk_management_models: List[IRiskManagementModel],
)
CompositeRiskManagementModel(
    *risk_management_models: Union[Any, Iterable[Any]]
)

Bases: RiskManagementModel

Provides an implementation of IRiskManagementModel that combines multiple risk models into a single risk management model and properly sets each insights 'SourceModel' property.

Initializes a new instance of the CompositeRiskManagementModel class

Parameters:

Name Type Description Default
risk_management_models Union[IRiskManagementModel, Iterable[IRiskManagementModel]] | Union[Any, Iterable[Any]]

The individual risk management models defining this composite model

()

add_risk_management

add_risk_management(py_risk_management_model: Any) -> None
add_risk_management(
    risk_management_model: IRiskManagementModel,
) -> None

Adds a new IRiskManagementModel instance

Parameters:

Name Type Description Default
py_risk_management_model Optional[Any]

The risk management model to add

None
risk_management_model Optional[IRiskManagementModel]

The risk management model to add

None

manage_risk

manage_risk(
    algorithm: QCAlgorithm, targets: List[IPortfolioTarget]
) -> Iterable[IPortfolioTarget]

Manages the algorithm's risk at each time step. This method patches this call through the each of the wrapped models.

Parameters:

Name Type Description Default
algorithm QCAlgorithm

The algorithm instance

required
targets List[IPortfolioTarget]

The current portfolio targets to be assessed for risk

required

Returns:

Type Description
Iterable[IPortfolioTarget]

The new portfolio targets.

on_securities_changed

on_securities_changed(
    algorithm: QCAlgorithm, changes: SecurityChanges
) -> None

Event fired each time the we add/remove securities from the data feed. This method patches this call through the each of the wrapped models.

Parameters:

Name Type Description Default
algorithm QCAlgorithm

The algorithm instance that experienced the change in securities

required
changes SecurityChanges

The security additions and removals from the algorithm

required