Skip to content

Commit

Permalink
Merge pull request #463 from ritik48/MIRR-Endpoint
Browse files Browse the repository at this point in the history
[Fixes: #414] Added Endpoint to Calculate MIRR
  • Loading branch information
ighoshsubho authored Jul 28, 2023
2 parents 11b4552 + 418dfc9 commit 3f5b431
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 36 deletions.
104 changes: 71 additions & 33 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
}
```


**GET** `/asset_portfolio`

- Required parameters : `price_A`, `price_B`, `return_A`, `return_B`, `standard_dev_A`, `standard_dev_B` and `correlation` where A and B refer to the 2 stocks.
Expand Down Expand Up @@ -1584,7 +1583,6 @@ Add-function-and-endpoint-to-calculate-lump-sum-mutual-fund-investment
}
```


**GET** `/asdcr`

- Required parameters :`net_operating_cost`,
Expand All @@ -1593,7 +1591,6 @@ Add-function-and-endpoint-to-calculate-lump-sum-mutual-fund-investment
`annual_debt_service`
- Sample output


```py
{

Expand All @@ -1603,28 +1600,32 @@ Add-function-and-endpoint-to-calculate-lump-sum-mutual-fund-investment
"Depreciation":20000.0,
"Non Cash Expenses":5000.0,
"Annual Debt":60000.0

}

```

**GET** `/calculate_vat`

- required parameters : `price`, `vat_rate`
- Sample Request: GET /calculate_vat?price=100&vat_rate=20
- Sample output

```py
{
"Price (excluding VAT)": 83.33,
"Price (including VAT)": 100.0,
"VAT Amount": 16.67

}
}
```

**GET** `/bond_equivalent_yield`

- required parameters : `face_value`, `purchase_price`,`days_to_maturity`
- Sample Request: GET /bond_equivalent_yield?face_value=1000&purchase_price=900&days_to_maturity=182
- Sample output

```py
{
"Tag": "Bond Equivalent Yield",
Expand All @@ -1638,10 +1639,10 @@ Add-function-and-endpoint-to-calculate-lump-sum-mutual-fund-investment
**GET** `/loan-affordability`

- Required parameters : `income`,
`expenses`,
`loan_term`,
`interest_rate`,
- Sample Request: `GET`, `http://127.0.0.1:8000/loan-affordability?income=5000&expenses=2000&loan_term=12&interest_rate=5`,
`expenses`,
`loan_term`,
`interest_rate`,
- Sample Request: `GET`, `http://127.0.0.1:8000/loan-affordability?income=5000&expenses=2000&loan_term=12&interest_rate=5`,

- Sample output

Expand All @@ -1659,13 +1660,12 @@ Add-function-and-endpoint-to-calculate-lump-sum-mutual-fund-investment
**GET** `/calculate_bvps`

- Required parameters : `stockholders_equity`,
`preferred_stock`, `average_outstanding_shares`,

`preferred_stock`, `average_outstanding_shares`,
- Sample output

```py
{

"Tag": "Calculate Book value per share",
"Stockholders Equity":1000000.0,
"Preferred Stock value":50000.0,
Expand All @@ -1676,11 +1676,13 @@ Add-function-and-endpoint-to-calculate-lump-sum-mutual-fund-investment
```

**GET** `/gratuity-amount`

- Required parameters : `last_salary`,
`tenure_years`,
`tenure_months`,
- Sample Request: `GET`, `http://localhost:8000/calculate_gratuity?last_salary=20000000&tenure_years=10&tenure_months=1`,
`tenure_years`,
`tenure_months`,
- Sample Request: `GET`, `http://localhost:8000/calculate_gratuity?last_salary=20000000&tenure_years=10&tenure_months=1`,
- Sample output

```py
{
{
Expand All @@ -1707,9 +1709,11 @@ Add-function-and-endpoint-to-calculate-lump-sum-mutual-fund-investment

```

**GET** `/personal_savings`
**GET** `/personal_savings`

- Required parameters : 'init','monthly', 'tenure'
- Sample output

