使用python库baostock获得中国海油的历史数据,存为stock_data_numeric.csv文件,备用。
python库baostock获取股票数据 – 网事-树莓派
library(readr)
stock_data_numeric <- read_csv("python/stock_data_numeric.csv")
View(stock_data_numeric)
# 安装并加载quantmod包
#install.packages("quantmod")
library(quantmod)
stock_data_numeric <- xts(stock_data_numeric[,-c(1,2)],order.by = as.Date(stock_data_numeric$date))
# 使用chartSeries绘制股票价格图
chartSeries(stock_data_numeric,
theme = "white", # 设置白色主题
name = "中国海油股价及20均价线SMA20",
TA = c(addVo(), #添加成交量图
addBBands())) # 添加布林带指标
