# Simulate portfolio growth
dates <- seq(as.Date("2024-01-01"), as.Date("2025-09-30"), by = "day")
returns <- rnorm(length(dates), mean = 0.00055, sd = 0.009)
equity <- 10000 * cumprod(1 + returns)
portfolio <- tibble(date = dates, equity = equity)
# Compute overall gain
start_value <- first(portfolio$equity)
end_value <- last(portfolio$equity)
gain_dollar <- end_value - start_value
gain_pct <- (end_value / start_value - 1) * 100
# Plot portfolio growth
library(ggplot2)
library(scales)
p <- ggplot(portfolio, aes(date, equity)) +
geom_line(color = "#2E8B57", linewidth = 1.2) +
geom_smooth(se = FALSE, span = 0.2, color = "#00B894", linewidth = 1, linetype = 2) +
scale_y_continuous(labels = label_dollar()) +
labs(
title = "Your Portfolio Value Over Time",
x = NULL, y = "Portfolio Value ($)"
)
p

industries <- c("Technology","Healthcare","Finance","Consumer Goods","Energy","Entertainment","Green Tech","Real Estate")
weights <- c(0.34,0.12,0.10,0.13,0.08,0.09,0.08,0.06)
industry_df <- tibble(industry = industries, weight = weights)
ggplot(industry_df, aes(x = "", y = weight, fill = industry)) +
geom_col(width = 1, color = "white") +
coord_polar(theta = "y") +
scale_fill_viridis_d(option = "C", begin = 0.1, end = 0.9) +
labs(
title = "How Your Investments Are Split by Industry",
fill = "Industry"
) +
theme_void(base_size = 14)

dates_m <- seq(as.Date("2024-01-01"), as.Date("2025-09-30"), by = "month")
mix <- expand_grid(date = dates_m, industry = industries) |>
mutate(weight = case_when(
industry == "Technology" ~ runif(n(), 0.25, 0.36),
industry == "Healthcare" ~ runif(n(), 0.08, 0.14),
industry == "Finance" ~ runif(n(), 0.08, 0.12),
industry == "Consumer Goods" ~ runif(n(), 0.10, 0.15),
industry == "Energy" ~ runif(n(), 0.05, 0.09),
industry == "Entertainment" ~ runif(n(), 0.08, 0.11),
industry == "Green Tech" ~ runif(n(), 0.05, 0.10),
industry == "Real Estate" ~ runif(n(), 0.03, 0.06)
)) |>
group_by(date) |>
mutate(weight = weight / sum(weight)) |>
ungroup()
ggplot(mix, aes(date, weight, fill = industry)) +
geom_area(alpha = 0.95, color = "white", size = 0.15) +
scale_fill_viridis_d(option = "B", begin = 0, end = 0.9) +
scale_y_continuous(labels = percent_format()) +
labs(
title = "How Your Portfolio Evolved Over Time",
x = NULL, y = "Portfolio Weight (%)",
fill = "Industry"
)

daily_ret <- tibble(ret = rnorm(400, mean = 0.0005, sd = 0.011))
ggplot(daily_ret, aes(ret)) +
geom_histogram(bins = 45, fill = "#5DADE2", alpha = 0.9) +
geom_vline(xintercept = 0, color = "#E74C3C", linetype = "dashed") +
scale_x_continuous(labels = percent_format()) +
labs(
title = "Your Day-to-Day Returns",
x = "Daily Return", y = "Days"
)

industry_perf <- tibble(
industry = industries,
avg_return = c(0.16, 0.09, 0.08, 0.10, 0.06, 0.11, 0.12, 0.07)
)
ggplot(industry_perf, aes(reorder(industry, avg_return), avg_return, fill = industry)) +
geom_col(width = 0.7, color = "white") +
coord_flip() +
scale_y_continuous(labels = percent_format()) +
scale_fill_viridis_d(option = "D") +
labs(
title = "Average Annual Return by Industry",
x = NULL, y = "Average Annual Return (%)",
fill = "Industry"
)

risk_df <- tibble(
industry = industries,
annual_return = c(0.16, 0.09, 0.08, 0.10, 0.06, 0.11, 0.12, 0.07),
volatility = c(0.18, 0.10, 0.08, 0.09, 0.07, 0.12, 0.13, 0.06),
weight = weights
)
ggplot(risk_df, aes(volatility, annual_return, size = weight, fill = industry, label = industry)) +
geom_point(shape = 21, color = "white", alpha = 0.9) +
geom_text_repel(size = 3.5, color = "#1C2833") +
scale_x_continuous(labels = percent_format()) +
scale_y_continuous(labels = percent_format()) +
scale_fill_viridis_d(option = "C") +
scale_size_continuous(range = c(3, 12), guide = "none") +
labs(
title = "Finding Your Sweet Spot: Risk vs. Return",
x = "Volatility (Risk)", y = "Expected Return", fill = "Industry"
)
