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 Apple

apple_df <- getSymbols('AAPL', src='yahoo', auto.assign=FALSE)
apple_df
##             AAPL.Open  AAPL.High   AAPL.Low AAPL.Close AAPL.Volume
## 2007-01-03   3.081786   3.092143   2.925000   2.992857  1238319600
## 2007-01-04   3.001786   3.069643   2.993571   3.059286   847260400
## 2007-01-05   3.063214   3.078571   3.014286   3.037500   834741600
## 2007-01-08   3.070000   3.090357   3.045714   3.052500   797106800
## 2007-01-09   3.087500   3.320714   3.041071   3.306071  3349298400
## 2007-01-10   3.383929   3.492857   3.337500   3.464286  2952880000
## 2007-01-11   3.426429   3.456429   3.396429   3.421429  1440252800
## 2007-01-12   3.378214   3.395000   3.329643   3.379286  1312690400
## 2007-01-16   3.417143   3.473214   3.408929   3.467857  1244076400
## 2007-01-17   3.484286   3.485714   3.386429   3.391071  1646260000
##        ...                                                        
## 2023-07-17 191.899994 194.320007 191.809998 193.990005    50520200
## 2023-07-18 193.350006 194.330002 192.419998 193.729996    48353800
## 2023-07-19 193.100006 198.229996 192.649994 195.100006    80507300
## 2023-07-20 195.089996 196.470001 192.500000 193.130005    59581200
## 2023-07-21 194.100006 194.970001 191.229996 191.940002    71917800
## 2023-07-24 193.410004 194.910004 192.250000 192.750000    45377800
## 2023-07-25 193.330002 194.440002 192.919998 193.619995    37283200
## 2023-07-26 193.669998 195.639999 193.320007 194.500000    47471900
## 2023-07-27 196.020004 197.199997 192.550003 193.220001    47460200
## 2023-07-28 194.669998 196.630005 194.139999 195.830002    48254600
##            AAPL.Adjusted
## 2007-01-03      2.543757
## 2007-01-04      2.600218
## 2007-01-05      2.581702
## 2007-01-08      2.594450
## 2007-01-09      2.809970
## 2007-01-10      2.944445
## 2007-01-11      2.908019
## 2007-01-12      2.872200
## 2007-01-16      2.947480
## 2007-01-17      2.882216
##        ...              
## 2023-07-17    193.990005
## 2023-07-18    193.729996
## 2023-07-19    195.100006
## 2023-07-20    193.130005
## 2023-07-21    191.940002
## 2023-07-24    192.750000
## 2023-07-25    193.619995
## 2023-07-26    194.500000
## 2023-07-27    193.220001
## 2023-07-28    195.830002

Grafica

chartSeries(apple_df, name="AAPL", subset="last 6 months", theme=chartTheme("white"))

La tendencia de esta grafica nos dice que es altista quiere decir que tiende mas a subir

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.59807
## 2007-01-10     29.80     29.89    29.43      29.66    55017400      21.38181
## 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-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
## 2023-07-24    345.85    346.92   342.31     345.11    26678100     345.10999
## 2023-07-25    347.11    351.89   345.07     350.98    41637700     350.98001
## 2023-07-26    341.44    344.67   333.11     337.77    58383700     337.76999
## 2023-07-27    340.48    341.33   329.05     330.72    39635300     330.72000
## 2023-07-28    333.67    340.01   333.17     338.37    28463000     338.37000

Grafica

chartSeries(apple_df, name="MSFT", subset="last 6 months", theme=chartTheme("white"))

Su tendencia igual es altista pero con mayor bajas

Scraping a Sony

