xts时间序列对象中每月月底的HT指数RSI值

发布于 2024-09-15 10:35:14 字数 325 浏览 2 评论 0原文

首先,我读入 csv 并创建一个 xts 对象。

require(quantmod)

sugar  <- as.xts(read.zoo("SUGAR.CSV", sep=",", format ="%m/%d/%Y", header=TRUE))

然后我使用 TTR 创建一系列新的 RSI 值(使用 quantmod 加载)

sugarRSI <- RSI(sugar)

现在我想获得一个仅包含每个月最后一天的值的新系列。 xts中有一个last()函数,但不清楚如何有效地部署它。

First I read-in a csv and create an xts object.

require(quantmod)

sugar  <- as.xts(read.zoo("SUGAR.CSV", sep=",", format ="%m/%d/%Y", header=TRUE))

Then I create a new series of RSI values using TTR (loads with quantmod)

sugarRSI <- RSI(sugar)

Now I'd like to get a new series that only includes the value of the last day of each month. There is a last() function in xts, but not clear on how to deploy it efficiently.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浸婚纱 2024-09-22 10:35:14

我认为 apply.monthly(sugarRSI, last) 会做你想要的。

I think apply.monthly(sugarRSI, last) will do what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文