[R-SIG-Finance] quantmod package documentation
Jeffrey Ryan
jeffrey.ryan at lemnica.com
Thu Nov 3 20:27:40 CET 2011
On Thu, Nov 3, 2011 at 2:05 PM, Andreas Voellenklee <wotuzu17 at gmail.com> wrote:
> Hello,
>
> I have some questions about the quantmod package documentation and the
> function getSymbols.
>
> 1) altough I have quantmod_0.3-17 installed, the documentation says
> it's version 0.3-8 from 2007-11-20. Maybe someone of the developer
> group fix this?
Its been like this for years, somewhere between a joke and don't fix
it lest it's broke.
Kidding aside, I have committed a rev 572 that addresses. Any
breakages are not my fault ;-)
>
> 2) I've seen code that uses a undocumented parameter adjust=TRUE in
> getSymbols. I thought this would be a convenient way to retrieve and
> adjust prices in one line of code, but the result is somewhat
> surprising.
>
> Let's compare these three different snippets:
>
> Version 1:
>> getSymbols("C") # retrieve unadjusted prices
> [1] "C"
>> head(C)
> C.Open C.High C.Low C.Close C.Volume C.Adjusted
> 2007-01-03 55.66 56.28 54.72 55.25 2282100 499.32
> 2007-01-04 55.25 56.15 54.72 55.06 1658700 497.60
> 2007-01-05 55.00 55.05 54.46 54.77 1317900 494.98
> 2007-01-08 54.60 55.15 54.30 55.05 1236900 497.51
> 2007-01-09 55.01 55.15 54.19 54.57 1963000 493.17
> 2007-01-10 54.27 54.49 53.95 54.13 1744900 489.20
>
> Version 2:
>> getSymbols("C", adjust=TRUE) # retrieve adjusted prices
> [1] "C"
>> head(C)
> C.Open C.High C.Low C.Close C.Volume C.Adjusted
> 2007-01-03 191.1241 193.2530 187.8963 189.7162 6646032 499.32
> 2007-01-04 189.7162 192.8066 187.8963 189.0638 4830539 497.60
> 2007-01-05 188.8578 189.0295 187.0036 188.0680 3838046 494.98
> 2007-01-08 187.4843 189.3729 186.4542 189.0295 3602155 497.51
> 2007-01-09 188.8921 189.3729 186.0764 187.3813 5716735 493.17
> 2007-01-10 186.3511 187.1066 185.2523 185.8704 5081575 489.20
>
> Version 3:
>> getSymbols("C") # retrieve unadjusted prices
>> assign("C", adjustOHLC(get("C"),use.Adjusted=TRUE)) # adjust prices using quantmod::adjustOHLC
>> head(C)
> C.Open C.High C.Low C.Close C.Volume C.Adjusted
> 2007-01-03 503.0254 508.6286 494.5301 499.32 2282100 499.32
> 2007-01-04 499.3171 507.4508 494.5273 497.60 1658700 497.60
> 2007-01-05 497.0586 497.5105 492.1784 494.98 1317900 494.98
> 2007-01-08 493.4432 498.4137 490.7319 497.51 1236900 497.51
> 2007-01-09 497.1464 498.4117 489.7358 493.17 1963000 493.17
> 2007-01-10 490.4653 492.4535 487.5732 489.20 1744900 489.20
>
>
> Does anybody know what the parameter adjust in Version 2 is supposed
> to adjust? And why it's not documented?
>
It is meant to adjust. The issue was exactly _where_ to document - as
it would be in getSymbols.yahoo, but the way the functions are called
it isn't technically a param to that function:
> args(getSymbols.yahoo)
function (Symbols, env, return.class = "xts", index.class = "Date",
from = "2007-01-01", to = Sys.Date(), ...)
Can't really document something that isn't there ;-)
That said, I'll think about how to do that without breaking code (see
my comment above about 'not being broken')
Why it isn't working on "C" is odd. My thinking is that it has
something to do with C being a function in R. Trying on MSFT shows it
does indeed work:
> getSymbols("MSFT")
[1] "MSFT"
> head(MSFT)
MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
2007-01-03 29.91 30.25 29.40 29.86 76935100 27.17
2007-01-04 29.70 29.97 29.44 29.81 45774500 27.13
2007-01-05 29.63 29.75 29.45 29.64 44607200 26.97
2007-01-08 29.65 30.10 29.53 29.93 50220200 27.24
2007-01-09 30.00 30.18 29.73 29.96 44636600 27.26
2007-01-10 29.80 29.89 29.43 29.66 55017400 26.99
> getSymbols("MSFT", adjust=TRUE)
[1] "MSFT"
> head(MSFT)
MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
2007-01-03 27.21858 27.52798 26.75447 27.17308 84542580 27.17
2007-01-04 27.02748 27.27318 26.79087 27.12758 50300764 27.13
2007-01-05 26.96377 27.07298 26.79997 26.97287 49018039 26.97
2007-01-08 26.98197 27.39148 26.87277 27.23678 55186063 27.24
2007-01-09 27.30048 27.46428 27.05478 27.26408 49050346 27.26
2007-01-10 27.11848 27.20038 26.78177 26.99107 60457618 26.99
Thanks for the email, question, and 'documenting' adjust for us. I'll
look into the C case.
Jeff
> Thanks,
> Andreas
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>
--
Jeffrey Ryan
jeffrey.ryan at lemnica.com
www.lemnica.com
www.esotericR.com
More information about the R-SIG-Finance
mailing list