[QuantMod] Load all stock symbols

3 messages Options
Embed this post
Permalink
Paolo Cabaleiro

[QuantMod] Load all stock symbols

Reply Threaded More More options
Print post
Permalink
Hello everybody,

I was wondering how to load all the symbols at once using Quantmod.

I am trying to load them, so I will be able to test a set of parameters
for each one.

For example, if the S&P where to have only 3 symbols, I could just write
this...
 > getSymbols("KO;PEP;SBUX")
 > test(KO)
 > test(PEP)
 > test(SBUX)

but, how can I try this over all the S&P?
btw, test is a made-up function to illustrate the idea.

Thanks you

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Jeff Ryan

Re: [QuantMod] Load all stock symbols

Reply Threaded More More options
Print post
Permalink
Just extend the logic you have.

A full list of S&P symbols can be found via google (current and
historical), and you can just create a semi-colon delimited string to
pass into the function.

The function will pause 1s between requests after 5 symbols in one
call, so as to be kind to the Yahoo servers.  Left as a user exercise
if you are bent on bypassing.

HTH
Jeff

On Mon, Nov 9, 2009 at 10:24 AM, Paolo Cabaleiro
<[hidden email]> wrote:

> Hello everybody,
>
> I was wondering how to load all the symbols at once using Quantmod.
>
> I am trying to load them, so I will be able to test a set of parameters for
> each one.
>
> For example, if the S&P where to have only 3 symbols, I could just write
> this...
>> getSymbols("KO;PEP;SBUX")
>> test(KO)
>> test(PEP)
>> test(SBUX)
>
> but, how can I try this over all the S&P?
> btw, test is a made-up function to illustrate the idea.
>
> Thanks you
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



--
Jeffrey Ryan
[hidden email]

ia: insight algorithmics
www.insightalgo.com

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Khanh Nguyen

Re: [QuantMod] Load all stock symbols

Reply Threaded More More options
Print post
Permalink
In reply to this post by Paolo Cabaleiro
Assume you have all the stock tickers...

> tickers <- "KO;PEP;SBUX"
> tickers
[1] "KO;PEP;SBUX"
> getSymbols("KO;PEP;SBUX")
[1] "KO"   "PEP"  "SBUX"
> r <- getSymbols("KO;PEP;SBUX")
> r
[1] "KO"   "PEP"  "SBUX"
> f <- function(x) {
+ mean(get(x))
+ }
> lapply(r, f)
[[1]]
[1] 1850594

[[2]]
[1] 1216594

[[3]]
[1] 2232611

Hope it helps,

-k

On Mon, Nov 9, 2009 at 11:24 AM, Paolo Cabaleiro
<[hidden email]> wrote:

> Hello everybody,
>
> I was wondering how to load all the symbols at once using Quantmod.
>
> I am trying to load them, so I will be able to test a set of parameters for
> each one.
>
> For example, if the S&P where to have only 3 symbols, I could just write
> this...
>> getSymbols("KO;PEP;SBUX")
>> test(KO)
>> test(PEP)
>> test(SBUX)
>
> but, how can I try this over all the S&P?
> btw, test is a made-up function to illustrate the idea.
>
> Thanks you
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.