apple_df <- getSymbols('SONY', src='yahoo', auto.assign=FALSE)
apple_df
##            SONY.Open SONY.High SONY.Low SONY.Close SONY.Volume SONY.Adjusted
## 2007-01-03     42.90     43.37    42.73      42.91     1200600      42.34515
## 2007-01-04     43.18     43.88    43.12      43.80     1209600      43.22343
## 2007-01-05     43.98     45.60    43.96      44.80     3197500      44.21027
## 2007-01-08     44.81     45.33    44.43      44.81     2344300      44.22013
## 2007-01-09     46.25     47.00    45.80      46.40     1731000      45.78920
## 2007-01-10     45.65     45.95    45.38      45.78      826200      45.17737
## 2007-01-11     45.27     45.99    45.26      45.65      958400      45.04908
## 2007-01-12     46.50     47.85    46.40      47.68     4216400      47.05235
## 2007-01-16     47.22     47.32    46.78      47.00     1498500      46.38131
## 2007-01-17     47.12     47.90    47.00      47.54     1656400      46.91420
##        ...                                                                  
## 2023-07-17     92.53     94.29    92.37      93.57      769700      93.57000
## 2023-07-18     94.86     95.42    94.58      95.10      967100      95.10000
## 2023-07-19     94.76     95.00    94.13      94.57      539100      94.57000
## 2023-07-20     93.29     93.86    93.18      93.25      650700      93.25000
## 2023-07-21     93.82     93.96    93.28      93.39      425700      93.39000
## 2023-07-24     93.39     93.92    93.26      93.66      386200      93.66000
## 2023-07-25     93.03     93.79    92.80      93.69      437300      93.69000
## 2023-07-26     93.39     94.07    93.20      93.74      374700      93.74000
## 2023-07-27     94.70     95.19    93.59      93.76      686100      93.76000
## 2023-07-28     93.77     94.17    93.40      93.47      679800      93.47000

Grafica

chartSeries(apple_df, name="SONY", subset="last 6 months", theme=chartTheme("white"))

La tendencia de esta grafica es muy volatil ya que sus velitas suben y bajan

Scraping a Tesla

apple_df <- getSymbols('TSLA', src='yahoo', auto.assign=FALSE)
apple_df
##             TSLA.Open  TSLA.High   TSLA.Low TSLA.Close TSLA.Volume
## 2010-06-29   1.266667   1.666667   1.169333   1.592667   281494500
## 2010-06-30   1.719333   2.028000   1.553333   1.588667   257806500
## 2010-07-01   1.666667   1.728000   1.351333   1.464000   123282000
## 2010-07-02   1.533333   1.540000   1.247333   1.280000    77097000
## 2010-07-06   1.333333   1.333333   1.055333   1.074000   103003500
## 2010-07-07   1.093333   1.108667   0.998667   1.053333   103825500
## 2010-07-08   1.076000   1.168000   1.038000   1.164000   115671000
## 2010-07-09   1.172000   1.193333   1.103333   1.160000    60759000
## 2010-07-12   1.196667   1.204667   1.133333   1.136667    33037500
## 2010-07-13   1.159333   1.242667   1.126667   1.209333    40201500
##        ...                                                        
## 2023-07-17 286.630005 292.230011 283.570007 290.380005   131569600
## 2023-07-18 290.149994 295.260010 286.010010 293.339996   112434700
## 2023-07-19 296.040009 299.290009 289.519989 291.260010   142355400
## 2023-07-20 279.559998 280.929993 261.200012 262.899994   175158300
## 2023-07-21 268.000000 268.000000 255.800003 260.019989   161050100
## 2023-07-24 255.850006 269.850006 254.119995 269.059998   136508500
## 2023-07-25 272.380005 272.899994 265.000000 265.279999   112757300
## 2023-07-26 263.250000 268.040009 261.750000 264.350006    95856200
## 2023-07-27 268.309998 269.130005 255.300003 255.710007   103697300
## 2023-07-28 259.859985 267.250000 258.230011 266.440002   111149300
##            TSLA.Adjusted
## 2010-06-29      1.592667
## 2010-06-30      1.588667
## 2010-07-01      1.464000
## 2010-07-02      1.280000
## 2010-07-06      1.074000
## 2010-07-07      1.053333
## 2010-07-08      1.164000
## 2010-07-09      1.160000
## 2010-07-12      1.136667
## 2010-07-13      1.209333
##        ...              
## 2023-07-17    290.380005
## 2023-07-18    293.339996
## 2023-07-19    291.260010
## 2023-07-20    262.899994
## 2023-07-21    260.019989
## 2023-07-24    269.059998
## 2023-07-25    265.279999
## 2023-07-26    264.350006
## 2023-07-27    255.710007
## 2023-07-28    266.440002

Grafica

chartSeries(apple_df, name="TSLA", subset="last 6 months", theme=chartTheme("white"))

La tendecia de esta grafica esta llegando a su punto maximo que en algun momento su tendencia puede bajar mas