```py
{
"Tag": "Simple Personal Savings",
Expand All @@ -1721,9 +1725,11 @@ Add-function-and-endpoint-to-calculate-lump-sum-mutual-fund-investment
```

**GET** `/accrint`

- Required parameters : `issue_date`,`settlement_date`,`rate`,`par`,
- Sample Request: `GET`, `http://localhost:8000/accrint?issue_date=01-01-2012&settlement_date=15-02-2012&rate=5.25&par=5000&frequency=4&basis=3`,
- Sample Request: `GET`, `http://localhost:8000/accrint?issue_date=01-01-2012&settlement_date=15-02-2012&rate=5.25&par=5000&frequency=4&basis=3`,
- Sample output

```py
{
"Tag":"Accrued Interest",
Expand All @@ -1737,12 +1743,13 @@ Add-function-and-endpoint-to-calculate-lump-sum-mutual-fund-investment
}
```

# GET # Endpoint --> '/mortrage'

# GET # Endpoint --> '/mortrage'
Required Paramenters --> princial:int,interest_rate:float,years:int,down_payment:int,property_tax_rate:float,insurance_rate:float
Sample request --> http://127.0.0.1:8000/mortrages?princial=200000&interest_rate=4.5&years=45&down_payment=50000&property_tax_rate=1.3&insurance_rate=0.5

Sample Output

```py
{
"Monthly Payment": 648.4110284532501,
Expand All @@ -1755,10 +1762,12 @@ Sample Output
```

## GET ## Endpoint --> '/social_securities'

Required Parameters --> birth_date:str,earnings:int,retirement_age:int

Sample request --> http://127.0.0.1:8000/social_securities?birth_date=10-08-2002&earnings=250000&retirement_age=70
Sample Output

