Q1: AI helped me pivot the return structure correctly.

#daily_prices <- tq_get(tickers, from = start_date, to = end_date) pulls in dividend-adjusted closing prices

#monthly_prices <- daily_prices %>% AI helped collapse daily prices into end-of-month prices

#tq_transmute arithemetic returns

#pivot_wide helps run regressions

#capm_tsla/ nvda linear regression models

#library(broom) #capm_results <- bind_rows extract the regression outputs and then combined the results for TSLA and NVDA into one table

#kable(capm_results, digits = 4) print regression

#ggplot accurate scatterplot

#mu <- colMeans, Expected return for TSLA and NVDA #cov_matrix, calculate risk based on RV calculated annualized mean returns and the covariance matrix.

#max_sharpe best return for the risk #min_vol safest combination

#ggplot The plot maps all 10k portfolios based on risk/ return, with colors differentiating Sharpe ratios