Skip to content

Merge xts and Return.portfolio

3 messages · Simone Medori, Joshua Ulrich

#
Hi,
I'm triyng to merge two xts time series objects, one of them is from Return.portfolio (PerformanceAnalytics).

Despite the merging xts objects have the same indexes, the merged object shows extra lines at the day before of every entry.

I noticed that indexes of merging objects have different classes ("POSIXct" and "Date"): might be this the reason? Why do I get different extra dates anyway?

Kind regards,

Simone
#
On Fri, Nov 15, 2013 at 6:32 AM, Simone Medori <simone.medori at me.com> wrote:
Yes, this is the reason.  Specifically, the cause is the difference in
timezone between the POSIXct index and the Date index.

For some reason, Return.portfolio returns a xts object with a POSIXct
index.  Convert it to Date and your merge will work.
rp <- Return.portfolio(returns)
index(rp) <- as.Date(index(rp))
merge(returns,rp)
Best,
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
#
Thanks

Simone