CorporateFactorProvider
QuantConnect.Data.Auxiliary.CorporateFactorProvider
CorporateFactorProvider(
permtick: str,
data: List[CorporateFactorRow],
factor_file_minimum_date: Optional[datetime] = None,
)
Bases: FactorFile[CorporateFactorRow]
Corporate related factor provider. Factors based on splits and dividends
Creates a new instance
permtick
permtick: str
Gets the symbol this factor file represents
factor_file_minimum_date
factor_file_minimum_date: Optional[datetime]
The minimum tradeable date for the symbol
reversed_factor_file_dates
reversed_factor_file_dates: List[datetime]
Keeping a reversed version is more performant that reversing it each time we need it
This codeEntityType is protected.
sorted_factor_file_data
sorted_factor_file_data: SortedList[
datetime, List[QuantConnect_Data_Auxiliary_FactorFile_T]
]
The factor file data rows sorted by date
most_recent_factor_change
most_recent_factor_change: datetime
Gets the most recent factor change in the factor file
apply
apply(
data: List[BaseData],
exchange_hours: SecurityExchangeHours,
) -> CorporateFactorProvider
Creates a new factor file with the specified data applied. Only Dividend and Split data types will be used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
List[BaseData]
|
The data to apply |
required |
exchange_hours
|
SecurityExchangeHours
|
Exchange hours used for resolving the previous trading day |
required |
Returns:
| Type | Description |
|---|---|
CorporateFactorProvider
|
A new factor file that incorporates the specified dividend. |
get_price_factor
get_price_factor(
search_date: Union[datetime, date],
data_normalization_mode: DataNormalizationMode,
data_mapping_mode: Optional[DataMappingMode] = None,
contract_offset: int = 0,
) -> float
Gets the price scale factor that includes dividend and split adjustments for the specified search date
get_scaling_factors
get_scaling_factors(
search_date: Union[datetime, date],
) -> CorporateFactorRow
Gets price and split factors to be applied at the specified date
get_splits_and_dividends
get_splits_and_dividends(
symbol: Union[Symbol, str, BaseContract],
exchange_hours: SecurityExchangeHours,
decimal_places: int = 2,
) -> List[BaseData]
Gets all of the splits and dividends represented by this factor file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol to ues for the dividend and split objects |
required |
exchange_hours
|
SecurityExchangeHours
|
Exchange hours used for resolving the previous trading day |
required |
decimal_places
|
int
|
The number of decimal places to round the dividend's distribution to, defaulting to 2 |
2
|
Returns:
| Type | Description |
|---|---|
List[BaseData]
|
All splits and dividends represented by this factor file in chronological order. |
has_dividend_event_on_next_trading_day
has_dividend_event_on_next_trading_day(
date: Union[datetime, date],
price_factor_ratio: Optional[float],
reference_price: Optional[float],
) -> Tuple[bool, float, float]
Returns true if the specified date is the last trading day before a dividend event is to be fired
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[datetime, date]
|
The date to check the factor file for a dividend event |
required |
price_factor_ratio
|
Optional[float]
|
When this function returns true, this value will be populated with the price factor ratio required to scale the closing value (pf_i/pf_i+1) |
required |
reference_price
|
Optional[float]
|
When this function returns true, this value will be populated with the reference raw price, which is the close of the provided date |
required |
has_split_event_on_next_trading_day
has_split_event_on_next_trading_day(
date: Union[datetime, date],
split_factor: Optional[float],
reference_price: Optional[float],
) -> Tuple[bool, float, float]
Returns true if the specified date is the last trading day before a split event is to be fired
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[datetime, date]
|
The date to check the factor file for a split event |
required |
split_factor
|
Optional[float]
|
When this function returns true, this value will be populated with the split factor ratio required to scale the closing value |
required |
reference_price
|
Optional[float]
|
When this function returns true, this value will be populated with the reference raw price, which is the close of the provided date |
required |
get_enumerator
get_enumerator() -> IEnumerator[IFactorRow]
Returns an enumerator that iterates through the collection.
Returns:
| Type | Description |
|---|---|
IEnumerator[IFactorRow]
|
A System.Collections.Generic.IEnumerator`1 that can be used to iterate through the collection. |
get_file_format
get_file_format() -> Iterable[str]
Writes this factor file data to an enumerable of csv lines
Returns:
| Type | Description |
|---|---|
Iterable[str]
|
An enumerable of lines representing this factor file. |
write_to_file
write_to_file(
symbol: Union[Symbol, str, BaseContract],
) -> None
Write the factor file to the correct place in the default Data folder
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol this factor file represents |
required |