diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 4ce85ec1..8a686f2a 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -1,8 +1,16 @@ -| 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/book_value_per_share_ratio |Calculating the Book Value Per Share Ratio| - `shareholders_equity`(int):Shareholders Equity | +| | | - `preferred_equity`(int):Preferred Equity | +| | | -` total_common_share_outstanding`(int):Total Common Share Outstanding | +|POST/operating_margin_ratio |Calculating the Operating Margin Ratio | -` operating_income`(int):Operating Income | +| | | -` net_sales`(int):Net Sales | + + + diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 0b1bb25f..07b9e578 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2048,3 +2048,42 @@ Sample Output "Capitalization Rate": 6.16% } ``` +**POST** `/book_value_per_share_ratio` + +- Request body : `{ + "shareholders_equity": 20, + "preferred_equity": 5, + "total_common_share_outstanding":5 +}` +- Sample output + +```py +{ + "Tag": "Book Value Per Share Ratio", + "Shareholders Equity": 20, + "Preferred Equity": 5, + "Total Common Share Outstanding": 5, + "Book Value Per Share Ratio": "3" +} +``` + +**POST** `/operating_margin_ratio` + +- Request body : `{ + "operating_income": 1000, + "net_sales": 100 +}` +- Sample output + +```py +{ + "Tag": "Operating Margin Ratio", + "Operating Income": 1000, + "Net Sales": 100, + "Operating Margin Ratio" : "10" +} +``` + + + + diff --git a/helpers/functions.py b/helpers/functions.py index 7ba95169..0b97ee95 100644 --- a/helpers/functions.py +++ b/helpers/functions.py @@ -1998,3 +1998,11 @@ def net_worth_calculation(assets: float, liabilities: float, loans: float, mortg "Liabilities": total_liabilities, "Net Worth": net_worth, } + +# Endpoint to calculate the Book Value Per Share Ratio +def book_value_per_share_ratio(shareholders_equity: int,preferred_equity:int,total_common_share_outstanding:int): + return (shareholders_equity-preferred_equity)/total_common_share_outstanding + +# Endpoint to calculate the Operating Margin Ratio +def operating_margin_ratio(operating_income: int,net_sales:int): + return operating_income/net_sales diff --git a/main.py b/main.py index 6b97957f..32c8a17d 100644 --- a/main.py +++ b/main.py @@ -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 BookValuePerShareRatio, OperatingMarginRatio # Creating the app app = FastAPI( @@ -1844,4 +1845,25 @@ 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) \ No newline at end of file + return accounts_payable_turnover_ratio_task(total_supply_purchases, beginning_accounts_payable, ending_accounts_payable) + +# Endpoint to calculate the Book Value Per Share Ratio +@app.post( + "/book_value_per_share_ratio", + tags=["book_value_per_share_ratio"], + description="Calculating the Book Value Per Share Ratio", +) +def book_value_per_share_ratio(request: BookValuePerShareRatio): + return book_value_per_share_ratio(request.shareholders_equity, request.preferred_equity,request.total_common_share_outstanding) + +# Endpoint to calculate the Operating Margin Ratio +@app.post( + "/operating_margin_ratio", + tags=["operating_margin_ratio"], + description="Calculating the Operating Margin Ratio", +) +def operating_margin_ratio(request: OperatingMarginRatio): + return operating_margin_ratio(request.operating_income, request.net_sales) + + + diff --git a/tasks/book_value_per_share_ratio.py b/tasks/book_value_per_share_ratio.py new file mode 100644 index 00000000..0fa659dd --- /dev/null +++ b/tasks/book_value_per_share_ratio.py @@ -0,0 +1,15 @@ +from helpers import functions +from fastapi import HTTPException, status + +def book_value_per_share_ratio(shareholders_equity:int,preferred_equity:int,total_common_share_outstanding:int): + try: + book_value_per_share_ratio_value = functions.book_value_per_share_ratio(shareholders_equity,preferred_equity,total_common_share_outstanding) + return { + "Tag": "Book Value Per Share Ratio", + "Shareholders Equity": shareholders_equity , + "Preferred Equity":preferred_equity, + "Total Common Share Outstanding": total_common_share_outstanding , + "Book Value Per Share Ratio": book_value_per_share_ratio_value, + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) \ No newline at end of file diff --git a/tasks/break_even_point.py b/tasks/break_even_point.py new file mode 100644 index 00000000..4752d897 --- /dev/null +++ b/tasks/break_even_point.py @@ -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) \ No newline at end of file diff --git a/tasks/cash_ratio.py b/tasks/cash_ratio.py new file mode 100644 index 00000000..0df77de7 --- /dev/null +++ b/tasks/cash_ratio.py @@ -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) diff --git a/tasks/day_sales_in_inventory_ratio.py b/tasks/day_sales_in_inventory_ratio.py new file mode 100644 index 00000000..7a8dcc9f --- /dev/null +++ b/tasks/day_sales_in_inventory_ratio.py @@ -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) diff --git a/tasks/net_income.py b/tasks/net_income.py new file mode 100644 index 00000000..298e8818 --- /dev/null +++ b/tasks/net_income.py @@ -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) \ No newline at end of file diff --git a/tasks/operating_margin_ratio.py b/tasks/operating_margin_ratio.py new file mode 100644 index 00000000..a96503c7 --- /dev/null +++ b/tasks/operating_margin_ratio.py @@ -0,0 +1,14 @@ +from helpers import functions +from fastapi import HTTPException, status + +def operating_margin_ratio(operating_income:int,net_sales:int): + try: + operating_margin_ratio_value = operating_income/net_sales + return { + "Tag": "Operating Margin Ratio", + "Operating Income": operating_income , + "Net Sales": net_sales , + "Operating Margin Ratio": operating_margin_ratio_value, + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) diff --git a/validators/request_validators.py b/validators/request_validators.py index 8e845f5f..d7411478 100644 --- a/validators/request_validators.py +++ b/validators/request_validators.py @@ -855,4 +855,14 @@ class calculateMarketCap(BaseModel): class calculateBvps(BaseModel): total_equity: float - number_of_shares: float \ No newline at end of file + number_of_shares: float + +class BookValuePerShareRatio(BaseModel): + shareholders_equity :int + preferred_equity: int + total_common_share_outstanding:int + +class OperatingMarginRatio(BaseModel): + operating_income:int + net_sales:int +