Skip to content

PortfolioTarget

QuantConnect.Algorithm.Framework.Portfolio.PortfolioTarget

PortfolioTarget(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    tag: str = ...,
)
PortfolioTarget(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    tag: str = ...,
)
PortfolioTarget(
    symbol: Union[Symbol, str, BaseContract],
    insight_direction: InsightDirection,
    tag: str = ...,
)

Bases: Object, IPortfolioTarget

Provides an implementation of IPortfolioTarget that specifies a specified quantity of a security to be held by the algorithm

Initializes a new instance of the PortfolioTarget class

Parameters:

Name Type Description Default
symbol Union[Symbol, str, BaseContract]

The symbol this target is for

required
quantity Optional[float | int]

The target quantity

None
tag str

The target tag with additional information

...
insight_direction Optional[InsightDirection]

The insight direction, which will be used to calculate the target quantity

None

minimum_order_margin_percentage_warning_sent

minimum_order_margin_percentage_warning_sent: Optional[bool]

Flag to determine if the minimum order margin portfolio percentage warning should or has already been sent to the user algorithm IAlgorithmSettings.minimum_order_margin_portfolio_percentage

symbol

symbol: Symbol

Gets the symbol of this target

quantity

quantity: float

Gets the target quantity for the symbol

tag

tag: str

Portfolio target tag with additional information

percent

percent(
    algorithm: IAlgorithm,
    symbol: Union[Symbol, str, BaseContract],
    percent: float,
) -> IPortfolioTarget
percent(
    algorithm: IAlgorithm,
    symbol: Union[Symbol, str, BaseContract],
    percent: float,
    tag: str,
) -> IPortfolioTarget
percent(
    algorithm: IAlgorithm,
    symbol: Union[Symbol, str, BaseContract],
    percent: float,
    return_delta_quantity: bool = False,
    tag: str = ...,
) -> IPortfolioTarget

Creates a new target for the specified percent

Parameters:

Name Type Description Default
algorithm IAlgorithm

The algorithm instance, used for getting total portfolio value and current security price

required
symbol Union[Symbol, str, BaseContract]

The symbol the target is for

required
percent float

The requested target percent of total portfolio value

required
tag Optional[str]

The target tag with additional information

...
return_delta_quantity Optional[bool]

True, result quantity will be the Delta required to reach target percent.

False

Returns:

Type Description
IPortfolioTarget

A portfolio target for the specified symbol/percent.

to_string

to_string() -> str

Returns a string that represents the current object.

Returns:

Type Description
str

A string that represents the current object.