#install.packages("quantmod")
# http://www.quantmod.com/
运行 python stock1.py 600030
生成 600030.txt
表头:date,open,high,close,low,volume,price_change,p_change,ma5,ma10,ma20,v_ma5,v_ma10,v_ma20
kline1.R
library(TTR)
library(zoo)
library(xts)
library(quantmod)
setwd("D:/stock/")
code = "600030"
txt <- paste(code,"txt",sep='.')
df <- read.csv(txt, header=T, sep=',')
myvars <- c("open","high","low","close","volume")
data <- xts(df[myvars], order.by=as.Date(as.character(df[,1]),format="%Y-%m-%d"))
head(data)
stock <- as.xts(data, descr=code)
chartSeries(x=stock["2019"], name=code, line.type="l", bar.type="ohcl",
theme="white", up.col='red', dn.col='green',
TA="addVo();addSMA(5);addSMA(10);addSMA(20);addBBands();addMACD();")
addATR(): 加 (Average True Range) 真实波幅的移动平均值。
addVo(): 加 Volume 成交量。
addSMA(?): 加?日移动平均线。
addBBands(): 加布林带指标,这个指标用来比较一段时间内价格的波动。
addMACD(): 这个指标是对股票价格的收盘价进行平滑处理,求出算术平均值后,再次计算,是一种趋向类指标。