quantmod
程序包只能采集到每日价格而已,倘若要每分钟数据或者tick data
的话,就得另行寻找了...
require('quantmod')
> getSymbols('AAPL', from = today('GMT') - 10, to = today('GMT') - 1, src = 'google')
Error in make.names(col.names, unique = TRUE) :
invalid multibyte string at '<ef>サ<bf>Date'
> getSymbols('AAPL', from = today('GMT') - 10, to = today('GMT') - 1) #默认src为雅虎
[1] "AAPL"
> AAPL
AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted
2017-11-06 172.37 174.99 171.72 174.25 35026300 173.6258
2017-11-07 173.91 175.25 173.60 174.81 24361500 174.1838
2017-11-08 174.66 176.24 174.33 176.24 24409500 175.6087
2017-11-09 175.11 176.10 173.14 175.88 29482600 175.2500
2017-11-10 175.11 175.38 174.27 174.67 25145500 174.6700
> Cl(AAPL)
AAPL.Close
2017-11-06 174.25
2017-11-07 174.81
2017-11-08 176.24
2017-11-09 175.88
2017-11-10 174.67
> index(AAPL)
[1] "2017-11-06" "2017-11-07" "2017-11-08" "2017-11-09" "2017-11-10"
题外话:倘若是外汇的话,只有yahoo数据才有开高低闭市价格,而oanda价格也并非闭市价...
> getSymbols('JPY=X', from = today('GMT') - 10, to = today('GMT') - 1, auto.assign = FALSE)
JPY=X.Open JPY=X.High JPY=X.Low JPY=X.Close JPY=X.Volume JPY=X.Adjusted
2017-11-06 114.190 114.725 113.789 114.178 0 114.178
2017-11-07 113.771 114.332 113.723 113.771 0 113.771
2017-11-08 113.732 113.913 113.403 113.761 0 113.761
2017-11-09 113.927 114.063 113.241 113.927 0 113.927
2017-11-10 113.369 113.624 113.236 113.375 0 113.375
2017-11-13 113.520 113.705 113.246 113.686 0 113.686
> getSymbols.oanda('USD/JPY', from = today('GMT') - 10, to = today('GMT') - 1, auto.assign = FALSE)
USD.JPY
2017-11-04 114.0455
2017-11-05 114.0523
2017-11-06 114.1040
2017-11-07 114.0120
2017-11-08 113.7376
2017-11-09 113.5478
2017-11-10 113.4529
2017-11-11 113.5251
2017-11-12 113.5314
2017-11-13 113.5249
> getSymbols.oanda('USD/JPY', from = today('GMT') - 10, to = today('GMT') - 1, auto.assign = FALSE) %>% Cl
Error in Cl(.) :
subscript out of bounds: no column name containing "Close"
> getSymbols.oanda('USD/JPY', from = today('GMT') - 10, to = today('GMT') - 1, auto.assign = FALSE) %>% index
[1] "2017-11-04" "2017-11-05" "2017-11-06" "2017-11-07" "2017-11-08" "2017-11-09" "2017-11-10"
[8] "2017-11-11" "2017-11-12" "2017-11-13"
> getSymbols('JPY=X', from = today('GMT') - 10, to = today('GMT') - 1, auto.assign = FALSE) %>% Cl
JPY=X.Close
2017-11-06 114.178
2017-11-07 113.771
2017-11-08 113.761
2017-11-09 113.927
2017-11-10 113.375
2017-11-13 113.686