rquantmod

Delimit dates with get Symbols


Why if I am writting en "subset='2023-01::2023-07",I am getting data since 2007-01-03. I believe that is not a problem of format because I I tried all possibilities

getSymbols("AAPL",subset='01-2023::06-2023')
getSymbols("AAPL",subset='01-01-2023::01-06-2023')

Solution

  • getSymbols() doesn't have a subset argument. You need to use to and from if you want to specify a date range.

    quantmod::getSymbols("AAPL", from = "2023-01-01", to = "2023-06-01")
    print(AAPL)
    ##             AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted
    ##  2023-01-03    130.28    130.90   124.17     125.07   112117500      124.7068
    ##  2023-01-04    126.89    128.66   125.08     126.36    89113600      125.9931
    ##  2023-01-05    127.13    127.77   124.76     125.02    80962700      124.6570
    ##  2023-01-06    126.01    130.29   124.89     129.62    87754700      129.2436
    ##  2023-01-09    130.47    133.41   129.89     130.15    70790800      129.7721
    ##  2023-01-10    130.26    131.26   128.12     130.73    63896200      130.3504
    ##  2023-01-11    131.25    133.51   130.46     133.49    69458900      133.1024
    ##  2023-01-12    133.88    134.26   131.44     133.41    71379600      133.0226
    ##  2023-01-13    132.03    134.92   131.66     134.76    57809700      134.3687
    ##  2023-01-17    134.83    137.29   134.13     135.94    63646600      135.5453
    ##         ...
    ##  2023-05-17    171.71    172.93   170.42     172.69    57951600      172.6900
    ##  2023-05-18    173.00    175.24   172.58     175.05    65496700      175.0500
    ##  2023-05-19    176.39    176.39   174.94     175.16    55772400      175.1600
    ##  2023-05-22    173.98    174.71   173.45     174.20    43570900      174.2000
    ##  2023-05-23    173.13    173.38   171.28     171.56    50747300      171.5600
    ##  2023-05-24    171.09    172.42   170.52     171.84    45143500      171.8400
    ##  2023-05-25    172.41    173.90   171.69     172.99    56058300      172.9900
    ##  2023-05-26    173.32    175.77   173.11     175.43    54835000      175.4300
    ##  2023-05-30    176.96    178.99   176.57     177.30    55964400      177.3000
    ##  2023-05-31    177.33    179.35   176.76     177.25    99625300      177.2500
    

    You also need to specify dates in an ISO-8601 format: 4-digit year, 2-digit month, 2-digit day. For example: 2023-07-10.