Skip to content

get data in quantmod

3 messages · BearXu, Rowe, Brian Lee Yung (Portfolio Analytics), Jeff Ryan

#
1: From the code for getSymbols.yahoo this appears to be hardcoded. The
parameter to set the series frequency on yahoo is 'g':

http://chart.yahoo.com/table.csv?s=FXP&a=0&b=01&c=2007&d=1&e=25&f=2009&g
=m&q=q&y=0&z=FXP&x=.csv - returns monthly

http://chart.yahoo.com/table.csv?s=FXP&a=0&b=01&c=2007&d=1&e=25&f=2009&g
=d&q=q&y=0&z=FXP&x=.csv - returns daily

Here is the code in getSymbols.yahoo:
        download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
            from.m, "&b=", sprintf("%.2d", from.d), "&c=", from.y,
            "&d=", to.m, "&e=", sprintf("%.2d", to.d), "&f=",
            to.y, "&g=d&q=q&y=0", "&z=", Symbols.name, "&x=.csv",
            sep = ""), destfile = tmp, quiet = !verbose)

Note the "&g=d" is hardcoded (at least in my versions 0.3-6, 0.3-7)

2: This has been asked before (see attached).

HTH,
Brian

-----Original Message-----
From: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of BearXu
Sent: Wednesday, February 25, 2009 10:11 AM
To: r-sig-finance at stat.math.ethz.ch
Subject: [R-SIG-Finance] get data in quantmod


I have two questions about how to get data in quantmod
1)Yahoo Finance provide us with data in daily, weekly, monthly. When we
are
using getSymbols can we choose the time spectrum?

2)I want to download some Chinese Stock Data, So I use this command:
getSymbols("600089.SS"), but when I want to use command
barChart(600089.SS),
it's wrong. Maybe the problem is the name of the object "600089.SS". So
can
I give another name to the object from the getSymbols?

Thanks


_______________________________________________
R-SIG-Finance at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.

--------------------------------------------------------------------------
This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. References to "Merrill Lynch" are references to any company in the Merrill Lynch & Co., Inc. group of companies, which are wholly-owned by Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this E-communication may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing.
--------------------------------------------------------------------------

-------------- next part --------------
An embedded message was scrubbed...
From: "Brian Lee Yung Rowe" <brian at muxspace.com>
Subject: Re: [R-SIG-Finance] Newbie question on getSymbols() in quantmod
Date: Tue, 30 Dec 2008 22:31:39 -0500
Size: 4340
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20090225/6a13787d/attachment.mht>
-------------- next part --------------
An embedded message was scrubbed...
From: "Jeff Ryan" <jeff.a.ryan at gmail.com>
Subject: Re: [R-SIG-Finance] Newbie question on getSymbols() in quantmod
Date: Wed, 31 Dec 2008 00:04:21 -0500
Size: 5616
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20090225/6a13787d/attachment-0001.mht>
#
To add to what Brian has said:
auto.assign is the current workaround.  Other options I will have to
work on.  Maybe a "name" arg or a "prefix" arg.

As far as periodicity.  I will add the option to getSymbols.yahoo to
allow for that to be specified.  A more flexible approach (as you
can't easily make daily data from monthly...) is to use the
*to.period* functions now in xts.

?to.monthly
An 'xts' object from 2007-01-01 to 2009-02-24 containing:
  Data: num [1:536, 1:6] 14.9 14.9 14.9 15.2 15.5 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:6] "600089.SS.Open" "600089.SS.High" "600089.SS.Low"
"600089.SS.Close" ...
  Indexed by objects of class: [Date]
   xts Attributes:
List of 2
 $ src    : chr "yahoo"
 $ updated: POSIXct[1:1], format: "2009-02-25 09:25:48"
Daily periodicity from 2007-01-01 to 2009-02-24
Weekly periodicity from 2007-01-05 to 2009-02-24
Monthly periodicity from Jan 2007 to Feb 2009
SS600089.Open SS600089.High SS600089.Low SS600089.Close
Jan 2007         14.95         23.54        14.95          20.74
Feb 2007         20.15         21.00        19.00          20.41
Mar 2007         20.41         20.41        20.41          20.41
Apr 2007         20.41         20.41        20.41          20.41
May 2007         20.41         20.41        20.41          20.41
Jun 2007         20.41         35.89        20.41          30.75
         SS600089.Volume SS600089.Adjusted
Jan 2007       177635800             20.62
Feb 2007        10694100             20.29
Mar 2007               0             20.29
Apr 2007               0             20.29
May 2007               0             20.29
Jun 2007        58088500             30.72


HTH,
Jeff
On Wed, Feb 25, 2009 at 9:30 AM, Rowe, Brian Lee Yung (Portfolio
Analytics) <B_Rowe at ml.com> wrote: