Skip to content

QuantBook

QuantConnect.Research.QuantBook

QuantBook()

Bases: QCAlgorithm

Provides access to data for quantitative analysis

QuantBook constructor. Provides access to data for quantitative analysis

account_currency

account_currency: str

Gets the account currency

security_initializer

security_initializer: ISecurityInitializer

Gets an instance that is to be used to initialize newly created securities.

insights_generated

insights_generated: _EventContainer[
    Callable[
        [IAlgorithm, GeneratedInsightsCollection], Any
    ],
    Any,
]

Event fired when the algorithm generates insights

time_keeper

time_keeper: ITimeKeeper

Gets the time keeper instance

subscription_manager

subscription_manager: SubscriptionManager

Generic Data Manager - Required for compiling all data feeds in order, and passing them into algorithm event methods. The subscription manager contains a list of the data feed's we're subscribed to and properties of each data feed.

project_id

project_id: int

The project id associated with this algorithm if any

securities

securities: SecurityManager

Security collection is an array of the security objects such as Equity and Forex. Securities data manages the properties of tradeable assets such as price, open and close time and holdings information.

universe_manager

universe_manager: UniverseManager

Gets universe manager which holds universes keyed by their symbol

portfolio

Portfolio object provieds easy access to the underlying security-holding properties; summed together in a way to make them useful. This saves the user time by providing common portfolio requests in a single

transactions

Transaction Manager - Process transaction fills and order management.

brokerage_model

brokerage_model: IBrokerageModel

Gets the brokerage model - used to model interactions with specific brokerages.

brokerage_name

brokerage_name: BrokerageName

Gets the brokerage name.

risk_free_interest_rate_model

risk_free_interest_rate_model: IRiskFreeInterestRateModel

Gets the risk free interest rate model used to get the interest rates

brokerage_message_handler

brokerage_message_handler: IBrokerageMessageHandler

Gets the brokerage message handler used to decide what to do with each message sent from the brokerage

notify

Notification Manager for Sending Live Runtime Notifications to users about important events.

schedule

schedule: ScheduleManager

Gets schedule manager for adding/removing scheduled events

history_provider

history_provider: IHistoryProvider

Gets or sets the history provider for the algorithm

status

Gets or sets the current status of the algorithm

is_warming_up

is_warming_up: bool

Gets whether or not this algorithm is still warming up

name

name: str

Public name for the algorithm as automatically generated by the IDE. Intended for helping distinguish logs by noting the algorithm-id.

tags

tags: HashSet[str]

A list of tags associated with the algorithm or the backtest, useful for categorization

name_updated

name_updated: _EventContainer[
    Callable[[IAlgorithm, str], Any], Any
]

Event fired algorithm's name is changed

tags_updated

tags_updated: _EventContainer[
    Callable[[IAlgorithm, HashSet[str]], Any], Any
]

Event fired when the tag collection is updated

time

time: datetime

Read-only value for current time frontier of the algorithm in terms of the time_zone

time_zone

time_zone: Any

Gets the time zone used for the time property. The default value is TimeZones.NEW_YORK

utc_time

utc_time: datetime

Current date/time in UTC.

start_date

start_date: datetime

Value of the user set start-date from the backtest.

end_date

end_date: datetime

Value of the user set start-date from the backtest. Controls the period of the backtest.

algorithm_id

algorithm_id: str

Algorithm Id for this backtest or live algorithm.

live_mode

live_mode: bool

Boolean property indicating the algorithm is currently running in live mode.

algorithm_mode

algorithm_mode: AlgorithmMode

Algorithm running mode.

deployment_target

deployment_target: DeploymentTarget

Deployment target, either local or cloud.

universe_settings

universe_settings: UniverseSettings

Gets the universe settings to be used when adding securities via universe selection

debug_messages

debug_messages: ConcurrentQueue[str]

Storage for debugging messages before the event handler has passed control back to the Lean Engine.

error_messages

error_messages: ConcurrentQueue[str]

List of error messages generated by the user's code calling the "Error" function.

log_messages

log_messages: ConcurrentQueue[str]

Storage for log messages before the event handlers have passed control back to the Lean Engine.

run_time_error

run_time_error: Exception

Gets the run time error from the algorithm, or null if none was encountered.

runtime_statistics

runtime_statistics: ConcurrentDictionary[str, str]

Access to the runtime statistics property. User provided statistics.

statistics

statistics: StatisticsResults

The current statistics for the running algorithm.

benchmark

benchmark: IBenchmark

The IBenchmark for the algorithm

trade_builder

trade_builder: ITradeBuilder

Gets the Trade Builder to generate trades from executions

settings

Gets the user settings for the algorithm

option_chain_provider

option_chain_provider: IOptionChainProvider

Gets the option chain provider, used to get the list of option contracts for an underlying symbol

OptionChainProvider property is will soon be deprecated. The new OptionChain() method should be used to fetch option chains, which will contain additional data per contract, like daily price data, implied volatility and greeks.

future_chain_provider

future_chain_provider: IFutureChainProvider

Gets the future chain provider, used to get the list of future contracts for an underlying symbol

FutureChainProvider property is will soon be deprecated. The new FuturesChain() method should be used to fetch futures chains, which will contain additional data per contract, like daily price data.

insights

insights: InsightManager

Gets the insight manager

object_store

object_store: ObjectStore

Gets the object store, used for persistence

current_slice

current_slice: Slice

Returns the current Slice object

universe

Gets a helper that provides pre-defined universe definitions, such as top dollar volume

debug_mode

debug_mode: bool

Enables additional logging of framework models including: All insights, portfolio targets, order events, and any risk management altered targets

universe_selection

universe_selection: IUniverseSelectionModel

Gets or sets the universe selection model.

alpha

alpha: IAlphaModel

Gets or sets the alpha model

portfolio_construction

portfolio_construction: IPortfolioConstructionModel

Gets or sets the portfolio construction model

execution

execution: IExecutionModel

Gets or sets the execution model

risk_management

risk_management: IRiskManagementModel

Gets or sets the risk management model

MAX_NAME_AND_TAGS_LENGTH

MAX_NAME_AND_TAGS_LENGTH: int = 200

Maximum length of the name or tags of a backtest

This codeEntityType is protected.

MAX_TAGS_COUNT

MAX_TAGS_COUNT: int = 100

Maximum number of tags allowed for a backtest

This codeEntityType is protected.

market_hours_database

market_hours_database: MarketHoursDatabase

Gets the market hours database in use by this algorithm

This codeEntityType is protected.

symbol_properties_database

symbol_properties_database: SymbolPropertiesDatabase

Gets the symbol properties database in use by this algorithm

This codeEntityType is protected.

active_securities

active_securities: IReadOnlyDictionary[Symbol, Security]

Read-only dictionary containing all active securities. An active security is a security that is currently selected by the universe or has holdings or open orders.

signal_export

signal_export: SignalExportManager

SignalExport - Allows sending export signals to different 3rd party API's. For example, it allows to send signals to Collective2, CrunchDAO and Numerai API's

candlestick_patterns

candlestick_patterns: CandlestickPatterns

Gets an instance to access the candlestick pattern helper methods

date_rules

date_rules: DateRules

Gets the date rules helper object to make specifying dates for events easier

time_rules

time_rules: TimeRules

Gets the time rules helper object to make specifying times for events easier

trading_calendar

trading_calendar: TradingCalendar

Gets trading calendar populated with trading events

default_order_properties

default_order_properties: IOrderProperties

Gets the default order properties

enable_automatic_indicator_warm_up

enable_automatic_indicator_warm_up: bool

Gets whether or not WarmUpIndicator is allowed to warm up indicators

Please use Settings.AutomaticIndicatorWarmUp

pandas_converter

pandas_converter: PandasConverter

PandasConverter for this Algorithm

history

history: History

History

History

Bases: Generic[QuantConnect_Algorithm_QCAlgorithm_History_T]

