Skip to content
Open
27 changes: 19 additions & 8 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
| Endpoint | Description | Parameters |
|---------------------------|----------------------------------------|---------------------------------------------------------|
| GET /simple_interest_rate | Calculate simple interest rates | - `amount_paid` (float): The amount paid. |
| | | - `principle_amount` (float): The principle amount. |
| | | - `months` (int): The number of months. |
| GET /future_sip | Calculate Future Value of SIP | - `interval_investment` (float): The interval investment|
| | | - `rate_of_return` (float): The rate of return. |
| | | - `number_of_payments` (int): The number of payments. |
| Endpoint | Description | Parameters |
|----------------------------------|----------------------------------------|----------------------------------------------------------------|
| GET /simple_interest_rate | Calculate simple interest rates | - `amount_paid` (float): The amount paid. |
| | | - `principle_amount` (float): The principle amount. |
| | | - `months` (int): The number of months. |
| GET /future_sip | Calculate Future Value of SIP | - `interval_investment` (float): The interval investment |
| | | - `rate_of_return` (float): The rate of return. |
| | | - `number_of_payments` (int): The number of payments. |
| POST /net_income | Calculate Net Income | - `revenue` (float): The revenue. |
| | | - `expenses` (float): The revenue. |
| POST/break_even_point | Calculate Break-even point | - `fixed_costs` (int): The Fixed Cost |
| | | - `sales_price_per_unit`(float):The sales price per unit |
| | | - `variable_price_per_unit`(float):variable price per unit |
|POST/day_sales_in_inventory_ratio | Calculate Day Sales in Inventory Ratio | - `avg_inventory` (int): The average inventory. |
| | | - `cost_of_goods_sold` (int):The cost of goods sold. |
| | | - `no_of_days` (int): The number of days. |
| POST /cash_ratio | Calculate Cash Ratio | - `cash` (float): The Cash Amount |
| | | - `cash_equivalents` (float): The cash equivalents. |
| | | - `current_liabilities` (float):The Current liabilities. |
66 changes: 66 additions & 0 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2048,3 +2048,69 @@ Sample Output
"Capitalization Rate": 6.16%
}
```

**POST** `/net_income`

- Request body : `{
"revenue" : 30000,
"expenses": 25000
}`
- Sample output
```py
{
"Tag" : "Net Income",
"Revenue" : 30000,
"Expenses": 25000,
"Net Income" : 5000
}
```

**POST** `/break_even_point`
- Request body : `{
"fixed_costs": 2500,
"sales_price_per_unit": 2.95,
"variable_price_per_unit": 1.40
}`
- Sample output
```py
{
"Tag": "Break-even Point",
"Fixed Costs": 2500,
"Sales Price Per Unit": 2.95,
"Variable Price Per Unit": 1.40,
"Break-even Point": 1612.9032258064512
}
```
**POST** `/day_sales_in_inventory_ratio`
- Request body : `{
"avg_inventory": 50000,
"cost_of_goods_sold": 200000,
"no_of_days": 365
}`
- Sample outputt
```py
{
"Tag": "Day Sales in Inventory Ratio",
"Average Inventory": 50000,
"Cost of Goods Sold": 200000,
"No of Days": 365,
"Day Sales in Inventory Ratio": "91.25"
}
```
**POST** `/cash_ratio`
- Request body : `{
"cash": 37.1,
"cash_equivalents": 26.8,
"current_liabilities": 123.5
}`
- Sample output
```py
{
"Tag": "Cash Ratio",
"Cash": 37.1,
"Cash Equivalents": 26.8,
"Current Liabilities": 123.5,
"Cash Ratio": "0.52"
}
```

16 changes: 16 additions & 0 deletions helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1998,3 +1998,19 @@ def net_worth_calculation(assets: float, liabilities: float, loans: float, mortg
"Liabilities": total_liabilities,
"Net Worth": net_worth,
}

# Function to calculate the net income
def net_income(revenue: float, expenses: float):
return float(revenue)-float(expenses)

# Function to calculate the break-even point
def break_even_point(fixed_costs:int ,sales_price_per_unit: float,variable_price_per_unit:float):
return fixed_costs/(sales_price_per_unit-variable_price_per_unit)

# Function to calculate the Day Sales in Inventory Ratio
def day_sales_in_inventory_ratio(avg_inventory:int ,cost_of_goods_sold: int,no_of_days:int):
return (avg_inventory/cost_of_goods_sold)*no_of_days

# Function to calculate the Cash Ratio
def cash_ratio(cash:float ,cash_equivalents:float,current_liabilities:float):
return (cash+cash_equivalents)/current_liabilities
42 changes: 41 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
from tasks.personal_savings import personal_savings_task
from tasks.portfolio_return_monte_carlo import portfolio_return_monte_carlo_task
from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod
from validators.request_validators import NetIncome, CashRatio, DaySalesinInventoryRatio, BreakevenPoint


# Creating the app
app = FastAPI(
Expand Down Expand Up @@ -1844,4 +1846,42 @@ def capitalization_rate(
def accounts_payable_turnover_ratio(total_supply_purchases: float,
beginning_accounts_payable: float,
ending_accounts_payable: float):
return accounts_payable_turnover_ratio_task(total_supply_purchases, beginning_accounts_payable, ending_accounts_payable)
return accounts_payable_turnover_ratio_task(total_supply_purchases, beginning_accounts_payable, ending_accounts_payable)


# Endpoint to calculate the net income
@app.get(
"/net_income",
tags=["net_income"],
description="Calculating the Net Income",
)
def net_income(request:NetIncome):
return net_income(request.revenue, request.expenses)

# Endpoint to calculate the break-even point
@app.get(
"/break_even_point",
tags=["break_even_point"],
description="Calculating the Break-even Point",
)
def break_even_point(request:BreakevenPoint):
return break_even_point(request.avg_inventory, request.sales_price_per_unit,request.variable_price_per_unit)

# Endpoint to calculate the Day Sales in Inventory Ratio
@app.get(
"/day_sales_in_inventory_ratio",
tags=["day_sales_in_inventory_ratio"],
description="Calculating the Day Sales in Inventory Ratio",
)
def day_sales_in_inventory_ratio(request:DaySalesinInventoryRatio):
return day_sales_in_inventory_ratio(request.avg_inventory, request.cost_of_goods_sold,request.no_of_days)

# Endpoint to calculate the Cash Ratio
@app.get(
"/cash_ratio",
tags=["cash_ratio"],
description="Calculating the Cash Ratio",
)
def cash_ratio(request:CashRatio):
return cash_ratio(request.cash, request.cash_equivalents,request.current_liabilities)

14 changes: 14 additions & 0 deletions tasks/break_even_point.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from helpers import functions
from fastapi import HTTPException, status
def break_even_point(fixed_costs: int, sales_price_per_unit: float, variable_price_per_unit: float):
try:
break_even_point_value = functions.break_even_point(fixed_costs,sales_price_per_unit,variable_price_per_unit)
return {
"Tag": "Break-even Point",
"Fixed Costs": fixed_costs,
"Sales Price Per Unit": sales_price_per_unit,
"Variable Price Per Unit":variable_price_per_unit ,
"Break-even Point": break_even_point_value,
}
except:
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
15 changes: 15 additions & 0 deletions tasks/cash_ratio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from helpers import functions
from fastapi import HTTPException, status

def cash_ratio(cash: float, cash_equivalents: float, current_liabilities: float):
try:
cash_ratio_value = functions.cash_ratio(cash,cash_equivalents,current_liabilities)
return {
"Tag": "Cash Ratio",
"Cash": cash,
"Cash Equivalents": cash_equivalents,
"Current Liabilities":current_liabilities ,
"Cash Ratio": cash_ratio_value,
}
except:
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
15 changes: 15 additions & 0 deletions tasks/day_sales_in_inventory_ratio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from helpers import functions
from fastapi import HTTPException, status

def day_sales_in_inventory_ratio(avg_inventory: int, cost_of_goods_sold: int, no_of_days: int):
try:
day_sales_in_inventory_ratio_value = functions.day_sales_in_inventory_ratio(avg_inventory,cost_of_goods_sold,no_of_days)
return {
"Tag": "Day Sales in Inventory Ratio",
"Average Inventory": avg_inventory,
"Cost Of Goods Sold": cost_of_goods_sold,
"Number Of Days":no_of_days ,
"Day Sales in Inventory Ratio": day_sales_in_inventory_ratio_value,
}
except:
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
13 changes: 13 additions & 0 deletions tasks/net_income.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from helpers import functions
from fastapi import HTTPException, status
def net_income(revenue: float, expenses: int):
try:
net_income_value = functions.net_income(revenue,expenses)
return {
"Tag": "Net Income",
"Revenue": revenue,
"Expenses": expenses,
"Net Income": net_income_value,
}
except:
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
21 changes: 20 additions & 1 deletion validators/request_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,4 +855,23 @@ class calculateMarketCap(BaseModel):

class calculateBvps(BaseModel):
total_equity: float
number_of_shares: float
number_of_shares: float

class NetIncome(BaseModel):
revenue: float
expenses: float

class BreakevenPoint(BaseModel):
fixed_costs: int
sales_price_per_unit: float
variable_price_per_unit: float

class DaySalesinInventoryRatio(BaseModel):
avg_inventory : int
no_of_days: int
cost_of_goods_sold: int

class CashRatio(BaseModel):
cash :float
cash_equivalents: float
current_liabilities: float