Skip to content
Prev 14613 / 15274 Next

xts 'order.by' cannot contain 'NA', 'NaN', or 'Inf' in optimize.portfolio.rebalancing

As Amit already said, zero is a better answer than -100.  log returns
don't behave well with -100x compounding returns.  This is what is
causing Inf/-Inf problems.  there is a 'zerofill' utility function
available in PerformanceAnalytics to make this replacement easier.  

see:

?zerofill

If you are *also* having a problem with order.by, your sample data
would b e insufficient to reproduce it, since the index in the subset
you pasted seems well-formed.

If Amit's and my suggestion to replace NA with 0 in your returns
doesn't solve the problem, then please reply to this thread with a
fully reproducible example (including data e.g. using dput function the
or reprex package).

Regards,

Brian