Vizly: AI-powered data analysis

Try for yourself

Statistical Analysis of S&P 500, Treasuries, and Corporates Over Time

Compute the means, standard deviations, and covariance matrix as numpy arrays.

We computed the following statistics for the S&P 500, Treasuries, and Corporates from the dataset:
  • Means:
    • S&P 500: 0.086
    • Treasuries: 0.021
    • Corporates: 0.042
  • Standard Deviations:
    • S&P 500: 0.193
    • Treasuries: 0.086
    • Corporates: 0.087
  • Covariance Matrix:
    [[0.03738632, 0.00086909, 0.00695467],
     [0.00086909, 0.00746865, 0.00520909],
     [0.00695467, 0.00520909, 0.00750272]]
    

Find the frontier portfolios with weights summing to 1 and plot their means and standard deviations

We simulated 10,000 portfolios with random weights for S&P 500, Treasuries, and Corporates that sum to 1. We then plotted these portfolios on the mean-standard deviation plane, showcasing the efficient frontier. The plot illustrates the trade-off between risk (standard deviation) and return for these portfolios, with varying combinations of the three assets.

The risk-free rate is 5% - find the tangency portfolio and to include the capital allocation line in the plot

We found the tangency portfolio by calculating the Sharpe ratio for each of the 10,000 simulated portfolios, given a risk-free rate of 5%. The portfolio with the highest Sharpe ratio was identified as the tangency portfolio. We then plotted the efficient frontier again, adding the capital allocation line (CAL) that starts from the risk-free rate and touches the efficient frontier at the tangency portfolio point. The CAL represents the set of portfolios that optimally combine the risk-free asset and the tangency portfolio for different levels of risk appetite.

Vizly

AI-powered data analysis

Try for yourself