Basic-Financial-Literacy / src /streamlit_app.py
eagle0504's picture
Update src/streamlit_app.py
030cdae verified
raw
history blame
5.37 kB
import streamlit as st
import numpy as np
import plotly.graph_objects as go
# Title
st.title("Financial Modeling App")
# Tab setup
tabs = st.tabs(["Time Value of Money", "Consistent Cash Flow Investment", "Monte Carlo Simulation", "Basic Company Evaluation"])
# --- Time Value of Money ---
with tabs[0]:
st.header("Time Value of Money")
a = st.number_input("Base Amount (a)", min_value=0.0, value=1000.0, key="tv_a")
r = st.number_input("Annual Return Rate (r)", min_value=0.0, value=0.05, key="tv_r")
T = st.number_input("Number of Years (T)", min_value=0, value=10, key="tv_T")
future_value = a * ((1 + r) ** T)
st.write(f"Future Value = {a} * (1 + {r})^{T} = **{future_value:,.2f}**")
# --- Consistent Cash Flow Investment ---
with tabs[1]:
st.header("Consistent Cash Flow Investment")
a_cf = st.number_input("Annual Cash Flow (a)", min_value=0.0, value=1000.0, key="cf_a")
r_cf = st.number_input("Annual Return Rate (r)", min_value=0.0, value=0.05, key="cf_r")
T_cf = st.number_input("Number of Years (T)", min_value=0, value=10, key="cf_T")
if r_cf > 0:
fv_cf = a_cf * (((1 + r_cf) ** T_cf - 1) / r_cf)
else:
fv_cf = a_cf * T_cf
st.write(f"Future Value of Cash Flows = **{fv_cf:,.2f}**")
# --- Monte Carlo Simulation ---
with tabs[2]:
st.header("Monte Carlo Simulation")
mean_return = st.number_input("Mean Annual Return", value=0.07, key="mc_mean")
std_dev = st.number_input("Standard Deviation", value=0.15, key="mc_std")
years = st.slider("Number of Years", 1, 100, 30, key="mc_years")
simulations = 50
# Simulate paths
np.random.seed(42)
results = np.zeros((simulations, years))
for i in range(simulations):
returns = np.random.normal(loc=mean_return, scale=std_dev, size=years)
results[i] = np.cumprod(1 + returns)
# Plot
fig = go.Figure()
for i in range(simulations):
fig.add_trace(go.Scatter(y=results[i], mode='lines', name=f'Sim {i+1}', line=dict(width=1)))
fig.update_layout(title="Monte Carlo Simulations of Portfolio Growth",
xaxis_title="Years",
yaxis_title="Portfolio Value (normalized)",
showlegend=False)
st.plotly_chart(fig)
# --- Company Evaluation ---
with tabs[3]:
st.header("Basic Company Evaluation")
st.success("Please copy the following into ChatGPT or any AI model with internet accesss.")
st.markdown(
"""
Please feel free to use our [searchbot](https://huggingface.co/spaces/eagle0504/searchbot).
"""
)
st.warning("Please change COMPANY_NAME to the name you want.")
st.markdown(
"""
TITLE: Company/Business Evaluation Framework
Guidance: Use the following structured framework to assess the investment or acquisition value of target company: {{COMPANY_NAME}}, or to diagnose its strategic and operational profile.
1. Industry Attributes
Evaluate the industry characteristics and growth potential. Which one of the following does the target company belong to and why?
- Top-tier sectors (CAGR > 60%): e.g., internet finance, online gaming, digital commerce.
- High-growth sectors (CAGR 30–60%): e.g., new energy, advanced tech, core materials, biotech, beauty.
- Stable-growth sectors (CAGR 10–30%): e.g., general pharma, premium liquor, education, wellness.
- Moderate-growth sectors (CAGR 5–10%): e.g., general consumer, finance, securities, municipal infrastructure.
- Special industries: e.g., defense/military.
2. Industry Cycle Position
Determine the phase of the current industry cycle. Which of the following cycle does the target company belong to and why?
- Expansion (growth phase)
- Maturity (balanced/stable phase)
- Contraction (declining phase)
- Bottoming out (recovery phase)
3. Business Model and Market Position
Assess the competitive stance and strategic capabilities:
- Technological leadership and risk of substitution
- Market share and dominance of top players
- Revenue structure and key client profiles (who, where, what need)
- Operational strengths (management, R&D, cost efficiency)
- Depth and stability of the core technical team
4. Corporate Governance
Evaluate internal management practices:
- Leadership strength and strategic execution
- Governance structure (Board-CEO role clarity, org design, delegation)
- Internal controls and processes
- Use of technology in business operations
- Risk and compliance management (business, tax, legal)
5. Financial Health
Review critical financial metrics and provide summary statistics about the target company:
- Sustained revenue growth above 20% over multiple years
- Gross margin above 40%
- Debt-to-asset ratio below 60%
- Low accounts receivable/payable risk
- Positive operating cash flow
- Return on equity/investment above 10%
6. Valuation
Estimate the fair value and pricing of the business:
- Base valuation on cash holdings, net assets, and profitability: Provide basic stats regarding this point.
- P/E multiples: High-growth firms may justify 20–40x earnings; most public firms fall between 10–20x; <10x suggests undervaluation or risk: Provide basic stats regarding this point.
- EBITDA multiples: Use a benchmark multiple of 5–15x EBITDA, depending on sector maturity and profitability: Provide basic stats regarding this point.
"""
)