Skip to content

Commit

Permalink
Merge pull request #394 from ritik48/fix-issue-384
Browse files Browse the repository at this point in the history
[Fixes #384] Removed redundant compounded annual growth rate endpoint
  • Loading branch information
ighoshsubho authored Jul 1, 2023
2 parents d735488 + f0f2116 commit 1d07447
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 113 deletions.
14 changes: 0 additions & 14 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,6 @@
}
```

**GET** `/compounded_annual_growth_rate`

- Required parameters : `end_investment_value`, `initial_investment_value` and`years`
- Sample output

```py
{
"Tag":"Compounded Annual Growth Rate",
"End investment value":100000,
"Initial investment value":70000,
"Years":3,
"Compunded Annual Growth Rate":0.12624788
}
```

**GET** `/asset_portfolio`

Expand Down
18 changes: 0 additions & 18 deletions helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ def return_on_investment(current_value_of_investment: float, cost_of_investment:
return decimal_to_percent(roi)


# Function to calculate Compounded Annual Growth Rate (CAGR)
def compounded_annual_growth_rate(
end_investment_value: float, initial_investment_value: float, years: int
):
n = 1 / years
cagr = (end_investment_value / initial_investment_value) ** n - 1
return cagr


# Function to calculate Jensens Alpha
def jensens_alpha(
return_from_investment: float,
Expand Down Expand Up @@ -650,15 +641,6 @@ def present_value_of_annuity_due(
return present_value_of_annuity_due


# function to calculate compound annual growth rate
def compound_annual_growth_rate_1(
ending_value: float, beginning_value: float, number_of_periods: float
):
a = (ending_value // beginning_value) ** (1 // number_of_periods)
cagr = a - 1
return cagr


# Function to calculate loan to value
def loan_to_value(mortage_value: float, appraised_value: float):
ratio = mortage_value / appraised_value
Expand Down
28 changes: 0 additions & 28 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from tasks.certificate_of_deposit import certificate_of_deposit_task
from tasks.inflation import inflation_task
from tasks.roi import return_on_investment_task
from tasks.compounded_annual_growth_rate import compounded_annual_growth_rate_task
from tasks.jensens_alpha import jensens_alpha_task
from tasks.social_securities import ss_task
from tasks.tax_equivalent_yield import tax_equivalent_yield_task
Expand Down Expand Up @@ -48,7 +47,6 @@
from tasks.monthly_payment import monthly_payment_task
from tasks.convexity_duration import duration_task
from tasks.current_ratio import current_ratio_task
from tasks.compound_annual_growth_rate import compound_annual_growth_rate_1_task
from tasks.credit_card_equation import credit_card_equation_task
from tasks.credit_card_payoff import credit_card_payoff_task
from tasks.discount_opex import discount_opex_task
Expand Down Expand Up @@ -171,7 +169,6 @@ def index():
"/inflation": "Calculate Inflated amount",
"/effective_annual_rate": "Calculate Effective Annual Rate",
"/roi": "Calculate return on investment",
"/compounded_annual_growth_rate": "Calculate compounded annual growth rate",
"/jensens_alpha": "Calculate Jensen's Alpha of a market return",
"/wacc": "Calculate Weighted Average Cost of Capital (WACC)",
"/loan_emi": "Calculate Loan EMI",
Expand Down Expand Up @@ -381,18 +378,6 @@ def return_on_investment(current_value_of_investment: float, cost_of_investment:
return return_on_investment_task(current_value_of_investment, cost_of_investment)


# Endpoint to calculate Compounded Annual Growth Rate.
@app.get(
"/compounded_annual_growth_rate",
tags=["compounded_annual_growth_rate"],
description="Calculate compounded annual growth rate",
)
def compounded_annual_growth_rate(
end_investment_value: float, initial_investment_value: float, years: int
):
return compounded_annual_growth_rate_task( end_investment_value, initial_investment_value, years)


# Endpoint to calculate Jensen's Alpha
@app.get(
"/jensens_alpha",
Expand Down Expand Up @@ -933,19 +918,6 @@ def present_value_of_annuity_due(
return present_value_of_annuity_due_task( periodic_payment, number_of_periods, rate_per_period)


@app.get(
"/compound_annual_growth_rate",
tags=["compound_annual_growth_rate"],
description="Calculating compound annual growth rate",
)
def compound_annual_growth_rate_1(
ending_value: float, beginning_value: float, number_of_periods: float
):
return compound_annual_growth_rate_1_task(
ending_value, beginning_value, number_of_periods
)


# Endpoint to calculate loan to value
@app.get(
"/loan_to_value",
Expand Down
19 changes: 0 additions & 19 deletions tasks/compound_annual_growth_rate.py

This file was deleted.

20 changes: 0 additions & 20 deletions tasks/compounded_annual_growth_rate.py

This file was deleted.

14 changes: 0 additions & 14 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,6 @@ def test_return_on_investment():
"Return on Investment": "1891.1764705882351%"
}

def test_compounded_annual_growth_rate():
response = client.get(
"http://127.0.0.1:8000/compounded_annual_growth_rate?end_investment_value=456&initial_investment_value=113&years=4"
)
assert response.status_code == status.HTTP_200_OK

assert response.json() == {
"Tag": "Compounded Annual Growth Rate",
"End investment value": 456,
"Initial investment value": 113,
"Years": 4,
"Compounded Annual Growth Rate": "0.4173320235605005%"
}

def test_jensens_alpha():
response = client.get(
"http://127.0.0.1:8000/jensens_alpha?return_from_investment=4566&return_of_appropriate_market_index=32&risk_free_rate=3&beta=45"
Expand Down

0 comments on commit 1d07447

Please sign in to comment.