Как насчет этого?
library(dplyr)
library("rvest")
url <- "https://www.bseindia.com/markets/equity/EQReports/MarketWatch.aspx"
data <- url %>%
read_html() %>%
html_table(fill = TRUE)
df <- data[[9]]
df <- df[, -c(11:21)]
Или, вы можете пойти дальше и получить прибыль (вы можете делать и другие вещи в дополнение к этому).
library(timeSeries)
library(fPortfolio)
library(quantmod)
library(caTools)
library(dplyr)
library(PerformanceAnalytics)
library(ggplot2)
library(BatchGetSymbols)
library(tidyr)
library(quantmod)
# set dates
first.date <- Sys.Date() - 360
last.date <- Sys.Date()
# set tickers
tickers <- c('MMM','ABT','ABBV','ABMD',
'ACN','ATVI','AYI','ADBE','AMD','AAP')
out <- BatchGetSymbols(tickers = tickers,
first.date = first.date,
last.date = last.date,
cache.folder = file.path(tempdir(),
'BGS_Cache') )
out<-out$df.tickers
out<-out[,c("ref.date","ticker", "price.adjusted")]
q <- spread(out, ticker, price.adjusted)
portfolioPrices <- xts(q[,-1], order.by=q[,1])
out<-out$df.tickers
out<-out[,c("ref.date","ticker", "price.adjusted")]
# Eliminate Dupes
deduped_data <- unique( out[ , 1:3 ] )
q <- spread(deduped_data, ticker, price.adjusted)
portfolioPrices <- xts(q[,-1], order.by=q[,1])
#Rename Columns
colnames(portfolioPrices) <- tickers
#Calculate Returns: Daily RoC
portfolioReturns <- na.omit(ROC(portfolioPrices, type="discrete"))
portfolioReturns <- as.timeSeries(portfolioReturns)
Я считаю, что API Yahoo был выключен около 2 лет назад.