第九次作业

股票趋势图

数据抓取

library(Defaults)
library(xts)
## Loading required package: zoo
## Attaching package: 'zoo'
## The following object(s) are masked from 'package:base':
## 
## as.Date, as.Date.numeric
library(zoo)
library(TTR)
library(quantmod)
## Version 0.4-0 included new data defaults. See ?getSymbols.
getSymbols("ORCL", src = "yahoo", from = "1986-01-01")
## 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 ?getSymbol for more details
## [1] "ORCL"
Max <- Hi(ORCL[which.max(ORCL$ORCL.High)])
Min <- Lo(ORCL[which.min(ORCL$ORCL.Low)])
chartSeries(ORCL, theme = "white")

plot of chunk unnamed-chunk-1

addTA(Max, col = "red", type = "b", lwd = 2, on = 1)

plot of chunk unnamed-chunk-1

addTA(Min, col = "blue", type = "b", lwd = 2, on = 1)

plot of chunk unnamed-chunk-1