getReturns (stockPortfolio package)

getReturns(ticker, freq=”month”, get=”overlapOnly”, start=”1970-01-01″, end=NULL)
Retrieve stock performance data from Yahoo! Finance. Use the returned object to fit a stock model (via stockModel) and then estimate the optimal portfolio based on that model (via optimalPort).
  • ticker – A character vector of stock tickers.
  • freq – Indicate what resolution should be retrieved: "month" (the default), "week", or "day".
  • get – Indicate whether the processed returns should include only overlapping dates for the stocks (the default) or whether all processed returns data should be provided ("all").
  • start – The earliest date to begin retrieving stock data, input as "YYYY-MM-DD".
  • end – The end date as "YYYY-MM-DD" (default is the most recent trading day).

Continue reading

getForm, postForm (RCurl package)

The getForm and postForm functions from the RCurl package can be used to submit forms from R. The GET and POST methods for form submission are similar but meaningfully different; check the <form> tag in the HTML of a form to determine which function to use. In the right circumstances, these functions can be useful for automating retrieval of data sets that might otherwise require a form submission for each data set.
getForm(url, …)
  • url – A character string of a URL.
  • – The GET names and their values.
postForm(url, …)
  • url – A character string of a URL.
  • – The POST names and their values.

Continue reading

getURL, getURLContent (RCurl package)

getURL(url), getURLContent(url)
The getURL and getURLContent functions from the RCurl package are used to retrieve the source of a webpage, which is especially useful for retrieving pages for data processing (i.e. scraping). The getURLContent function is a little more robust, but the getURL function is usually sufficient.
  • url – A character string of a URL.

Continue reading