Skip to content

HistoryRequest

QuantConnect.Data.HistoryRequest

HistoryRequest(
    start_time_utc: Union[datetime, date],
    end_time_utc: Union[datetime, date],
    data_type: Type,
    symbol: Union[Symbol, str, BaseContract, Security],
    resolution: Resolution,
    exchange_hours: SecurityExchangeHours,
    data_time_zone: Any,
    fill_forward_resolution: Optional[Resolution],
    include_extended_market_hours: bool,
    is_custom_data: bool,
    data_normalization_mode: DataNormalizationMode,
    tick_type: TickType,
    data_mapping_mode: DataMappingMode = ...,
    contract_depth_offset: int = 0,
)
HistoryRequest(
    request: HistoryRequest,
    new_symbol: Union[Symbol, str, BaseContract, Security],
    new_start_time_utc: Union[datetime, date],
    new_end_time_utc: Union[datetime, date],
)
HistoryRequest(
    config: SubscriptionDataConfig,
    hours: SecurityExchangeHours,
    start_time_utc: Union[datetime, date],
    end_time_utc: Union[datetime, date],
)

Bases: BaseDataRequest

Represents a request for historical data

Signature descriptions:

  • Initializes a new instance of the HistoryRequest class from the specified parameters

  • Initializes a new instance of the HistoryRequest class with new Symbol, StartTimeUtc, EndTimeUtc

  • Initializes a new instance of the HistoryRequest class from the specified config and exchange hours

Parameters:

Name Type Description Default
start_time_utc Optional[Union[datetime, date]]

The start time for this request,

None
end_time_utc Optional[Union[datetime, date]]

The end time for this request

None
data_type Optional[Type]

The data type of the output data

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

The symbol to request data for

None
resolution Optional[Resolution]

The requested data resolution

None
exchange_hours Optional[SecurityExchangeHours]

The exchange hours used in fill forward processing

None
data_time_zone Optional[Any]

The time zone of the data

None
fill_forward_resolution Optional[Optional[Resolution]]

The requested fill forward resolution for this request

None
include_extended_market_hours Optional[bool]

True to include data from pre/post market hours

None
is_custom_data Optional[bool]

True for custom user data, false for normal QC data

None
data_normalization_mode Optional[DataNormalizationMode]

Specifies normalization mode used for this subscription

None
tick_type Optional[TickType]

The tick type used to created the SubscriptionDataConfig for the retrieval of history data

None
data_mapping_mode Optional[DataMappingMode]

The contract mapping mode to use for the security

...
contract_depth_offset Optional[int]

The continuous contract desired offset from the current front month.

0
request Optional[HistoryRequest]

Represents a request for historical data

None
new_start_time_utc Optional[Union[datetime, date]]

The start time for this request

None
new_end_time_utc Optional[Union[datetime, date]]

The end time for this request

None
config Optional[SubscriptionDataConfig]

The subscription data config used to initialize this request

None
hours Optional[SecurityExchangeHours]

The exchange hours used for fill forward processing

None

symbol

symbol: Symbol

Gets the symbol to request data for

resolution

resolution: Resolution

Gets the requested data resolution

fill_forward_resolution

fill_forward_resolution: Optional[Resolution]

Gets the requested fill forward resolution, set to null for no fill forward behavior. Will always return null when Resolution is set to Tick.

include_extended_market_hours

include_extended_market_hours: bool

Gets whether or not to include extended market hours data, set to false for only normal market hours

data_time_zone

data_time_zone: Any

Gets the time zone of the time stamps on the raw input data

tick_type

tick_type: TickType

TickType of the history request

data_normalization_mode

data_normalization_mode: DataNormalizationMode

Gets the normalization mode used for this subscription

data_mapping_mode

data_mapping_mode: DataMappingMode

Gets the data mapping mode used for this subscription

contract_depth_offset

contract_depth_offset: int

The continuous contract desired offset from the current front month. For example, 0 (default) will use the front month, 1 will use the back month contract

tradable_days_in_data_time_zone

tradable_days_in_data_time_zone: Iterable[datetime]

Gets the tradable days specified by this request, in the security's data time zone

start_time_utc

start_time_utc: datetime

Gets the beginning of the requested time interval in UTC

end_time_utc

end_time_utc: datetime

Gets the end of the requested time interval in UTC

start_time_local

start_time_local: datetime

Gets the start_time_utc in the security's exchange time zone

end_time_local

end_time_local: datetime

Gets the end_time_utc in the security's exchange time zone

exchange_hours

exchange_hours: SecurityExchangeHours

Gets the exchange hours used for processing fill forward requests

is_custom_data

is_custom_data: bool

Gets true if this is a custom data request, false for normal QC data

data_type

data_type: Type

The data type of this request

split_history_request_with_updated_mapped_symbol

split_history_request_with_updated_mapped_symbol(
    map_file_provider: IMapFileProvider,
) -> Sequence[HistoryRequest]

Split HistoryRequest on several request with update mapped symbol.

Parameters:

Name Type Description Default
map_file_provider IMapFileProvider

Provides instances of MapFileResolver at run time

required

Returns:

Type Description
Sequence[HistoryRequest]

Return HistoryRequests with different BaseDataRequest.start_time_utc - BaseDataRequest.end_time_utc range and Symbol.value.

to_subscription_data_config

to_subscription_data_config(
    is_internal_feed: bool = False,
    is_filtered_subscription: bool = True,
) -> SubscriptionDataConfig

Converts a Data.HistoryRequest instance to a SubscriptionDataConfig instance

Parameters:

Name Type Description Default
is_internal_feed bool

Set to true if this subscription is added for the sole purpose of providing currency conversion rates, setting this flag to true will prevent the data from being sent into the algorithm's OnData methods

False
is_filtered_subscription bool

True if this subscription should have filters applied to it (market hours/user filters from security), false otherwise

True

Returns:

Type Description
SubscriptionDataConfig

Subscription data configuration.