dindizz commited on
Commit
5095092
1 Parent(s): ff74333

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Function to calculate total returns
4
+ def calculate_returns(initial_investment, annual_dividend_yield, monthly_sip, expected_return, time_duration):
5
+ months = time_duration * 12
6
+ monthly_return = (1 + expected_return) ** (1 / 12) - 1
7
+ total_value = initial_investment
8
+
9
+ for i in range(months):
10
+ total_value = (total_value + monthly_sip) * (1 + monthly_return)
11
+ total_value += total_value * (annual_dividend_yield / 12) # Add monthly dividend yield
12
+
13
+ return total_value
14
+
15
+ # Gradio interface function
16
+ def total_returns_calculator(initial_investment, annual_dividend_yield, monthly_sip, expected_return, time_duration):
17
+ annual_dividend_yield /= 100 # Convert percentage to decimal
18
+ expected_return /= 100 # Convert percentage to decimal
19
+ total_returns = calculate_returns(initial_investment, annual_dividend_yield, monthly_sip, expected_return, time_duration)
20
+ return f"Total Returns after {time_duration} years: {total_returns:.2f}"
21
+
22
+ # Gradio interface setup
23
+ inputs = [
24
+ gr.Number(label="Initial Investment Corpus"),
25
+ gr.Number(label="Annual Dividend Yield (%)"),
26
+ gr.Number(label="Monthly SIP Contribution"),
27
+ gr.Number(label="Expected Annual Return (%)"),
28
+ gr.Number(label="Time Duration (years)")
29
+ ]
30
+
31
+ outputs = gr.Textbox(label="Total Returns")
32
+
33
+ gr.Interface(
34
+ fn=total_returns_calculator,
35
+ inputs=inputs,
36
+ outputs=outputs,
37
+ title="Total Returns Calculator"
38
+ ).launch()