File size: 862 Bytes
e229c4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr

def calculate_dcf(fcf_per_share, years, growth_rate_percent, discount_rate_percent):
    growth_rate = growth_rate_percent / 100
    discount_rate = discount_rate_percent / 100

    A = fcf_per_share * (1 + growth_rate) * (1 - (1 + growth_rate) ** years / (1 + discount_rate) ** years)
    B = discount_rate - growth_rate

    result = A / B
    return result

iface = gr.Interface(
    fn=calculate_dcf,
    inputs=[
        gr.inputs.Number(label="FCF per Share"),
        gr.inputs.Number(label="Years"),
        gr.inputs.Slider(minimum=0, maximum=100, label="Growth Rate (%)"),
        gr.inputs.Slider(minimum=0, maximum=100, label="Discount Rate (%)"),
    ],
    outputs="number",
    title="Discounted Cash Flow (DCF) Calculator",
    description="Calculate the Discounted Cash Flow (DCF) using the given inputs.",
)

iface.launch()