标签: quantmod

Plot() 只有一列数据

我在 r 中使用以下代码读取股票价格的 CSV 文件。

library(quantmod)

#column headings ("open","high","low","close","volume","adj.")

fmt <- '%Y-%m-%d'
SPY <- read.zoo("~/Stocks/csv/SPY.csv",header=TRUE,sep=',',tz='',format=fmt,index=0:1)

plot(SPY['open'])
Run Code Online (Sandbox Code Playgroud)

我可以成功地用于plot(SPY)绘制所有列。

我将如何按名称仅选择一列,例如仅绘制“打开”列?我已经尝试了很多事情,例如plot(SPY['open'])但无法弄清楚。

有人可以帮忙吗?非常感谢!

r quantmod

1
推荐指数
1
解决办法
4910
查看次数

quantmod - SSL:无法在 R 中获取本地颁发者证书

I\xe2\x80\x99m 尝试使用quantmodR 中的包从雅虎获取财务数据。它在我的个人笔记本电脑(Mac 和 Win)上完美运行。但我无法让它在我的工作计算机(Win7)上运行。

\n

我的代码是:

\n
getSymbols("JPM", src = "yahoo")\n
Run Code Online (Sandbox Code Playgroud)\n

请注意,它仅不适用于我公司的笔记本电脑。

\n

这是错误代码:

\n
Error in curl::curl_download(cu, tmp, handle = h) : \nSSL certificate problem: unable to get local issuer certificate\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试通过以下方式解决问题:

\n
    \n
  1. 安装httr

    \n
  2. \n
  3. 删除curlquantmod重新安装

    \n
  4. \n
  5. 更新到最新版本的 R、RStudio curl、、、httrRCurlquantmod

    \n
  6. \n
  7. 安装openssl

    \n
  8. \n
  9. ssl_verifypeer = 0L

    \n
  10. \n
  11. 之前添加以下内容getSymbols

    \n

    options(download.file.method = "wget", download.file.extra …

url ssl curl r quantmod

1
推荐指数
1
解决办法
5083
查看次数

一旦我在 Quantstrat R 中建仓,就停止添加更多仓位

我正在研究基本 RSI 交易信号。当股票低于 20 RSI 时买入 100 股,当股票高于 80 RSI 时平仓。

发生的情况是,一旦股票跌破 20,我就买入 100 股,如果股票再次跌破 20,而 RSI 没有首先达到 80,我最终会再买入 100 股(总共 200 股)。

一旦我有了一个仓位,我就不想再增加了。谢谢。

rm.strat(portfolio.st)
rm.strat(strategy.st)
rm.strat(account.st)

#setup
Sys.setenv(TZ = "UTC")
stock.str = "AAPL"
currency('USD')
stock("AAPL", currency= "USD", multiplier = 1)

initDate = "2010-01-01"
startDate = "2011-01-01"
to = Sys.Date()
initEq = 100000

portfolio.st = account.st = strategy.st = 'rsi'

getSymbols("AAPL", from = initDate)

initPortf(portfolio.st, symbols = stock.str,
          initDate = initDate)
initAcct(account.st,
         portfolio.st,
         initDate = initDate, initEq = initEq)
initOrders(portfolio.st, …
Run Code Online (Sandbox Code Playgroud)

r quantmod quantstrat

1
推荐指数
1
解决办法
293
查看次数

使用R中的quantmod包装载日本的库存信息

我遇到了使用R/quantmod包的一个问题.我可以获得韩国的股票信息,但我没有获得日本的信息:

getSymbols("DEXKOUS",src="FRED") #load Korea
[1] "DEXKOUS"
getSymbols("DEXJPUS",src="FRED") #load Japan   
Error as.POSIXlt.character(x, tz, ...) : 
  character string is not in a standard unambiguous format
Run Code Online (Sandbox Code Playgroud)

欢迎您的意见.


sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936 
[2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936   
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
[4] LC_NUMERIC=C                                                   
[5] LC_TIME=Chinese (Simplified)_People's Republic of China.936    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] PerformanceAnalytics_1.0.3.2 quantmod_0.3-17              TTR_0.21-0                  
 [4] xts_0.8-2                    zoo_1.7-4 …
Run Code Online (Sandbox Code Playgroud)

r quantmod

0
推荐指数
1
解决办法
725
查看次数

在R中获取多年的股票年度财务数据

假设我想要在R Rross Profit on Total Revenue中回归.我需要这方面的数据,越多越好.我发现CRAN上有一个非常有用的库:quantmod,它可以满足我的需要.

library(quantmod)
getFinancials(Symbol="AMD", src="google")
#to get the names of the matrix: rownames(AMD.f$IS$A)
Total.Revenue<-AMD.f$IS$A["Revenue",]
Gross.Profit<-AMD.f$IS$A["Gross Profit",]

#finally:
reg1<-lm(Gross.Profit~Total.Revenue)
Run Code Online (Sandbox Code Playgroud)

我所遇到的最大问题是这个库只能获取4年的数据(4次观察,并且只有4次观察才能进行回归).有没有其他方式(可能是其他库)可以获得超过4年的数据?

r quantitative-finance quantmod

0
推荐指数
1
解决办法
5321
查看次数

过滤 xts 格式的日期索引

我从 FRED 下载了一些费率,如何过滤索引日期以便仅保留“2010”之后的日期?

在此输入图像描述

r quantmod

-3
推荐指数
1
解决办法
2524
查看次数

标签 统计

quantmod ×6

r ×6

curl ×1

quantitative-finance ×1

quantstrat ×1

ssl ×1

url ×1