-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add inflation calculator function
- Loading branch information
1 parent
c575e73
commit d66f26e
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__all__ = ["const", "create_mapping_files", "investment_costs"] | ||
__all__ = ["const", "create_mapping_files", "inflation", "investment_costs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
inflation_rate_pct = { | ||
2010: 1.5, | ||
2011: 3.0, | ||
2012: 1.7, | ||
2013: 1.5, | ||
2014: 0.8, | ||
2015: 0.7, | ||
2016: 2.1, | ||
2017: 2.1, | ||
2018: 1.9, | ||
2019: 2.3, | ||
2020: 1.3, | ||
} | ||
|
||
|
||
def calculate_inflation(start_year, end_year): | ||
if start_year not in inflation_rate_pct: | ||
raise ValueError | ||
if (end_year - 1) not in inflation_rate_pct: | ||
raise ValueError | ||
factor = 1 | ||
for i in range(start_year, end_year): | ||
factor *= 1 + (inflation_rate_pct[i] / 100) | ||
return factor |