I am using the package in R
to pull historical data from Yahoo Finance.
I use a lot of ticker list to use the package:
symbols & lt; - C ( "MSFT", "ORCL", "AAPL", "FB")
To get historical data I quantlib method getSymbols call:
try (getSymbols (sym, src = "yahoo"))
this ORCL
, APPL < Generates variables in my environment called / code> and
FB
.
A connection between MSFT and ORCL with closing prices I can use
To calculate core (Cl (MSFT), chlorine (ORCL))
To get:
ORCL.Close MSFT.Close 0.6597159
I have this general so that I can pull Are 20 symbols and runs that can make the relationship between them?
I do not know how to reference the variable given to a string. That is, I have the string "MFST", how do I reference variables MSFT
? I string "Mfsti" and "Oarsiel" I found that I could do to use the Core (MSFT), Cl (ORCL)
write
< Div class = "post-text" itemprop = "text">
The easiest way is to store data in the loop environment above all objects in the environment, and then eapply
:
Library (quantmod) dataEnv & lt; - New.env () getSymbols ( "MSFT; ORCL; AAPL; FB", env = dataEnv) # Remove the closest corner of the objects, then add an object cl all close columns & lt; - do.call (Merge, Apely (dataEnv chlorine)) # Warn in the details section of note? The "pairwise.complete.obs" Core to about (CL Core # use, = "pairwise.complete.obs") # AAPL.Close ORCL.Close MSFT.Close FB.Close # AAPL.Close 1.0000000 0.6467283 0.2528689 -0.5 99 7337 # ORCL.Close 0,6467283 1,0000000 0,6597159 0,8211939 # MSFT.Close 0,2528689 0,6597159 1,0000000 0,8979836 # FB.Cl OISE -0.5 99 7337 0.8211939 0.8979836 1.0000000 < / Code>
Comments
Post a Comment