-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpage_elements.py
More file actions
140 lines (127 loc) · 5.26 KB
/
Copy pathpage_elements.py
File metadata and controls
140 lines (127 loc) · 5.26 KB
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
128
129
130
131
132
133
134
135
136
137
138
import streamlit as st
import base64
#creating reusable footer for the app
def footer():
st.divider()
st.write("""Created by [Denver Data Design](https://denverdatadesign.com/)
| Follow Amy on [LinkedIn](https://www.linkedin.com/in/amy-folkestad-76873884/)
| See her work on [GitHub](https://github.com/BotanicalAmy)""")
st.markdown('''*The retirement predictions created by this application are for educational and entertainment purposes.
While applied mathematics can deliver probable results, past performance is not indicative of future returns.*''')
def V_SPACE(lines):
for _ in range(lines):
st.write(' ')
def retirement_inputs():
col1, col2, col3 = st.columns(3, gap="medium")
with col1:
st.markdown('**What is your initial investment?**')
investment_str = st.text_input(label="Initial investment", label_visibility="collapsed", placeholder='e.g. 50,000')
investment = None
if investment_str:
try:
investment = int(float(investment_str.replace(',', '').replace('$', '').strip()))
if investment < 1000:
st.warning("Value must be at least $1,000")
investment = None
except ValueError:
st.error("Please enter a valid number")
st.markdown('**What will your annual contribution be?**')
contribution_str = st.text_input(label="Annual contribution", label_visibility="collapsed", placeholder='e.g. 5,000 (optional)')
contribution = 0
if contribution_str:
try:
contribution = int(float(contribution_str.replace(',', '').replace('$', '').strip()))
except ValueError:
st.error("Please enter a valid number")
contribution = 0
with col2:
st.markdown('**What type of investor are you?**')
investor = st.selectbox('Investor type', ('Moderate', 'Aggressive', 'Conservative'), label_visibility="collapsed")
st.markdown('**Select a retirement withdrawal rate**')
percent = st.selectbox('Withdrawal rate', ['3%', '4%', '5%', '6%'], index=1, label_visibility="collapsed")
withdrawl_rate = float(percent.strip('%')) / 100
with col3:
st.markdown('**How many years until you retire?**')
years = st.slider('Years until retirement', 0, 50, 20, label_visibility="collapsed")
st.markdown("""
<style>
section[data-testid="stMain"] .stButton > button {
background-color: #59579e !important;
color: white !important;
border: none !important;
margin-top: 30px !important;
}
section[data-testid="stMain"] .stButton > button:hover {
background-color: #645c77 !important;
color: white !important;
}
@media (max-width: 768px) {
section[data-testid="stMain"] .stButton > button {
margin-top: 0px !important;
}
}
</style>
""", unsafe_allow_html=True)
forecast_clicked = st.button("Forecast your Future")
return investment, contribution, investor, years, percent, withdrawl_rate, forecast_clicked
def side_content():
with open('images/DenverDataLogo.png', 'rb') as f:
logo_b64 = base64.b64encode(f.read()).decode()
st.markdown(f"""
<style>
[data-testid="stDataFrame"] th {{
background-color: #f7f7f9 !important;
color: #374151 !important;
}}
[data-testid="stDataFrame"] [col-id="0"] {{
color: #374151 !important;
}}
[data-testid="stSidebarNavLink"] {{
font-weight: bold !important;
font-size: 1rem !important;
text-decoration: none !important;
color: #374151 !important;
}}
[data-testid="stSidebarNavLink"] span {{
font-weight: bold !important;
font-size: 1rem !important;
color: #374151 !important;
}}
[data-testid="stSidebarNavLink"][aria-current="page"],
[data-testid="stSidebarNavLink"][aria-current="page"] span {{
color: #59579e !important;
}}
[data-testid="stSidebarNavLink"]:hover,
[data-testid="stSidebarNavLink"]:hover span {{
color: #645c77 !important;
}}
[data-testid="stSidebarNav"]::before {{
content: '';
display: block;
background-image: url('data:image/png;base64,{logo_b64}');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
width: 100%;
height: 150px;
margin-bottom: 20px;
}}
.logo-link-overlay {{
position: fixed;
top: 55px;
left: 0;
width: 22rem;
height: 150px;
z-index: 1000;
display: block;
cursor: pointer;
}}
</style>
<a href="https://denverdatadesign.com" target="_blank" class="logo-link-overlay"></a>
""", unsafe_allow_html=True)
st.markdown('<strong>Denver Data Design</strong>', unsafe_allow_html=True)
st.markdown('''Amy is a data engineer and technical leader with a background in applied math and statistics. Built for an AI course, this simulator ultimately worked better with applied math.''')
st.markdown('''<a href="https://denverdatadesign.com/about-amy/" target="_blank"
onmouseover="this.style.color='#645c77'" onmouseout="this.style.color='#59579e'"
style="color:#59579e; font-weight:bold; text-decoration:none;">
About Amy</a>''', unsafe_allow_html=True)