Instalación
install.packages("quantmod")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
## (as 'lib' is unspecified)
Ejecución de la libreria
library("quantmod")
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
Scraping a Microsoft
apple_df <- getSymbols('MSFT', src='yahoo', auto.assign=FALSE)
apple_df
## MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2007-01-03 29.91 30.25 29.40 29.86 76935100 21.52599
## 2007-01-04 29.70 29.97 29.44 29.81 45774500 21.48994
## 2007-01-05 29.63 29.75 29.45 29.64 44607200 21.36738
## 2007-01-08 29.65 30.10 29.53 29.93 50220200 21.57645
## 2007-01-09 30.00 30.18 29.73 29.96 44636600 21.59808
## 2007-01-10 29.80 29.89 29.43 29.66 55017400 21.38180
## 2007-01-11 29.76 30.75 29.65 30.70 99464300 22.13154
## 2007-01-12 30.65 31.39 30.64 31.21 103972500 22.49919
## 2007-01-16 31.26 31.45 31.03 31.16 62379600 22.46315
## 2007-01-17 31.26 31.44 31.01 31.10 58519600 22.41990
## ...
## 2023-07-10 334.60 335.23 327.59 331.83 32791400 331.82999
## 2023-07-11 331.06 332.86 327.00 332.47 26698200 332.47000
## 2023-07-12 336.60 341.65 335.67 337.20 29995300 337.20001
## 2023-07-13 339.56 343.74 339.02 342.66 20567200 342.66000
## 2023-07-14 347.59 351.43 344.31 345.24 28302200 345.23999
## 2023-07-17 345.68 346.99 342.20 345.73 20363900 345.73001
## 2023-07-18 345.83 366.78 342.17 359.49 64872700 359.48999
## 2023-07-19 361.75 362.46 352.44 355.08 39732900 355.07999
## 2023-07-20 353.57 357.97 345.37 346.87 33778400 346.87000
## 2023-07-21 349.15 350.30 339.83 343.77 69368900 343.76999
Grafica
chartSeries(apple_df, name="MSFT", subset="last 6 months", theme=chartTheme("white"))