__call__
__call__(
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[
    DataDictionary[
        QuantConnect_Algorithm_QCAlgorithm_History_T
    ]
]
__call__(
    symbols: List[Symbol],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[
    DataDictionary[
        QuantConnect_Algorithm_QCAlgorithm_History_T
    ]
]
__call__(
    symbols: List[Symbol],
    periods: int,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[
    DataDictionary[
        QuantConnect_Algorithm_QCAlgorithm_History_T
    ]
]
__call__(
    symbols: List[Symbol],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[
    DataDictionary[
        QuantConnect_Algorithm_QCAlgorithm_History_T
    ]
]
__call__(
    symbol: Union[Symbol, str, BaseContract],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[QuantConnect_Algorithm_QCAlgorithm_History_T]
__call__(
    symbol: Union[Symbol, str, BaseContract],
    periods: int,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[QuantConnect_Algorithm_QCAlgorithm_History_T]
__call__(
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[QuantConnect_Algorithm_QCAlgorithm_History_T]

__call__

__call__(
    tickers: Any,
    periods: int,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
    flatten: bool = False,
) -> DataFrame
__call__(
    tickers: Any,
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
    flatten: bool = False,
) -> DataFrame
__call__(
    tickers: Any,
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
    flatten: bool = False,
) -> DataFrame
__call__(
    type: Type,
    tickers: Any,
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
    flatten: bool = False,
) -> DataFrame
__call__(
    type: Type,
    tickers: Any,
    periods: int,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
    flatten: bool = False,
) -> DataFrame
__call__(
    type: Type,
    tickers: Any,
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
    flatten: bool = False,
) -> DataFrame
__call__(
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[Slice]
__call__(
    periods: int,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[Slice]
__call__(
    universe: Universe,
    periods: int,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[BaseDataCollection]
__call__(
    universe: Universe,
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[BaseDataCollection]
__call__(
    universe: Universe,
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[BaseDataCollection]
__call__(
    symbol: Union[Symbol, str, BaseContract],
    periods: int,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[TradeBar]
__call__(
    symbol: Union[Symbol, str, BaseContract],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[TradeBar]
__call__(
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[TradeBar]
__call__(
    symbols: List[Symbol],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[Slice]
__call__(
    symbols: List[Symbol],
    periods: int,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[Slice]
__call__(
    symbols: List[Symbol],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[Slice]
__call__(request: HistoryRequest) -> Iterable[Slice]
__call__(requests: List[HistoryRequest]) -> Iterable[Slice]
__call__(
    type: Type,
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
    flatten: bool = False,
) -> DataFrame
__call__(
    type: Type,
    symbol: Union[Symbol, str, BaseContract],
    periods: int,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
    flatten: bool = False,
) -> DataFrame
__call__(
    type: Type,
    symbol: Union[Symbol, str, BaseContract],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
    flatten: bool = False,
) -> DataFrame

__getitem__

__getitem__(
    type: Type[
        QuantConnect_Algorithm_QCAlgorithm_History_T
    ],
) -> History[QuantConnect_Algorithm_QCAlgorithm_History_T]

get_fundamental

get_fundamental(
    input: Any,
    selector: str = None,
    start: Optional[datetime] = None,
    end: Optional[datetime] = None,
) -> DataFrame
get_fundamental(
    symbols: List[Symbol],
    selector: str = None,
    start: Optional[datetime] = None,
    end: Optional[datetime] = None,
) -> Iterable[DataDictionary[Any]]
get_fundamental(
    symbol: Union[Symbol, str, BaseContract],
    selector: str = None,
    start: Optional[datetime] = None,
    end: Optional[datetime] = None,
) -> Iterable[DataDictionary[Any]]
get_fundamental(
    tickers: List[str],
    selector: str = None,
    start: Optional[datetime] = None,
    end: Optional[datetime] = None,
) -> Iterable[DataDictionary[Any]]
get_fundamental(
    ticker: str,
    selector: str = None,
    start: Optional[datetime] = None,
    end: Optional[datetime] = None,
) -> Any

Signature descriptions:

  • Python implementation of GetFundamental, get fundamental data for input symbols or tickers

  • Get fundamental data from given symbols

  • Get fundamental data for a given symbol

  • Get fundamental data for a given set of tickers

  • Get fundamental data for a given ticker

Parameters:

Name Type Description Default
input Optional[Any]

The symbols or tickers to retrieve fundamental data for

None
selector str

Selects a value from the Fundamental data to filter the request output

None
start Optional[datetime]

The start date of selected data

None
end Optional[datetime]

The end date of selected data

None
symbols Optional[List[Symbol]]

The symbols to retrieve fundamental data for

None
symbol Optional[Union[Symbol, str, BaseContract]]

The symbol to retrieve fundamental data for

None
tickers Optional[List[str]]

The tickers to retrieve fundamental data for

None

Returns:

Type Description
DataFrame | Iterable[DataDictionary[Any]] | Any

Depends on the signature used. Case 1: [pandas DataFrame.]; Case 2: [Enumerable collection of DataDictionaries, one dictionary for each day there is data.]; Case 3: [Enumerable collection of DataDictionaries, one Dictionary for each day there is data.]

get_option_history

get_option_history(
    symbol: Union[Symbol, str, BaseContract],
    target_option: str,
    start: Union[datetime, date],
    end: Optional[datetime] = None,
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    extended_market_hours: bool = False,
) -> OptionHistory
get_option_history(
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Optional[datetime] = None,
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    extended_market_hours: bool = False,
) -> OptionHistory

Gets option_history object for a given symbol, date and resolution

Parameters:

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

The symbol to retrieve historical option data for

required
target_option Optional[str]

The target option ticker. This is useful when the option ticker does not match the underlying, e.g. SPX index and the SPXW weekly option. If null is provided will use underlying

None
start Union[datetime, date]

The history request start time

required
end Optional[datetime]

The history request end time. Defaults to 1 day if null

None
resolution Optional[Resolution]

The resolution to request

None
fill_forward bool

True to fill forward missing data, false otherwise

True
extended_market_hours bool

True to include extended market hours data, false otherwise

False

Returns:

Type Description
OptionHistory

A option_history object that contains historical option data.

future_history

future_history(
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Optional[datetime] = None,
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    extended_market_hours: bool = False,
) -> FutureHistory

Gets future_history object for a given symbol, date and resolution

Parameters:

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

The symbol to retrieve historical future data for

required
start Union[datetime, date]

The history request start time

required
end Optional[datetime]

The history request end time. Defaults to 1 day if null

None
resolution Optional[Resolution]

The resolution to request

None
fill_forward bool

True to fill forward missing data, false otherwise

True
extended_market_hours bool

True to include extended market hours data, false otherwise

False

Returns:

Type Description
FutureHistory

A future_history object that contains historical future data.

indicator

indicator(
    indicator: IndicatorBase[IndicatorDataPoint],
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame
indicator(
    indicator: IndicatorBase[IBaseDataBar],
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> DataFrame
indicator(
    indicator: IndicatorBase[TradeBar],
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> DataFrame
indicator(
    indicator: IndicatorBase[IndicatorDataPoint],
    symbol: Union[Symbol, str, BaseContract],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame
indicator(
    indicator: IndicatorBase[IBaseDataBar],
    symbol: Union[Symbol, str, BaseContract],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> DataFrame
indicator(
    indicator: IndicatorBase[TradeBar],
    symbol: Union[Symbol, str, BaseContract],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> DataFrame
indicator(
    indicator: IndicatorBase[IndicatorDataPoint],
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame
indicator(
    indicator: IndicatorBase[IBaseDataBar],
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> DataFrame
indicator(
    indicator: IndicatorBase[TradeBar],
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> DataFrame

Signature descriptions:

  • Gets the historical data of an indicator for the specified symbol. The exact number of bars will be returned. The symbol must exist in the Securities collection.

  • Gets the historical data of a bar indicator for the specified symbol. The exact number of bars will be returned. The symbol must exist in the Securities collection.

Parameters:

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

The symbol to retrieve historical data for

required
resolution Optional[Resolution]

The resolution to request

None
selector Callable[[IBaseData], float] | Callable[[IBaseData], IBaseDataBar] | Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None
indicator IndicatorBase[IndicatorDataPoint] | IndicatorBase[IBaseDataBar] | IndicatorBase[TradeBar]

Indicator

required
span Optional[timedelta]

The span over which to retrieve recent historical data

None
start Optional[Union[datetime, date]]

The start time in the algorithm's time zone

None
end Optional[Union[datetime, date]]

The end time in the algorithm's time zone

None

Returns:

Type Description
DataFrame

Depends on the signature used. Case 1: [pandas.DataFrame of historical data of an indicator.]; Case 2: [pandas.DataFrame of historical data of a bar indicator.]

option_history

option_history(
    symbol: Union[Symbol, str, BaseContract],
    target_option: str,
    start: Union[datetime, date],
    end: Optional[datetime] = None,
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    extended_market_hours: bool = False,
) -> OptionHistory
option_history(
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Optional[datetime] = None,
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    extended_market_hours: bool = False,
) -> OptionHistory

Gets option_history object for a given symbol, date and resolution

Parameters:

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

The symbol to retrieve historical option data for

required
target_option Optional[str]

The target option ticker. This is useful when the option ticker does not match the underlying, e.g. SPX index and the SPXW weekly option. If null is provided will use underlying

None
start Union[datetime, date]

The history request start time

required
end Optional[datetime]

The history request end time. Defaults to 1 day if null

None
resolution Optional[Resolution]

The resolution to request

None
fill_forward bool

True to fill forward missing data, false otherwise

True
extended_market_hours bool

True to include extended market hours data, false otherwise

False

Returns:

Type Description
OptionHistory

A option_history object that contains historical option data.

universe_history

universe_history(
    universe: Any,
    start: Union[datetime, date],
    end: Optional[datetime] = None,
    func: Any = None,
    date_rule: IDateRule = None,
    flatten: bool = False,
) -> Any
universe_history(
    universe: Universe,
    start: Union[datetime, date],
    end: Optional[datetime] = None,
    date_rule: IDateRule = None,
) -> Iterable[Iterable[BaseData]]

Will return the universe selection data and will optionally perform selection

Parameters:

Name Type Description Default
universe Any | Universe

The universe to fetch the data for

required
start Union[datetime, date]

The start date

required
end Optional[datetime]

Optionally the end date, will default to today

None
func Optional[Any]

Optionally the universe selection function

None
date_rule IDateRule

Date rule to apply for the history data

None
flatten Optional[bool]

Whether to flatten the resulting data frame.

False

Returns:

Type Description
Any | Iterable[Iterable[BaseData]]

Enumerable of universe selection data for each date, filtered if the func was provided.

get_future_history

get_future_history(
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Optional[datetime] = None,
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    extended_market_hours: bool = False,
) -> FutureHistory

Gets future_history object for a given symbol, date and resolution

Please use the 'FutureHistory()' API

Parameters:

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

The symbol to retrieve historical future data for

required
start Union[datetime, date]

The history request start time

required
end Optional[datetime]

The history request end time. Defaults to 1 day if null

None
resolution Optional[Resolution]

The resolution to request

None
fill_forward bool

True to fill forward missing data, false otherwise

True
extended_market_hours bool

True to include extended market hours data, false otherwise

False

Returns:

Type Description
FutureHistory

A future_history object that contains historical future data.

get_portfolio_statistics

get_portfolio_statistics(data_frame: Any) -> Dict[Any, Any]

Gets Portfolio Statistics from a pandas.DataFrame with equity and benchmark values

Parameters:

Name Type Description Default
data_frame Any

pandas.DataFrame with the information required to compute the Portfolio statistics

required

Returns:

Type Description
Dict[Any, Any]

PortfolioStatistics object wrapped in a PyDict with the portfolio statistics.

add_security

add_security(
    security_type: SecurityType,
    ticker: str,
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    extended_market_hours: bool = False,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
) -> Security
add_security(
    security_type: SecurityType,
    ticker: str,
    resolution: Optional[Resolution],
    fill_forward: bool,
    leverage: float,
    extended_market_hours: bool,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
) -> Security
add_security(
    security_type: SecurityType,
    ticker: str,
    resolution: Optional[Resolution],
    market: str,
    fill_forward: bool,
    leverage: float,
    extended_market_hours: bool,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
) -> Security
add_security(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    leverage: float = ...,
    extended_market_hours: bool = False,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: int = 0,
) -> Security

Signature descriptions:

  • Add specified data to our data subscriptions. QuantConnect will funnel this data to the handle data routine.

  • Add specified data to required list. QC will funnel this data to the handle data routine.

  • Set a required SecurityType-symbol and resolution for algorithm

Parameters:

Name Type Description Default
security_type Optional[SecurityType]

MarketType Type: Equity, Commodity, Future, FOREX or Crypto

None
ticker Optional[str]

The security ticker

None
resolution Optional[Resolution]

Resolution of the Data Required

None
fill_forward bool

When no data available on a tradebar, return the last data that was generated

True
extended_market_hours bool

Use extended market hours data

False
data_mapping_mode Optional[DataMappingMode]

The contract mapping mode to use for the security

None
data_normalization_mode Optional[DataNormalizationMode]

The price scaling mode to use for the security

None
leverage Optional[float]

Custom leverage per security

...
market Optional[str]

The market the requested security belongs to, such as 'usa' or 'fxcm'

None
symbol Optional[Union[Symbol, str, BaseContract]]

The security Symbol

None
contract_depth_offset Optional[int]

The continuous contract desired offset from the current front month.

0

Returns:

Type Description
Security

The new Security that was added to the algorithm.

get_last_known_prices

get_last_known_prices(
    security: Security,
) -> Iterable[BaseData]
get_last_known_prices(
    symbol: Union[Symbol, str, BaseContract],
) -> Iterable[BaseData]
get_last_known_prices(
    securities: List[Security],
) -> DataDictionary[Iterable[BaseData]]
get_last_known_prices(
    symbols: List[Symbol],
) -> DataDictionary[Iterable[BaseData]]

Signature descriptions:

  • Yields data to warmup a security for all it's subscribed data types

  • Yields data to warm up a security for all its subscribed data types

  • Yields data to warm up multiple securities for all their subscribed data types

Parameters:

Name Type Description Default
security Optional[Security]

Security object for which to retrieve historical data

None
symbol Optional[Union[Symbol, str, BaseContract]]

The symbol we want to get seed data for

None
securities Optional[List[Security]]

The securities we want to get seed data for

None
symbols Optional[List[Symbol]]

The symbols we want to get seed data for

None

Returns:

Type Description
Iterable[BaseData] | DataDictionary[Iterable[BaseData]]

Securities historical data.

get_parameter

get_parameter(name: str, default_value: str = None) -> str
get_parameter(name: str, default_value: int) -> int
get_parameter(name: str, default_value: float) -> float

Signature descriptions:

  • Gets the parameter with the specified name. If a parameter with the specified name does not exist, the given default value is returned if any, else null

  • Gets the parameter with the specified name parsed as an integer. If a parameter with the specified name does not exist, or the conversion is not possible, the given default value is returned

  • Gets the parameter with the specified name parsed as a double. If a parameter with the specified name does not exist, or the conversion is not possible, the given default value is returned

Parameters:

Name Type Description Default
name str

The name of the parameter to get

required
default_value str | int | float

The default value to return

None

Returns:

Type Description
str | int | float

The value of the specified parameter, or default_value if not found or null if there's no default value.

set_cash

set_cash(starting_cash: float) -> None
set_cash(starting_cash: int) -> None
set_cash(
    symbol: str,
    starting_cash: float,
    conversion_rate: float = 0,
) -> None

Signature descriptions:

  • Set initial cash for the strategy while backtesting. During live mode this value is ignored and replaced with the actual cash of your brokerage account.

  • Set the cash for the specified symbol

Parameters:

Name Type Description Default
starting_cash float | int

Starting cash for the strategy backtest

required
symbol Optional[str]

The cash symbol to set

None
conversion_rate Optional[float]

The current conversion rate for the

0

add_chart

add_chart(chart: Chart) -> None

Add a Chart object to algorithm collection

Parameters:

Name Type Description Default
chart Chart

Chart object to add to collection.

required

add_future_contract

add_future_contract(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    leverage: float = ...,
    extended_market_hours: bool = False,
) -> Future

Creates and adds a new single Future contract to the algorithm

Parameters:

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

The futures contract symbol

required
resolution Optional[Resolution]

The Resolution of market data, Tick, Second, Minute, Hour, or Daily. Default is Resolution.MINUTE

None
fill_forward bool

If true, returns the last available data even if none in that timeslice. Default is true

True
leverage float

The requested leverage for this future. Default is set by security_initializer

...
extended_market_hours bool

Use extended market hours data

False

Returns:

Type Description
Future

The new Future security.

add_option_contract

add_option_contract(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    leverage: float = ...,
    extended_market_hours: bool = False,
) -> Option

Creates and adds a new single Option contract to the algorithm

Parameters:

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

The option contract symbol

required
resolution Optional[Resolution]

The Resolution of market data, Tick, Second, Minute, Hour, or Daily. Default is Resolution.MINUTE

None
fill_forward bool

If true, returns the last available data even if none in that timeslice. Default is true

True
leverage float

The requested leverage for this option. Default is set by security_initializer

...
extended_market_hours bool

Use extended market hours data

False

Returns:

Type Description
Option

The new Option security.

add_tag

add_tag(tag: str) -> None

Adds a tag to the algorithm

Parameters:

Name Type Description Default
tag str

The tag to add

required

debug

debug(message: Any) -> None
debug(message: str) -> None
debug(message: int) -> None
debug(message: float) -> None

Send a debug message to the web console:

Parameters:

Name Type Description Default
message Any | str | int | float

Message to send to debug console

required

error

error(message: Any) -> None
error(message: str) -> None
error(message: int) -> None
error(message: float) -> None
error(error: Exception) -> None

Signature descriptions:

  • Send a string error message to the Console.

  • Send a int error message to the Console.

  • Send a double error message to the Console.

Parameters:

Name Type Description Default
message Optional[Any | str | int | float]

Message to display in errors grid

None
error Optional[Exception]

Exception object captured from a try catch loop

None

get_chart_updates

get_chart_updates(
    clear_chart_data: bool = False,
) -> Iterable[Chart]

Get the chart updates by fetch the recent points added and return for dynamic Charting.

Parameters:

Name Type Description Default
clear_chart_data bool
False

Returns:

Type Description
Iterable[Chart]

List of chart updates since the last request.

get_last_known_price

get_last_known_price(security: Security) -> BaseData
get_last_known_price(
    symbol: Union[Symbol, str, BaseContract],
) -> BaseData

Get the last known price using the history provider. Useful for seeding securities with the correct price

Parameters:

Name Type Description Default
security Optional[Security]

Security object for which to retrieve historical data

None
symbol Optional[Union[Symbol, str, BaseContract]]

Symbol for which to retrieve historical data

None

Returns:

Type Description
BaseData

A single BaseData object with the last known price.

get_locked

get_locked() -> bool

Gets whether or not this algorithm has been locked and fully initialized

get_parameters

get_parameters() -> IReadOnlyDictionary[str, str]

Gets a read-only dictionary with all current parameters

initialize

initialize() -> None

Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.

liquidate

liquidate(
    symbol: Union[Symbol, str, BaseContract] = None,
    asynchronous: bool = False,
    tag: str = None,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]
liquidate(
    symbols: List[Symbol],
    asynchronous: bool = False,
    tag: str = None,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]
liquidate(
    symbol_to_liquidate: Union[Symbol, str, BaseContract],
    tag: str,
) -> List[OrderTicket]

Signature descriptions:

  • Liquidate your portfolio holdings

  • Liquidate all holdings and cancel open orders. Called at the end of day for tick-strategies.

Parameters:

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

Specific asset to liquidate, defaults to all

None
asynchronous Optional[bool]

Flag to indicate if the symbols should be liquidated asynchronously

False
tag str

Custom tag to know who is calling this

None
order_properties Optional[IOrderProperties]

Order properties to use

None
symbols Optional[List[Symbol]]

List of symbols to liquidate, defaults to all

None
symbol_to_liquidate Optional[Union[Symbol, str, BaseContract]]

Symbol we wish to liquidate

None

Returns:

Type Description
List[OrderTicket]

Array of order ids for liquidated symbols.

log

log(message: Any) -> None
log(message: str) -> None
log(message: int) -> None
log(message: float) -> None

Added another method for logging if user guessed.

Parameters:

Name Type Description Default
message Any | str | int | float

String message to log.

required

on_assignment_order_event

on_assignment_order_event(
    assignment_event: OrderEvent,
) -> None

Option assignment event handler. On an option assignment event for short legs the resulting information is passed to this method.

Parameters:

Name Type Description Default
assignment_event OrderEvent

Option exercise event details containing details of the assignment

required

on_brokerage_disconnect

on_brokerage_disconnect() -> None

Brokerage disconnected event handler. This method is called when the brokerage connection is lost.

on_brokerage_message

on_brokerage_message(
    message_event: BrokerageMessageEvent,
) -> None

Brokerage message event handler. This method is called for all types of brokerage messages.

Parameters:

Name Type Description Default
message_event BrokerageMessageEvent

The brokerage message event instance containing the message details.

required

on_brokerage_reconnect

on_brokerage_reconnect() -> None

Brokerage reconnected event handler. This method is called when the brokerage connection is restored after a disconnection.

on_command

on_command(data: Any) -> Optional[bool]

Generic untyped command call handler

Parameters:

Name Type Description Default
data Any

The associated data

required

Returns:

Type Description
Optional[bool]

True if success, false otherwise. Returning null will disable command feedback.

on_data

on_data(slice: Slice) -> None

Event - v3.0 DATA EVENT HANDLER: (Pattern) Basic template for user to override for receiving all subscription data in a single event

Parameters:

Name Type Description Default
slice Slice

The current slice of data keyed by symbol string

required

on_delistings

on_delistings(delistings: Delistings) -> None

Event handler to be called when there's been a delistings event

Parameters:

Name Type Description Default
delistings Delistings

The current time slice delistings

required

on_dividends

on_dividends(dividends: Dividends) -> None

Event handler to be called when there's been a dividend event

Parameters:

Name Type Description Default
dividends Dividends

The current time slice dividends

required

on_end_of_algorithm

on_end_of_algorithm() -> None

End of algorithm run event handler. This method is called at the end of a backtest or live trading operation. Intended for closing out logs.

on_end_of_day

on_end_of_day(symbol: Symbol) -> None

End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets).

Parameters:

Name Type Description Default
symbol Symbol

Asset symbol for this end of day event. Forex and equities have different closing hours.

required

on_end_of_time_step

on_end_of_time_step() -> None

Invoked at the end of every time step. This allows the algorithm to process events before advancing to the next time step.

on_framework_data

on_framework_data(slice: Slice) -> None

Used to send data updates to algorithm framework models

Parameters:

Name Type Description Default
slice Slice

The current data Slice

required

on_framework_securities_changed

on_framework_securities_changed(
    changes: SecurityChanges,
) -> None

Used to send security changes to algorithm framework models

Parameters:

Name Type Description Default
changes SecurityChanges

Security additions/removals for this time step

required

on_margin_call

on_margin_call(requests: List[SubmitOrderRequest]) -> None

Margin call event handler. This method is called right before the margin call orders are placed in the market.

Parameters:

Name Type Description Default
requests List[SubmitOrderRequest]

The orders to be executed to bring this algorithm within margin limits

required

on_margin_call_warning

on_margin_call_warning() -> None

Margin call warning event handler. This method is called when Portfolio.MarginRemaining is under 5% of your Portfolio.TotalPortfolioValue

on_order_event

on_order_event(order_event: OrderEvent) -> None

Order fill event handler. On an order fill update the resulting information is passed to this method.

Parameters:

Name Type Description Default
order_event OrderEvent

Order event details containing details of the events

required

on_securities_changed

on_securities_changed(changes: SecurityChanges) -> None

Event fired each time the we add/remove securities from the data feed

Parameters:

Name Type Description Default
changes SecurityChanges

Security additions/removals for this time step

required

on_splits

on_splits(splits: Splits) -> None

Event handler to be called when there's been a split event

Parameters:

Name Type Description Default
splits Splits

The current time slice splits

required

on_symbol_changed_events

on_symbol_changed_events(
    symbols_changed: SymbolChangedEvents,
) -> None

Event handler to be called when there's been a symbol changed event

Parameters:

Name Type Description Default
symbols_changed SymbolChangedEvents

The current time slice symbol changed events

required

on_warmup_finished

on_warmup_finished() -> None

Called when the algorithm has completed initialization and warm up.

post_initialize

post_initialize() -> None

Called by setup handlers after Initialize and allows the algorithm a chance to organize the data gather in the Initialize method

remove_security

remove_security(
    symbol: Union[Symbol, str, BaseContract],
    tag: str = None,
) -> bool

Removes the security with the specified symbol. This will cancel all open orders and then liquidate any existing holdings

Parameters:

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

The symbol of the security to be removed

required
tag str

Optional tag to indicate the cause of removal

None

run_command

run_command(
    command: CallbackCommand,
) -> CommandResultPacket

Run a callback command instance

Parameters:

Name Type Description Default
command CallbackCommand

The callback command instance

required

Returns:

Type Description
CommandResultPacket

The command result.

set_account_currency

set_account_currency(
    account_currency: str,
    starting_cash: Optional[float] = None,
) -> None

Sets the account currency cash symbol this algorithm is to manage, as well as the starting cash in this currency if given

Parameters:

Name Type Description Default
account_currency str

The account currency cash symbol to set

required
starting_cash Optional[float]

The account currency starting cash to set

None

set_algorithm_id

set_algorithm_id(algorithm_id: str) -> None

Set the algorithm id (backtestId or live deployId for the algorithm).

Parameters:

Name Type Description Default
algorithm_id str

String Algorithm Id

required

set_algorithm_mode

set_algorithm_mode(algorithm_mode: AlgorithmMode) -> None

Sets the algorithm running mode

Parameters:

Name Type Description Default
algorithm_mode AlgorithmMode

Algorithm mode

required

set_api

set_api(api: IApi) -> None

Provide the API for the algorithm.

Parameters:

Name Type Description Default
api IApi

Initiated API

required

set_available_data_types

set_available_data_types(
    available_data_types: Dictionary[
        SecurityType, List[TickType]
    ],
) -> None

Set the available data feeds in the SecurityManager

Parameters:

Name Type Description Default
available_data_types Dictionary[SecurityType, List[TickType]]

The different TickType each Security supports

required

set_brokerage_message_handler

set_brokerage_message_handler(handler: Any) -> None
set_brokerage_message_handler(
    handler: IBrokerageMessageHandler,
) -> None

Sets the implementation used to handle messages from the brokerage. The default implementation will forward messages to debug or error and when a BrokerageMessageType.ERROR occurs, the algorithm is stopped.

Parameters:

Name Type Description Default
handler Any | IBrokerageMessageHandler

The message handler to use

required

set_brokerage_model

set_brokerage_model(
    brokerage: BrokerageName,
    account_type: AccountType = ...,
) -> None
set_brokerage_model(model: IBrokerageModel) -> None

Signature descriptions:

  • Sets the brokerage to emulate in backtesting or paper trading. This can be used for brokerages that have been implemented in LEAN

  • Sets the brokerage to emulate in backtesting or paper trading. This can be used to set a custom brokerage model.

Parameters:

Name Type Description Default
brokerage Optional[BrokerageName]

The brokerage to emulate

None
account_type Optional[AccountType]

The account type (Cash or Margin)

...
model Optional[IBrokerageModel]

The brokerage model to use

None

set_current_slice

set_current_slice(slice: Slice) -> None

Sets the current slice

Parameters:

Name Type Description Default
slice Slice

The Slice object

required

set_date_time

set_date_time(frontier: Union[datetime, date]) -> None

Update the internal algorithm time frontier.

Parameters:

Name Type Description Default
frontier Union[datetime, date]

Current utc datetime.

required

set_deployment_target

set_deployment_target(
    deployment_target: DeploymentTarget,
) -> None

Sets the algorithm deployment target

Parameters:

Name Type Description Default
deployment_target DeploymentTarget

Deployment target

required

set_end_date

set_end_date(year: int, month: int, day: int) -> None
set_end_date(end: Union[datetime, date]) -> None

Signature descriptions:

  • Set the end date for a backtest run

  • Set the end date for a backtest.

Parameters:

Name Type Description Default
day Optional[int]

Int end date 1-30

None
month Optional[int]

Int month end date

None
year Optional[int]

Int year end date

None
end Optional[Union[datetime, date]]

Datetime value for end date

None

set_finished_warming_up

set_finished_warming_up() -> None

Sets IAlgorithm.is_warming_up to false to indicate this algorithm has finished its warm up

set_future_chain_provider

set_future_chain_provider(
    future_chain_provider: IFutureChainProvider,
) -> None

Sets the future chain provider, used to get the list of future contracts for an underlying symbol

Parameters:

Name Type Description Default
future_chain_provider IFutureChainProvider

The future chain provider

required

set_history_provider

set_history_provider(
    history_provider: IHistoryProvider,
) -> None

Set the historical data provider

Parameters:

Name Type Description Default
history_provider IHistoryProvider

Historical data provider

required

set_live_mode

set_live_mode(live: bool) -> None

Set live mode state of the algorithm run: Public setter for the algorithm property LiveMode.

set_locked

set_locked() -> None

Lock the algorithm initialization to avoid user modifiying cash and data stream subscriptions

set_maximum_orders

set_maximum_orders(max: int) -> None

Maximum number of orders for the algorithm

Parameters:

Name Type Description Default
max int
required

set_name

set_name(name: str) -> None

Sets name to the currently running backtest

Parameters:

Name Type Description Default
name str

The name for the backtest

required

set_object_store

set_object_store(object_store: IObjectStore) -> None

Sets the object store

Parameters:

Name Type Description Default
object_store IObjectStore

The object store

required

set_option_chain_provider

set_option_chain_provider(
    option_chain_provider: IOptionChainProvider,
) -> None

Sets the option chain provider, used to get the list of option contracts for an underlying symbol

Parameters:

Name Type Description Default
option_chain_provider IOptionChainProvider

The option chain provider

required

set_parameters

set_parameters(parameters: Dictionary[str, str]) -> None

Sets the parameters from the dictionary

Parameters:

Name Type Description Default
parameters Dictionary[str, str]

Dictionary containing the parameter names to values

required

set_run_time_error

set_run_time_error(exception: Exception) -> None

Set the runtime error

Parameters:

Name Type Description Default
exception Exception

Represents error that occur during execution

required

set_start_date

set_start_date(year: int, month: int, day: int) -> None
set_start_date(start: Union[datetime, date]) -> None

Signature descriptions:

  • Set the start date for backtest.

  • Set the start date for the backtest

Parameters:

Name Type Description Default
day Optional[int]

Int starting date 1-30

None
month Optional[int]

Int month starting date

None
year Optional[int]

Int year starting date

None
start Optional[Union[datetime, date]]

The start date for the backtest

None

set_statistics_service

set_statistics_service(
    statistics_service: IStatisticsService,
) -> None

Sets the statistics service instance to be used by the algorithm

Parameters:

Name Type Description Default
statistics_service IStatisticsService

The statistics service instance

required

set_status

set_status(status: AlgorithmStatus) -> None

Set the state of a live deployment

Parameters:

Name Type Description Default
status AlgorithmStatus

Live deployment status

required

set_tags

set_tags(tags: HashSet[str]) -> None

Sets the tags for the algorithm

Parameters:

Name Type Description Default
tags HashSet[str]

The tags

required

shortable

shortable(symbol: Union[Symbol, str, BaseContract]) -> bool
shortable(
    symbol: Union[Symbol, str, BaseContract],
    short_quantity: float,
    update_order_id: Optional[int] = None,
) -> bool

Determines if the Symbol is shortable at the brokerage

Parameters:

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

Symbol to check if shortable

required
short_quantity Optional[float]

Order's quantity to check if it is currently shortable, taking into account current holdings and open orders

None
update_order_id Optional[Optional[int]]

Optionally the id of the order being updated. When updating an order

None

Returns:

Type Description
bool

Depends on the signature used. Case 1: [True if shortable.]; Case 2: [True if the symbol can be shorted by the requested quantity.]

shortable_quantity

shortable_quantity(
    symbol: Union[Symbol, str, BaseContract],
) -> int

Gets the quantity shortable for the given asset

Returns:

Type Description
int

Quantity shortable for the given asset. Zero if not shortable, or a number greater than zero if shortable.

submit_order_request

submit_order_request(
    request: SubmitOrderRequest,
) -> OrderTicket

Will submit an order request to the algorithm

Parameters:

Name Type Description Default
request SubmitOrderRequest

The request to submit

required

Returns:

Type Description
OrderTicket

The order ticket.

symbol

symbol(ticker: str) -> Symbol

Converts the string 'ticker' symbol into a full symbol object This requires that the string 'ticker' has been added to the algorithm

Parameters:

Name Type Description Default
ticker str

The ticker symbol. This should be the ticker symbol as it was added to the algorithm

required

Returns:

Type Description
Symbol

The symbol object mapped to the specified ticker.

ticker

ticker(symbol: Union[Symbol, str, BaseContract]) -> str

For the given symbol will resolve the ticker it used at the current algorithm date

Parameters:

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

The symbol to get the ticker for

required

Returns:

Type Description
str

The mapped ticker for a symbol.

add_data

add_data(
    type: Type,
    ticker: str,
    resolution: Optional[Resolution],
    time_zone: Any,
    fill_forward: bool = False,
    leverage: float = 1.0,
) -> Security
add_data(
    type: Type,
    underlying: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution],
    time_zone: Any,
    fill_forward: bool = False,
    leverage: float = 1.0,
) -> Security
add_data(
    data_type: Type,
    ticker: str,
    resolution: Optional[Resolution],
    time_zone: Any,
    fill_forward: bool = False,
    leverage: float = 1.0,
) -> Security
add_data(
    data_type: Type,
    underlying: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    time_zone: Any = None,
    fill_forward: bool = False,
    leverage: float = 1.0,
) -> Security
add_data(
    type: Type,
    ticker: str,
    resolution: Optional[Resolution] = None,
) -> Security
add_data(
    type: Type,
    underlying: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
) -> Security
add_data(
    type: Type,
    ticker: str,
    properties: SymbolProperties,
    exchange_hours: SecurityExchangeHours,
    resolution: Optional[Resolution] = None,
    fill_forward: bool = False,
    leverage: float = 1.0,
) -> Security

Signature descriptions:

  • AddData a new user defined data source, requiring only the minimum config options. This method is meant for custom data types that require a ticker, but have no underlying Symbol. Examples of data sources that meet this criteria are U.S. Treasury Yield Curve Rates and Trading Economics data

  • AddData a new user defined data source, requiring only the minimum config options. This adds a Symbol to the Underlying property in the custom data Symbol object. Use this method when adding custom data with a ticker from the past, such as "AOL" before it became "TWX", or if you need to filter using custom data and place trades on the Symbol associated with the custom data.

  • AddData a new user defined data source, requiring only the minimum config options. The data is added with a default time zone of NewYork (Eastern Daylight Savings Time). This method is meant for custom data types that require a ticker, but have no underlying Symbol. Examples of data sources that meet this criteria are U.S. Treasury Yield Curve Rates and Trading Economics data

  • AddData a new user defined data source, requiring only the minimum config options. The data is added with a default time zone of NewYork (Eastern Daylight Savings Time). This adds a Symbol to the Underlying property in the custom data Symbol object. Use this method when adding custom data with a ticker from the past, such as "AOL" before it became "TWX", or if you need to filter using custom data and place trades on the Symbol associated with the custom data.

  • AddData a new user defined data source including symbol properties and exchange hours, all other vars are not required and will use defaults. This overload reflects the C# equivalent for custom properties and market hours

Parameters:

Name Type Description Default
type Optional[Type]

Data source type

None
ticker Optional[str]

Key/Ticker for data

None
resolution Optional[Resolution]

Resolution of the Data Required

None
time_zone Optional[Any]

Specifies the time zone of the raw data

None
fill_forward Optional[bool]

When no data available on a tradebar, return the last data that was generated

False
leverage Optional[float]

Custom leverage per security

1.0
underlying Optional[Union[Symbol, str, BaseContract]]

The underlying symbol for the custom data

None
data_type Optional[Type]

Data source type

None
properties Optional[SymbolProperties]

The properties of this new custom data

None
exchange_hours Optional[SecurityExchangeHours]

The Exchange hours of this symbol

None

Returns:

Type Description
Security

The new Security.

add_index_option

add_index_option(
    underlying: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
) -> IndexOption
add_index_option(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
) -> IndexOption
add_index_option(
    symbol: Union[Symbol, str, BaseContract],
    target_option: str,
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
) -> IndexOption
add_index_option(
    underlying: str,
    target_option: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
) -> IndexOption

Creates and adds index options to the algorithm.

Parameters:

Name Type Description Default
underlying Optional[str]

The underlying ticker of the IndexOption

None
resolution Optional[Resolution]

Resolution of the index option contracts, i.e. the granularity of the data

None
market Optional[str]

The foreign exchange trading market, Market. Default value is null and looked up using IBrokerageModel.default_markets in AddSecurity{T}

None
fill_forward bool

If true, this will fill in missing data points with the previous data point

True
symbol Optional[Union[Symbol, str, BaseContract]]

The Symbol of the Security returned from add_index

None
target_option Optional[str]

The target option ticker. This is useful when the option ticker does not match the underlying, e.g. SPX index and the SPXW weekly option. If null is provided will use underlying

None

Returns:

Type Description
IndexOption

Canonical Option security.

add_option

add_option(
    underlying: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
    leverage: float = ...,
) -> Option
add_option(
    underlying: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
    leverage: float = ...,
) -> Option
add_option(
    underlying: Union[Symbol, str, BaseContract],
    target_option: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
    leverage: float = ...,
) -> Option

Signature descriptions:

  • Creates and adds a new equity Option security to the algorithm

  • Creates and adds a new Option security to the algorithm. This method can be used to add options with non-equity asset classes to the algorithm (e.g. Future Options).

Parameters:

Name Type Description Default
underlying str | Union[Symbol, str, BaseContract]

The underlying equity ticker

required
resolution Optional[Resolution]

The Resolution of market data, Tick, Second, Minute, Hour, or Daily. Default is Resolution.MINUTE

None
market str

The equity's market, Market. Default is value null and looked up using BrokerageModel.DefaultMarkets in AddSecurity{T}

None
fill_forward bool

If true, returns the last available data even if none in that timeslice. Default is true

True
leverage float

The requested leverage for this equity. Default is set by security_initializer

...
target_option Optional[str]

The target option ticker. This is useful when the option ticker does not match the underlying, e.g. SPX index and the SPXW weekly option. If null is provided will use underlying

None

Returns:

Type Description
Option

Depends on the signature used. Case 1: [The new Option security.]; Case 2: [The new option security instance.]

add_security_initializer

add_security_initializer(
    security_initializer: ISecurityInitializer,
) -> None
add_security_initializer(
    security_initializer: Callable[[Security], Any],
) -> None

Signature descriptions:

  • Adds a security initializer, used to initialize/configure securities after creation. The initializer will appended to the default initializer and others that might have been added using this method, and will be applied to all universes and manually added securities.

  • Adds a security initializer, used to initialize/configure securities after creation.

Parameters:

Name Type Description Default
security_initializer ISecurityInitializer | Callable[[Security], Any]

The security initializer

required

add_universe

add_universe(t: Type, name: str, selector: Any) -> Universe
add_universe(
    t: Type,
    name: str,
    resolution: Resolution,
    selector: Any,
) -> Universe
add_universe(
    t: Type,
    name: str,
    resolution: Resolution,
    universe_settings: UniverseSettings,
    selector: Any,
) -> Universe
add_universe(
    t: Type,
    name: str,
    universe_settings: UniverseSettings,
    selector: Any,
) -> Universe
add_universe(
    t: Type,
    security_type: SecurityType,
    name: str,
    resolution: Resolution,
    market: str,
    selector: Any,
) -> Universe
add_universe(
    t: Type,
    security_type: SecurityType,
    name: str,
    resolution: Resolution,
    market: str,
    universe_settings: UniverseSettings,
    selector: Any,
) -> Universe
add_universe(
    data_type: Type,
    security_type: Optional[SecurityType] = None,
    name: str = None,
    resolution: Optional[Resolution] = None,
    market: str = None,
    universe_settings: UniverseSettings = None,
    py_selector: Any = None,
) -> Universe
add_universe(universe: Universe) -> Universe
add_universe(
    selector: Callable[[List[Fundamental]], List[Symbol]],
) -> Universe
add_universe(
    date_rule: IDateRule,
    selector: Callable[[List[Fundamental]], List[Symbol]],
) -> Universe
add_universe(
    universe: Universe,
    fine_selector: Callable[
        [List[Fundamental]], List[Symbol]
    ],
) -> Universe
add_universe(
    name: str, selector: Callable[[datetime], List[str]]
) -> Universe
add_universe(
    name: str,
    resolution: Resolution,
    selector: Callable[[datetime], List[str]],
) -> Universe
add_universe(
    security_type: SecurityType,
    name: str,
    resolution: Resolution,
    market: str,
    universe_settings: UniverseSettings,
    selector: Callable[[datetime], List[str]],
) -> Universe
add_universe(
    coarse_selector: Callable[
        [List[CoarseFundamental]], List[Symbol]
    ],
    fine_selector: Callable[
        [List[FineFundamental]], List[Symbol]
    ],
) -> Universe

Signature descriptions:

  • Creates a new universe and adds it to the algorithm. This will use the default universe settings specified via the universe_settings property. This universe will use the defaults of SecurityType.Equity, Resolution.Daily, Market.USA, and UniverseSettings

  • Creates a new universe and adds it to the algorithm. This will use the default universe settings specified via the universe_settings property. This universe will use the defaults of SecurityType.Equity, Market.USA and UniverseSettings

  • Creates a new universe and adds it to the algorithm. This will use the default universe settings specified via the universe_settings property. This universe will use the defaults of SecurityType.Equity, and Market.USA

  • Creates a new universe and adds it to the algorithm. This will use the default universe settings specified via the universe_settings property. This universe will use the defaults of SecurityType.Equity, Resolution.Daily, and Market.USA

  • Creates a new universe and adds it to the algorithm. This will use the default universe settings specified via the universe_settings property.

  • Creates a new universe and adds it to the algorithm

  • Adds the universe to the algorithm

  • Creates a new universe and adds it to the algorithm. This is for fundamental US Equity data and will be executed on day changes in the NewYork time zone (TimeZones.NEW_YORK)

  • Creates a new universe and adds it to the algorithm. This is for fundamental US Equity data and will be executed based on the provided IDateRule in the NewYork time zone (TimeZones.NEW_YORK)

  • Creates a new universe and adds it to the algorithm. This is for fine fundamental US Equity data and will be executed on day changes in the NewYork time zone (TimeZones.NEW_YORK)

  • Creates a new universe and adds it to the algorithm. This can be used to return a list of string symbols retrieved from anywhere and will loads those symbols under the US Equity market.

  • Creates a new user defined universe that will fire on the requested resolution during market hours.

  • Creates a new universe and adds it to the algorithm. This is for coarse and fine fundamental US Equity data and will be executed on day changes in the NewYork time zone (TimeZones.NEW_YORK)

Parameters:

Name Type Description Default
t Optional[Type]

The data type

None
name Optional[str]

A unique name for this universe

None
selector Optional[Any | Callable[[List[Fundamental]], List[Symbol]] | Callable[[datetime], List[str]]]

Function delegate that performs selection on the universe data

None
resolution Optional[Resolution | Optional[Resolution]]

The expected resolution of the universe data

None
universe_settings Optional[UniverseSettings]

The settings used for securities added by this universe

None
security_type Optional[SecurityType | Optional[SecurityType]]

The security type the universe produces

None
market Optional[str]

The market for selected symbols

None
data_type Optional[Type]

The data type

None
py_selector Optional[Any]

Function delegate that performs selection on the universe data

None
universe Optional[Universe]

The universe to be added

None
date_rule Optional[IDateRule]

Date rule that will be used to set the Data.UniverseSelection.UniverseSettings.Schedule

None
fine_selector Optional[Callable[[List[Fundamental]], List[Symbol]] | Callable[[List[FineFundamental]], List[Symbol]]]

Defines a more detailed selection with access to more data

None
coarse_selector Optional[Callable[[List[CoarseFundamental]], List[Symbol]]]

Defines an initial coarse selection

None

add_universe_options

add_universe_options(
    underlying_symbol: Union[Symbol, str, BaseContract],
    option_filter: Callable[
        [OptionFilterUniverse], OptionFilterUniverse
    ],
) -> None
add_universe_options(
    universe: Universe,
    option_filter: Callable[
        [OptionFilterUniverse], OptionFilterUniverse
    ],
) -> None

Signature descriptions:

  • Adds a new universe that creates options of the security by monitoring any changes in the Universe the provided security is in. Additionally, a filter can be applied to the options generated when the universe of the security changes.

  • Creates a new universe selection model and adds it to the algorithm. This universe selection model will chain to the security changes of a given universe selection output and create a new OptionChainUniverse for each of them

Parameters:

Name Type Description Default
underlying_symbol Optional[Union[Symbol, str, BaseContract]]

Underlying Symbol to add as an option. For Futures, the option chain constructed will be per-contract, as long as a canonical Symbol is provided.

None
option_filter Callable[[OptionFilterUniverse], OptionFilterUniverse]

User-defined filter used to select the options we want out of the option chain provided.

required
universe Optional[Universe]

The universe we want to chain an option universe selection model too

None

arima

arima(
    symbol: Union[Symbol, str, BaseContract],
    ar_order: int,
    diff_order: int,
    ma_order: int,
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> AutoRegressiveIntegratedMovingAverage
arima(
    symbol: Union[Symbol, str, BaseContract],
    ar_order: int,
    diff_order: int,
    ma_order: int,
    period: int,
    intercept: bool,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> AutoRegressiveIntegratedMovingAverage

Creates a new ARIMA indicator.

Parameters:

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

The symbol whose ARIMA indicator we want

required
ar_order int

AR order (p) -- defines the number of past values to consider in the AR component of the model.

required
diff_order int

Difference order (d) -- defines how many times to difference the model before fitting parameters.

required
ma_order int

MA order (q) -- defines the number of past values to consider in the MA component of the model.

required
period int

Size of the rolling series to fit onto

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None
intercept Optional[bool]

Whether or not to include the intercept term

None

Returns:

Type Description
AutoRegressiveIntegratedMovingAverage

The ARIMA indicator for the requested symbol over the specified period.

aroon

aroon(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> AroonOscillator
aroon(
    symbol: Union[Symbol, str, BaseContract],
    up_period: int,
    down_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> AroonOscillator

Creates a new AroonOscillator indicator which will compute the AroonUp and AroonDown (as well as the delta)

Parameters:

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

The symbol whose Aroon we seek

required
period Optional[int]

The look back period for computing number of periods since maximum and minimum

None
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None
up_period Optional[int]

The look back period for computing number of periods since maximum

None
down_period Optional[int]

The look back period for computing number of periods since minimum

None

Returns:

Type Description
AroonOscillator

An AroonOscillator configured with the specified periods.

buy

buy(
    symbol: Union[Symbol, str, BaseContract], quantity: int
) -> OrderTicket
buy(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
) -> OrderTicket
buy(
    strategy: OptionStrategy,
    quantity: int,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]

Signature descriptions:

  • Buy Stock (Alias of Order)

  • Buy Option Strategy (Alias of Order)

Parameters:

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

string Symbol of the asset to trade

None
quantity int | float

int Quantity of the asset to trade

required
strategy Optional[OptionStrategy]

Specification of the strategy to trade

None
asynchronous Optional[bool]

Send the order asynchronously (false). Otherwise we'll block until it fills

False
tag Optional[str]

String tag for the order (optional)

...
order_properties Optional[IOrderProperties]

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket | List[OrderTicket]

Depends on the signature used. Case 1: [The order ticket instance.]; Case 2: [Sequence of order tickets.]

cik

cik(
    cik: int, trading_date: Optional[datetime] = None
) -> List[Symbol]
cik(
    symbol: Union[Symbol, str, BaseContract],
) -> Optional[int]

Signature descriptions:

  • Converts a CIK identifier into symbol array

  • Converts a symbol into a CIK identifier

Parameters:

Name Type Description Default
cik Optional[int]

The CIK identifier of an asset

None
trading_date Optional[Optional[datetime]]

The date that the stock being looked up is/was traded at.

None
symbol Optional[Union[Symbol, str, BaseContract]]

The symbol

None

Returns:

Type Description
List[Symbol] | Optional[int]

Depends on the signature used. Case 1: [Symbols corresponding to the CIK. If no Symbol with a matching CIK was found, returns empty array.]; Case 2: [CIK corresponding to the Symbol. If no matching CIK is found, returns null.]

composite_figi

composite_figi(
    composite_figi: str,
    trading_date: Optional[datetime] = None,
) -> Symbol
composite_figi(
    symbol: Union[Symbol, str, BaseContract],
) -> str

Signature descriptions:

  • Converts a composite FIGI identifier into a symbol

  • Converts a symbol into a composite FIGI identifier

Parameters:

Name Type Description Default
composite_figi Optional[str]

The composite Financial Instrument Global Identifier (FIGI) of an asset

None
trading_date Optional[Optional[datetime]]

The date that the stock being looked up is/was traded at.

None
symbol Optional[Union[Symbol, str, BaseContract]]

The symbol

None

Returns:

Type Description
Symbol | str

Depends on the signature used. Case 1: [Symbol corresponding to the composite FIGI. If no Symbol with a matching composite FIGI was found, returns null.]; Case 2: [Composite FIGI corresponding to the Symbol. If no matching composite FIGI is found, returns null.]

consolidate

consolidate(
    type: Type,
    symbol: Union[Symbol, str, BaseContract],
    size: float,
    tick_type: Optional[TickType],
    handler: Any,
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    period: Resolution,
    handler: Any,
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    period: Resolution,
    tick_type: Optional[TickType],
    handler: Any,
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    period: timedelta,
    handler: Any,
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    period: timedelta,
    tick_type: Optional[TickType],
    handler: Any,
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    calendar: Callable[[datetime], CalendarInfo],
    handler: Any,
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    calendar: Callable[[datetime], CalendarInfo],
    tick_type: Optional[TickType],
    handler: Any,
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    period: Resolution,
    handler: Callable[[TradeBar], Any],
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    period: timedelta,
    handler: Callable[[TradeBar], Any],
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    period: Resolution,
    handler: Callable[[QuoteBar], Any],
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    period: timedelta,
    handler: Callable[[QuoteBar], Any],
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    calendar: Callable[[datetime], CalendarInfo],
    handler: Callable[[QuoteBar], Any],
) -> IDataConsolidator
consolidate(
    symbol: Union[Symbol, str, BaseContract],
    calendar: Callable[[datetime], CalendarInfo],
    handler: Callable[[TradeBar], Any],
) -> IDataConsolidator

Signature descriptions:

  • Creates and registers a consolidator for the following bar types: RenkoBar, VolumeRenkoBar, or RangeBar for the specified symbol and threshold. The specified handler will be invoked with each new consolidated bar.

  • Registers the handler to receive consolidated data for the specified symbol

Parameters:

Name Type Description Default
type Optional[Type]

The Python type of the bar (RenkoBar, VolumeRenkoBar, or RangeBar)

None
symbol Union[Symbol, str, BaseContract]

The symbol whose data is to be consolidated

required
size Optional[float]

The size value for the consolidator (e.g., brick size, range size or maxCount)

None
tick_type Optional[Optional[TickType]]

The tick type to consolidate. If null, the first matching subscription is used.

None
handler Any | Callable[[TradeBar], Any] | Callable[[QuoteBar], Any]

The callback to invoke with each new consolidated bar

required
period Optional[Resolution | timedelta]

The consolidation period

None
calendar Optional[Callable[[datetime], CalendarInfo]]

The consolidation calendar

None

Returns:

Type Description
IDataConsolidator

Depends on the signature used. Case 1: [The created and registered IDataConsolidator instance.]; Case 2: [A new consolidator matching the requested parameters with the handler already registered.]

create_date_range_history_requests

create_date_range_history_requests(
    symbols: List[Symbol],
    start_algo_tz: Union[datetime, date],
    end_algo_tz: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[HistoryRequest]
create_date_range_history_requests(
    symbols: List[Symbol],
    requested_type: Type,
    start_algo_tz: Union[datetime, date],
    end_algo_tz: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    fill_forward: Optional[bool] = None,
    extended_market_hours: Optional[bool] = None,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: Optional[int] = None,
) -> Iterable[HistoryRequest]

Signature descriptions:

  • Helper method to create history requests from a date range

  • Helper method to create history requests from a date range with custom data type

create_indicator_name

create_indicator_name(
    symbol: Union[Symbol, str, BaseContract],
    type: FormattableString,
    resolution: Optional[Resolution],
) -> str
create_indicator_name(
    symbol: Union[Symbol, str, BaseContract],
    type: str,
    resolution: Optional[Resolution],
) -> str

Creates a new name for an indicator created with the convenience functions (SMA, EMA, ect...)

Parameters:

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

The symbol this indicator is registered to

required
type FormattableString | str

The indicator type, for example, 'SMA(5)'

required
resolution Optional[Resolution]

The resolution requested

required

Returns:

Type Description
str

A unique for the given parameters.

cusip

cusip(
    cusip: str, trading_date: Optional[datetime] = None
) -> Symbol
cusip(symbol: Union[Symbol, str, BaseContract]) -> str

Signature descriptions:

  • Converts a CUSIP identifier into a symbol

  • Converts a symbol into a CUSIP identifier

Parameters:

Name Type Description Default
cusip Optional[str]

The CUSIP number of an asset

None
trading_date Optional[Optional[datetime]]

The date that the stock being looked up is/was traded at.

None
symbol Optional[Union[Symbol, str, BaseContract]]

The symbol

None

Returns:

Type Description
Symbol | str

Depends on the signature used. Case 1: [Symbol corresponding to the CUSIP. If no Symbol with a matching CUSIP was found, returns null.]; Case 2: [CUSIP corresponding to the Symbol. If no matching CUSIP is found, returns null.]

dch

dch(
    symbol: Union[Symbol, str, BaseContract],
    upper_period: int,
    lower_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> DonchianChannel
dch(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> DonchianChannel

Signature descriptions:

  • Creates a new Donchian Channel indicator which will compute the Upper Band and Lower Band. The indicator will be automatically updated on the given resolution.

  • Overload shorthand to create a new symmetric Donchian Channel indicator which has the upper and lower channels set to the same period length.

Parameters:

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

The symbol whose Donchian Channel we seek.

required
upper_period Optional[int]

The period over which to compute the upper Donchian Channel.

None
lower_period Optional[int]

The period over which to compute the lower Donchian Channel.

None
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None
period Optional[int]

The period over which to compute the Donchian Channel.

None

Returns:

Type Description
DonchianChannel

The Donchian Channel indicator for the requested symbol.

download

download(address: str) -> str
download(
    address: str, headers: List[KeyValuePair[str, str]]
) -> str
download(
    address: str,
    headers: List[KeyValuePair[str, str]],
    user_name: str,
    password: str,
) -> str

Downloads the requested resource as a string. The resource to download is specified as a string containing the URI.

Parameters:

Name Type Description Default
address str

A string containing the URI to download

required
headers Optional[List[KeyValuePair[str, str]]]

Defines header values to add to the request

None
user_name Optional[str]

The user name associated with the credentials

None
password Optional[str]

The password for the user name associated with the credentials

None

Returns:

Type Description
str

The requested resource as a string.

ema

ema(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> ExponentialMovingAverage
ema(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    smoothing_factor: float,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> ExponentialMovingAverage

Creates an ExponentialMovingAverage indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose EMA we want

required
period int

The period of the EMA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None
smoothing_factor Optional[float]

The percentage of data from the previous value to be carried into the next value

None

Returns:

Type Description
ExponentialMovingAverage

The ExponentialMovingAverage for the given parameters.

emit_insights

emit_insights(
    *insights: Union[Insight, Iterable[Insight]]
) -> None
emit_insights(insight: Insight) -> None

Manually emit insights from an algorithm. This is typically invoked before calls to submit orders in algorithms written against QCAlgorithm that have been ported into the algorithm framework.

Parameters:

Name Type Description Default
insights Union[Insight, Iterable[Insight]]

The array of insights to be emitted

()
insight Optional[Insight]

The insight to be emitted

None

filtered_identity

filtered_identity(
    symbol: Union[Symbol, str, BaseContract],
    selector: Callable[[IBaseData], IBaseDataBar] = None,
    filter: Callable[[IBaseData], bool] = None,
    field_name: str = None,
) -> FilteredIdentity
filtered_identity(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Resolution,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
    filter: Callable[[IBaseData], bool] = None,
    field_name: str = None,
) -> FilteredIdentity
filtered_identity(
    symbol: Union[Symbol, str, BaseContract],
    resolution: timedelta,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
    filter: Callable[[IBaseData], bool] = None,
    field_name: str = None,
) -> FilteredIdentity

Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The symbol whose values we want as an indicator

required
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None
filter Callable[[IBaseData], bool]

Filters the IBaseData send into the indicator, if null defaults to true (x => true) which means no filter

None
field_name str

The name of the field being selected

None
resolution Optional[Resolution | timedelta]

The desired resolution of the data

None

Returns:

Type Description
FilteredIdentity

A new FilteredIdentity indicator for the specified symbol and selector.

fundamentals

fundamentals(
    symbol: Union[Symbol, str, BaseContract],
) -> Fundamental
fundamentals(symbols: List[Symbol]) -> List[Fundamental]

Signature descriptions:

  • Get the fundamental data for the requested symbol at the current time

  • Get the fundamental data for the requested symbols at the current time

Parameters:

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

The symbol

None
symbols Optional[List[Symbol]]

The symbol

None

Returns:

Type Description
Fundamental | List[Fundamental]

Depends on the signature used. Case 1: [The fundamental data for the Symbol.]; Case 2: [The fundamental data for the symbols.]

identity

identity(
    symbol: Union[Symbol, str, BaseContract],
    selector: Callable[[IBaseData], float] = None,
    field_name: str = None,
) -> Identity
identity(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Resolution,
    selector: Callable[[IBaseData], float] = None,
    field_name: str = None,
) -> Identity
identity(
    symbol: Union[Symbol, str, BaseContract],
    resolution: timedelta,
    selector: Callable[[IBaseData], float] = None,
    field_name: str = None,
) -> Identity

Creates a new Identity indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The symbol whose values we want as an indicator

required
selector Callable[[IBaseData], float]

Selects a value from the BaseData, if null defaults to the .Value property (x => x.Value)

None
field_name str

The name of the field being selected

None
resolution Optional[Resolution | timedelta]

The desired resolution of the data

None

Returns:

Type Description
Identity

A new Identity indicator for the specified symbol and selector.

indicator_history

indicator_history(
    indicator: IndicatorBase[IndicatorDataPoint],
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame
indicator_history(
    indicator: IndicatorBase[IndicatorDataPoint],
    symbols: List[Symbol],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame
indicator_history(
    indicator: IndicatorBase[IndicatorDataPoint],
    symbol: Union[Symbol, str, BaseContract],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame
indicator_history(
    indicator: IndicatorBase[IndicatorDataPoint],
    symbols: List[Symbol],
    span: timedelta,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame
indicator_history(
    indicator: IndicatorBase[IndicatorDataPoint],
    symbols: List[Symbol],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame
indicator_history(
    indicator: IndicatorBase[IndicatorDataPoint],
    symbol: Union[Symbol, str, BaseContract],
    start: Union[datetime, date],
    end: Union[datetime, date],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame
indicator_history(
    indicator: IndicatorBase[IndicatorDataPoint],
    history: List[Slice],
    selector: Callable[[IBaseData], float] = None,
) -> DataFrame

Signature descriptions:

  • Gets the historical data of an indicator for the specified symbol. The exact number of bars will be returned. The symbol must exist in the Securities collection.

  • Gets the historical data of an indicator for the specified symbols. The exact number of bars will be returned. The symbol must exist in the Securities collection.

  • Gets the historical data of an indicator and convert it into pandas.DataFrame

Parameters:

Name Type Description Default
indicator IndicatorBase[IndicatorDataPoint]

The target indicator

required
symbol Optional[Union[Symbol, str, BaseContract]]

The symbol to retrieve historical data for

None
period Optional[int]

The number of bars to request

None
resolution Optional[Optional[Resolution]]

The resolution to request

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None
symbols Optional[List[Symbol]]

The symbols to retrieve historical data for

None
span Optional[timedelta]

The span over which to retrieve recent historical data

None
start Optional[Union[datetime, date]]

The start time in the algorithm's time zone

None
end Optional[Union[datetime, date]]

The end time in the algorithm's time zone

None
history Optional[List[Slice]]

Historical data used to calculate the indicator

None

Returns:

Type Description
DataFrame

Depends on the signature used. Case 1: [pandas.DataFrame of historical data of an indicator.]; Case 2: [pandas.DataFrame containing the historical data of indicator.]

isin

isin(
    isin: str, trading_date: Optional[datetime] = None
) -> Symbol
isin(symbol: Union[Symbol, str, BaseContract]) -> str

Signature descriptions:

  • Converts an ISIN identifier into a symbol

  • Converts a symbol into an ISIN identifier

Parameters:

Name Type Description Default
isin Optional[str]

The International Securities Identification Number (ISIN) of an asset

None
trading_date Optional[Optional[datetime]]

The date that the stock being looked up is/was traded at.

None
symbol Optional[Union[Symbol, str, BaseContract]]

The symbol

None

Returns:

Type Description
Symbol | str

Depends on the signature used. Case 1: [Symbol corresponding to the ISIN. If no Symbol with a matching ISIN was found, returns null.]; Case 2: [ISIN corresponding to the Symbol. If no matching ISIN is found, returns null.]

kama

kama(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> KaufmanAdaptiveMovingAverage
kama(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    fast_ema_period: int,
    slow_ema_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> KaufmanAdaptiveMovingAverage

Creates a new KaufmanAdaptiveMovingAverage indicator.

Parameters:

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

The symbol whose KAMA we want

required
period int

The period of the Efficiency Ratio (ER) of KAMA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None
fast_ema_period Optional[int]

The period of the fast EMA used to calculate the Smoothing Constant (SC)

None
slow_ema_period Optional[int]

The period of the slow EMA used to calculate the Smoothing Constant (SC)

None

Returns:

Type Description
KaufmanAdaptiveMovingAverage

The KaufmanAdaptiveMovingAverage indicator for the requested symbol over the specified period.

limit_if_touched_order

limit_if_touched_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    trigger_price: float,
    limit_price: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
limit_if_touched_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    trigger_price: float,
    limit_price: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket

Send a limit if touched order to the transaction handler:

Parameters:

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

String symbol for the asset

required
quantity int | float

Quantity of shares for limit order

required
trigger_price float

Trigger price for this order

required
limit_price float

Limit price to fill this order

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it is fully submitted

False
tag str

String tag for the order (optional)

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket

The order ticket instance.

limit_order

limit_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    limit_price: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
limit_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    limit_price: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket

Send a limit order to the transaction handler:

Parameters:

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

String symbol for the asset

required
quantity int | float

Quantity of shares for limit order

required
limit_price float

Limit price to fill this order

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it is fully submitted

False
tag str

String tag for the order (optional)

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket

The order ticket instance.

market_on_close_order

market_on_close_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
market_on_close_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket

Market on close order implementation: Send a market order when the exchange closes

Parameters:

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

The symbol to be ordered

required
quantity int | float

The number of shares to required

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it is fully submitted

False
tag str

Place a custom order property or tag (e.g. indicator data).

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket

The order ticket instance.

market_on_open_order

market_on_open_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
market_on_open_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket

Market on open order implementation: Send a market order when the exchange opens

Parameters:

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

The symbol to be ordered

required
quantity float | int

The number of shares to required

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it is fully submitted

False
tag str

Place a custom order property or tag (e.g. indicator data).

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket

The order ticket instance.

market_order

market_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
market_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket

Market order implementation: Send a market order and wait for it to be filled.

Parameters:

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

Symbol of the MarketType Required.

required
quantity int | float

Number of shares to request.

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it fills

False
tag str

Place a custom order property or tag (e.g. indicator data).

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket

The order ticket instance.

order

order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
) -> OrderTicket
order(
    symbol: Union[Symbol, str, BaseContract], quantity: int
) -> OrderTicket
order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
order(
    strategy: OptionStrategy,
    quantity: int,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]
order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    type: OrderType,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    type: OrderType,
) -> OrderTicket
order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    type: OrderType,
) -> OrderTicket

Signature descriptions:

  • Issue an order/trade for asset: Alias wrapper for Order(string, int);

  • Issue an order/trade for asset

  • Wrapper for market order method: submit a new order for quantity of symbol using type order.

  • Issue an order/trade for buying/selling an option strategy

  • Obsolete implementation of Order method accepting a OrderType. This was deprecated since it was impossible to generate other orders via this method. Any calls to this method will always default to a Market Order.

  • Obsolete method for placing orders.

Parameters:

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

Symbol to order

None
quantity float | int

Quantity to order

required
asynchronous Optional[bool]

Send the order asynchronously (false). Otherwise we'll block until it fills

False
tag Optional[str]

Place a custom order property or tag (e.g. indicator data).

...
order_properties Optional[IOrderProperties]

The order properties to use. Defaults to default_order_properties

None
strategy Optional[OptionStrategy]

Specification of the strategy to trade

None
type Optional[OrderType]

Order Type

None

Returns:

Type Description
OrderTicket | List[OrderTicket]

Depends on the signature used. Case 1: [The order ticket instance.]; Case 2: [Sequence of order tickets.]

plot

plot(series: str, value: float) -> None
plot(series: str, value: int) -> None
plot(chart: str, series: str, value: float) -> None
plot(chart: str, series: str, value: int) -> None
plot(
    series: str,
    open: float,
    high: float,
    low: float,
    close: float,
) -> None
plot(
    series: str, open: int, high: int, low: int, close: int
) -> None
plot(
    chart: str,
    series: str,
    open: float,
    high: float,
    low: float,
    close: float,
) -> None
plot(
    chart: str,
    series: str,
    open: int,
    high: int,
    low: int,
    close: int,
) -> None
plot(series: str, bar: TradeBar) -> None
plot(chart: str, series: str, bar: TradeBar) -> None
plot(
    chart: str,
    *indicators: Union[
        IndicatorBase, Iterable[IndicatorBase]
    ]
) -> None

Signature descriptions:

  • Plot a chart using string series name, with value.

  • Plot a chart using string series name, with int value.

  • Plot a chart to string chart name, using string series name, with double value.

  • Plot a chart to string chart name, using string series name, with int value

  • Plot a candlestick to the default/primary chart series by the given series name.

  • Plot a candlestick to the given series of the given chart.

  • Plots the value of each indicator on the chart

Parameters:

Name Type Description Default
series Optional[str]

Name of the plot series

None
value Optional[float | int]

Value to plot

None
open Optional[float | int]

The candlestick open value

None
high Optional[float | int]

The candlestick high value

None
low Optional[float | int]

The candlestick low value

None
close Optional[float | int]

The candlestick close value

None
chart Optional[str]

Chart name

None
bar Optional[TradeBar]

The trade bar to be plotted to the candlestick series

None
indicators Union[IndicatorBase, Iterable[IndicatorBase]]

The indicators to plot

()

plot_indicator

plot_indicator(
    chart: str,
    *indicators: Union[
        IndicatorBase, Iterable[IndicatorBase]
    ]
) -> None
plot_indicator(
    chart: str,
    wait_for_ready: bool,
    *indicators: Union[
        IndicatorBase, Iterable[IndicatorBase]
    ]
) -> None

Signature descriptions:

  • Automatically plots each indicator when a new value is available

  • Automatically plots each indicator when a new value is available, optionally waiting for indicator.IsReady to return true

pphl

pphl(
    symbol: Union[Symbol, str, BaseContract],
    length_high: int,
    length_low: int,
    last_stored_values: int,
    resolution: Optional[Resolution],
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> PivotPointsHighLow
pphl(
    symbol: Union[Symbol, str, BaseContract],
    length_high: int,
    length_low: int,
    last_stored_values: int = 100,
    strict: bool = True,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> PivotPointsHighLow

Creates a new PivotPointsHighLow indicator which will compute the high and low pivot points based on the configurable surrounding bars count.

Parameters:

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

The symbol whose PPHL we seek

required
length_high int

The number of surrounding bars whose high values should be less than the current bar's for the bar high to be marked as high pivot point

required
length_low int

The number of surrounding bars whose low values should be more than the current bar's for the bar low to be marked as low pivot point

required
last_stored_values int

The number of last stored indicator values

100
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None
strict Optional[bool]

When true (default), uses strict inequalities (greater than and less than). When false, uses relaxed inequalities (greater than or equal and less than or equal) allowing equal values to be detected as pivot points.

True

Returns:

Type Description
PivotPointsHighLow

The PivotPointsHighLow indicator for the requested symbol.

quit

quit(message: Any) -> None
quit(message: str = ...) -> None

Terminate the algorithm after processing the current event handler.

Parameters:

Name Type Description Default
message Any | str

Exit message to display on quitting

...

record

record(series: str, value: int) -> None
record(series: str, value: float) -> None

Signature descriptions:

  • Plot a chart using string series name, with int value. Alias of Plot();

  • Plot a chart using string series name, with double value. Alias of Plot();

register_indicator

register_indicator(
    symbol: Union[Symbol, str, BaseContract],
    indicator: IndicatorBase[IndicatorDataPoint],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> None
register_indicator(
    symbol: Union[Symbol, str, BaseContract],
    indicator: IndicatorBase[IndicatorDataPoint],
    resolution: Optional[timedelta] = None,
    selector: Callable[[IBaseData], float] = None,
) -> None
register_indicator(
    symbol: Union[Symbol, str, BaseContract],
    indicator: IndicatorBase[IndicatorDataPoint],
    consolidator: Union[
        IDataConsolidator, PythonConsolidator, timedelta
    ],
    selector: Callable[[IBaseData], float] = None,
) -> None

Signature descriptions:

  • Creates and registers a new consolidator to receive automatic updates at the specified resolution as well as configures the indicator to receive updates from the consolidator.

  • Registers the consolidator to receive automatic updates as well as configures the indicator to receive updates from the consolidator.

Parameters:

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

The symbol to register against

required
indicator IndicatorBase[IndicatorDataPoint]

The indicator to receive data from the consolidator

required
resolution Optional[Optional[Resolution] | Optional[timedelta]]

The resolution at which to send data to the indicator, null to use the same resolution as the subscription

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None
consolidator Optional[Union[IDataConsolidator, PythonConsolidator, timedelta]]

The consolidator to receive raw subscription data

None

resolve_consolidator

resolve_consolidator(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution],
    data_type: Type = None,
) -> IDataConsolidator
resolve_consolidator(
    symbol: Union[Symbol, str, BaseContract],
    time_span: Optional[timedelta],
    data_type: Type = None,
) -> IDataConsolidator

Gets the default consolidator for the specified symbol and resolution

Parameters:

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

The symbol whose data is to be consolidated

required
resolution Optional[Optional[Resolution]]

The resolution for the consolidator, if null, uses the resolution from subscription

None
data_type Type

The data type for this consolidator, if null, uses TradeBar over QuoteBar if present

None
time_span Optional[Optional[timedelta]]

The requested time span for the consolidator, if null, uses the resolution from subscription

None

Returns:

Type Description
IDataConsolidator

The new default consolidator.

sedol

sedol(
    sedol: str, trading_date: Optional[datetime] = None
) -> Symbol
sedol(symbol: Union[Symbol, str, BaseContract]) -> str

Signature descriptions:

  • Converts a SEDOL identifier into a symbol

  • Converts a symbol into a SEDOL identifier

Parameters:

Name Type Description Default
sedol Optional[str]

The SEDOL identifier of an asset

None
trading_date Optional[Optional[datetime]]

The date that the stock being looked up is/was traded at.

None
symbol Optional[Union[Symbol, str, BaseContract]]

The symbol

None

Returns:

Type Description
Symbol | str

Depends on the signature used. Case 1: [Symbol corresponding to the SEDOL. If no Symbol with a matching SEDOL was found, returns null.]; Case 2: [SEDOL corresponding to the Symbol. If no matching SEDOL is found, returns null.]

sell

sell(
    symbol: Union[Symbol, str, BaseContract], quantity: int
) -> OrderTicket
sell(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
) -> OrderTicket
sell(
    strategy: OptionStrategy,
    quantity: int,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]

Signature descriptions:

  • Sell stock (alias of Order)

  • Sell Option Strategy (alias of Order)

Parameters:

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

string Symbol of the asset to trade

None
quantity int | float

int Quantity of the asset to trade

required
strategy Optional[OptionStrategy]

Specification of the strategy to trade

None
asynchronous Optional[bool]

Send the order asynchronously (false). Otherwise we'll block until it fills

False
tag Optional[str]

String tag for the order (optional)

...
order_properties Optional[IOrderProperties]

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket | List[OrderTicket]

Depends on the signature used. Case 1: [The order ticket instance.]; Case 2: [Sequence of order tickets.]

set_benchmark

set_benchmark(
    security_type: SecurityType, symbol: str
) -> None
set_benchmark(ticker: str) -> None
set_benchmark(
    symbol: Union[Symbol, str, BaseContract],
) -> None
set_benchmark(
    benchmark: Callable[[datetime], float],
) -> None

Signature descriptions:

  • Sets the benchmark used for computing statistics of the algorithm to the specified symbol

  • Sets the benchmark used for computing statistics of the algorithm to the specified ticker, defaulting to SecurityType.EQUITY if the ticker doesn't exist in the algorithm

  • Sets the specified function as the benchmark, this function provides the value of the benchmark at each date/time requested

Parameters:

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

symbol to use as the benchmark

None
security_type Optional[SecurityType]

Is the symbol an equity, forex, base, etc. Default SecurityType.EQUITY

None
ticker Optional[str]

Ticker to use as the benchmark

None
benchmark Optional[Callable[[datetime], float]]

The benchmark producing function

None

set_holdings

set_holdings(
    targets: List[PortfolioTarget],
    liquidate_existing_holdings: bool = False,
    asynchronous: bool = False,
    tag: str = None,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]
set_holdings(
    symbol: Union[Symbol, str, BaseContract],
    percentage: float,
    liquidate_existing_holdings: bool = False,
    asynchronous: bool = False,
    tag: str = None,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]
set_holdings(
    symbol: Union[Symbol, str, BaseContract],
    percentage: int,
    liquidate_existing_holdings: bool = False,
    asynchronous: bool = False,
    tag: str = None,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]

Signature descriptions:

  • Sets holdings for a collection of targets. The implementation will order the provided targets executing first those that reduce a position, freeing margin.

  • Alias for SetHoldings to avoid the M-decimal errors.

Parameters:

Name Type Description Default
targets Optional[List[PortfolioTarget]]

The portfolio desired quantities as percentages

None
liquidate_existing_holdings bool

True will liquidate existing holdings

False
asynchronous bool

Send the orders asynchronously (false). Otherwise we'll block until it is fully submitted (or filled for market orders)

False
tag str

Tag the order with a short string.

None
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None
symbol Optional[Union[Symbol, str, BaseContract]]

string symbol we wish to hold

None
percentage Optional[float | int]

double percentage of holdings desired

None

Returns:

Type Description
List[OrderTicket]

A list of order tickets.

set_runtime_statistic

set_runtime_statistic(name: str, value: str) -> None
set_runtime_statistic(name: str, value: float) -> None
set_runtime_statistic(name: str, value: int) -> None

Set a runtime statistic for the algorithm. Runtime statistics are shown in the top banner of a live algorithm GUI.

Parameters:

Name Type Description Default
name str

Name of your runtime statistic

required
value str | float | int

String value of your runtime statistic

required

set_security_initializer

set_security_initializer(
    security_initializer: ISecurityInitializer,
) -> None
set_security_initializer(
    security_initializer: Callable[[Security], Any],
) -> None
set_security_initializer(
    security_initializer: Callable[[Security, bool], Any],
) -> None

Signature descriptions:

  • Sets the security initializer, used to initialize/configure securities after creation. The initializer will be applied to all universes and manually added securities.

  • Sets the security initializer function, used to initialize/configure securities after creation. The initializer will be applied to all universes and manually added securities.

Parameters:

Name Type Description Default
security_initializer ISecurityInitializer | Callable[[Security], Any] | Callable[[Security, bool], Any]

The security initializer

required

set_summary_statistic

set_summary_statistic(name: str, value: str) -> None
set_summary_statistic(name: str, value: int) -> None
set_summary_statistic(name: str, value: float) -> None

Set a custom summary statistic for the algorithm.

Parameters:

Name Type Description Default
name str

Name of the custom summary statistic

required
value str | int | float

Value of the custom summary statistic

required

set_time_zone

set_time_zone(time_zone: Any) -> None
set_time_zone(time_zone: str) -> None

Sets the time zone of the time property in the algorithm

Parameters:

Name Type Description Default
time_zone Any | str

The desired time zone

required

set_warm_up

set_warm_up(time_span: timedelta) -> None
set_warm_up(
    time_span: timedelta, resolution: Optional[Resolution]
) -> None
set_warm_up(bar_count: int) -> None
set_warm_up(
    bar_count: int, resolution: Optional[Resolution]
) -> None

Signature descriptions:

  • Sets the warm up period to the specified value

  • Sets the warm up period by resolving a start date that would send that amount of data into the algorithm. The highest (smallest) resolution in the securities collection will be used. For example, if an algorithm has minute and daily data and 200 bars are requested, that would use 200 minute bars.

  • Sets the warm up period by resolving a start date that would send that amount of data into the algorithm.

Parameters:

Name Type Description Default
time_span Optional[timedelta]

The amount of time to warm up, this does not take into account market hours/weekends

None
resolution Optional[Optional[Resolution]]

The resolution to request

None
bar_count Optional[int]

The number of data points requested for warm up

None

set_warmup

set_warmup(time_span: timedelta) -> None
set_warmup(
    time_span: timedelta, resolution: Optional[Resolution]
) -> None
set_warmup(bar_count: int) -> None
set_warmup(
    bar_count: int, resolution: Optional[Resolution]
) -> None

Signature descriptions:

  • Sets the warm up period to the specified value

  • Sets the warm up period by resolving a start date that would send that amount of data into the algorithm. The highest (smallest) resolution in the securities collection will be used. For example, if an algorithm has minute and daily data and 200 bars are requested, that would use 200 minute bars.

  • Sets the warm up period by resolving a start date that would send that amount of data into the algorithm.

Parameters:

Name Type Description Default
time_span Optional[timedelta]

The amount of time to warm up, this does not take into account market hours/weekends

None
resolution Optional[Optional[Resolution]]

The resolution to request

None
bar_count Optional[int]

The number of data points requested for warm up

None

sto

sto(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    k_period: int,
    d_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> Stochastic
sto(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> Stochastic

Signature descriptions:

  • Creates a new Stochastic indicator.

  • Overload short hand to create a new Stochastic indicator; defaulting to the 3 period for dStoch

Parameters:

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

The symbol whose stochastic we seek

required
period int

The period of the stochastic. Normally 14

required
k_period Optional[int]

The sum period of the stochastic. Normally 14

None
d_period Optional[int]

The sum period of the stochastic. Normally 3

None
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
Stochastic

Stochastic indicator for the requested symbol.

stop_limit_order

stop_limit_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    stop_price: float,
    limit_price: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
stop_limit_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    stop_price: float,
    limit_price: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket

Send a stop limit order to the transaction handler:

Parameters:

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

String symbol for the asset

required
quantity int | float

Quantity of shares for limit order

required
stop_price float

Stop price for this order

required
limit_price float

Limit price to fill this order

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it is fully submitted

False
tag str

String tag for the order (optional)

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket

The order ticket instance.

stop_market_order

stop_market_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    stop_price: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
stop_market_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    stop_price: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket

Create a stop market order and return the newly created order id; or negative if the order is invalid

Parameters:

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

String symbol for the asset we're trading

required
quantity int | float

Quantity to be traded

required
stop_price float

Price to fill the stop order

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it is fully submitted

False
tag str

Optional string data tag for the order

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket

The order ticket instance.

trailing_stop_order

trailing_stop_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    trailing_amount: float,
    trailing_as_percentage: bool,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
trailing_stop_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    trailing_amount: float,
    trailing_as_percentage: bool,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
trailing_stop_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    stop_price: float,
    trailing_amount: float,
    trailing_as_percentage: bool,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket
trailing_stop_order(
    symbol: Union[Symbol, str, BaseContract],
    quantity: float,
    stop_price: float,
    trailing_amount: float,
    trailing_as_percentage: bool,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket

Signature descriptions:

  • Create a trailing stop order and return the newly created order id; or negative if the order is invalid. It will calculate the stop price using the trailing amount and the current market price.

  • Create a trailing stop order and return the newly created order id; or negative if the order is invalid

Parameters:

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

Trading asset symbol

required
quantity int | float

Quantity to be traded

required
trailing_amount float

The trailing amount to be used to update the stop price

required
trailing_as_percentage bool

Whether the trailing_amount is a percentage or an absolute currency value

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it is fully submitted

False
tag str

Optional string data tag for the order

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None
stop_price Optional[float]

Initial stop price at which the order should be triggered

None

Returns:

Type Description
OrderTicket

The order ticket instance.

train

train(training_code: Callable[[], Any]) -> ScheduledEvent
train(
    date_rule: IDateRule,
    time_rule: ITimeRule,
    training_code: Callable[[], Any],
) -> ScheduledEvent

Signature descriptions:

  • Schedules the provided training code to execute immediately

  • Schedules the training code to run using the specified date and time rules

Parameters:

Name Type Description Default
training_code Callable[[], Any]

The training code to be invoked

required
date_rule Optional[IDateRule]

Specifies what dates the event should run

None
time_rule Optional[ITimeRule]

Specifies the times on those dates the event should run

None

v

v(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: Optional[OptionPricingModelType] = None,
    iv_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> Vega
v(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> Variance

Signature descriptions:

  • Creates a new Vega indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

  • Creates a new Variance indicator. This will return the population variance of samples over the specified period.

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Optional[Union[Symbol, str, BaseContract]]

The mirror option for parity calculation

None
risk_free_rate Optional[Optional[float]]

The risk free rate

None
dividend_yield Optional[Optional[float]]

The dividend yield

None
option_model Optional[Optional[OptionPricingModelType]]

The option pricing model used to estimate Vega

None
iv_model Optional[Optional[OptionPricingModelType]]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None
period Optional[int]

The period over which to compute the variance

None
selector Optional[Callable[[IBaseData], float]]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
Vega | Variance

Depends on the signature used. Case 1: [A new Vega indicator for the specified symbol.]; Case 2: [The Variance indicator for the requested symbol over the specified period.]

var

var(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    confidence_level: float,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> ValueAtRisk
var(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> Variance

Signature descriptions:

  • Creates a new ValueAtRisk indicator.

  • Creates a new Variance indicator. This will return the population variance of samples over the specified period.

Parameters:

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

The symbol whose VAR we want

required
period int

The period over which to compute the VAR

required
confidence_level Optional[float]

The confidence level for Value at risk calculation

None
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
ValueAtRisk | Variance

Depends on the signature used. Case 1: [The ValueAtRisk indicator for the requested Symbol, lookback period, and confidence level.]; Case 2: [The Variance indicator for the requested symbol over the specified period.]

vwap

vwap(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> VolumeWeightedAveragePriceIndicator
vwap(
    symbol: Union[Symbol, str, BaseContract],
) -> IntradayVwap

Signature descriptions:

  • Creates an VolumeWeightedAveragePrice (VWAP) indicator for the symbol. The indicator will be automatically updated on the given resolution.

  • Creates the canonical VWAP indicator that resets each day. The indicator will be automatically updated on the security's configured resolution.

Parameters:

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

The symbol whose VWAP we want

required
period Optional[int]

The period of the VWAP

None
resolution Optional[Optional[Resolution]]

The resolution

None
selector Optional[Callable[[IBaseData], TradeBar]]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
VolumeWeightedAveragePriceIndicator | IntradayVwap

Depends on the signature used. Case 1: [The VolumeWeightedAveragePrice for the given parameters.]; Case 2: [The IntradayVWAP for the specified symbol.]

warm_up_indicator

warm_up_indicator(
    symbol: Union[Symbol, str, BaseContract],
    indicator: IndicatorBase[IndicatorDataPoint],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> None
warm_up_indicator(
    symbols: List[Symbol],
    indicator: IndicatorBase[IndicatorDataPoint],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> None
warm_up_indicator(
    symbol: Union[Symbol, str, BaseContract],
    indicator: IndicatorBase[IndicatorDataPoint],
    period: timedelta,
    selector: Callable[[IBaseData], float] = None,
) -> None
warm_up_indicator(
    symbols: List[Symbol],
    indicator: IndicatorBase[IndicatorDataPoint],
    period: timedelta,
    selector: Callable[[IBaseData], float] = None,
) -> None

Warms up a given indicator with historical data

Parameters:

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

The symbol whose indicator we want

None
indicator IndicatorBase[IndicatorDataPoint]

The indicator we want to warm up

required
resolution Optional[Optional[Resolution]]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None
symbols Optional[List[Symbol]]

The symbols whose indicator we want

None
period Optional[timedelta]

The necessary period to warm up the indicator

None

a

a(
    target: Union[Symbol, str, BaseContract],
    reference: Union[Symbol, str, BaseContract],
    alpha_period: int = 1,
    beta_period: int = 252,
    resolution: Optional[Resolution] = None,
    risk_free_rate: Optional[float] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> Alpha

Creates a Alpha indicator for the given target symbol in relation with the reference used. The indicator will be automatically updated on the given resolution.

Parameters:

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

The target symbol whose Alpha value we want

required
reference Union[Symbol, str, BaseContract]

The reference symbol to compare with the target symbol

required
alpha_period int

The period of the Alpha indicator

1
beta_period int

The period of the Beta indicator

252
resolution Optional[Resolution]

The resolution

None
risk_free_rate Optional[float]

The risk free rate

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
Alpha

The Alpha indicator for the given parameters.

abands

abands(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    width: float = 4,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> AccelerationBands

Creates a new Acceleration Bands indicator.

Parameters:

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

The symbol whose Acceleration Bands we want.

required
period int

The period of the three moving average (middle, upper and lower band).

required
width float

A coefficient specifying the distance between the middle band and upper or lower bands.

4
moving_average_type MovingAverageType

Type of the moving average.

...
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar.

None

ad

ad(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> AccumulationDistribution

Creates a new AccumulationDistribution indicator.

Parameters:

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

The symbol whose AD we want

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
AccumulationDistribution

The AccumulationDistribution indicator for the requested symbol over the specified period.

add_alpha

add_alpha(alpha: IAlphaModel) -> None

Adds a new alpha model

Parameters:

Name Type Description Default
alpha IAlphaModel

Model that generates alpha to add

required

add_cfd

add_cfd(
    ticker: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
    leverage: float = ...,
) -> Cfd

add_command

add_command(type: Type) -> None

Register a command type to be used

Parameters:

Name Type Description Default
type Type

The command type

required

add_crypto

add_crypto(
    ticker: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
    leverage: float = ...,
) -> Crypto

add_crypto_future

add_crypto_future(
    ticker: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
    leverage: float = ...,
) -> CryptoFuture

add_equity

add_equity(
    ticker: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
    leverage: float = ...,
    extended_market_hours: bool = False,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
) -> Equity

Creates and adds a new Equity security to the algorithm

Parameters:

Name Type Description Default
ticker str

The equity ticker symbol

required
resolution Optional[Resolution]

The Resolution of market data, Tick, Second, Minute, Hour, or Daily. Default is Resolution.MINUTE

None
market str

The equity's market, Market. Default value is null and looked up using BrokerageModel.DefaultMarkets in AddSecurity{T}

None
fill_forward bool

If true, returns the last available data even if none in that timeslice. Default is true

True
leverage float

The requested leverage for this equity. Default is set by security_initializer

...
extended_market_hours bool

True to send data during pre and post market sessions. Default is false

False
data_normalization_mode Optional[DataNormalizationMode]

The price scaling mode to use for the equity

None

Returns:

Type Description
Equity

The new Equity security.

add_forex

add_forex(
    ticker: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
    leverage: float = ...,
) -> Forex

add_future

add_future(
    ticker: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
    leverage: float = ...,
    extended_market_hours: bool = False,
    data_mapping_mode: Optional[DataMappingMode] = None,
    data_normalization_mode: Optional[
        DataNormalizationMode
    ] = None,
    contract_depth_offset: int = 0,
) -> Future

add_future_option

add_future_option(
    symbol: Union[Symbol, str, BaseContract],
    option_filter: Callable[
        [OptionFilterUniverse], OptionFilterUniverse
    ] = None,
) -> None

Creates and adds a new Future Option contract to the algorithm.

Parameters:

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

The Future canonical symbol (i.e. Symbol returned from add_future)

required
option_filter Callable[[OptionFilterUniverse], OptionFilterUniverse]

Filter to apply to option contracts loaded as part of the universe

None

Returns:

Type Description
None

The new Option security, containing a Future as its underlying.

add_future_option_contract

add_future_option_contract(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
    leverage: float = ...,
    extended_market_hours: bool = False,
) -> Option

Adds a future option contract to the algorithm.

Parameters:

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

Option contract Symbol

required
resolution Optional[Resolution]

Resolution of the option contract, i.e. the granularity of the data

None
fill_forward bool

If true, this will fill in missing data points with the previous data point

True
leverage float

The leverage to apply to the option contract

...
extended_market_hours bool

Use extended market hours data

False

Returns:

Type Description
Option

Option security.

addiff

addiff(
    symbols: List[Symbol],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> AdvanceDeclineDifference

Creates a new Advance/Decline Difference indicator

Parameters:

Name Type Description Default
symbols List[Symbol]

The symbols whose A/D Difference we want

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
AdvanceDeclineDifference

The Advance/Decline Difference indicator for the requested symbol over the specified period.

add_index

add_index(
    ticker: str,
    resolution: Optional[Resolution] = None,
    market: str = None,
    fill_forward: bool = True,
) -> Index

add_index_option_contract

add_index_option_contract(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    fill_forward: bool = True,
) -> IndexOption

Adds an index option contract to the algorithm.

Parameters:

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

Symbol of the index option contract

required
resolution Optional[Resolution]

Resolution of the index option contract, i.e. the granularity of the data

None
fill_forward bool

If true, this will fill in missing data points with the previous data point

True

Returns:

Type Description
IndexOption

Index Option Contract.

add_risk_management

add_risk_management(
    risk_management: IRiskManagementModel,
) -> None

Adds a new risk management model

Parameters:

Name Type Description Default
risk_management IRiskManagementModel

Model defining how risk is managed to add

required

add_series

add_series(
    chart: str,
    series: str,
    series_type: SeriesType,
    unit: str = "$",
) -> None

Add a series object for charting. This is useful when initializing charts with series other than type = line. If a series exists in the chart with the same name, then it is replaced.

Parameters:

Name Type Description Default
chart str

The chart name

required
series str

The series name

required
series_type SeriesType

The type of series, i.e, Scatter

required
unit str

The unit of the y axis, usually $

'$'

add_universe_selection

add_universe_selection(
    universe_selection: IUniverseSelectionModel,
) -> None

Adds a new universe selection model

Parameters:

Name Type Description Default
universe_selection IUniverseSelectionModel

Model defining universes for the algorithm to add

required

adosc

adosc(
    symbol: Union[Symbol, str, BaseContract],
    fast_period: int,
    slow_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> AccumulationDistributionOscillator

Creates a new AccumulationDistributionOscillator indicator.

Parameters:

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

The symbol whose ADOSC we want

required
fast_period int

The fast moving average period

required
slow_period int

The slow moving average period

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
AccumulationDistributionOscillator

The AccumulationDistributionOscillator indicator for the requested symbol over the specified period.

adr

adr(
    symbols: List[Symbol],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> AdvanceDeclineRatio

Creates a new Advance/Decline Ratio indicator

Parameters:

Name Type Description Default
symbols List[Symbol]

The symbols whose A/D Ratio we want

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
AdvanceDeclineRatio

The Advance/Decline Ratio indicator for the requested symbol over the specified period.

advr

advr(
    symbols: List[Symbol],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> AdvanceDeclineVolumeRatio

Creates a new Advance/Decline Volume Ratio indicator

Parameters:

Name Type Description Default
symbols List[Symbol]

The symbol whose A/D Volume Rate we want

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
AdvanceDeclineVolumeRatio

The Advance/Decline Volume Ratio indicator for the requested symbol over the specified period.

adx

adx(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> AverageDirectionalIndex

Creates a new Average Directional Index indicator. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose Average Directional Index we seek

required
resolution Optional[Resolution]

The resolution.

None
period int

The period over which to compute the Average Directional Index

required
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
AverageDirectionalIndex

The Average Directional Index indicator for the requested symbol.

adxr

adxr(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> AverageDirectionalMovementIndexRating

Creates a new AverageDirectionalMovementIndexRating indicator.

Parameters:

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

The symbol whose ADXR we want

required
period int

The period over which to compute the ADXR

required
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
AverageDirectionalMovementIndexRating

The AverageDirectionalMovementIndexRating indicator for the requested symbol over the specified period.

alma

alma(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    sigma: int = 6,
    offset: float = 0.85,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> ArnaudLegouxMovingAverage

Creates a new ArnaudLegouxMovingAverage indicator.

Parameters:

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

The symbol whose ALMA we want

required
period int

int - the number of periods to calculate the ALMA

required
sigma int

int - this parameter is responsible for the shape of the curve coefficients.

6
offset float

decimal - This parameter allows regulating the smoothness and high sensitivity of the Moving Average. The range for this parameter is <0, 1>.

0.85
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
ArnaudLegouxMovingAverage

The ArnaudLegouxMovingAverage indicator for the requested symbol over the specified period.

ao

ao(
    symbol: Union[Symbol, str, BaseContract],
    fast_period: int,
    slow_period: int,
    type: MovingAverageType,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> AwesomeOscillator

Creates a new Awesome Oscillator from the specified periods.

Parameters:

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

The symbol whose Awesome Oscillator we seek

required
resolution Optional[Resolution]

The resolution.

None
fast_period int

The period of the fast moving average associated with the AO

required
slow_period int

The period of the slow moving average associated with the AO

required
type MovingAverageType

The type of moving average used when computing the fast and slow term. Defaults to simple moving average.

required
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

apo

apo(
    symbol: Union[Symbol, str, BaseContract],
    fast_period: int,
    slow_period: int,
    moving_average_type: MovingAverageType,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> AbsolutePriceOscillator

Creates a new AbsolutePriceOscillator indicator.

Parameters:

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

The symbol whose APO we want

required
fast_period int

The fast moving average period

required
slow_period int

The slow moving average period

required
moving_average_type MovingAverageType

The type of moving average to use

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
AbsolutePriceOscillator

The AbsolutePriceOscillator indicator for the requested symbol over the specified period.

aps

aps(
    symbol: Union[Symbol, str, BaseContract],
    period: int = 3,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> AugenPriceSpike

Creates an AugenPriceSpike indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose APS we want

required
period int

The period of the APS

3
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
AugenPriceSpike

The AugenPriceSpike indicator for the given parameters.

ar

ar(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> AverageRange

Creates a new Average Range (AR) indicator.

Parameters:

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

The symbol whose Average Range we want to calculate

required
period int

The period over which to compute the Average Range

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator. If null, defaults to the Value property of BaseData (x => x.Value).

None

Returns:

Type Description
AverageRange

The Average Range indicator for the requested symbol over the specified period.

asi

asi(
    symbol: Union[Symbol, str, BaseContract],
    limit_move: float,
    resolution: Optional[Resolution] = ...,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> WilderAccumulativeSwingIndex

Creates a Wilder Accumulative Swing Index (ASI) indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose ASI we want

required
limit_move float

The maximum daily change in price for the ASI

required
resolution Optional[Resolution]

The resolution

...
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
WilderAccumulativeSwingIndex

The WilderAccumulativeSwingIndex for the given parameters.

atr

atr(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> AverageTrueRange

Creates a new AverageTrueRange indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose ATR we want

required
period int

The smoothing period used to smooth the computed TrueRange values

required
type MovingAverageType

The type of smoothing to use

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
AverageTrueRange

A new AverageTrueRange indicator with the specified smoothing type and period.

b

b(
    target: Union[Symbol, str, BaseContract],
    reference: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> Beta

Creates a Beta indicator for the given target symbol in relation with the reference used. The indicator will be automatically updated on the given resolution.

Parameters:

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

The target symbol whose Beta value we want

required
reference Union[Symbol, str, BaseContract]

The reference symbol to compare with the target symbol

required
period int

The period of the Beta indicator

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
Beta

The Beta indicator for the given parameters.

bb

bb(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    k: float,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> BollingerBands

Creates a new BollingerBands indicator which will compute the MiddleBand, UpperBand, LowerBand, and StandardDeviation

Parameters:

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

The symbol whose BollingerBands we seek

required
period int

The period of the standard deviation and moving average (middle band)

required
k float

The number of standard deviations specifying the distance between the middle band and upper or lower bands

required
moving_average_type MovingAverageType

The type of moving average to be used

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
BollingerBands

A BollingerBands configured with the specified period.

bop

bop(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> BalanceOfPower

Creates a new Balance Of Power indicator. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose Balance Of Power we seek

required
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
BalanceOfPower

The Balance Of Power indicator for the requested symbol.

broadcast_command

broadcast_command(command: Any) -> RestResponse

Broadcast a live command

Parameters:

Name Type Description Default
command Any

The target command

required

Returns:

Type Description
RestResponse

RestResponse.

c

c(
    target: Union[Symbol, str, BaseContract],
    reference: Union[Symbol, str, BaseContract],
    period: int,
    correlation_type: CorrelationType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> Correlation

Creates a Correlation indicator for the given target symbol in relation with the reference used. The indicator will be automatically updated on the given resolution.

Parameters:

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

The target symbol of this indicator

required
reference Union[Symbol, str, BaseContract]

The reference symbol of this indicator

required
period int

The period of this indicator

required
correlation_type CorrelationType

Correlation type

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
Correlation

The Correlation indicator for the given parameters.

calculate_order_quantity

calculate_order_quantity(
    symbol: Union[Symbol, str, BaseContract], target: float
) -> float

Calculate the order quantity to achieve target-percent holdings.

Parameters:

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

Security object we're asking for

required
target float

Target percentage holdings

required

Returns:

Type Description
float

Order quantity to achieve this percentage.

cc

cc(
    symbol: Union[Symbol, str, BaseContract],
    short_roc_period: int = 11,
    long_roc_period: int = 14,
    lwma_period: int = 10,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> CoppockCurve

Initializes a new instance of the CoppockCurve indicator

Parameters:

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

The symbol whose Coppock Curve we want

required
short_roc_period int

The period for the short ROC

11
long_roc_period int

The period for the long ROC

14
lwma_period int

The period for the LWMA

10
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
CoppockCurve

The Coppock Curve indicator for the requested symbol over the specified period.

cci

cci(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> CommodityChannelIndex

Creates a new CommodityChannelIndex indicator. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose CCI we want

required
period int

The period over which to compute the CCI

required
moving_average_type MovingAverageType

The type of moving average to use in computing the typical price average

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
CommodityChannelIndex

The CommodityChannelIndex indicator for the requested symbol over the specified period.

chop

chop(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> ChoppinessIndex

Creates a new ChoppinessIndex indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose CHOP we want

required
period int

The input window period used to calculate max high and min low

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
ChoppinessIndex

A new ChoppinessIndex indicator with the window period.

cks

cks(
    symbol: Union[Symbol, str, BaseContract],
    atr_period: int,
    atr_mult: float,
    period: int,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> ChandeKrollStop

Creates a new Chande Kroll Stop indicator which will compute the short and lower stop. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose Chande Kroll Stop we seek.

required
atr_period int

The period over which to compute the average true range.

required
atr_mult float

The ATR multiplier to be used to compute stops distance.

required
period int

The period over which to compute the max of high stop and min of low stop.

required
resolution Optional[Resolution]

The resolution.

None
moving_average_type MovingAverageType

The type of smoothing used to smooth the true range values

...
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
ChandeKrollStop

The Chande Kroll Stop indicator for the requested symbol.

cmf

cmf(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> ChaikinMoneyFlow

Creates a new ChaikinMoneyFlow indicator.

Parameters:

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

The symbol whose CMF we want

required
period int

The period over which to compute the CMF

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
ChaikinMoneyFlow

The ChaikinMoneyFlow indicator for the requested symbol over the specified period.

cmo

cmo(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> ChandeMomentumOscillator

Creates a new ChandeMomentumOscillator indicator.

Parameters:

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

The symbol whose CMO we want

required
period int

The period over which to compute the CMO

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
ChandeMomentumOscillator

The ChandeMomentumOscillator indicator for the requested symbol over the specified period.

co

co(
    symbol: Union[Symbol, str, BaseContract],
    fast_period: int,
    slow_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> ChaikinOscillator

Creates a new Chaikin Oscillator indicator.

Parameters:

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

The symbol whose CO we want

required
fast_period int

The fast moving average period

required
slow_period int

The slow moving average period

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
ChaikinOscillator

The Chaikin Oscillator indicator for the requested symbol over the specified period.

combo_leg_limit_order

combo_leg_limit_order(
    legs: List[Leg],
    quantity: int,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]

Issue a combo leg limit order/trade for multiple assets, each having its own limit price.

Parameters:

Name Type Description Default
legs List[Leg]

The list of legs the order consists of

required
quantity int

The total quantity for the order

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it is fully submitted

False
tag str

String tag for the order (optional)

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
List[OrderTicket]

Sequence of order tickets, one for each leg.

combo_limit_order

combo_limit_order(
    legs: List[Leg],
    quantity: int,
    limit_price: float,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]

Issue a combo limit order/trade for multiple assets. A single limit price is defined for the combo order and will fill only if the sum of the assets price compares properly to the limit price, depending on the direction.

Parameters:

Name Type Description Default
legs List[Leg]

The list of legs the order consists of

required
quantity int

The total quantity for the order

required
limit_price float

The compound limit price to use for a ComboLimit order. This limit price will compared to the sum of the assets price in order to fill the order.

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it is fully submitted

False
tag str

String tag for the order (optional)

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
List[OrderTicket]

Sequence of order tickets, one for each leg.

combo_market_order

combo_market_order(
    legs: List[Leg],
    quantity: int,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> List[OrderTicket]

Issue a combo market order/trade for multiple assets

Parameters:

Name Type Description Default
legs List[Leg]

The list of legs the order consists of

required
quantity int

The total quantity for the order

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it fills

False
tag str

String tag for the order (optional)

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
List[OrderTicket]

Sequence of order tickets, one for each leg.

create_consolidator

create_consolidator(
    period: timedelta,
    consolidator_input_type: Type,
    tick_type: Optional[TickType] = None,
) -> IDataConsolidator

Creates a new consolidator for the specified period, generating the requested output type.

Parameters:

Name Type Description Default
period timedelta

The consolidation period

required
consolidator_input_type Type

The desired input type of the consolidator, such as TradeBar or QuoteBar

required
tick_type Optional[TickType]

Trade or Quote. Optional, defaults to trade

None

Returns:

Type Description
IDataConsolidator

A new consolidator matching the requested parameters.

crsi

crsi(
    symbol: Union[Symbol, str, BaseContract],
    rsi_period: int,
    rsi_period_streak: int,
    look_back_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> ConnorsRelativeStrengthIndex

Creates a new Connors Relative Strength Index (CRSI) indicator, which combines the traditional Relative Strength Index (RSI), Streak RSI (SRSI), and Percent Rank to provide a more robust measure of market strength. This indicator oscillates based on momentum, streak behavior, and price change over the specified periods.

Parameters:

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

The symbol whose CRSI is to be calculated.

required
rsi_period int

The period for the traditional RSI calculation.

required
rsi_period_streak int

The period for the Streak RSI calculation (SRSI).

required
look_back_period int

The look-back period for calculating the Percent Rank.

required
resolution Optional[Resolution]

The resolution of the data (optional).

None
selector Callable[[IBaseData], float]

Function to select a value from the BaseData to input into the indicator. Defaults to using the 'Value' property of BaseData if null.

None

Returns:

Type Description
ConnorsRelativeStrengthIndex

The Connors Relative Strength Index (CRSI) for the specified symbol and periods.

d

d(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: Optional[OptionPricingModelType] = None,
    iv_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> Delta

Creates a new Delta indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Union[Symbol, str, BaseContract]

The mirror option for parity calculation

None
risk_free_rate Optional[float]

The risk free rate

None
dividend_yield Optional[float]

The dividend yield

None
option_model Optional[OptionPricingModelType]

The option pricing model used to estimate Delta

None
iv_model Optional[OptionPricingModelType]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None

Returns:

Type Description
Delta

A new Delta indicator for the specified symbol.

dem

dem(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    type: MovingAverageType,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> DeMarkerIndicator

Creates a new DeMarker Indicator (DEM), an oscillator-type indicator measuring changes in terms of an asset's High and Low tradebar values.

Parameters:

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

The symbol whose DEM we seek.

required
period int

The period of the moving average implemented

required
type MovingAverageType

Specifies the type of moving average to be used

required
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
DeMarkerIndicator

The DeMarker indicator for the requested symbol.

dema

dema(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DoubleExponentialMovingAverage

Creates a new DoubleExponentialMovingAverage indicator.

Parameters:

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

The symbol whose DEMA we want

required
period int

The period over which to compute the DEMA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
DoubleExponentialMovingAverage

The DoubleExponentialMovingAverage indicator for the requested symbol over the specified period.

deregister_indicator

deregister_indicator(indicator: IndicatorBase) -> None

Will deregister an indicator and it's associated consolidator instance so they stop receiving data updates

Parameters:

Name Type Description Default
indicator IndicatorBase

The indicator instance to deregister

required

do

do(
    symbol: Union[Symbol, str, BaseContract],
    rsi_period: int,
    smoothing_rsi_period: int,
    double_smoothing_rsi_period: int,
    signal_line_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DerivativeOscillator

Creates a new DerivativeOscillator indicator.

Parameters:

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

The symbol whose DO we want

required
rsi_period int

The period over which to compute the RSI

required
smoothing_rsi_period int

The period over which to compute the smoothing RSI

required
double_smoothing_rsi_period int

The period over which to compute the double smoothing RSI

required
signal_line_period int

The period over which to compute the signal line

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
DerivativeOscillator

The DerivativeOscillator indicator for the requested symbol over the specified period.

dpo

dpo(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> DetrendedPriceOscillator

Creates a new DetrendedPriceOscillator indicator.

Parameters:

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

The symbol whose DPO we want

required
period int

The period over which to compute the DPO

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
DetrendedPriceOscillator

A new registered DetrendedPriceOscillator indicator for the requested symbol over the specified period.

emv

emv(
    symbol: Union[Symbol, str, BaseContract],
    period: int = 1,
    scale: int = 10000,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> EaseOfMovementValue

Creates an EaseOfMovementValue indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose EMV we want

required
period int

The period of the EMV

1
scale int

The length of the outputed value

10000
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
EaseOfMovementValue

The EaseOfMovementValue indicator for the given parameters.

exercise_option

exercise_option(
    option_symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    asynchronous: bool = False,
    tag: str = ...,
    order_properties: IOrderProperties = None,
) -> OrderTicket

Send an exercise order to the transaction handler

Parameters:

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

String symbol for the option position

required
quantity int

Quantity of options contracts

required
asynchronous bool

Send the order asynchronously (false). Otherwise we'll block until it fills

False
tag str

String tag for the order (optional)

...
order_properties IOrderProperties

The order properties to use. Defaults to default_order_properties

None

Returns:

Type Description
OrderTicket

The order ticket instance.

fi

fi(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> ForceIndex

Creates a new ForceIndex indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose ForceIndex we want

required
period int

The smoothing period used to smooth the computed ForceIndex values

required
type MovingAverageType

The type of smoothing to use

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
ForceIndex

A new ForceIndex indicator with the specified smoothing type and period.

fish

fish(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> FisherTransform

Creates an FisherTransform indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose FisherTransform we want

required
period int

The period of the FisherTransform

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
FisherTransform

The FisherTransform for the given parameters.

frama

frama(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    long_period: int = 198,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> FractalAdaptiveMovingAverage

Creates an FractalAdaptiveMovingAverage (FRAMA) indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose FRAMA we want

required
period int

The period of the FRAMA

required
long_period int

The long period of the FRAMA

198
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
FractalAdaptiveMovingAverage

The FRAMA for the given parameters.

framework_post_initialize

framework_post_initialize() -> None

Called by setup handlers after initialize and allows the algorithm a chance to organize the data gather in the initialize method

future_chain

future_chain(
    symbol: Union[Symbol, str, BaseContract],
    flatten: bool = False,
) -> FuturesChain

Get the futures chain for the specified symbol at the current time (time)

Parameters:

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

The symbol for which the futures chain is asked for. It can be either the canonical future, a contract or an option symbol.

required
flatten bool

Whether to flatten the resulting data frame. Used from Python when accessing FuturesChain.DataFrame. See history(PyObject, int, Resolution?, bool?, bool?, DataMappingMode?, DataNormalizationMode?, int?, bool)

False

Returns:

Type Description
FuturesChain

The futures chain.

future_chains

future_chains(
    symbols: List[Symbol], flatten: bool = False
) -> FuturesChains

Get the futures chains for the specified symbols at the current time (time)

Parameters:

Name Type Description Default
symbols List[Symbol]

The symbols for which the futures chains are asked for. It can be either the canonical future, a contract or an option symbol.

required
flatten bool

Whether to flatten the resulting data frame. Used from Python when accessing FuturesChains.DataFrame. See history(PyObject, int, Resolution?, bool?, bool?, DataMappingMode?, DataNormalizationMode?, int?, bool)

False

Returns:

Type Description
FuturesChains

The futures chains.

futures_chain

futures_chain(
    symbol: Union[Symbol, str, BaseContract],
    flatten: bool = False,
) -> FuturesChain

Get the futures chain for the specified symbol at the current time (time)

Parameters:

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

The symbol for which the futures chain is asked for. It can be either the canonical future, a contract or an option symbol.

required
flatten bool

Whether to flatten the resulting data frame. Used from Python when accessing FuturesChain.DataFrame. See history(PyObject, int, Resolution?, bool?, bool?, DataMappingMode?, DataNormalizationMode?, int?, bool)

False

Returns:

Type Description
FuturesChain

The futures chain.

futures_chains

futures_chains(
    symbols: List[Symbol], flatten: bool = False
) -> FuturesChains

Get the futures chains for the specified symbols at the current time (time)

Parameters:

Name Type Description Default
symbols List[Symbol]

The symbols for which the futures chains are asked for. It can be either the canonical future, a contract or an option symbol.

required
flatten bool

Whether to flatten the resulting data frame. Used from Python when accessing FuturesChains.DataFrame. See history(PyObject, int, Resolution?, bool?, bool?, DataMappingMode?, DataNormalizationMode?, int?, bool)

False

Returns:

Type Description
FuturesChains

The futures chains.

g

g(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: Optional[OptionPricingModelType] = None,
    iv_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> Gamma

Creates a new Gamma indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Union[Symbol, str, BaseContract]

The mirror option for parity calculation

None
risk_free_rate Optional[float]

The risk free rate

None
dividend_yield Optional[float]

The dividend yield

None
option_model Optional[OptionPricingModelType]

The option pricing model used to estimate Gamma

None
iv_model Optional[OptionPricingModelType]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None

Returns:

Type Description
Gamma

A new Gamma indicator for the specified symbol.

he

he(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    max_lag: int = 20,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> HurstExponent

Creates a new Hurst Exponent indicator for the specified symbol. The Hurst Exponent measures the long-term memory or self-similarity in a time series. The default max_lag value of 20 is chosen for reliable and accurate results, but using a higher lag may reduce precision.

Parameters:

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

The symbol for which the Hurst Exponent is calculated.

required
period int

The number of data points used to calculate the indicator at each step.

required
max_lag int

The maximum time lag used to compute the tau values for the Hurst Exponent calculation.

20
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Function to select a value from the BaseData to input into the indicator. Defaults to using the 'Value' property of BaseData if null.

None

Returns:

Type Description
HurstExponent

The Hurst Exponent indicator for the specified symbol.

heikin_ashi

heikin_ashi(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> HeikinAshi

Creates a new Heikin-Ashi indicator.

Parameters:

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

The symbol whose Heikin-Ashi we want

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
HeikinAshi

The Heikin-Ashi indicator for the requested symbol over the specified period.

hma

hma(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> HullMovingAverage

Creates a new HullMovingAverage indicator. The Hull moving average is a series of nested weighted moving averages, is fast and smooth.

Parameters:

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

The symbol whose Hull moving average we want

required
period int

The period over which to compute the Hull moving average

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

ht

ht(
    symbol: Union[Symbol, str, BaseContract],
    length: int,
    in_phase_multiplication_factor: float,
    quadrature_multiplication_factor: float,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> HilbertTransform

Creates a new Hilbert Transform indicator

Parameters:

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

The symbol whose Hilbert transform we want

required
length int

The length of the FIR filter used in the calculation of the Hilbert Transform. This parameter determines the number of filter coefficients in the FIR filter.

required
in_phase_multiplication_factor float

The multiplication factor used in the calculation of the in-phase component of the Hilbert Transform. This parameter adjusts the sensitivity and responsiveness of the transform to changes in the input signal.

required
quadrature_multiplication_factor float

The multiplication factor used in the calculation of the quadrature component of the Hilbert Transform. This parameter also adjusts the sensitivity and responsiveness of the transform to changes in the input signal.

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

ibs

ibs(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> InternalBarStrength

Creates a new InternalBarStrength indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose IBS we want

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
InternalBarStrength

A new InternalBarStrength indicator.

ichimoku

ichimoku(
    symbol: Union[Symbol, str, BaseContract],
    tenkan_period: int,
    kijun_period: int,
    senkou_a_period: int,
    senkou_b_period: int,
    senkou_a_delay_period: int,
    senkou_b_delay_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> IchimokuKinkoHyo

Creates a new IchimokuKinkoHyo indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose ICHIMOKU we want

required
tenkan_period int

The period to calculate the Tenkan-sen period

required
kijun_period int

The period to calculate the Kijun-sen period

required
senkou_a_period int

The period to calculate the Tenkan-sen period

required
senkou_b_period int

The period to calculate the Tenkan-sen period

required
senkou_a_delay_period int

The period to calculate the Tenkan-sen period

required
senkou_b_delay_period int

The period to calculate the Tenkan-sen period

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
IchimokuKinkoHyo

A new IchimokuKinkoHyo indicator with the specified periods and delays.

is_market_open

is_market_open(
    symbol: Union[Symbol, str, BaseContract],
) -> bool

Determines if the exchange for the specified symbol is open at the current time.

Parameters:

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

The symbol

required

Returns:

Type Description
bool

True if the exchange is considered open at the current time, false otherwise.

iv

iv(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> ImpliedVolatility

Creates a new ImpliedVolatility indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Union[Symbol, str, BaseContract]

The mirror option contract used for parity type calculation

None
risk_free_rate Optional[float]

The risk free rate

None
dividend_yield Optional[float]

The dividend yield

None
option_model Optional[OptionPricingModelType]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None

Returns:

Type Description
ImpliedVolatility

A new ImpliedVolatility indicator for the specified symbol.

kch

kch(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    k: float,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> KeltnerChannels

Creates a new Keltner Channels indicator. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose Keltner Channel we seek

required
period int

The period over which to compute the Keltner Channels

required
k float

The number of multiples of the AverageTrueRange from the middle band of the Keltner Channels

required
moving_average_type MovingAverageType

Specifies the type of moving average to be used as the middle line of the Keltner Channel

...
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
KeltnerChannels

The Keltner Channel indicator for the requested symbol.

ker

ker(
    symbol: Union[Symbol, str, BaseContract],
    period: int = 2,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> KaufmanEfficiencyRatio

Creates an KaufmanEfficiencyRatio indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose EF we want

required
period int

The period of the EF

2
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
KaufmanEfficiencyRatio

The KaufmanEfficiencyRatio indicator for the given parameters.

kst

kst(
    symbol: Union[Symbol, str, BaseContract],
    roc_1_period: int = 10,
    roc_1_ma_period: int = 10,
    roc_2_period: int = 15,
    roc_2_ma_period: int = 10,
    roc_3_period: int = 20,
    roc_3_ma_period: int = 10,
    roc_4_period: int = 30,
    roc_4_ma_period: int = 15,
    signal_period: int = 9,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> KnowSureThing

Creates a new KnowSureThing indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose KST we want

required
roc_1_period int

The period over which to compute ROC1

10
roc_1_ma_period int

The smoothing period used to smooth the computed ROC1 values

10
roc_2_period int

The period over which to compute ROC2

15
roc_2_ma_period int

The smoothing period used to smooth the computed ROC2 values

10
roc_3_period int

The period over which to compute ROC3

20
roc_3_ma_period int

The smoothing period used to smooth the computed ROC3 values

10
roc_4_period int

The period over which to compute ROC4

30
roc_4_ma_period int

The smoothing period used to smooth the computed ROC4 values

15
signal_period int

The smoothing period used to smooth the signal values

9
moving_average_type MovingAverageType

Specifies the type of moving average to be used as smoother for KnowSureThing values

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
KnowSureThing

A new KnowSureThing indicator with the specified smoothing type and period.

kvo

kvo(
    symbol: Union[Symbol, str, BaseContract],
    fast_period: int,
    slow_period: int,
    signal_period: int = 13,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> KlingerVolumeOscillator

Creates a new Klinger Volume Oscillator (KVO) indicator

Parameters:

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

The symbol whose KVO we want

required
fast_period int

The period of the fast EMA used to calculate KVO

required
slow_period int

The period of the slow EMA used to calculate KVO, default to 13

required
signal_period int

The period of the signal EMA of the raw KVO value

13
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
KlingerVolumeOscillator

The Klinger Volume Oscillator indicator for the requested symbol.

link(command: Any) -> str

Get an authenticated link to execute the given command instance

Parameters:

Name Type Description Default
command Any

The target command

required

Returns:

Type Description
str

The authenticated link.

logr

logr(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> LogReturn

Creates a new LogReturn indicator.

Parameters:

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

The symbol whose log return we seek

required
period int

The period of the log return.

required
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar.

None

Returns:

Type Description
LogReturn

log return indicator for the requested symbol.

lsma

lsma(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> LeastSquaresMovingAverage

Creates and registers a new Least Squares Moving Average instance.

Parameters:

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

The symbol whose LSMA we seek.

required
period int

The LSMA period. Normally 14.

required
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar.

None

Returns:

Type Description
LeastSquaresMovingAverage

A LeastSquaredMovingAverage configured with the specified period.

lwma

lwma(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> LinearWeightedMovingAverage

Creates a new LinearWeightedMovingAverage indicator. This indicator will linearly distribute the weights across the periods.

Parameters:

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

The symbol whose LWMA we want

required
period int

The period over which to compute the LWMA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

macd

macd(
    symbol: Union[Symbol, str, BaseContract],
    fast_period: int,
    slow_period: int,
    signal_period: int,
    type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> MovingAverageConvergenceDivergence

Creates a MACD indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose MACD we want

required
fast_period int

The period for the fast moving average

required
slow_period int

The period for the slow moving average

required
signal_period int

The period for the signal moving average

required
type MovingAverageType

The type of moving average to use for the MACD

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
MovingAverageConvergenceDivergence

The moving average convergence divergence between the fast and slow averages.

mad

mad(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> MeanAbsoluteDeviation

Creates a new MeanAbsoluteDeviation indicator.

Parameters:

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

The symbol whose MeanAbsoluteDeviation we want

required
period int

The period over which to compute the MeanAbsoluteDeviation

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
MeanAbsoluteDeviation

The MeanAbsoluteDeviation indicator for the requested symbol over the specified period.

mama

mama(
    symbol: Union[Symbol, str, BaseContract],
    fast_limit: float = 0.5,
    slow_limit: float = 0.05,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> MesaAdaptiveMovingAverage

Creates a new Mesa Adaptive Moving Average (MAMA) indicator. The MAMA adjusts its smoothing factor based on the market's volatility, making it more adaptive than a simple moving average.

Parameters:

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

The symbol for which the MAMA indicator is being created.

required
fast_limit float

The fast limit for the adaptive moving average.

0.5
slow_limit float

The slow limit for the adaptive moving average.

0.05
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Optional function to select a value from the BaseData. Defaults to casting the input to a TradeBar.

None

Returns:

Type Description
MesaAdaptiveMovingAverage

The Mesa Adaptive Moving Average (MAMA) indicator for the requested symbol with the specified limits.

mass

mass(
    symbol: Union[Symbol, str, BaseContract],
    ema_period: int = 9,
    sum_period: int = 25,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> MassIndex

Creates a new Mass Index indicator. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose Mass Index we want.

required
ema_period int

The period used by both EMA.

9
sum_period int

The sum period.

25
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
MassIndex

The Mass Index indicator for the requested symbol over the specified period.

max

max(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> Maximum

Creates a new Maximum indicator to compute the maximum value

Parameters:

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

The symbol whose max we want

required
period int

The look back period over which to compute the max value

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null and the symbol is of type TradeBar defaults to the High property, otherwise it defaults to Value property of BaseData (x => x.Value)

None

Returns:

Type Description
Maximum

A Maximum indicator that compute the max value and the periods since the max value.

mfi

mfi(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> MoneyFlowIndex

Creates a new MoneyFlowIndex indicator. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose MFI we want

required
period int

The period over which to compute the MFI

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
MoneyFlowIndex

The MoneyFlowIndex indicator for the requested symbol over the specified period.

mgd

mgd(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> McGinleyDynamic

Creates a new McGinley Dynamic indicator

Parameters:

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

The symbol whose McGinley Dynamic indicator value we want

required
period int

The period of the McGinley Dynamic indicator

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
McGinleyDynamic

The McGinley Dynamic indicator for the requested symbol over the specified period.

midpoint

midpoint(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> MidPoint

Creates a new MidPoint indicator.

Parameters:

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

The symbol whose MIDPOINT we want

required
period int

The period over which to compute the MIDPOINT

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
MidPoint

The MidPoint indicator for the requested symbol over the specified period.

midprice

midprice(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> MidPrice

Creates a new MidPrice indicator.

Parameters:

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

The symbol whose MIDPRICE we want

required
period int

The period over which to compute the MIDPRICE

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
MidPrice

The MidPrice indicator for the requested symbol over the specified period.

min

min(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> Minimum

Creates a new Minimum indicator to compute the minimum value

Parameters:

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

The symbol whose min we want

required
period int

The look back period over which to compute the min value

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null and the symbol is of type TradeBar defaults to the Low property, otherwise it defaults to Value property of BaseData (x => x.Value)

None

Returns:

Type Description
Minimum

A Minimum indicator that compute the in value and the periods since the min value.

mom

mom(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> Momentum

Creates a new Momentum indicator. This will compute the absolute n-period change in the security. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose momentum we want

required
period int

The period over which to compute the momentum

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
Momentum

The momentum indicator for the requested symbol over the specified period.

momersion

momersion(
    symbol: Union[Symbol, str, BaseContract],
    min_period: Optional[int],
    full_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> Momersion

Creates a new Momersion indicator.

Parameters:

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

The symbol whose Momersion we want

required
min_period Optional[int]

The minimum period over which to compute the Momersion. Must be greater than 3. If null, only full period will be used in computations.

required
full_period int

The full period over which to compute the Momersion

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
Momersion

The Momersion indicator for the requested symbol over the specified period.

momp

momp(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> MomentumPercent

Creates a new MomentumPercent indicator. This will compute the n-period percent change in the security. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose momentum we want

required
period int

The period over which to compute the momentum

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
MomentumPercent

The momentum indicator for the requested symbol over the specified period.

mosc

mosc(
    symbols: List[Symbol],
    fast_period: int = 19,
    slow_period: int = 39,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> McClellanOscillator

Creates a new McClellan Oscillator indicator

Parameters:

Name Type Description Default
symbols List[Symbol]

The symbols whose McClellan Oscillator we want

required
fast_period int

Fast period EMA of advance decline difference

19
slow_period int

Slow period EMA of advance decline difference

39
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
McClellanOscillator

The McClellan Oscillator indicator for the requested symbol over the specified period.

msi

msi(
    symbols: List[Symbol],
    fast_period: int = 19,
    slow_period: int = 39,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> McClellanSummationIndex

Creates a new McClellan Summation Index indicator

Parameters:

Name Type Description Default
symbols List[Symbol]

The symbols whose McClellan Summation Index we want

required
fast_period int

Fast period EMA of advance decline difference

19
slow_period int

Slow period EMA of advance decline difference

39
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
McClellanSummationIndex

The McClellan Summation Index indicator for the requested symbol over the specified period.

natr

natr(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> NormalizedAverageTrueRange

Creates a new NormalizedAverageTrueRange indicator.

Parameters:

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

The symbol whose NATR we want

required
period int

The period over which to compute the NATR

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
NormalizedAverageTrueRange

The NormalizedAverageTrueRange indicator for the requested symbol over the specified period.

obv

obv(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> OnBalanceVolume

Creates a new On Balance Volume indicator. This will compute the cumulative total volume based on whether the close price being higher or lower than the previous period. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose On Balance Volume we seek

required
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
OnBalanceVolume

The On Balance Volume indicator for the requested symbol.

option_chain

option_chain(
    symbol: Union[Symbol, str, BaseContract],
    flatten: bool = False,
) -> OptionChain

Get the option chain for the specified symbol at the current time (time)

Parameters:

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

The symbol for which the option chain is asked for. It can be either the canonical option or the underlying symbol.

required
flatten bool

Whether to flatten the resulting data frame. Used from Python when accessing OptionChain.DataFrame. See history(PyObject, int, Resolution?, bool?, bool?, DataMappingMode?, DataNormalizationMode?, int?, bool)

False

Returns:

Type Description
OptionChain

The option chain.

option_chains

option_chains(
    symbols: List[Symbol], flatten: bool = False
) -> OptionChains

Get the option chains for the specified symbols at the current time (time)

Parameters:

Name Type Description Default
symbols List[Symbol]

The symbols for which the option chain is asked for. It can be either the canonical options or the underlying symbols.

required
flatten bool

Whether to flatten the resulting data frame. Used from Python when accessing OptionChain.DataFrame. See history(PyObject, int, Resolution?, bool?, bool?, DataMappingMode?, DataNormalizationMode?, int?, bool)

False

Returns:

Type Description
OptionChains

The option chains.

ppo

ppo(
    symbol: Union[Symbol, str, BaseContract],
    fast_period: int,
    slow_period: int,
    moving_average_type: MovingAverageType,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> PercentagePriceOscillator

Creates a new PercentagePriceOscillator indicator.

Parameters:

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

The symbol whose PPO we want

required
fast_period int

The fast moving average period

required
slow_period int

The slow moving average period

required
moving_average_type MovingAverageType

The type of moving average to use

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
PercentagePriceOscillator

The PercentagePriceOscillator indicator for the requested symbol over the specified period.

psar

psar(
    symbol: Union[Symbol, str, BaseContract],
    af_start: float = 0.02,
    af_increment: float = 0.02,
    af_max: float = 0.2,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> ParabolicStopAndReverse

Creates a new Parabolic SAR indicator

Parameters:

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

The symbol whose PSAR we seek

required
af_start float

Acceleration factor start value. Normally 0.02

0.02
af_increment float

Acceleration factor increment value. Normally 0.02

0.02
af_max float

Acceleration factor max value. Normally 0.2

0.2
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
ParabolicStopAndReverse

A ParabolicStopAndReverse configured with the specified periods.

pso

pso(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    ema_period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> PremierStochasticOscillator

Creates a new instance of the Premier Stochastic Oscillator for the specified symbol.

Parameters:

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

The symbol for which the stochastic indicator is being calculated.

required
period int

The period for calculating the Stochastic K value.

required
ema_period int

The period for the Exponential Moving Average (EMA) used to smooth the Stochastic K.

required
resolution Optional[Resolution]

The data resolution (e.g., daily, hourly) for the indicator

None
selector Callable[[IBaseData], TradeBar]

Optional function to select a value from the BaseData. Defaults to casting the input to a TradeBar.

None

Returns:

Type Description
PremierStochasticOscillator

A PremierStochasticOscillator instance for the specified symbol.

r

r(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: Optional[OptionPricingModelType] = None,
    iv_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> Rho

Creates a new Rho indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Union[Symbol, str, BaseContract]

The mirror option for parity calculation

None
risk_free_rate Optional[float]

The risk free rate

None
dividend_yield Optional[float]

The dividend yield

None
option_model Optional[OptionPricingModelType]

The option pricing model used to estimate Rho

None
iv_model Optional[OptionPricingModelType]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None

Returns:

Type Description
Rho

A new Rho indicator for the specified symbol.

rc

rc(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    k: float,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> RegressionChannel

Creates a new RegressionChannel indicator which will compute the LinearRegression, UpperChannel and LowerChannel lines, the intercept and slope

Parameters:

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

The symbol whose RegressionChannel we seek

required
period int

The period of the standard deviation and least square moving average (linear regression line)

required
k float

The number of standard deviations specifying the distance between the linear regression and upper or lower channel lines

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
RegressionChannel

A Regression Channel configured with the specified period and number of standard deviation.

rdv

rdv(
    symbol: Union[Symbol, str, BaseContract],
    period: int = 2,
    resolution: Resolution = ...,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> RelativeDailyVolume

Creates an RelativeDailyVolume indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose RDV we want

required
period int

The period of the RDV

2
resolution Resolution

The resolution

...
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
RelativeDailyVolume

The Relative Volume indicator for the given parameters.

remove_option_contract

remove_option_contract(
    symbol: Union[Symbol, str, BaseContract],
    tag: str = None,
) -> bool

Removes the security with the specified symbol. This will cancel all open orders and then liquidate any existing holdings

Parameters:

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

The symbol of the security to be removed

required
tag str

Optional tag to indicate the cause of removal

None

rma

rma(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> RelativeMovingAverage

Creates a new Relative Moving Average indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose relative moving average we seek

required
period int

The period of the relative moving average

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
RelativeMovingAverage

A relative moving average configured with the specified period and number of standard deviation.

roc

roc(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> RateOfChange

Creates a new RateOfChange indicator. This will compute the n-period rate of change in the security. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose RateOfChange we want

required
period int

The period over which to compute the RateOfChange

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
RateOfChange

The RateOfChange indicator for the requested symbol over the specified period.

rocp

rocp(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> RateOfChangePercent

Creates a new RateOfChangePercent indicator. This will compute the n-period percentage rate of change in the security. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose RateOfChangePercent we want

required
period int

The period over which to compute the RateOfChangePercent

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
RateOfChangePercent

The RateOfChangePercent indicator for the requested symbol over the specified period.

rocr

rocr(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> RateOfChangeRatio

Creates a new RateOfChangeRatio indicator.

Parameters:

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

The symbol whose ROCR we want

required
period int

The period over which to compute the ROCR

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
RateOfChangeRatio

The RateOfChangeRatio indicator for the requested symbol over the specified period.

rsi

rsi(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> RelativeStrengthIndex

Creates a new RelativeStrengthIndex indicator. This will produce an oscillator that ranges from 0 to 100 based on the ratio of average gains to average losses over the specified period.

Parameters:

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

The symbol whose RSI we want

required
period int

The period over which to compute the RSI

required
moving_average_type MovingAverageType

The type of moving average to use in computing the average gain/loss values

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
RelativeStrengthIndex

The RelativeStrengthIndex indicator for the requested symbol over the specified period.

rsv

rsv(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> RogersSatchellVolatility

Creates a new RogersSatchellVolatility indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose RogersSatchellVolatility we want

required
period int

The period of the rolling window used to compute volatility

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
RogersSatchellVolatility

A new RogersSatchellVolatility indicator with the specified smoothing type and period.

rvi

rvi(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> RelativeVigorIndex

Creates a new RelativeVigorIndex indicator.

Parameters:

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

The symbol whose RVI we want

required
period int

The period over which to compute the RVI

required
moving_average_type MovingAverageType

The type of moving average to use

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
RelativeVigorIndex

The RelativeVigorIndex indicator for the requested symbol over the specified period.

sarext

sarext(
    symbol: Union[Symbol, str, BaseContract],
    sar_start: float = 0.0,
    offset_on_reverse: float = 0.0,
    af_start_short: float = 0.02,
    af_increment_short: float = 0.02,
    af_max_short: float = 0.2,
    af_start_long: float = 0.02,
    af_increment_long: float = 0.02,
    af_max_long: float = 0.2,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> ParabolicStopAndReverseExtended

Creates a new Parabolic SAR Extended indicator

Parameters:

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

The symbol whose SAREXT we seek

required
sar_start float

The starting value for the Stop and Reverse indicator

0.0
offset_on_reverse float

The offset value to be applied on reverse

0.0
af_start_short float

The starting acceleration factor for short positions

0.02
af_increment_short float

The increment value for the acceleration factor for short positions

0.02
af_max_short float

The maximum value for the acceleration factor for short positions

0.2
af_start_long float

The starting acceleration factor for long positions

0.02
af_increment_long float

The increment value for the acceleration factor for long positions

0.02
af_max_long float

The maximum value for the acceleration factor for long positions

0.2
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
ParabolicStopAndReverseExtended

A ParabolicStopAndReverseExtended configured with the specified periods.

set_alpha

set_alpha(alpha: IAlphaModel) -> None

Sets the alpha model

Parameters:

Name Type Description Default
alpha IAlphaModel

Model that generates alpha

required

set_execution

set_execution(execution: IExecutionModel) -> None

Sets the execution model

Parameters:

Name Type Description Default
execution IExecutionModel

Model defining how to execute trades to reach a portfolio target

required

set_portfolio_construction

set_portfolio_construction(
    portfolio_construction: IPortfolioConstructionModel,
) -> None

Sets the portfolio construction model

Parameters:

Name Type Description Default
portfolio_construction IPortfolioConstructionModel

Model defining how to build a portfolio from insights

required

set_quit

set_quit(quit: bool) -> None

Set the Quit flag property of the algorithm.

Parameters:

Name Type Description Default
quit bool

Boolean quit state

required

set_risk_free_interest_rate_model

set_risk_free_interest_rate_model(
    model: IRiskFreeInterestRateModel,
) -> None

Sets the risk free interest rate model to be used in the algorithm

Parameters:

Name Type Description Default
model IRiskFreeInterestRateModel

The risk free interest rate model to use

required

set_risk_management

set_risk_management(
    risk_management: IRiskManagementModel,
) -> None

Sets the risk management model

Parameters:

Name Type Description Default
risk_management IRiskManagementModel

Model defining how risk is managed

required

set_trade_builder

set_trade_builder(trade_builder: ITradeBuilder) -> None

Set the ITradeBuilder implementation to generate trades from executions and market price updates

set_universe_selection

set_universe_selection(
    universe_selection: IUniverseSelectionModel,
) -> None

Sets the universe selection model

Parameters:

Name Type Description Default
universe_selection IUniverseSelectionModel

Model defining universes for the algorithm

required

si

si(
    symbol: Union[Symbol, str, BaseContract],
    limit_move: float,
    resolution: Optional[Resolution] = ...,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> WilderSwingIndex

Creates a Wilder Swing Index (SI) indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose SI we want

required
limit_move float

The maximum daily change in price for the SI

required
resolution Optional[Resolution]

The resolution

...
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
WilderSwingIndex

The WilderSwingIndex for the given parameters.

sm

sm(
    symbol: Union[Symbol, str, BaseContract],
    bollinger_period: int = 20,
    bollinger_multiplier: float = 2,
    keltner_period: int = 20,
    keltner_multiplier: float = 1.5,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> SqueezeMomentum

Creates a Squeeze Momentum indicator to identify market squeezes and potential breakouts. Compares Bollinger Bands and Keltner Channels to signal low or high volatility periods.

Parameters:

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

The symbol for which the indicator is calculated.

required
bollinger_period int

The period for Bollinger Bands.

20
bollinger_multiplier float

The multiplier for the Bollinger Bands' standard deviation.

2
keltner_period int

The period for Keltner Channels.

20
keltner_multiplier float

The multiplier for the Average True Range in Keltner Channels.

1.5
resolution Optional[Resolution]

The resolution of the data.

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator. If null, defaults to the Value property of BaseData (x => x.Value).

None

Returns:

Type Description
SqueezeMomentum

The configured Squeeze Momentum indicator.

sma

sma(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> SimpleMovingAverage

Creates an SimpleMovingAverage indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose SMA we want

required
period int

The period of the SMA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
SimpleMovingAverage

The SimpleMovingAverage for the given parameters.

sobv

sobv(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> SmoothedOnBalanceVolume

Creates a new SmoothedOnBalanceVolume indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose SmoothedOnBalanceVolume we want

required
period int

The smoothing period used to smooth the computed OnBalanceVolume values

required
type MovingAverageType

The type of smoothing to use

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
SmoothedOnBalanceVolume

A new SmoothedOnBalanceVolume indicator with the specified smoothing type and period.

sortino

sortino(
    symbol: Union[Symbol, str, BaseContract],
    sortino_period: int,
    minimum_acceptable_return: float = 0.0,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> SortinoRatio

Creates a new Sortino indicator.

Parameters:

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

The symbol whose Sortino we want

required
sortino_period int

Period of historical observation for Sortino ratio calculation

required
minimum_acceptable_return float

Minimum acceptable return (eg risk-free rate) for the Sortino ratio calculation

0.0
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
SortinoRatio

The SortinoRatio indicator for the requested symbol over the specified period.

sr

sr(
    symbol: Union[Symbol, str, BaseContract],
    sharpe_period: int,
    risk_free_rate: Optional[float] = None,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> SharpeRatio

Creates a new SharpeRatio indicator.

Parameters:

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

The symbol whose RSR we want

required
sharpe_period int

Period of historical observation for sharpe ratio calculation

required
risk_free_rate Optional[float]

Risk-free rate for sharpe ratio calculation. If not specified, it will use the algorithms' risk_free_interest_rate_model

None
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
SharpeRatio

The SharpeRatio indicator for the requested symbol over the specified period.

srsi

srsi(
    symbol: Union[Symbol, str, BaseContract],
    rsi_period: int,
    stoch_period: int,
    k_smoothing_period: int,
    d_smoothing_period: int,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> StochasticRelativeStrengthIndex

Creates a new Stochastic RSI indicator which will compute the %K and %D

Parameters:

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

The symbol whose Stochastic RSI we seek

required
rsi_period int

The period of the relative strength index

required
stoch_period int

The period of the stochastic indicator

required
k_smoothing_period int

The smoothing period of K output

required
d_smoothing_period int

The smoothing period of D output

required
moving_average_type MovingAverageType

The type of moving average to be used

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
StochasticRelativeStrengthIndex

A StochasticRelativeStrengthIndex configured with the specified periods and moving average type.

stc

stc(
    symbol: Union[Symbol, str, BaseContract],
    cycle_period: int,
    fast_period: int,
    slow_period: int,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> SchaffTrendCycle

Creates a new Schaff Trend Cycle indicator

Parameters:

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

The symbol for the indicator to track

required
fast_period int

The fast moving average period

required
slow_period int

The slow moving average period

required
cycle_period int

The signal period

required
moving_average_type MovingAverageType

The type of moving average to use

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
SchaffTrendCycle

The SchaffTrendCycle indicator for the requested symbol over the specified period.

std

std(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> StandardDeviation

Creates a new StandardDeviation indicator. This will return the population standard deviation of samples over the specified period.

Parameters:

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

The symbol whose STD we want

required
period int

The period over which to compute the STD

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
StandardDeviation

The StandardDeviation indicator for the requested symbol over the specified period.

str

str(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    multiplier: float,
    moving_average_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> SuperTrend

Creates a new SuperTrend indicator.

Parameters:

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

The symbol whose SuperTrend indicator we want.

required
period int

The smoothing period for average true range.

required
multiplier float

Multiplier to calculate basic upper and lower bands width.

required
moving_average_type MovingAverageType

Smoother type for average true range, defaults to Wilders.

...
resolution Optional[Resolution]

The resolution.

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

sum

sum(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> Sum

Creates a new Sum indicator.

Parameters:

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

The symbol whose Sum we want

required
period int

The period over which to compute the Sum

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
Sum

The Sum indicator for the requested symbol over the specified period.

swiss

swiss(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    delta: float,
    tool: SwissArmyKnifeTool,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> SwissArmyKnife

Creates Swiss Army Knife transformation for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol to use for calculations

required
period int

The period of the calculation

required
delta float

The delta scale of the BandStop or BandPass

required
tool SwissArmyKnifeTool

The tool os the Swiss Army Knife

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

elects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
SwissArmyKnife

The calculation using the given tool.

t

t(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: Optional[OptionPricingModelType] = None,
    iv_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> Theta

Creates a new Theta indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Union[Symbol, str, BaseContract]

The mirror option for parity calculation

None
risk_free_rate Optional[float]

The risk free rate

None
dividend_yield Optional[float]

The dividend yield

None
option_model Optional[OptionPricingModelType]

The option pricing model used to estimate Theta

None
iv_model Optional[OptionPricingModelType]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None

Returns:

Type Description
Theta

A new Theta indicator for the specified symbol.

t_3

t_3(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    volume_factor: float = 0.7,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> T3MovingAverage

Creates a new T3MovingAverage indicator.

Parameters:

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

The symbol whose T3 we want

required
period int

The period over which to compute the T3

required
volume_factor float

The volume factor to be used for the T3 (value must be in the <0,1> range, defaults to 0.7)

0.7
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
T3MovingAverage

The T3MovingAverage indicator for the requested symbol over the specified period.

tdd

tdd(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    minimum_acceptable_return: float = 0,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> TargetDownsideDeviation

Creates a new TargetDownsideDeviation indicator. The target downside deviation is defined as the root-mean-square, or RMS, of the deviations of the realized return’s underperformance from the target return where all returns above the target return are treated as underperformance of 0.

Parameters:

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

The symbol whose TDD we want

required
period int

The period over which to compute the TDD

required
resolution Optional[Resolution]

The resolution

None
minimum_acceptable_return float

Minimum acceptable return (MAR) for the target downside deviation calculation

0
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
TargetDownsideDeviation

The TargetDownsideDeviation indicator for the requested symbol over the specified period.

tds

tds(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> TomDemarkSequential

Creates a new TomDemark Sequential candlestick indicator for the symbol. The indicator will be automatically updated on the symbol's subscription resolution.

Parameters:

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

The symbol whose TomDemark Sequential we want

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a IBaseDataBar

None

Returns:

Type Description
TomDemarkSequential

The TomDemark Sequential indicator for the requested symbol over the specified period.

tema

tema(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> TripleExponentialMovingAverage

Creates a new TripleExponentialMovingAverage indicator.

Parameters:

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

The symbol whose TEMA we want

required
period int

The period over which to compute the TEMA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
TripleExponentialMovingAverage

The TripleExponentialMovingAverage indicator for the requested symbol over the specified period.

tp

tp(
    symbol: Union[Symbol, str, BaseContract],
    period: int = 2,
    value_area_volume_percentage: float = 0.7,
    price_range_round_off: float = 0.05,
    resolution: Resolution = ...,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> TimeProfile

Creates an Market Profile indicator for the symbol with Time Price Opportunity (TPO) mode. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose TP we want

required
period int

The period of the TP

2
value_area_volume_percentage float

The percentage of volume contained in the value area

0.7
price_range_round_off float

How many digits you want to round and the precision. i.e 0.01 round to two digits exactly.

0.05
resolution Resolution

The resolution

...
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
TimeProfile

The Time Profile indicator for the given parameters.

tr

tr(
    symbol: Union[Symbol, str, BaseContract],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> TrueRange

Creates a new TrueRange indicator.

Parameters:

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

The symbol whose TR we want

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
TrueRange

The TrueRange indicator for the requested symbol.

trima

trima(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> TriangularMovingAverage

Creates a new TriangularMovingAverage indicator.

Parameters:

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

The symbol whose TRIMA we want

required
period int

The period over which to compute the TRIMA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
TriangularMovingAverage

The TriangularMovingAverage indicator for the requested symbol over the specified period.

trin

trin(
    symbols: List[Symbol],
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> ArmsIndex

Creates a new Arms Index indicator

Parameters:

Name Type Description Default
symbols List[Symbol]

The symbols whose Arms Index we want

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
ArmsIndex

The Arms Index indicator for the requested symbol over the specified period.

trix

trix(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> Trix

Creates a new Trix indicator.

Parameters:

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

The symbol whose TRIX we want

required
period int

The period over which to compute the TRIX

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
Trix

The Trix indicator for the requested symbol over the specified period.

tsf

tsf(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> TimeSeriesForecast

Creates a new Time Series Forecast indicator

Parameters:

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

The symbol whose TSF we want

required
period int

The period of the TSF

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to Value property of BaseData (x => x.Value)

None

Returns:

Type Description
TimeSeriesForecast

The TimeSeriesForecast indicator for the requested symbol over the specified period.

tsi

tsi(
    symbol: Union[Symbol, str, BaseContract],
    long_term_period: int = 25,
    short_term_period: int = 13,
    signal_period: int = 7,
    signal_type: MovingAverageType = ...,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> TrueStrengthIndex

Creates a TrueStrengthIndex indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose TSI we want

required
short_term_period int

Period used for the first price change smoothing

13
long_term_period int

Period used for the second (double) price change smoothing

25
signal_period int

The signal period

7
signal_type MovingAverageType

The type of moving average to use for the signal

...
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
TrueStrengthIndex

The TrueStrengthIndex indicator for the given parameters.

ultosc

ultosc(
    symbol: Union[Symbol, str, BaseContract],
    period_1: int,
    period_2: int,
    period_3: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> UltimateOscillator

Creates a new UltimateOscillator indicator.

Parameters:

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

The symbol whose ULTOSC we want

required
period_1 int

The first period over which to compute the ULTOSC

required
period_2 int

The second period over which to compute the ULTOSC

required
period_3 int

The third period over which to compute the ULTOSC

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
UltimateOscillator

The UltimateOscillator indicator for the requested symbol over the specified period.

unregister_indicator

unregister_indicator(indicator: IndicatorBase) -> None

Will unregister an indicator and it's associated consolidator instance so they stop receiving data updates

Parameters:

Name Type Description Default
indicator IndicatorBase

The indicator instance to unregister

required

vidya

vidya(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> VariableIndexDynamicAverage

Creates a new Chande's Variable Index Dynamic Average indicator.

Parameters:

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

The symbol whose VIDYA we want

required
period int

The period over which to compute the VIDYA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
VariableIndexDynamicAverage

The VariableIndexDynamicAverage indicator for the requested symbol over the specified period.

vp

vp(
    symbol: Union[Symbol, str, BaseContract],
    period: int = 2,
    value_area_volume_percentage: float = 0.7,
    price_range_round_off: float = 0.05,
    resolution: Resolution = ...,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> VolumeProfile

Creates an Market Profile indicator for the symbol with Volume Profile (VOL) mode. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose VP we want

required
period int

The period of the VP

2
value_area_volume_percentage float

The percentage of volume contained in the value area

0.7
price_range_round_off float

How many digits you want to round and the precision. i.e 0.01 round to two digits exactly.

0.05
resolution Resolution

The resolution

...
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
VolumeProfile

The Volume Profile indicator for the given parameters.

vtx

vtx(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> Vortex

Creates a new Vortex indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose VWMA we want

required
period int

The smoothing period used to smooth the computed VWMA values

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
Vortex

A new Vortex indicator with the specified smoothing period.

vwma

vwma(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], TradeBar] = None,
) -> VolumeWeightedMovingAverage

Creates a new VolumeWeightedMovingAverage indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose VWMA we want

required
period int

The smoothing period used to smooth the computed VWMA values

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], TradeBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
VolumeWeightedMovingAverage

A new VolumeWeightedMovingAverage indicator with the specified smoothing period.

wilr

wilr(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> WilliamsPercentR

Creates a new Williams %R indicator. This will compute the percentage change of the current closing price in relation to the high and low of the past N periods. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose Williams %R we want

required
period int

The period over which to compute the Williams %R

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar

None

Returns:

Type Description
WilliamsPercentR

The Williams %R indicator for the requested symbol over the specified period.

wwma

wwma(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> WilderMovingAverage

Creates a WilderMovingAverage indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose WMA we want

required
period int

The period of the WMA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
WilderMovingAverage

The WilderMovingAverage for the given parameters.

zlema

zlema(
    symbol: Union[Symbol, str, BaseContract],
    period: int,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], float] = None,
) -> ZeroLagExponentialMovingAverage

Creates a ZeroLagExponentialMovingAverage indicator for the symbol. The indicator will be automatically updated on the given resolution.

Parameters:

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

The symbol whose ZLEMA we want

required
period int

The period of the ZLEMA

required
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], float]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
ZeroLagExponentialMovingAverage

The ZeroLagExponentialMovingAverage for the given parameters.

zz

zz(
    symbol: Union[Symbol, str, BaseContract],
    sensitivity: float = 0.05,
    min_trend_length: int = 1,
    resolution: Optional[Resolution] = None,
    selector: Callable[[IBaseData], IBaseDataBar] = None,
) -> ZigZag

Creates a ZigZag indicator for the specified symbol, with adjustable sensitivity and minimum trend length.

Parameters:

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

The symbol for which to create the ZigZag indicator.

required
sensitivity float

The sensitivity for detecting pivots.

0.05
min_trend_length int

The minimum number of bars required for a trend before a pivot is confirmed.

1
resolution Optional[Resolution]

The resolution

None
selector Callable[[IBaseData], IBaseDataBar]

Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)

None

Returns:

Type Description
ZigZag

The configured ZigZag indicator.

γ

γ(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: OptionPricingModelType = ...,
    iv_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> Gamma

Creates a new Gamma indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Union[Symbol, str, BaseContract]

The mirror option for parity calculation

None
risk_free_rate Optional[float]

The risk free rate

None
dividend_yield Optional[float]

The dividend yield

None
option_model OptionPricingModelType

The option pricing model used to estimate Gamma

...
iv_model Optional[OptionPricingModelType]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None

Returns:

Type Description
Gamma

A new Gamma indicator for the specified symbol.

δ

δ(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: OptionPricingModelType = ...,
    iv_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> Delta

Creates a new Delta indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Union[Symbol, str, BaseContract]

The mirror option for parity calculation

None
risk_free_rate Optional[float]

The risk free rate

None
dividend_yield Optional[float]

The dividend yield

None
option_model OptionPricingModelType

The option pricing model used to estimate Delta

...
iv_model Optional[OptionPricingModelType]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None

Returns:

Type Description
Delta

A new Delta indicator for the specified symbol.

θ

θ(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: OptionPricingModelType = ...,
    iv_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> Theta

Creates a new Theta indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Union[Symbol, str, BaseContract]

The mirror option for parity calculation

None
risk_free_rate Optional[float]

The risk free rate

None
dividend_yield Optional[float]

The dividend yield

None
option_model OptionPricingModelType

The option pricing model used to estimate Theta

...
iv_model Optional[OptionPricingModelType]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None

Returns:

Type Description
Theta

A new Theta indicator for the specified symbol.

ρ

ρ(
    symbol: Union[Symbol, str, BaseContract],
    mirror_option: Union[Symbol, str, BaseContract] = None,
    risk_free_rate: Optional[float] = None,
    dividend_yield: Optional[float] = None,
    option_model: OptionPricingModelType = ...,
    iv_model: Optional[OptionPricingModelType] = None,
    resolution: Optional[Resolution] = None,
) -> Rho

Creates a new Rho indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

Parameters:

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

The option symbol whose values we want as an indicator

required
mirror_option Union[Symbol, str, BaseContract]

The mirror option for parity calculation

None
risk_free_rate Optional[float]

The risk free rate

None
dividend_yield Optional[float]

The dividend yield

None
option_model OptionPricingModelType

The option pricing model used to estimate Rho

...
iv_model Optional[OptionPricingModelType]

The option pricing model used to estimate IV

None
resolution Optional[Resolution]

The desired resolution of the data

None

Returns:

Type Description
Rho

A new Rho indicator for the specified symbol.