Question: Graph an Efficient Frontier using 3 stocks: Walmart, Facebook, and British Petroleum. The data range is from 05-31-2012 to 05-31-2019. How to set up the
Graph an Efficient Frontier using 3 stocks: Walmart, Facebook, and British Petroleum. The data range is from 05-31-2012 to 05-31-2019.
How to set up the graphing of an efficient frontier of the stocks in Python is fine.
Obtain historical price data: Gather the yearly closing prices for each of the three stocks (Walmart, Facebook, and British Petroleum) for the specified date range (05-31-2012 to 05-31-2019). You can retrieve this data from reliable financial sources or use a financial data provider.
Calculate returns: Calculate the periodic returns for each stock. You can compute returns using the formula: [(Ending Price - Beginning Price) / Beginning Price].
Create a portfolio: Generate different portfolio allocations for the three stocks by assigning different weights or proportions to each stock. For example, you can allocate 40% to Walmart, 40% to Facebook, and 20% to British Petroleum. Create multiple portfolios with various weight combinations.
Calculate portfolio returns and risks: For each portfolio, calculate the weighted average return by multiplying each stock's return by its corresponding weight and summing the values. Calculate the portfolio risk using measures such as variance or standard deviation.
Plot the efficient frontier: Plot the portfolio returns on the y-axis and the portfolio risks (standard deviation) on the x-axis. Each point on the graph represents a different portfolio allocation. Connect the points to form a curve, which represents the efficient frontier.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
