臺灣50指數

see http://www.twse.com.tw/ch/trading/indices/twco/tai50i.php.

臺灣個股 sample

http://finance.yahoo.com/quote/6139.tw?ltr=1.

臺灣50指數 元大台灣50 個股股價 元大台灣50反1(00632R) 個股股價

library(quantmod)
## Warning: package 'quantmod' was built under R version 3.3.3
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.
getSymbols("^TWII")
##     As of 0.4-0, 'getSymbols' uses env=parent.frame() and
##  auto.assign=TRUE by default.
## 
##  This  behavior  will be  phased out in 0.5-0  when the call  will
##  default to use auto.assign=FALSE. getOption("getSymbols.env") and 
##  getOptions("getSymbols.auto.assign") are now checked for alternate defaults
## 
##  This message is shown once per session and may be disabled by setting 
##  options("getSymbols.warning4.0"=FALSE). See ?getSymbols for more details.
## [1] "TWII"
barChart(TWII)

addMACD()

userInput="^TWII"
TW50<-as.data.frame(getSymbols(Symbols = userInput, src = "yahoo", from = "2016-03-01",to = "2017-03-17", env = NULL))
head(TW50)
##            TWII.Open TWII.High TWII.Low TWII.Close TWII.Volume
## 2016-03-01   8381.38   8489.01  8378.06    8485.69     1945500
## 2016-03-02   8544.66   8586.25  8540.17    8544.05     2308200
## 2016-03-03   8569.05   8630.77  8561.74    8611.79     2574500
## 2016-03-04   8611.37   8648.94  8584.06    8643.55     2396100
## 2016-03-07   8656.74   8727.88  8632.21    8659.55     2424900
## 2016-03-08   8655.86   8668.51  8575.70    8664.31     2643600
##            TWII.Adjusted
## 2016-03-01      8485.672
## 2016-03-02      8544.031
## 2016-03-03      8611.772
## 2016-03-04      8643.531
## 2016-03-07      8659.531
## 2016-03-08      8664.291
userInput="6139.TW"
TW6139<-as.data.frame(getSymbols(Symbols = userInput, src = "yahoo", from = "2016-03-01",to = "2017-03-17", env = NULL))
head(TW6139)
##            6139.TW.Open 6139.TW.High 6139.TW.Low 6139.TW.Close
## 2016-03-01         27.5        29.45       27.30         29.45
## 2016-03-02         29.8        29.95       28.55         29.15
## 2016-03-03         29.7        31.20       28.80         29.25
## 2016-03-04         30.6        30.75       29.55         30.30
## 2016-03-07         30.6        30.90       29.25         29.30
## 2016-03-08         29.5        29.55       27.65         28.55
##            6139.TW.Volume 6139.TW.Adjusted
## 2016-03-01       10111000          28.4184
## 2016-03-02        6896000          28.1289
## 2016-03-03        8543000          28.2254
## 2016-03-04        6783000          29.2386
## 2016-03-07        4915000          28.2737
## 2016-03-08        5022000          27.5499
plot(TW6139$`6139.TW.Close`)

userInput="0050.TW"
T50<-as.data.frame(getSymbols(Symbols = userInput, src = "yahoo", from = "2016-03-01",to = "2017-03-17", env = NULL))
head(T50)
##            0050.TW.Open 0050.TW.High 0050.TW.Low 0050.TW.Close
## 2016-03-01        61.25        61.95       61.10         61.85
## 2016-03-02        62.35        62.75       62.25         62.35
## 2016-03-03        62.35        63.30       62.35         62.95
## 2016-03-04        62.90        63.30       62.75         63.10
## 2016-03-07        63.20        63.70       62.90         63.10
## 2016-03-08        63.00        63.10       62.50         63.05
##            0050.TW.Volume 0050.TW.Adjusted
## 2016-03-01       17213000            61.10
## 2016-03-02       22851000            61.59
## 2016-03-03       32561000            62.18
## 2016-03-04       24034000            62.33
## 2016-03-07       21482000            62.33
## 2016-03-08       13615000            62.28
plot(T50$`0050.TW.Close`)

userInput="00632R.TW"
IT50<-as.data.frame(getSymbols(Symbols = userInput, src = "yahoo", from = "2016-03-01",to = "2017-03-17", env = NULL))
head(IT50)
##            00632R.TW.Open 00632R.TW.High 00632R.TW.Low 00632R.TW.Close
## 2016-03-01          19.48          19.49         19.21           19.26
## 2016-03-02          19.07          19.16         19.00           19.14
## 2016-03-03          19.11          19.11         18.94           19.02
## 2016-03-04          18.97          19.04         18.90           18.94
## 2016-03-07          18.91          18.99         18.75           18.92
## 2016-03-08          18.94          19.09         18.90           18.92
##            00632R.TW.Volume 00632R.TW.Adjusted
## 2016-03-01         58709000              19.26
## 2016-03-02         61160000              19.14
## 2016-03-03         78931000              19.02
## 2016-03-04         51426000              18.94
## 2016-03-07         70051000              18.92
## 2016-03-08         67474000              18.92
plot(IT50$`00632R.TW.Close`)