• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Calculating returns to date -help- "R"

Joined
9/13/17
Messages
11
Points
13
Hey guys,

I'm in the process of starting my investment fund and I've ran into a little trouble calculating the returns to date on a portfolio over a given time. I want to know how to calculate the total amount of returns my portfolio has made from one date (date of investment) to the current date using xts daily time series data. If someone could correct me on the following that would be awesome.

To calculate portfolio capital returns (ignoring dividends etc.. for a second which can be added after) the following steps are required:

Begin with a weighted portfolio with total weights = 1
For example: AMZN:0.25, GOOG:0.25, FB:0.35: BA:0.15

Get the closing data for each of these companies -> convert to returns.

Calculate the weighting differences from the base weights on a daily basis by multiplying the initial weights by the returns over time (without any rebalancing).

Multiply the returns of the 4 companies by their respective daily weights to get the daily portfolio returns.

Sum the daily returns r1 + r2 + r3 + rn... to get aggregate return.

So at a basic level, does the daily return on a portfolio = Daily returns of each stock * current weight of each stock.

And thus the returns to date = sum(daily portfolio returns).

I'd be really keen to get some help around this. I'm currently using R and building my portfolio management system through a cloud database, web-scraper and shiny dashboard frontend with algorithms backtesting on R.

Thanks a lot.
 
If you are only interested in the simple returns, then what you are doing is correct. In R you can use matrices multiplication for this.

Total return = Income return + Price Return.

You are basically computing only the price return. If you incur any fees in the construction of your portfolio, you might to consider the gross of fee vs. net of fee returns.

Moreover, if you periodically use external cash to make purchases of assets for your portfolio, you will have to consider:
  • Money-weighted rate of return, also known as internal rate of return
  • Time-weighted rate of return

I am actually in the process of building a Shiny application on how to do Performance Analysis using R. Let me know if you need any help.

These are links to some shiny apps I developed: Lift Risk, SWAP Predictor.
 
Hi Felix,

I've got some more questions that you could probably help with, and I'd be keen to share my dashboard work to date. Could we communicate over email by chance?
 
Back
Top