-
Install R Program from https://www.r-project.org/
-
Install "quantmod" package.
Install "quantmod" package
- Load "quantmod" package.
- quantmod basic
-
data type
常见数据类型 -
ETL functions
ETL类函数 -
getSymbols to get stock information
loadSymbols('GE', src='yahoo', from="2007-01-01", to="2017-12-30")
Get the GE data from 2007-01-01 to 2017-12-30 through yahoo
GE["2017-01-01/2017-01-25"] GE.Open GE.High GE.Low GE.Close GE.Volume GE.Adjusted 2017-01-03 30.45192 30.61538 30.19231 30.47115 33435400 28.06163 2017-01-04 30.52885 30.60577 30.40385 30.48077 22300600 28.07048 2017-01-05 30.35577 30.52885 30.10577 30.30769 26891000 27.91109 2017-01-06 30.36538 30.54808 30.15385 30.39423 23005600 27.99079 2017-01-09 30.42308 30.44231 30.22115 30.25000 22113000 27.85797 2017-01-10 30.25000 30.40385 30.16346 30.16346 28290600 27.77827 2017-01-11 30.03846 30.30769 30.03846 30.25962 29520500 27.86682 2017-01-12 30.24038 30.25962 29.93269 30.18269 31112700 27.79598 2017-01-13 30.15385 30.24038 30.04808 30.15385 25296700 27.76942 2017-01-17 29.97115 30.24038 29.96154 30.06731 29980300 27.68971 2017-01-18 30.00962 30.13462 29.93269 30.02885 25689400 27.65430 2017-01-19 30.04808 30.13462 29.85577 30.00962 39205800 27.63659 2017-01-20 29.57692 29.71154 29.13462 29.35577 86894800 27.03444 2017-01-23 29.32692 29.33654 28.44231 28.60577 61457100 26.34375 2017-01-24 28.71154 28.90385 28.67308 28.84615 35033900 26.56513 2017-01-25 29.25000 29.29808 29.05769 29.20192 39656900 26.89277
Check the GE.Adjusted column data
geAdj = GE$GE.Adjusted["2017-01-01/2017-01-25"] geAdj GE.Adjusted 2017-01-03 28.06163 2017-01-04 28.07048 2017-01-05 27.91109 2017-01-06 27.99079 2017-01-09 27.85797 2017-01-10 27.77827 2017-01-11 27.86682 2017-01-12 27.79598 2017-01-13 27.76942 2017-01-17 27.68971 2017-01-18 27.65430 2017-01-19 27.63659 2017-01-20 27.03444 2017-01-23 26.34375 2017-01-24 26.56513 2017-01-25 26.89277
max, min, mean
max(geAdj); min(geAdj); mean(geAdj) [1] 28.07048 [1] 26.34375 [1] 27.55745
visualization
chartSeries(GE)
chartSeries(GE, subset='2017-01::2017-10')
chartSeries(GE, subset='2017-01::2017-10')
- Save
saveRDS(GE,file="GE.rds")
网友评论