src.projection_entities.economy.index.Index¶
- class src.projection_entities.economy.index.Index(time_steps: TimeSteps, data_sources: AnnuityDataSources, index_name: str)¶
Economic index, like S&P 500, Big Mac, or Inverse Cramer.
Inheritance Diagram

Variables & Properties
Data sources to initialize projection values.
The current economic scenario.
Index name.
Index value.
Index percent change, from one period to the next.
Methods
__init__(time_steps, data_sources, index_name)Constructor method.
Projects the index forward one time step by:
calc_pct_change(t1, t2)Calculates the percentage growth in the index between two points in time:
write_projection_values(output_file_path)Writes all
ProjectionValueattributes in this projection entity to a CSV file.Convenience method that writes
ProjectionValueattributes for itself, as well as any nestedProjectionEntityattributes.Details
- __init__(time_steps: TimeSteps, data_sources: AnnuityDataSources, index_name: str)¶
Constructor method.
- Parameters:
time_steps – Projection-wide timekeeping object.
data_sources – Annuity data sources.
index_name – Name of this index.
- age_index() None¶
Projects the index forward one time step by:
Updating the index value.
Calculating the percent change in the index from the previous time step to the current time step.
- Returns:
Nothing.
- calc_pct_change(t1: date, t2: date) float¶
Calculates the percentage growth in the index between two points in time:
\[percent\, change = \frac{rate_{t1}}{rate_{t2}} - 1\]Warning
This algorithm does not handle division-by-zero.
- Parameters:
t1 – Start date.
t2 – End date.
- Returns:
Percent change.
- data_sources: AnnuityDataSources¶
Data sources to initialize projection values.
- economic_scenario: EconomicScenario¶
The current economic scenario.
- index_name: str¶
Index name.
- index_value: ProjectionValue¶
Index value.
- init_t: date¶
Initial time step. Marks when this entity first came into existence.
- pct_change: ProjectionValue¶
Index percent change, from one period to the next.
- write_projection_values(output_file_path: str) None¶
Writes all
ProjectionValueattributes in this projection entity to a CSV file. Existing file will be overwritten.- Parameters:
output_file_path – Output file path.
- Returns:
Nothing.
- write_projection_values_recursively(output_file_path: str) None¶
Convenience method that writes
ProjectionValueattributes for itself, as well as any nestedProjectionEntityattributes.This function behaves recursively, writing output for all nested projection entities no matter how deeply they are nested.
- Parameters:
output_file_path – Output file path
- Returns:
Nothing.