Portfolio Optimisation with Shiny and VIX: Application Guide
Introduction
This Shiny application is designed to assist users in optimising their investment portfolio using historical stock data and the Volatility Index (VIX). The app provides tools to visualize and analyze risk-return characteristics, calculate optimal portfolio weights, and explore efficient frontier plots. It includes selections for top US and Australian stocks and allows users to customize their portfolio by adjusting parameters like the risk-free rate and historical data period.
​
How to Use the Application
Step 1: Set the Risk-Free Rate
-
Use the slider to set the risk-free rate, which ranges from 0% to 40%. The default value is set to 3%. The risk-free rate is essential for calculating optimal portfolio weights and Sharpe ratios.
Step 2: Select Stocks
-
Select All US and AU Shares: Check this box to automatically select the top 10 US and top 10 Australian stocks.
-
Manual Stock Selection: If you prefer to select specific stocks, uncheck the "Select All" box and manually choose from the available list.
Step 3: Choose
Historical Data Period
-
Use the radio buttons to select the time period for historical data, ranging from 1 to 10 years. The default is set to 5 years. This data will be used to calculate returns and portfolio optimization metrics.
Step 4: Explore the Plots
The main panel of the application displays various plots:
-
Risk vs Return Plot: Shows the relationship between the variance (risk) and mean returns for the selected stocks.
-
Minimum Variance Portfolio Weights: Displays the optimal asset weights for a portfolio with the minimum variance.
-
Tangency Portfolio Weights: Displays the optimal asset weights for the tangency portfolio, which maximises the Sharpe ratio.
-
Efficient Frontier Plot: Shows the efficient frontier, a curve representing the set of optimal portfolios that offer the highest expected return for a defined level of risk.
-
VIX Plot: Displays the historical data for the VIX (Volatility Index), which indicates market volatility.
Step 5: View Diagnostics
-
The "Diagnostics" section provides detailed outputs such as predicted annual growth rates, portfolio risk, and Sharpe ratios for both the minimum variance and tangency portfolios.
Explanation of the App's Functionality
-
Stock Selection and Price Retrieval:
-
The app retrieves historical prices for the selected stocks using the Yahoo Finance API. For Australian stocks, prices are converted to USD to maintain consistency.
-
-
Portfolio Return Calculation:
-
Returns are calculated based on the selected historical data period, transforming raw price data into a time series of log returns.
-
-
VIX Data:
-
The app fetches VIX data from Yahoo Finance, which helps users gauge market volatility.
-
-
Risk vs Return Analysis:
-
The app plots variance against mean returns for each stock, allowing users to visually compare the risk-return profiles of different assets.
-
-
Portfolio Optimisation:
-
Minimum Variance Portfolio: Uses a portfolio optimisation algorithm to find the asset weights that minimize risk.
-
Tangency Portfolio: Identifies the portfolio that maximises the Sharpe ratio, balancing risk and return optimally.
-
-
Efficient Frontier:
-
The efficient frontier plot visualises all possible portfolios from the selected assets, highlighting the best possible trade-offs between risk and return.
-
-
Diagnostics:
-
This section calculates and displays key metrics like the predicted growth rate, portfolio risk, and Sharpe ratio for both the minimum variance and tangency portfolios. It provides insights into the expected performance of the portfolios.
-
Conclusion
This Shiny app is a powerful tool for investors looking to optimize their portfolios by selecting top US and Australian stocks, adjusting the risk-free rate, and analyzing various portfolio metrics. Whether you're a beginner or an experienced investor, this app offers a comprehensive way to explore and optimize your investment strategies.