Skip to content
22 changes: 14 additions & 8 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
| 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/gross_margin_ratio |Calculating the Gross Margin Ratio | - `net_sales`(int):Net Sales |
| | | - `gross_profit`(int):Gross Profit |
|POST/price_earnings_ratio |Calculating the Price Earnings Ratio | - `share_price`(int):Share Price |
| | | - `earnings_per_share`(int):Earnings Per Shares |
|POST/earnings_per_share_ratio |Calculating Earnings Per Share Ratio | - `net_earnings`(int):Net Earnings |
| | | - `total_share_outstanding`(int):Total Share Outstanding|
44 changes: 44 additions & 0 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2048,3 +2048,47 @@ Sample Output
"Capitalization Rate": 6.16%
}
```
**POST** `/gross_margin_ratio`
- Request body : `{
"gross_profit": 1000,
"net_sales": 100,
}`
- Sample output
```py
{
"Tag": "Gross Margin Ratio",
"Gross Profit": 1000,
"Net Sales": 100,
"Gross Margin Ratio":"10"
}
```

**POST** `/price_earnings_ratio`

- Request body : `{
"share_price": 1000,
"earnings_per_share": 100,
}`
- Sample output
```py
{
"Tag": "Price Earnings Ratio",
"Share Price": 1000,
"Earnings Per Share": 100,
"Price Earnings Ratio":"10"
}
```
**POST** `/earnings_per_share_ratio`
- Request body : `{
"net_earnings": 1000,
"total_share_outstanding": 100,
}`
- Sample output
```py
{
"Tag": "Earnings Per Share Ratio",
"Net Earnings": 1000,
"Total Share Outstanding": 100,
"Earnings Per Share Ratio":"10"
}
```
11 changes: 11 additions & 0 deletions helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1998,3 +1998,14 @@ def net_worth_calculation(assets: float, liabilities: float, loans: float, mortg
"Liabilities": total_liabilities,
"Net Worth": net_worth,
}
# Endpoint to calculate the Gross Margin Ratio
def gross_margin_ratio(gross_profit: int,net_sales:int):
return gross_profit/net_sales

# Endpoint to calculate the Price Earnings Ratio
def price_earnings_ratio(share_price: int,earnings_per_share:int):
return share_price/earnings_per_share

# Endpoint to calculate the Earnings Per Share Ratio
def earnings_per_share_ratio(net_earnings: int,total_share_outstanding:int):
return net_earnings/total_share_outstanding
33 changes: 32 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
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 EarningsPerShareRatio, GrossMarginRatio, OperatingMarginRatio

# Creating the app
app = FastAPI(
Expand Down Expand Up @@ -1844,4 +1845,34 @@ 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 Gross Margin Ratio
@app.post(
"/gross_margin_ratio",
tags=["gross_margin_ratio"],
description="Calculating the Gross Margin Ratio",
)
def gross_margin_ratio(request:GrossMarginRatio):
return gross_margin_ratio(request.gross_profit, request.net_sales)

# Endpoint to calculate the Price Earnings Ratio
@app.post(
"/price_earnings_ratio",
tags=["price_earnings_ratio"],
description="Calculating the Price Earnings Ratio",
)
def price_earnings_ratio(request: price_to_earning_ratio_task):
return price_earnings_ratio(request.share_price, request.earnings_per_share)

# Endpoint to calculate the Earnings Per Share Ratio
@app.post(
"/earnings_per_share_ratio",
tags=["earnings_per_share_ratio"],
description="Calculating the Earnings Per Share Ratio",
)
def earnings_per_share_ratio(request:EarningsPerShareRatio):
return earnings_per_share_ratio(request.net_earnings, request.total_share_outstanding)



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)
14 changes: 14 additions & 0 deletions tasks/earnings_per_share_ratio.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 earnings_per_share_ratio(net_earnings:int,total_share_outstanding: int):
try:
earnings_per_share_ratio_value = functions.earnings_per_share_ratio(net_earnings,total_share_outstanding)
return {
"Tag": "Earnings Per Share Ratio",
"Net Earnings": net_earnings ,
"Total Share Outstanding": total_share_outstanding ,
"Earnings Per Share Ratio": earnings_per_share_ratio_value,
}
except:
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
15 changes: 15 additions & 0 deletions tasks/gross_margin_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 gross_margin_ratio(gross_profit:int,net_sales: int):
try:
gross_margin_ratio_value = functions.gross_margin_ratio(gross_profit,net_sales)
return {
"Tag": "Gross Margin Ratio",
"Gross Profit": gross_profit ,
"Net Sales": net_sales ,
"Gross Margin Ratio": gross_margin_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)
14 changes: 14 additions & 0 deletions tasks/price_earnings_ratio.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 price_earnings_ratio(share_price:int,earnings_per_share: int):
try:
price_earnings_ratio_value = functions.price_earnings_ratio(share_price,earnings_per_share)
return {
"Tag": "Price Earnings Ratio",
"Share Price": share_price ,
"Earnings Per Shares": earnings_per_share ,
"Price Earnings Ratio": price_earnings_ratio_value,
}
except:
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
16 changes: 15 additions & 1 deletion validators/request_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,4 +855,18 @@ class calculateMarketCap(BaseModel):

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

class GrossMarginRatio(BaseModel):
gross_profit :int
net_sales: int

class PriceToEarningRatio(BaseModel):
share_price :int
earnings_per_share: int

class EarningsPerShareRatio(BaseModel):
net_earnings :int
total_share_outstanding: int