CorporateFactorRow
QuantConnect.Data.Auxiliary.CorporateFactorRow
CorporateFactorRow(
date: Union[datetime, date],
price_factor: float,
split_factor: float,
reference_price: float = 0,
)
Bases: Object, IFactorRow
Defines a single row in a factor_factor file. This is a csv file ordered as {date, price factor, split factor, reference price}
Initializes a new instance of the CorporateFactorRow class
date
date: datetime
Gets the date associated with this data
price_factor
price_factor: float
Gets the price factor associated with this data
split_factor
split_factor: float
Gets the split factor associated with the date
price_scale_factor
price_scale_factor: float
Gets the combined factor used to create adjusted prices from raw prices
reference_price
reference_price: float
Gets the raw closing value from the trading date before the updated factor takes effect
apply
apply(
dividend: Dividend,
exchange_hours: SecurityExchangeHours,
) -> CorporateFactorRow
apply(
split: Split, exchange_hours: SecurityExchangeHours
) -> CorporateFactorRow
Signature descriptions:
-
Applies the dividend to this factor file row. This dividend date must be on or before the factor file row date
-
Applies the split to this factor file row. This split date must be on or before the factor file row date
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dividend
|
Optional[Dividend]
|
The dividend to apply with reference price and distribution specified |
None
|
exchange_hours
|
SecurityExchangeHours
|
Exchange hours used for resolving the previous trading day |
required |
split
|
Optional[Split]
|
The split to apply with reference price and split factor specified |
None
|
Returns:
| Type | Description |
|---|---|
CorporateFactorRow
|
Depends on the signature used. Case 1: [A new factor file row that applies the dividend to this row's factors.]; Case 2: [A new factor file row that applies the split to this row's factors.] |
get_dividend
get_dividend(
next_corporate_factor_row: CorporateFactorRow,
symbol: Union[Symbol, str, BaseContract],
exchange_hours: SecurityExchangeHours,
decimal_places: int = 2,
) -> Dividend
Creates a new dividend from this factor file row and the one chronologically in front of it This dividend may have a distribution of zero if this row doesn't represent a dividend
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
next_corporate_factor_row
|
CorporateFactorRow
|
The next factor file row in time |
required |
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol to use for the dividend |
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 |
|---|---|
Dividend
|
A new dividend instance. |
get_file_format
get_file_format(source: str = None) -> str
Writes factor file row into it's file format
get_split
get_split(
next_corporate_factor_row: CorporateFactorRow,
symbol: Union[Symbol, str, BaseContract],
exchange_hours: SecurityExchangeHours,
) -> Split
Creates a new split from this factor file row and the one chronologically in front of it This split may have a split factor of one if this row doesn't represent a split
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
next_corporate_factor_row
|
CorporateFactorRow
|
The next factor file row in time |
required |
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol to use for the split |
required |
exchange_hours
|
SecurityExchangeHours
|
Exchange hours used for resolving the previous trading day |
required |
Returns:
| Type | Description |
|---|---|
Split
|
A new split instance. |
parse
parse(
lines: List[str],
factor_file_minimum_date: Optional[Optional[datetime]],
) -> Tuple[List[CorporateFactorRow], Optional[datetime]]
Parses the lines as factor files rows while properly handling inf entries
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
List[str]
|
The lines from the factor file to be parsed |
required |
factor_file_minimum_date
|
Optional[Optional[datetime]]
|
The minimum date from the factor file |
required |
Returns:
| Type | Description |
|---|---|
Tuple[List[CorporateFactorRow], Optional[datetime]]
|
An enumerable of factor file rows. |
to_string
to_string() -> str
Returns a string that represents the current object.
Returns:
| Type | Description |
|---|---|
str
|
A string that represents the current object. |