joshuaulrich / quantmod

Quantitative Financial Modelling Framework
http://www.quantmod.com/
GNU General Public License v3.0
794 stars 219 forks source link

getSymbols HTTP error 403 #370

Closed syshi88 closed 1 year ago

syshi88 commented 1 year ago

Description

I tried to use getSymbols("VIX") but failed to fetch the data. There was an error message of HTTP error 403. Could someone advise how to fix it?

Minimal, reproducible example

library(quantmod)
getSymbols("VIX")
#> Warning: VIX download failed; trying again.Error in getSymbols.yahoo(Symbols = "VIX", env = <environment>, verbose = FALSE,  : 
#>  Unable to import “VIX”.
#> VIX download failed after two attempts. Error message:
#> HTTP error 403.

Session Info

sessionInfo()
#> R version 4.2.2 (2022-10-31 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 22621)

#> Matrix products: default

#> locale:
#> [1] LC_COLLATE=Chinese (Simplified)_China.utf8  LC_CTYPE=Chinese (Simplified)_China.utf8   
#> [3] LC_MONETARY=Chinese (Simplified)_China.utf8 LC_NUMERIC=C                               
#> [5] LC_TIME=Chinese (Simplified)_China.utf8    

#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     

#> other attached packages:
#> [1] quantmod_0.4.20 TTR_0.24.3      xts_0.12.2      zoo_1.8-11      readxl_1.4.1    rio_0.5.29     

#> loaded via a namespace (and not attached):
#>  [1] zip_2.2.2         Rcpp_1.0.9        cellranger_1.1.0  pillar_1.8.1      compiler_4.2.2    forcats_1.0.0    
#>  [7] tools_4.2.2       digest_0.6.31     jsonlite_1.8.4    evaluate_0.20     lifecycle_1.0.3   tibble_3.1.8     
#> [13] lattice_0.20-45   pkgconfig_2.0.3   rlang_1.0.6       openxlsx_4.2.5.1  cli_3.6.0         rstudioapi_0.14  
#> [19] curl_5.0.0        yaml_2.3.6        haven_2.5.1       xfun_0.36         fastmap_1.1.0     xml2_1.3.3       
#> [25] knitr_1.41        vctrs_0.5.1       hms_1.1.2         grid_4.2.2        glue_1.6.2        data.table_1.14.6
#> [31] fansi_1.0.3       foreign_0.8-83    rmarkdown_2.20    magrittr_2.0.3    ellipsis_0.3.2    htmltools_0.5.4  
#> [37] utf8_1.2.2        stringi_1.7.12  
joshuaulrich commented 1 year ago

You want getSymbols("^VIX") (note the "^" prefix).