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

Inheritance diagram of Index

Variables & Properties

data_sources

Data sources to initialize projection values.

economic_scenario

The current economic scenario.

index_name

Index name.

index_value

Index value.

pct_change

Index percent change, from one period to the next.

Methods

__init__(time_steps, data_sources, index_name)

Constructor method.

age_index()

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 ProjectionValue attributes in this projection entity to a CSV file.

write_projection_values_recursively(...)

Convenience method that writes ProjectionValue attributes for itself, as well as any nested ProjectionEntity attributes.

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:

  1. Updating the index value.

  2. 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.

time_steps: TimeSteps

Projection-wide timekeeping object.

write_projection_values(output_file_path: str) None

Writes all ProjectionValue attributes 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 ProjectionValue attributes for itself, as well as any nested ProjectionEntity attributes.

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.