From 7d66444de7eeb71ff4cf09cfe67a7cb5a4cba11a Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:21:52 +0530 Subject: [PATCH 01/13] Add files via upload --- tasks/break_even_point.py | 14 ++++++++++++++ tasks/cash_ratio.py | 15 +++++++++++++++ tasks/day_sales_in_inventory_ratio.py | 15 +++++++++++++++ tasks/net_income.py | 13 +++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 tasks/break_even_point.py create mode 100644 tasks/cash_ratio.py create mode 100644 tasks/day_sales_in_inventory_ratio.py create mode 100644 tasks/net_income.py 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 From 4dbdbb5a26d71a3556447325ae3b4e4921ab2ad2 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:23:58 +0530 Subject: [PATCH 02/13] Update main.py --- main.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 6b97957f..6d12734e 100644 --- a/main.py +++ b/main.py @@ -1844,4 +1844,82 @@ 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 net income +@app.get( + "/net_income", + tags=["net_income"], + description="Calculating the Net Income", +) +def net_income(revenue: float, expenses: float): + 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) + +# 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(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) + +# 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(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) + +# Endpoint to calculate the Cash Ratio +@app.get( + "/cash_ratio", + tags=["cash_ratio"], + description="Calculating the Cash Ratio", +) +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 Libilites":current_liabilities , + "Cash Ratio": cash_ratio_value, + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) + From 9d7446c76a4bed4a9ad8e464cdc40dc9c41da9c6 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:28:07 +0530 Subject: [PATCH 03/13] Update main.py --- main.py | 74 --------------------------------------------------------- 1 file changed, 74 deletions(-) diff --git a/main.py b/main.py index 6d12734e..c863ed33 100644 --- a/main.py +++ b/main.py @@ -1848,78 +1848,4 @@ def accounts_payable_turnover_ratio(total_supply_purchases: float, -# Endpoint to calculate the net income -@app.get( - "/net_income", - tags=["net_income"], - description="Calculating the Net Income", -) -def net_income(revenue: float, expenses: float): - 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) - -# 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(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) - -# 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(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) - -# Endpoint to calculate the Cash Ratio -@app.get( - "/cash_ratio", - tags=["cash_ratio"], - description="Calculating the Cash Ratio", -) -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 Libilites":current_liabilities , - "Cash Ratio": cash_ratio_value, - } - except: - return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) From 93ab80785dba71acae955f348575291f87139ecd Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Mon, 31 Jul 2023 18:30:19 +0530 Subject: [PATCH 04/13] Update main.py --- main.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/main.py b/main.py index c863ed33..319ba3c4 100644 --- a/main.py +++ b/main.py @@ -1846,6 +1846,59 @@ def accounts_payable_turnover_ratio(total_supply_purchases: float, ending_accounts_payable: float): 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(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) + +# 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(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) + +# 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(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) From d01783bc10986a1c2063edd6eebd7a12ac94a3a0 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Mon, 31 Jul 2023 18:33:01 +0530 Subject: [PATCH 05/13] Update ENDPOINTS.md --- ENDPOINTS.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 0b1bb25f..1c538a30 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2048,3 +2048,40 @@ 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", + - Sample Output +} +``` +**POST** `price_earnings_ratio` +- Request body : `{ + "Share Price": 1000, + "Earnings Per Share": 100, + }` + - Sample output +```py +{ + "Tag": "Price Earnings Ratio", + - Sample Output +} +``` +**POST** `earnings_per_share_ratio` +- Request body : `{ + "Net Earnings": 1000, + "Total Share Outstanding": 100, + }` + - Sample output +```py +{ + "Tag": "Earnings Per Share Ratio", + - Sample Output +} +``` + From 81824d339d2ead6402f91907fbab51196fdc504b Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Mon, 31 Jul 2023 18:36:51 +0530 Subject: [PATCH 06/13] Update request_validators.py --- validators/request_validators.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/validators/request_validators.py b/validators/request_validators.py index 8e845f5f..ee66c7f3 100644 --- a/validators/request_validators.py +++ b/validators/request_validators.py @@ -855,4 +855,16 @@ class calculateMarketCap(BaseModel): class calculateBvps(BaseModel): total_equity: float - number_of_shares: float \ No newline at end of file + number_of_shares: float + +# 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 From 30c40648b412570024fce8e47d2a54569282fa06 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Mon, 31 Jul 2023 18:39:25 +0530 Subject: [PATCH 07/13] Update request_validators.py --- validators/request_validators.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/validators/request_validators.py b/validators/request_validators.py index ee66c7f3..7b86b1fe 100644 --- a/validators/request_validators.py +++ b/validators/request_validators.py @@ -857,14 +857,14 @@ class calculateBvps(BaseModel): total_equity: float number_of_shares: float -# Endpoint to calculate the Gross Margin Ratio -def gross_margin_ratio(gross_profit: int,net_sales:int): - return gross_profit/net_sales +class gross_margin_ratio(BaseModel): + gross_profit :int + net_sales: int -# Endpoint to calculate the Price Earnings Ratio -def price_earnings_ratio(share_price: int,earnings_per_share:int): - return share_price/earnings_per_share +class price_earnings_ratio(BaseModel): + share_price :int + earnings_per_share: int -# 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 +class earnings_per_share_ratio(BaseModel): + net_earnings :int + total_share_outstanding: int From e272f987ea1b019d93bdd83c348d7669a3f4925e Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Mon, 31 Jul 2023 18:42:23 +0530 Subject: [PATCH 08/13] Update functions.py --- helpers/functions.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/helpers/functions.py b/helpers/functions.py index 7ba95169..5f13e5e3 100644 --- a/helpers/functions.py +++ b/helpers/functions.py @@ -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 From dbd587526c9c0c926e9979d3566f2cae5a98ff85 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Mon, 31 Jul 2023 18:44:36 +0530 Subject: [PATCH 09/13] Add files via upload --- tasks/earnings_per_share_ratio.py | 14 ++++++++++++++ tasks/gross_margin_ratio.py | 15 +++++++++++++++ tasks/price_earnings_ratio.py | 14 ++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tasks/earnings_per_share_ratio.py create mode 100644 tasks/gross_margin_ratio.py create mode 100644 tasks/price_earnings_ratio.py diff --git a/tasks/earnings_per_share_ratio.py b/tasks/earnings_per_share_ratio.py new file mode 100644 index 00000000..d17f05cb --- /dev/null +++ b/tasks/earnings_per_share_ratio.py @@ -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) \ No newline at end of file diff --git a/tasks/gross_margin_ratio.py b/tasks/gross_margin_ratio.py new file mode 100644 index 00000000..26a9b488 --- /dev/null +++ b/tasks/gross_margin_ratio.py @@ -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) + + diff --git a/tasks/price_earnings_ratio.py b/tasks/price_earnings_ratio.py new file mode 100644 index 00000000..cf7d7f7a --- /dev/null +++ b/tasks/price_earnings_ratio.py @@ -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) \ No newline at end of file From 624f12e75f895bd64c756aec2495636db523678a Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Mon, 31 Jul 2023 18:48:55 +0530 Subject: [PATCH 10/13] Update DOCUMENTATION.md --- DOCUMENTATION.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 4ce85ec1..f9dda806 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -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| From 48e1014e2be79c764c05497844ae290c3b387f23 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 6 Aug 2023 19:47:01 +0530 Subject: [PATCH 11/13] Update ENDPOINTS.md --- ENDPOINTS.md | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 1c538a30..a2d00c0c 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2048,40 +2048,47 @@ Sample Output "Capitalization Rate": 6.16% } ``` -**POST** `gross_margin_ratio` +**POST** `/gross_margin_ratio` - Request body : `{ - "Gross Profit": 1000, - "Net Sales": 100, + "gross_profit": 1000, + "net_sales": 100, }` - Sample output ```py { - "Tag": "Gross Margin Ratio", - - Sample Output + "Tag": "Gross Margin Ratio", + "Gross Profit": 1000, + "Net Sales": 100, + "Gross Margin Ratio":"10" } ``` -**POST** `price_earnings_ratio` + +**POST** `/price_earnings_ratio` + - Request body : `{ - "Share Price": 1000, - "Earnings Per Share": 100, + "share_price": 1000, + "earnings_per_share": 100, }` - Sample output ```py { "Tag": "Price Earnings Ratio", - - Sample Output + "Share Price": 1000, + "Earnings Per Share": 100, + "Price Earnings Ratio":"10" } ``` -**POST** `earnings_per_share_ratio` +**POST** `/earnings_per_share_ratio` - Request body : `{ - "Net Earnings": 1000, - "Total Share Outstanding": 100, + "net_earnings": 1000, + "total_share_outstanding": 100, }` - Sample output ```py { - "Tag": "Earnings Per Share Ratio", - - Sample Output + "Tag": "Earnings Per Share Ratio", + "Net Earnings": 1000, + "Total Share Outstanding": 100, + "Earnings Per Share Ratio":"10" } ``` - From b1461d2fcbe099832e63ba0e6e6e30671014f117 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 6 Aug 2023 19:48:53 +0530 Subject: [PATCH 12/13] Update request_validators.py --- validators/request_validators.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/validators/request_validators.py b/validators/request_validators.py index 7b86b1fe..0a8fe228 100644 --- a/validators/request_validators.py +++ b/validators/request_validators.py @@ -857,14 +857,16 @@ class calculateBvps(BaseModel): total_equity: float number_of_shares: float -class gross_margin_ratio(BaseModel): +class GrossMarginRatio(BaseModel): gross_profit :int net_sales: int -class price_earnings_ratio(BaseModel): +class PriceToEarningRatio(BaseModel): share_price :int earnings_per_share: int -class earnings_per_share_ratio(BaseModel): +class EarningsPerShareRatio(BaseModel): net_earnings :int total_share_outstanding: int + + From 0bb6f7a46d95b62e09bcb8b1a642a24d65856918 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 6 Aug 2023 19:59:19 +0530 Subject: [PATCH 13/13] Update main.py --- main.py | 40 +++++++--------------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/main.py b/main.py index 319ba3c4..944099a2 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 EarningsPerShareRatio, GrossMarginRatio, OperatingMarginRatio # Creating the app app = FastAPI( @@ -1852,17 +1853,8 @@ def accounts_payable_turnover_ratio(total_supply_purchases: float, tags=["gross_margin_ratio"], description="Calculating the Gross Margin Ratio", ) -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) +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( @@ -1870,17 +1862,8 @@ def gross_margin_ratio(gross_profit:int,net_sales: int): tags=["price_earnings_ratio"], description="Calculating the Price Earnings Ratio", ) -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) +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( @@ -1888,17 +1871,8 @@ def price_earnings_ratio(share_price:int,earnings_per_share: int): tags=["earnings_per_share_ratio"], description="Calculating the Earnings Per Share Ratio", ) -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) +def earnings_per_share_ratio(request:EarningsPerShareRatio): + return earnings_per_share_ratio(request.net_earnings, request.total_share_outstanding)