diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index d2a4cbc..912a93c 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -66,6 +66,15 @@ The initial price of the product or service. | | | | - `ending_inventory` (float): The final amount of accounts payable ending the cycle. | | | | - `total_credit_purchases` (float): The amount of purchases on credit during the cycle. | |-----------------------------|----------------------------------------|---------------------------------------------------------------------| +|---------------------------|----------------------------------------|---------------------------------------------------------| +| GET /quick-ratio | Calculate quick ratio | - `cash` (float): Total cash as asset. | +| | | - `marketable_security` (float): Expected within an year amount. | +| | | - `current_liabilities` (float): current liabilities | +| | | - `accounts_receivable` (float): expected income | +|---------------------------|----------------------------------------|---------------------------------------------------------| +| GET /cash-ratio | Calculate cash ratio | - `cash` (float): Total cash as asset. | +| | | - `marketable_security` (float): Expected within an year amount. | +| | | - `current_liabilities` (float): current liabilities | | GET /saving_goal | Saving Goal Calculator | - `current_savings` (float): The current amount of savings. | | | | - `monthly_contributions` (float): The amount of money contributed each month towards the savings goal. | | | | - `interest_rate` (float): The annual interest rate on the savings. | diff --git a/ENDPOINTS.md b/ENDPOINTS.md index be417c0..6e6b799 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2289,6 +2289,44 @@ Sample Output } ``` + +**GET** `/quick_ratio` +- Request body : `{ + "cash" : 20000, + "marketable security" : 10000, + "accounts receivable" : 25000, + "current liabilities" : 5000, +}` +- Sample output + +```py +{ + "Tag": "quick_ratio", + "Total cash as asset" : 20000, + "Total receivable cash": 25000, + "Total marketable security" : 10000, + "Total current liabilities" : 5000, + "quick ratio": 2.0 % +} +``` +**GET** `/cash_ratio` +- Request body : `{ + "cash" : 5000, + "marketable security" : 5000, + "current liabilities" : 10000, +}` +- Sample output + +```py +{ + "Tag" : "cash ratio", + "cash" : 5000, + "marketable security" : 5000, + "current liabilities" : 10000, + "cash ratio" : 1.0 % +} +``` + **POST** `/saving_goal ` - Request body : `{ @@ -2305,6 +2343,9 @@ Sample Output "months_required": 18, "total_contributions": 3600, "interest_earned": 315.27777777777777 + }``` + +======= } ``` diff --git a/Readme.md b/Readme.md index 0a13159..810c8e2 100644 --- a/Readme.md +++ b/Readme.md @@ -21,7 +21,7 @@ Welcome to FinTech API, our powerful API is designed to simplify your life by of ## ✨ Features -- **Modular structure**: Not the API has a clean structure which benifits in improved code organizationqn and enhanced reusability of components +- **Modular structure**: Not the API has a clean structure which benefits in improved code organization and enhanced reusability of components - **Request validation**: It improves security, prevents errors and vulnerabilities to the API diff --git a/helpers/functions.py b/helpers/functions.py index ebfbbb7..ed8ce59 100644 --- a/helpers/functions.py +++ b/helpers/functions.py @@ -2055,6 +2055,21 @@ def average_payment_period(beginning_accounts_payable: float, ending_accounts_pa app = average_accounts_payable / (total_credit_purchases / 365) return app +# Function to Calculate Liquidity ratios + +# 1: Quick ratio +def quick_ratio(cash: float, accounts_recievable: float, marketable_security: float, current_liabilities: float): + quickRatio = (cash + accounts_recievable + marketable_security) / current_liabilities + return quickRatio +# 2: Current ratio (already exists) +# def current_ratio(current_assets: float, current_liabilities: float): +# currentRatio = (current_assets / current_liabilities) +# return currentRatio +# 3: Cash ratio +def cash_ratio(cash: float, marketable_securities: float, current_liabilities: float): + cashRatio = (cash + marketable_securities)/current_liabilities + return cashRatio + # Function to Saving Goal Calculator def saving_goal(current_savings: float, monthly_contributions: float, interest_rate: float, goal_amount: float): diff --git a/main.py b/main.py index 2f5cefc..91f1b45 100644 --- a/main.py +++ b/main.py @@ -139,6 +139,8 @@ from tasks.financialAssestRatio import financial_assest_ratio from tasks.PriceElasticity import calculate_price_elasticity from tasks.average_payment_period import average_payment_period_task +from tasks.quick_ratio import quick_ratio_task +from tasks.cash_ratio import cash_ratio_task from tasks.Saving_Goal import saving_goal from tasks.modified_internal_rate_of_return import calculate_modified_internal_rate_of_return_task from tasks.interest_coverage_ratio import interest_coverage_ratio_task @@ -1684,7 +1686,32 @@ def calculate_expected_return_of_portfolio(no_of_investments: int, "/calculate_salary", tags=["calculate_salary"], description="Calculate Net annual salary of an employee", -) + + ) +def calculate_salary(base:int, + jb:int, + stock:int, + pb:int, + bonus:int, + ptax:int, + deduction:int): + try: + calculate_salary = functions.calculate_salary(base,jb,stock,pb,bonus,ptax,deduction) + return { + + "Tag":"Net Salary Calculator", + "Base Salary per month":base, + "joining bonus/retention bonus":jb, + "RSU/stock bonus":stock, + "performance bonus":pb, + "any additional bonus":bonus, + "tax percentage":ptax, + "any additional deduction":deduction, + "ctc calculated": f"{ctc}", + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) + def calculate_salary(base: int, jb: int, stock: int, @@ -1990,6 +2017,26 @@ def average_payment_period(request: AveragePaymentPeriod): return average_payment_period_task(request.beginning_accounts_payable , request.ending_accounts_payable , request.total_credit_purchases) +# Endpoint to calculate Quick Ratio +@app.post( + "/quick_ratio", + tags=["quick_ratio"], + description="Calculate Quick Ratio", +) +def quick_ratio(cash: float , accounts_receivable: float , + marketable_security: float , current_liabilities: float): + return quick_ratio_task(cash , accounts_receivable , + marketable_security , current_liabilities) + +# Endpoint to get Cash Ratio +@app.post( + "/cash_ratio", + tags=["/cash_ratio"], + description="Calculate Cash Ratio", +) +def cash_ratio(cash: float , marketable_securities: float , current_liabilities: float): + return cash_ratio_task(cash , marketable_securities , current_liabilities) + # Endpoint to calculate Saving Goal @app.post( diff --git a/tasks/cash_ratio.py b/tasks/cash_ratio.py new file mode 100644 index 0000000..9eb494d --- /dev/null +++ b/tasks/cash_ratio.py @@ -0,0 +1,17 @@ +from helpers import functions +from fastapi import HTTPException, status + +def cash_ratio(cash: float, marketable_securities: float, current_liabilities: float): + try: + ratio=functions.cash_ratio(cash, marketable_securities, current_liabilities) + return { + "Tag": "cash ratio ~higher than 1 means better debt paying capacity", + "Total cash as asset": cash, + "marketable securities": marketable_securities, + "Total current liabilities": current_liabilities, + "cash ratio": "f{ratio}%" + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) + + \ No newline at end of file diff --git a/tasks/quick_ratio.py b/tasks/quick_ratio.py new file mode 100644 index 0000000..e1e6480 --- /dev/null +++ b/tasks/quick_ratio.py @@ -0,0 +1,16 @@ +from helpers import functions +from fastapi import HTTPException, status + +def quick_ratio(cash: float, accounts_receivable: float, marketable_security: float, current_liabilities: float): + try: + QR=functions.quick_ratio(cash, accounts_receivable, marketable_security, current_liabilities) + return{ + "Tag": "quick_ratio", + "Total cash as asset": cash, + "Total recievable cash": accounts_receivable, + "Total marketable security": marketable_security, + "Total current liabilities": current_liabilities, + "quick ratio":f"{QR}%" + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) diff --git a/validators/request_validators.py b/validators/request_validators.py index 96bd688..3da61d0 100644 --- a/validators/request_validators.py +++ b/validators/request_validators.py @@ -649,6 +649,17 @@ class AveragePaymentPeriod(BaseModel): ending_accounts_payable: float total_credit_purchases: float +class QuickRatio(BaseModel): + cash: float + accounts_receivable: float + marketable_security: float + current_liabilities: float + +class CashRatio(BaseModel): + cash: float + marketable_securities: float + current_liabilities: float + class SavingGoal(BaseModel): current_savings: float monthly_contributions : float