gpt4 book ai didi

R 中的砖形图

转载 作者:行者123 更新时间:2023-12-04 09:18:22 25 4
gpt4 key购买 nike

我正在尝试使用从 Yahoo Finance 获得的构建 Renko Chart 并想知道是否有任何包可以这样做。我查看了最多的财务包,但只能找到烛台图表。

有关 Renko 图表的更多信息,请使用给定的链接 here

最佳答案

真的很酷的问题!显然,R 确实没有那种可用的东西。有一些尝试在不同的站点上做类似的事情(例如,瀑布图),但它们都没有完全到位。 Soooo...我用它做了一个小周末项目 .
rrenko
我仍然希望优化一些错误、不稳定性和视觉效果(并且代码中充满了注释掉的调试注释),但主要思想应该在那里。开放获取反馈和改进点。

Caveats: There are still case where the data transformation screws up, especially if the size is very small or very large. This should be fixable in the near future. Also, the renko() function at the moment expects a dataframe with two columns: date (x-axis) and close (y-axis).



安装
devtools::install_github("RomanAbashin/rrenko")
library(rrenko)

代码
renko(df, size = 5, style = "modern") + 
scale_y_continuous(breaks = seq(0, 150, 10)) +
labs(x = "", y = "")

1
renko(df, size = 5, style = "classic") + 
scale_y_continuous(breaks = seq(0, 150, 10)) +
labs(x = "", y = "")

2

数据
set.seed(1702)
df <- data.frame(date = seq.Date(as.Date("2014-05-02"), as.Date("2018-05-04"), by = "week"),
close = abs(100 + cumsum(sample(seq(-4.9, 4.9, 0.1), 210, replace = TRUE))))

> head(df)
date close
1: 2014-05-02 104.0
2: 2014-05-09 108.7
3: 2014-05-16 111.5
4: 2014-05-23 110.3
5: 2014-05-30 108.9
6: 2014-06-06 106.5

关于R 中的砖形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43885357/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com