Python Tutorial - Portfolio returns

Portfolio Weights and Returns: A Guide to Diversification and Investment Strategy

When it comes to investing in the stock market, diversification is key. By allocating assets across different sectors and industries, investors can reduce their exposure to any one particular asset and minimize potential losses. One effective way to achieve diversification is by using portfolio weights. The portfolio weight of an asset in your portfolio is the percentage of the total value invested in that particular asset. This means that setting many relatively small weights allows you to diversify your portfolio, while larger weights for individual stocks can increase exposure to fluctuations in that particular stock.

Calculating Portfolio Weights

The easiest way to calculate a portfolio weight is to divide the dollar value of a stock by the total dollar value of the portfolio. This gives you the percentage portfolio weight. For example, if you have $10,000 invested in Apple and $5,000 invested in Amazon, your portfolio weights would be 10% for Apple and 5% for Amazon. By setting many relatively small weights, you can create a diversified portfolio that spreads risk across multiple assets.

Portfolio Weights are Key to Expressing Investment Strategy

Portfolio weights are crucial in expressing your investment strategy. A well-diversified portfolio with carefully considered weights can help achieve your investment goals while minimizing risk. There are different types of portfolios, including equal-weighted and market cap weighted portfolios, which are created by setting the weights a certain way. Portfolio managers' job is to determine the optimal portfolio weights given certain risk and return constraints and change those as market conditions change.

Portfolio Returns: Changes in Value Over Time

Portfolio returns refer to changes in value over time. In this example, you can see how a portfolio's value in red changes over the time span of a year, compared to the line in blue which is the S&P 500 return over that year. Portfolio returns are an indication of how well a portfolio performed over time. Returns can be calculated using the equation: (change in value / initial value) x 100.

Historic Returns and Expected Return

Historic returns are also used to calculate the portfolio's expected return for the future. It is essential to consider the probability that an asset will achieve its historical return given the current investing environment. Some assets, like bonds, are more likely to match their historical returns, while others, like stocks, may vary more widely from year to year.

Types of Returns

There are different types of returns, which can be a common cause of confusion. Most common are average returns, which are often the geometric mean of a return series over a given time span. This is not the same as cumulative return, which is the total return over a period. Active return refers to relative performance to a benchmark or annualized returns.

Calculating Portfolio Returns

To calculate portfolio returns, you need to take price data from three stocks - Apple, Amazon, and Tesla. The portfolio return will be today's value minus yesterday's value divided by yesterday's value. You can simply use the percentage change function to do this for you. A newly created daily returns data frame tells you how much percent the price of a stock has changed relative to yesterday's value.

Assigning Portfolio Weights and Calculating Average Daily Return

Now, let's assign some portfolio weights to our three stocks and take the mean of the daily returns value. This is straightforward because we now know what the average daily return was for each stock in our data. By multiplying the average returns with their associated weight, we get the average daily return for the portfolio.

Creating a Daily Return Series and Calculating Cumulative Returns

To create a daily return series for the portfolio, you need to multiply the weights with the returns. You need to use dot multiplication as you're multiplying a series of weights with a data frame of returns and do so element-wise. Now it's time to go from daily returns to cumulative returns, just like with interest in your bank account. Returns compound over time, which means you are multiplying percentage change over percentage change. Therefore, you need to use the cumulative product function, like 1 plus the daily return, as your multiplication factor over time, similar to compounding interest.

Plotting Cumulative Returns

Finally, let's plot the cumulative returns of our portfolio containing Apple, Amazon, and Tesla stock.

