2

Is there an R function or library that will give me the monthly (or any other specified timeframe) time weighted rate of return (twrr) for my portfolio?

I am including a dput dump of sample data below of the date and portfolio ending balance below. Not sure why the dates were dput'ed the way they were, but the first date 12053 is '2003-01-01' and the last date 12195 is '2003-05-23'.

portfolio.df <- structure(
    list(
        Date = structure(c(12053, 12054, 12055, 12058, 
            12059, 12060, 12061, 12062, 12065, 12066, 12067, 12068, 12069, 
            12073, 12074, 12075, 12076, 12079, 12080, 12081, 12082, 12083, 
            12086, 12087, 12088, 12089, 12090, 12093, 12094, 12095, 12096, 
            12097, 12101, 12102, 12103, 12104, 12107, 12108, 12109, 12110, 
            12111, 12114, 12115, 12116, 12117, 12118, 12121, 12122, 12123, 
            12124, 12125, 12128, 12129, 12130, 12131, 12132, 12135, 12136, 
            12137, 12138, 12139, 12142, 12143, 12144, 12145, 12146, 12149, 
            12150, 12151, 12152, 12153, 12156, 12157, 12158, 12159, 12163, 
            12164, 12165, 12166, 12167, 12170, 12171, 12172, 12173, 12174, 
            12177, 12178, 12179, 12180, 12181, 12184, 12185, 12186, 12187, 
            12188, 12191, 12192, 12193, 12194, 12195), 
        class = "Date"), 
        Ending_Balance = c(56250000L, 
            56852500L, 57080000L, 57355000L, 57477500L, 56817500L, 57885000L, 
            57810000L, 57732500L, 57670000L, 57520000L, 57285000L, 57270000L, 
            56655000L, 55802500L, 56337500L, 55642500L, 54510000L, 54987500L, 
            55802500L, 56065000L, 56865000L, 56635000L, 56497500L, 56640000L, 
            56155000L, 55757500L, 55972500L, 55865000L, 55535000L, 55885000L, 
            56840000L, 56902500L, 56945000L, 56622500L, 57012500L, 57200000L, 
            58072500L, 57612500L, 57447500L, 57157500L, 57032500L, 57405000L, 
            57502500L, 56785000L, 57007500L, 56342500L, 55697500L, 56655000L, 
            56900000L, 57002500L, 57465000L, 57467500L, 57382500L, 57982500L, 
            56562500L, 58065000L, 58935000L, 58502500L, 58200000L, 57767500L, 
            57757500L, 58055000L, 58305000L, 58277500L, 58295000L, 59047500L, 
            58907500L, 59125000L, 59072500L, 59107500L, 59315000L, 59690000L, 
            58957500L, 59407500L, 59385000L, 59965000L, 60297500L, 59890000L, 
            59822500L, 60367500L, 60407500L, 60380000L, 60815000L, 61155000L, 
            61080000L, 61132500L, 61265000L, 60912500L, 61107500L, 61445000L, 
            61345000L, 61137500L, 61035000L, 60707500L, 61340000L, 61365000L, 
            61402500L, 61640000L, 61675000L)), 
    .Names = c("Date", "Ending_Balance"), 
    row.names = c(NA, 100L), 
    class = "data.frame")
4
  • 1
    You need the cash flows to be able to calculate time-weighted return. Jun 2, 2011 at 17:52
  • well the daily cash flows are the differences in the ending balances, so they are there
    – Idr
    Jun 2, 2011 at 19:08
  • 1
    If the cash flows account for all the difference in ending balance, the time-weighted return is zero. You need to separate the change in ending balance due to additional investments from those due to returns. Jun 2, 2011 at 19:18
  • Or just start at zero like portfolio.df$flows <- c(0,diff(portfolio.df$Ending_Balance, lag=1)) Jun 2, 2011 at 19:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.