Skip to content

BacktestingFutureChainProvider

QuantConnect.Lean.Engine.DataFeeds.BacktestingFutureChainProvider

BacktestingFutureChainProvider()

Bases: BacktestingChainProvider, IFutureChainProvider

An implementation of IFutureChainProvider that reads the list of contracts from open interest zip data files

Initializes a new instance of the BacktestingChainProvider class

This codeEntityType is protected.

map_file_provider

map_file_provider: IMapFileProvider

The map file provider instance to use

This codeEntityType is protected.

history_provider

history_provider: IHistoryProvider

The history provider instance to use

This codeEntityType is protected.

get_future_contract_list

get_future_contract_list(
    symbol: Union[Symbol, str, BaseContract],
    date: Union[datetime, date],
) -> Iterable[Symbol]

Gets the list of future contracts for a given underlying symbol

Parameters:

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

The underlying symbol

required
date Union[datetime, date]

The date for which to request the future chain (only used in backtesting)

required

Returns:

Type Description
Iterable[Symbol]

The list of future contracts.

get_symbol

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

Helper method to get the symbol to use

This codeEntityType is protected.

get_symbols

get_symbols(
    canonical_symbol: Union[Symbol, str, BaseContract],
    date: Union[datetime, date],
) -> Iterable[Symbol]

Get the contract symbols associated with the given canonical symbol and date

This codeEntityType is protected.

Parameters:

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

The canonical symbol

required
date Union[datetime, date]

The date to search for

required

initialize

initialize(
    parameters: ChainProviderInitializeParameters,
) -> None

Initializes a new instance of the BacktestingChainProvider class

Parameters:

Name Type Description Default
parameters ChainProviderInitializeParameters

The initialization parameters

required

is_contract_expired

is_contract_expired(
    symbol: Union[Symbol, str, BaseContract],
    date: Union[datetime, date],
) -> bool

Helper method to determine if a contract is expired for the requested date

This codeEntityType is protected.