```py
[
"The monthly benefits are 20833.333333333332 and future benefits are 55349.83286723857"
Expand All @@ -1768,6 +1777,7 @@ Sample Output
**GET** `/calculate_net_profit_margin`
-Required parameters: `revenue`, `cost_of_goods_sold`, `operating_expenses`, `other_expenses`, `interest`, `taxes`
-Sample Output

```py
{
"Tag":"Net Profit Margin",
Expand All @@ -1785,6 +1795,7 @@ Sample Output
**GET** `/calculate_expected_return_of_portfolio`
-Required parameters: `no_of_investments`, `weight_of_investment`, `rate_of_return`
-Sample Output

```py
{
"Tag": "Expected Return of Portfolio",
Expand All @@ -1797,10 +1808,10 @@ Sample Output

```


**GET** `/calculate_sharpe_ratio_function`
-Required parameters: `returns`, `risk_free_rate`
-Sample Output

```py

{
Expand All @@ -1814,6 +1825,7 @@ Sample Output
**GET** `/calculate_post_tax_return_percentage`
-Required parameters: `tax_rate_percentage`, `annual_net_income`, `initial_cost_of_investment`
-Sample Output

```py
{
"Tag" : "Post Tax Return Percentage",
Expand All @@ -1829,6 +1841,7 @@ Sample Output

- Required parameters :`base`,`jb`,`stock`,`pb`,`bonus`,`ptax`,`deduction`
- Sample output

```py
{

Expand All @@ -1841,14 +1854,14 @@ Sample Output
"tax percentage":15,
"any additional deduction":0,
"ctc calculated":2040000.0

}

```

**GET** `/loan_to_value_ratio`

- Required parameters : `loan_amount`, `value_of_collateral`
- Required parameters : `loan_amount`, `value_of_collateral`
- Sample output

```py
Expand All @@ -1863,6 +1876,7 @@ Sample Output
**GET** `/calculate_treynor_ratio_function`
-Required parameters: `returns`, `risk_free_rate`,`beta`
-Sample Output

```py
{
"Tag": "Treynor Ratio",
Expand All @@ -1876,6 +1890,7 @@ Sample Output

- Required parameters
- Sample output

```py
{
"Tag":"Free Cash Flow to Equity",
Expand Down Expand Up @@ -1916,7 +1931,7 @@ Sample Output

**GET** `/capital_gains_yield`

- Required parameters : `inital_price`, `price_after_first_period`
- Required parameters : `inital_price`, `price_after_first_period`
- Sample output

```py
Expand All @@ -1927,18 +1942,20 @@ Sample Output
"Capital Gains Yield": 10%,
}
```

**GET** `/macaulay-duration`

- Required parameters : `face_value`,
`coupon_rate`,
`dt`,
`month`,
`year`,
`coupon_frequency`,
`discount_rate`,
`coupon_rate`,
`dt`,
`month`,
`year`,
`coupon_frequency`,
`discount_rate`,

- Sample Request: `GET`, `http://localhost:8000/calculate_macaulay_duration?face_value=1000.0&coupon_rate=0.06&dt=19&month=6&year=2026&coupon_frequency=2&discount_rate=0.06`,
- Sample Request: `GET`, `http://localhost:8000/calculate_macaulay_duration?face_value=1000.0&coupon_rate=0.06&dt=19&month=6&year=2026&coupon_frequency=2&discount_rate=0.06`,
- Sample output

```py
{
{
Expand All @@ -1958,6 +1975,7 @@ Sample Output
**GET** `/calculate_financial_leverage`
-Required parameters: `total_assets`, `total_liabilities`, `short_term_debt`, `long_term_debt`
-Sample Output

```py
{
"Tag" : "Calculate financial leverage",
Expand All @@ -1973,6 +1991,7 @@ Sample Output
**GET** `/portfolio_return_monte_carlo`
-Required parameters: `principal`, `expected_return_range_start`,`expected_return_range_end`, `volatility_range_start`,`volatility_range_end`, `num_simulations`
-Sample Output

```py
{
'Tag': 'Portfolio Return Monte Carlo',
Expand Down Expand Up @@ -2034,6 +2053,22 @@ Sample Output
"Capitalization Rate": 6.16%
}
```

**GET** `/modified_internal_rate_of_return`

- Required parameters : 'ending_cash_flow','initial_cash_flow', 'number_of_periods'
- Sample output

```py
{
"Tag": "Modified internal rate of return",
"Ending cash flow": 500000,
"Initial cash flow": -300000,
"Number of periods": 5,
"Modified internal rate of return": f"12.04%",
}
```

**POST** `/capm`

- Request body : `{
Expand Down Expand Up @@ -2084,6 +2119,7 @@ Sample Output
"profit": 1560.8,
"cost_price": 7500.4
}`

```py
{
"Tag": "Profit Percentage",
Expand All @@ -2103,6 +2139,7 @@ Sample Output
"non_cash_charges": 25000.00
}`
- Sample output

```py
{
"Tag": "Defensive Interval Ratio",
Expand All @@ -2115,7 +2152,7 @@ Sample Output
"Daily Operational Expenses": 753.42,
"Defensive Interval Ratio": 92.90
}
```
```

**POST** `/loss_percent`

Expand All @@ -2132,7 +2169,8 @@ Sample Output
"Cost Price": 7500.47,
"Loss Percentage": 6.67,
}
```
```

**POST** `/rate_return_calculator`

- Request body : `{
Expand Down Expand Up @@ -2250,4 +2288,4 @@ Sample Output
"Average Accounts Payable": 102500,
"Average Payment Period": "33.7days",
}
```
```
7 changes: 7 additions & 0 deletions helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2055,3 +2055,10 @@ def average_payment_period(beginning_accounts_payable: float, ending_accounts_pa
app = average_accounts_payable / (total_credit_purchases / 365)
return app

# Function to calculate Modified Internal Rate of Return (MIRR)

def calculate_modified_internal_rate_of_return(ending_cash_flow: float,
initial_cash_flow: float,
number_of_periods: int):
mirr = ((ending_cash_flow / initial_cash_flow) ** (1 / number_of_periods)) - 1
return mirr*100
Loading

0 comments on commit 3f5b431

Please sign in to comment.