diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 4ce85ec1..ed5f3e52 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -6,3 +6,7 @@ | 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/opearating_cash_flow |Calculate Operating Cash Flow Ratio | - `operating_cash_flow`(int):Operating cash flow | +|_ratio | | - `current_liabilities`(int):Current Liabilities | +|POST/interest_coverage |Calculate Interest Coverage Ratio | - `operating_income`(int):Operating Income | +|_ratio | | - `interest_expenses`(int):Interest Expenses | diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 0b1bb25f..e373288f 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2048,3 +2048,32 @@ Sample Output "Capitalization Rate": 6.16% } ``` +**POST** `/opearating_cash_flow_ratio` +- Request body : `{ + "operating_cash_flow": 150000, + "current_liabilities": 120000, +}` +- Sample output +```py +{ + "Tag": "Operating Cash Flow Ratio", + "Operating Cash Flow": 150000, + "Current Liabilities": 120000, + "Operating Cash Flow Ratio":"1.25" +} +``` + +**POST** `/interest_coverage_ratio` +- Request body : `{ + "operating_income": 1000, + "interest_expenses": 50, + }` + - Sample output +```py +{ + "Tag": "Interest Coverage Ratio", + "Operating Income": 1000, + "Interest Expenses": 50, + "Interest Coverage Ratio":"20" +} +``` diff --git a/main.py b/main.py index 6b97957f..65644811 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 InterestCoverageRatio, OperatingCashFlowRatio # Creating the app app = FastAPI( @@ -1844,4 +1845,26 @@ 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 Operating Cash Flow Ratio +@app.post( + "/opearating_cash_flow_ratio", + tags=["opearating_cash_flow_ratio"], + description="Calculating the Operating Cash Flow Ratio", +) +def opearating_cash_flow_ratio(request:OperatingCashFlowRatio): + return opearating_cash_flow_ratio(request.operating_cash_flow, request.current_liabilities) + + +# Endpoint to calculate the Interest Coverage Ratio +@app.post( + "/interest_coverage_ratio", + tags=["interest_coverage_ratio"], + description="Calculating the Interest Coverage Ratio", +) +def interest_coverage_ratio(request:InterestCoverageRatio): + return interest_coverage_ratio(request.gross_profit, request.net_sales) + + + 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/interest_coverage_ratio.py b/tasks/interest_coverage_ratio.py new file mode 100644 index 00000000..9255305c --- /dev/null +++ b/tasks/interest_coverage_ratio.py @@ -0,0 +1,15 @@ +from helpers import functions +from fastapi import HTTPException, status +def interest_coverage_ratio(operating_income: int, interest_expenses: int): + try: + interest_coverage_ratio_value = functions.interest_coverage_ratio(operating_income,interest_expenses) + return { + "Tag": "Interest Coverage Ratio", + "Operating Income": operating_income, + "Interest Expenses": interest_expenses, + "Interest Coverage Ratio": interest_coverage_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/opearating_cash_flow_ratio.py b/tasks/opearating_cash_flow_ratio.py new file mode 100644 index 00000000..c7259f18 --- /dev/null +++ b/tasks/opearating_cash_flow_ratio.py @@ -0,0 +1,16 @@ +from helpers import functions +from fastapi import HTTPException, status + +def opearating_cash_flow_ratio(operating_cash_flow: int, current_liabilities: int): + try: + opearating_cash_flow_ratio_value = functions.opearating_cash_flow_ratio(operating_cash_flow, current_liabilities) + return { + "Tag": "Operating Cash Flow Ratio", + "Operating Cash Flow": operating_cash_flow, + "Current Liabilities": current_liabilities, + "Opearating Cash Flow Ratio": opearating_cash_flow_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..ba063ac3 100644 --- a/validators/request_validators.py +++ b/validators/request_validators.py @@ -855,4 +855,12 @@ class calculateMarketCap(BaseModel): class calculateBvps(BaseModel): total_equity: float - number_of_shares: float \ No newline at end of file + number_of_shares: float + +class OperatingCashFlowRatio(BaseModel): + operating_cash_flow :int + current_liabilities: int + +class InterestCoverageRatio(BaseModel): + operating_income :int + interest_expenses: int