• 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 Daily Returns with Quantmod for R

First, I am still quite the novice when it comes to R in general.

I am finding some odd results with quantmod's functions for daily returns.

Start with the following code:
Code:
getSymbols('QQQ',src='yahoo')
testRet<-allReturns(QQQ,type='arithmetic')

Then I perform the following:
Code:
> testRet[2]
                daily weekly monthly quarterly
2007-01-04 0.01896392    NA      NA        NA

> QQQ$QQQ.Adjusted[2]
          QQQ.Adjusted
2007-01-04        42.97

> QQQ$QQQ.Adjusted[1]
          QQQ.Adjusted
2007-01-03        42.17
> (42.97-42.17)/42.17
[1] 0.01897083

Can somebody help me with this one? Is it a rounding issue?

Thanks!
 
Top