Skip to content

AddSecurityCommand

QuantConnect.Commands.AddSecurityCommand

AddSecurityCommand()

Bases: BaseCommand

Represents a command to add a security to the algorithm

Default construct that applies default values

security_type

security_type: SecurityType

The security type of the security

symbol

symbol: str

The security's ticker symbol

resolution

resolution: Resolution

The requested resolution, defaults to Resolution.Minute

market

market: str

The security's market, defaults to QuantConnect.Market.USA except for Forex, defaults to QuantConnect.Market.FXCM

fill_data_forward

fill_data_forward: bool

The fill forward behavior, true to fill forward, false otherwise - defaults to true

leverage

leverage: float

The leverage for the security, defaults to 2 for equity, 50 for forex, and 1 for everything else

extended_market_hours

extended_market_hours: bool

The extended market hours flag, true to allow pre/post market data, false for only in market data

id

id: str

Unique command id

Result

Result(
    command: AddSecurityCommand,
    success: bool,
    symbol: Union[Symbol, str, BaseContract],
)

Bases: CommandResultPacket

Result packet type for the AddSecurityCommand command

Initializes a new instance of the Result class

symbol

symbol: Symbol

The symbol result from the add security command

type

type: PacketType

Packet type defined by a string enum

channel

channel: str

User unique specific channel endpoint to send the packets

command_name

command_name: str

Gets or sets the command that produced this packet

success

success: Optional[bool]

Gets or sets whether or not the

run

run(algorithm: IAlgorithm) -> CommandResultPacket

Runs this command against the specified algorithm instance

Parameters:

Name Type Description Default
algorithm IAlgorithm

The algorithm to run this command against

required

get_symbol

get_symbol(
    ticker: str,
    security_type: SecurityType,
    market: str,
    symbol: Union[Symbol, str, BaseContract] = None,
) -> Symbol

Creats symbol using symbol properties.

This codeEntityType is protected.

Parameters:

Name Type Description Default
ticker str

The string ticker symbol

required
security_type SecurityType

The security type of the ticker. If security_type == Option, then a canonical symbol is created

required
market str

The market the ticker resides in

required
symbol Union[Symbol, str, BaseContract]

The algorithm to run this command against

None