George,

I can help you get names of _stocks_.  Look at yahooQF (type it without
quotes in an R console) for a list of fields you can get from yahoo using
getQuote.  The field you want is "Name"

> library(quantmod)
> sym <- "CSCO"
> paste(getQuote(sym, what=yahooQF("Name"))[,2])
[1] "Cisco Systems, In"


Alternatively, you can define a stock using the FinancialInstrument
package, and then update the metadata a few different ways.

> library(FinancialInstrument)
> stock(sym, currency("USD"))
[1] "CSCO"
> update_instruments.yahoo(sym)
[1] "CSCO"
> getInstrument(sym)$name
[1] "Cisco Systems, In"
>

The above will give you the same thing as using getQuote, which, as you
mentioned, does not give the whole name, only the first 17 characters.

For stocks that trade on AMEX, NASDAQ, or NYSE, you can use the
update_instruments.TTR function (this uses TTR:::stockSymbols which you
should also look at)

> update_instruments.TTR(sym)
Fetching AMEX symbols...
Fetching NASDAQ symbols...
Fetching NYSE symbols...
defining stocks...
[1] "CSCO"
> getInstrument(sym)$Name
[1] "Cisco Systems, Inc."
>


Finally, if you have an Interactive Brokers account, you can update the
instrument metadata using IB with the twsInstrument package.


> library(twsInstrument)
> update_instruments.IB(sym)
Connected with clientId 100.
Request complete: CSCO STK USD.
Disconnected.
[1] "CSCO"
> getInstrument(sym)$longName
[1] "CISCO SYSTEMS INC"
>

# Above is assuming the stock is already defined.  If not, you can define
it using the twsInstrument function "define_stocks" and then you won't have
to update it

> define_stocks(sym)
Connected with clientId 100.
Request complete: CSCO STK USD.
Disconnected.
[1] "CSCO"
> getInstrument("CSCO")$longName
[1] "CISCO SYSTEMS INC"


update_instruments.TTR and update_instruments.IB do not support mutual
funds.  So, yahoo is your best bet, but it truncates the name.

Of course, you _could_ do the web scraping yourself

HTH,
Garrett


On Mon, Nov 28, 2011 at 2:36 AM, George Kumar <grgkumar4@gmail.com> wrote:

> I tried using the following scipt
>
> ----------------------------------------
> Args <- commandArgs()      # retrieve cmdline args
> ticker <- as.character(Args[5])
> url =
> paste("http://download.finance.yahoo.com/d/quotes.csv?s=
> ",ticker,"&f=n",sep="")
> x<- read.table(url)
> compname=x[1,]
> compname=as.character(compname)
> cat("Comp name is ",compname, "\n")
>
> ----------------------------------------
>
> cat get_name_from_yahoo.R |  R --vanilla --slave --args FIIAX
> Output: FIDELITY ADVISOR
>
> So even this does not give the full name that one sees in yahoo finance web
> page - Fidelity Advisor Mid Cap II A
>
> Thanks a lot for your replies.
> George
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/How-to-get-name-of-a-ticker-using-Quantmod-R-tp4114044p4114517.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> R-SIG-Finance@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.
>

	[[alternative HTML version deleted]]

