Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R Quantmod添加指标并另存为csv(无图表)_R_Quantmod - Fatal编程技术网

R Quantmod添加指标并另存为csv(无图表)

R Quantmod添加指标并另存为csv(无图表),r,quantmod,R,Quantmod,我对R和Quantmod很陌生 是否可以添加MACD之类的指示器并将时间序列保存为csv 显示图表非常简单: getSymbols("AAPL",src="yahoo") barChart(AAPL) addMACD() 但我想将指示器添加到timeseries(另存为csv),不想显示它:) 谢谢 如何告诉移动平均线使用收盘列? e您可以使用cbind添加信号 library(quantmod) getSymbols("AAPL",src="yahoo") d <- cbind( A

我对R和Quantmod很陌生

是否可以添加MACD之类的指示器并将时间序列保存为csv

显示图表非常简单:

getSymbols("AAPL",src="yahoo") 
barChart(AAPL)
addMACD()
但我想将指示器添加到timeseries(另存为csv),不想显示它:)

谢谢

如何告诉移动平均线使用收盘列?
e您可以使用
cbind
添加信号

library(quantmod)
getSymbols("AAPL",src="yahoo")
d <- cbind( AAPL, MACD( AAPL ) )
write.csv(
  data.frame( date=index(d), coredata(d) ),
  row.names=FALSE,
  file="tmp.csv"
)
库(quantmod)
getSymbols(“AAPL”,src=“yahoo”)

d谢谢:)我会在家+1检查,不过我建议使用
write.zoo
而不是
write.csv
library(quantmod)
foo=getSymbols("AAPL",src="yahoo") 
# tip: use ?barChart to see usage. The option plot=FALSE turns off plotting
x=barChart(foo,plot=FALSE)
# Look up ?MACD for a reference.
# x is a S4 object (https://github.com/hadley/devtools/wiki/S4) 
ts_data=data.frame(cbind(x@xdata),MACD(x@xdata))
# ?write.csv is a function that will write this data frame to your current directory
write.csv(ts_data,file="my_data.csv")