"WEBVTTKind: captionsLanguage: enlet's discuss portfolio weights and returns the portfolio weight of an asset in your portfolio is the percentage of the total value invested in that particular asset the portfolio weight sum together add up to 100% by setting many relatively small weights you can diversify your portfolio the larger the weights to individual stocks the more exposed you are to fluctuations of that particular stock the easiest way to calculate a portfolio weight is to divide the dollar value of a stock by the total dollar value of the portfolio which gives you the percentage portfolio weights are key in expressing your investment strategy I already mentioned the equal weighted and market cap weighted portfolios which are created by setting the weights a certain way the portfolio managers job is to determine the optimal portfolio weights given certain risk and return constraints and change those as market conditions change portfolio returns are changes in value over time in this example you see how a portfolios value in red changes over the time span of a year you can also compare it to the line in blue which is the S&P 500 return over that year returns are an indication of how well a portfolio performed over time returns can be calculated as stated by this equation by taking the difference in value over a time period say from time t minus 1 to t divide the change in value over the initial value at t minus 1 which gives you the return as a percentage change the historic returns are also used to calculate the portfolio's expected return for the future always take into consideration the probability that an asset will achieve its historical return given the current investing environment some assets like bonds are more likely to match their historical returns while others like stocks may vary more widely from year to year there are different types of returns which are a common cause of confusion most common are average returns which are often the geometric mean of a return series over a given time span this is not the same as cumulative return which is the total return over a period active return which is the relative performance to a benchmark or annualized returns which are covered in the next chapter let's calculate portfolio returns let's take price data from these three stocks Apple Amazon and Tesla the portfolio return will be today's value minus yesterday's value divided by yesterday's value you can simply use percentage change function to do this for you the newly created daily returns data frame tells you by how much percent the price of a stocks has changed relative to yesterday's value now let's assign some portfolio weights to our three stocks and let's take the mean of the daily returns value this is very straightforward because we now know what the average daily return was for each stock in our data by then multiplying the average returns with their associated weight we get the average daily return for the portfolio the cumulative return allows you to track total performance over time first create a daily return series for the portfolio you do so by multiplying the weights with the returns you need to use dot multiplication as you're multiplying a series of weights with a data frame of returns and do so element wise now it's time to go from daily returns to cumulative returns just like with interest in your bank account returns compound over time that means you are multiplying percentage change over percentage change you need to therefore use the cumulative product function like this one plus the daily return is your multiplication factor over time just like with compounding interest now let's plot it and there you have it your daily cumulative returns of your portfolio containing Apple Amazon and Tesla stock that'slet's discuss portfolio weights and returns the portfolio weight of an asset in your portfolio is the percentage of the total value invested in that particular asset the portfolio weight sum together add up to 100% by setting many relatively small weights you can diversify your portfolio the larger the weights to individual stocks the more exposed you are to fluctuations of that particular stock the easiest way to calculate a portfolio weight is to divide the dollar value of a stock by the total dollar value of the portfolio which gives you the percentage portfolio weights are key in expressing your investment strategy I already mentioned the equal weighted and market cap weighted portfolios which are created by setting the weights a certain way the portfolio managers job is to determine the optimal portfolio weights given certain risk and return constraints and change those as market conditions change portfolio returns are changes in value over time in this example you see how a portfolios value in red changes over the time span of a year you can also compare it to the line in blue which is the S&P 500 return over that year returns are an indication of how well a portfolio performed over time returns can be calculated as stated by this equation by taking the difference in value over a time period say from time t minus 1 to t divide the change in value over the initial value at t minus 1 which gives you the return as a percentage change the historic returns are also used to calculate the portfolio's expected return for the future always take into consideration the probability that an asset will achieve its historical return given the current investing environment some assets like bonds are more likely to match their historical returns while others like stocks may vary more widely from year to year there are different types of returns which are a common cause of confusion most common are average returns which are often the geometric mean of a return series over a given time span this is not the same as cumulative return which is the total return over a period active return which is the relative performance to a benchmark or annualized returns which are covered in the next chapter let's calculate portfolio returns let's take price data from these three stocks Apple Amazon and Tesla the portfolio return will be today's value minus yesterday's value divided by yesterday's value you can simply use percentage change function to do this for you the newly created daily returns data frame tells you by how much percent the price of a stocks has changed relative to yesterday's value now let's assign some portfolio weights to our three stocks and let's take the mean of the daily returns value this is very straightforward because we now know what the average daily return was for each stock in our data by then multiplying the average returns with their associated weight we get the average daily return for the portfolio the cumulative return allows you to track total performance over time first create a daily return series for the portfolio you do so by multiplying the weights with the returns you need to use dot multiplication as you're multiplying a series of weights with a data frame of returns and do so element wise now it's time to go from daily returns to cumulative returns just like with interest in your bank account returns compound over time that means you are multiplying percentage change over percentage change you need to therefore use the cumulative product function like this one plus the daily return is your multiplication factor over time just like with compounding interest now let's plot it and there you have it your daily cumulative returns of your portfolio containing Apple Amazon and Tesla stock that's\n"