Is there a better to way to do it apart from using a combination of loop and paste() function.įinally, for question 3, I need a dataframe with three columns corresponding to closing prices. I have heard about Trycatch() function but do not know how to use it.Īs per question 2, I want the variable names for the first element of the list to be "MSFTopen", "MSFThigh", "MSFTlow", and "MSFTclose". The output is saved in csv format in the directory specified by the DIRECTORY parameter. The open, high, low prices are adjusted based on the adjClose field. The code stops at the third entry but I want to skip this ticker and move on to "MMM". Downloads 10 years worth of daily stock data from yahoo finance. Tckk <- c("MSFT", "C", "VIA/B", "MMM") # ticker names definedĪll_dat <- list() # empty list to fill in the dataĪll_dat] <- xxx <- (instrument = tckk, start=ustart, end=uend, quote = c("Open", "High", "Low", "Close"), provider = "yahoo", compression = "m") Yahoo Finance API is the most popular source for getting the stock market data and since many investors use Excel to track their stock portfolios, it is common. Here is the sample code for the simplified version of my problem. I need an efficient way to create a dataframe that has the closing prices as variables.I want the ticker names to be appended to variable names in element dataframes. Stock - Yahoo Finance Like Comment Share Copy.
0 Comments
Leave a Reply. |