Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
# Simple DCF Calculator Setup
|
| 6 |
def discounted_cash_flow(fcf, growth_rate, discount_rate, terminal_growth_rate, forecast_years=5):
|
|
@@ -27,21 +28,26 @@ def dcf_interface(fcf, growth_rate, discount_rate, terminal_growth_rate, forecas
|
|
| 27 |
fcf_forecast, present_values, terminal_value, terminal_value_pv, total_intrinsic_value = discounted_cash_flow(
|
| 28 |
fcf, growth_rate, discount_rate, terminal_growth_rate, forecast_years
|
| 29 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
|
|
|
|
|
|
| 39 |
Terminal Value (undiscounted): ${terminal_value:,.2f}
|
| 40 |
Present Value of Terminal Value: ${terminal_value_pv:,.2f}
|
| 41 |
-
|
| 42 |
-
🏦 Total Intrinsic Value Estimate: ${total_intrinsic_value:,.2f}
|
| 43 |
"""
|
| 44 |
-
return
|
| 45 |
|
| 46 |
iface = gr.Interface(
|
| 47 |
fn=dcf_interface,
|
|
@@ -52,10 +58,17 @@ iface = gr.Interface(
|
|
| 52 |
gr.Number(label="Terminal Growth Rate (e.g., 0.025 for 2.5%)"),
|
| 53 |
gr.Number(label="Forecast Years (e.g., 5 or 10)")
|
| 54 |
],
|
| 55 |
-
outputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
title="DCF Valuation Calculator",
|
| 57 |
-
description="
|
| 58 |
)
|
| 59 |
|
| 60 |
if __name__ == "__main__":
|
| 61 |
-
iface.launch()
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
import gradio as gr
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
|
| 6 |
# Simple DCF Calculator Setup
|
| 7 |
def discounted_cash_flow(fcf, growth_rate, discount_rate, terminal_growth_rate, forecast_years=5):
|
|
|
|
| 28 |
fcf_forecast, present_values, terminal_value, terminal_value_pv, total_intrinsic_value = discounted_cash_flow(
|
| 29 |
fcf, growth_rate, discount_rate, terminal_growth_rate, forecast_years
|
| 30 |
)
|
| 31 |
+
df = pd.DataFrame({
|
| 32 |
+
'Year': list(range(1, forecast_years + 1)),
|
| 33 |
+
'Forecasted FCF ($)': fcf_forecast,
|
| 34 |
+
'Present Value of FCF ($)': present_values
|
| 35 |
+
})
|
| 36 |
|
| 37 |
+
# Plot FCF
|
| 38 |
+
fig, ax = plt.subplots()
|
| 39 |
+
ax.plot(df['Year'], df['Forecasted FCF ($)'], marker='o')
|
| 40 |
+
ax.set_title('Forecasted Free Cash Flow Over Time')
|
| 41 |
+
ax.set_xlabel('Year')
|
| 42 |
+
ax.set_ylabel('Free Cash Flow ($)')
|
| 43 |
+
ax.grid(True)
|
| 44 |
|
| 45 |
+
summary = f"""
|
| 46 |
+
🏦 Total Intrinsic Value Estimate: ${total_intrinsic_value:,.2f}
|
| 47 |
Terminal Value (undiscounted): ${terminal_value:,.2f}
|
| 48 |
Present Value of Terminal Value: ${terminal_value_pv:,.2f}
|
|
|
|
|
|
|
| 49 |
"""
|
| 50 |
+
return df, fig, summary
|
| 51 |
|
| 52 |
iface = gr.Interface(
|
| 53 |
fn=dcf_interface,
|
|
|
|
| 58 |
gr.Number(label="Terminal Growth Rate (e.g., 0.025 for 2.5%)"),
|
| 59 |
gr.Number(label="Forecast Years (e.g., 5 or 10)")
|
| 60 |
],
|
| 61 |
+
outputs=[
|
| 62 |
+
gr.Dataframe(label="DCF Forecast Table"),
|
| 63 |
+
gr.Plot(label="Free Cash Flow Forecast Chart"),
|
| 64 |
+
gr.Textbox(label="Summary")
|
| 65 |
+
],
|
| 66 |
+
examples=[
|
| 67 |
+
[100_560_000_000, 0.06, 0.08, 0.025, 5] # Example: Apple
|
| 68 |
+
],
|
| 69 |
title="DCF Valuation Calculator",
|
| 70 |
+
description="Estimate a company's intrinsic value using Discounted Cash Flow (DCF) analysis. Adjust inputs or run a preset example."
|
| 71 |
)
|
| 72 |
|
| 73 |
if __name__ == "__main__":
|
| 74 |
+
iface.launch()
|