[问题类型]:
程式咨询(我想用R 做某件事情,但是我不知道要怎么用R 写出来)
[软件熟悉度]:
入门(写过其他程式,只是对语法不熟悉)
[问题叙述]
:
之前曾经用 quantmod package 抓过台湾个股的资料开发 shiny,
但在近期发现套件没办法到 Yahoo Finance 抓台湾个股资料了,
有上网查过问题,问题似乎来自 Yahoo Finance API 的网址有更动,
但网络好像没有解决方法(如下文),
但若直接到 Yahoo Finance 的 Historical Data 区似乎还是可以下载 csv 档,
不确定是否可以 debug,或有其他方法可以用 R 抓个股股价资料?
感激不尽(已跪)
根据此文:
https://github.com/joshuaulrich/quantmod/issues/149
[程式范例]:
> library(quantmod)
> getSymbols('2330.TW')
Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
无法开启 URL 'https://ichart.finance.yahoo.com/table.csv?s=2330.TW&a=0&b=01&
c=2007&d=6&e=08&f=2017&g=d&q=q&y=0&z=2330.TW&x=.csv'
此外: Warning message:
In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
URL 'https://ichart.finance.yahoo.com/table.csv?s=2330.TW&a=0&b=01&c=
2007&d=6&e=08&f=2017&g=d&q=q&y=0&z=2330.TW&x=.csv':
status was 'Couldn't resolve host name'
[环境叙述]:
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] zh_TW.UTF-8/zh_TW.UTF-8/zh_TW.UTF-8/C/zh_TW.UTF-8/zh_TW.UTF-8
attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base
other attached packages:
[1] gridExtra_2.2.1 urca_1.3-0
[3] quantmod_0.4-10 TTR_0.23-1
[5] xts_0.9-7 zoo_1.8-0
[7] plotly_4.7.0 ggplot2_2.2.1
[9] shiny_1.0.3
loaded via a namespace (and not attached):
[1] Rcpp_0.12.11 magrittr_1.5
[3] munsell_0.4.3 lattice_0.20-35
[5] viridisLite_0.2.0 colorspace_1.3-2
[7] xtable_1.8-2 R6_2.2.2
[9] httr_1.2.1 plyr_1.8.4
[11] dplyr_0.7.1 tools_3.4.0
[13] grid_3.4.0 nlme_3.1-131
[15] gtable_0.2.0 DBI_0.7
[17] htmltools_0.3.6 yaml_2.1.14
[19] lazyeval_0.2.0 digest_0.6.12
[21] assertthat_0.2.0 tibble_1.3.3
[23] tidyr_0.6.3 purrr_0.2.2.2
[25] htmlwidgets_0.8 mime_0.5
[27] compiler_3.4.0 scales_0.4.1
[29] jsonlite_1.5 httpuv_1.3.5
[关键字]:
quantmod