-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamlit_main.py
135 lines (114 loc) · 6.12 KB
/
streamlit_main.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import streamlit as st
from engine.analysis_engine import AnalysisEngine
#st.title('Fair Value Calculator')
st.set_page_config(page_title="My App",layout='wide')
def color(val):
color = 'green' if val else 'red'
return f'background-color: {color}'
def execute_model():
try:
engine = AnalysisEngine(ticker=ticker.lower())
engine.prepare_data()
engine.growth_analysis()
st.dataframe(engine.income,height=1000,width=2000)
#col_gr,col_quality = st.columns(2)
#with col_gr:
st.dataframe(engine.ratio, height=1000, width=2000)
#with col_quality:
st.dataframe(engine.cf,height=1000,width=2000)
#st.dataframe(engine.quality_check_dataframe.T.style.applymap(color,subset=['valuation']),height=1000, width=2000)'''
st.dataframe(engine.growths,height=1000,width=2000)
option = st.selectbox("Valuation Method", ['Discount Methods','EV/Ebitda'], index=0)
if option=="Discount Methods":
col1,col2,col3 = st.columns(3)
with col1:
years = st.selectbox("Years of Analysis", [3, 5, 7, 10])
revenue_gr = st.text_input("Revenue Growth % (You could insert multiple growth rate separated by ',' - es. 10,8)",placeholder="10")
discount_rate = st.text_input("Discount Rate", placeholder="12.5")
fair_value_btn = st.button("Discount Model",disabled=False)
with col2:
fcf_margin = st.text_input("Free Cash Flow Margin %",placeholder="10")
net_margin = st.text_input("Net Margin %",placeholder="10")
with col3:
terminal_multiple = st.text_input("Terminal Value",placeholder="16")
perpetuity = st.text_input("Perpetuity Growth",placeholder="0.03")
if fair_value_btn:
if len(terminal_multiple)==0:
terminal_multiple=16
else:
terminal_multiple = int(terminal_multiple)
if len(revenue_gr)==0:
st.errors("Revenue Growth is mandatory")
else:
grs = revenue_gr.split(",")
revenue_gr = [float(g)/100 for g in grs]
if len(fcf_margin)==0:
fcf_margin=None
else:
fcf_margin=float(fcf_margin)
if len(net_margin) == 0:
net_margin = None
else:
net_margin = float(net_margin)
if len(perpetuity) == 0:
perpetuity = 0.03
else:
perpetuity = float(perpetuity)
if len(discount_rate) == 0:
discount_rate = 0.125
else:
discount_rate = float(discount_rate)/100
engine.discounted_cash_flow_analysis(
years=years,
discount_rate=discount_rate,
terminal_value=terminal_multiple,
perpetuity_growth=perpetuity,
revenue_growth_rate=revenue_gr,fcf_margin=fcf_margin,net_margin=net_margin)
st.dataframe(engine.future_cf, height=1000, width=2000)
st.dataframe(engine.terminal_information, width=1000, height=2000)
st.dataframe(engine.discount_cash_flow_final_custom,width=1000,height=2000)
st.dataframe(engine.discount_cash_flow_final_analyst,width=1000,height=2000)
if option == "EV/Ebitda":
st.error("Not implemented yet")
col1, col2 = st.columns(2)
with col1:
years = st.selectbox("Years of Analysis", [3, 5, 7, 10])
revenue_gr = st.text_input(
"Revenue Growth % (You could insert multiple growth rate separated by ',' - es. 10,8)",
placeholder="10")
discount_rate = st.text_input("Discount Rate", placeholder="12.5")
fair_value_btn = st.button("EV/Ebitda Valuation", disabled=False)
with col2:
ebtda_margin = st.text_input("Ebitda Margin %", placeholder="10")
terminal_multiple = st.text_input("Terminal Value", placeholder="10")
if fair_value_btn:
if len(terminal_multiple) == 0:
terminal_multiple = 10
else:
terminal_multiple = int(terminal_multiple)
if len(revenue_gr) == 0:
st.errors("Revenue Growth is mandatory")
else:
grs = revenue_gr.split(",")
revenue_gr = [float(g) / 100 for g in grs]
if len(ebtda_margin) == 0:
ebitda_margin = None
else:
ebitda_margin = float(ebtda_margin)
if len(discount_rate) == 0:
discount_rate = 0.125
else:
discount_rate = float(discount_rate) / 100
#engine.enterprise_value_to_ebitda_analysis(
# years=years,
# discount_rate=discount_rate,
# terminal_value=terminal_multiple,
# revenue_growth_rate=revenue_gr, ebitda_margin=ebitda_margin)
st.dataframe(engine.future_ebitda, height=1000, width=2000)
st.dataframe(engine.terminal_information, width=1000, height=2000)
st.dataframe(engine.data_out_ebitda_analysis,width=1000,height=2000)
except Exception as e:
print(repr(e))
st.sidebar.header('Insert ticker here:')
ticker = st.sidebar.text_input('Ticker', 'META')
load_data_btn = st.sidebar.button("Load Data",on_click=execute_model())