R的Renko图表

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

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

最佳答案 真的很酷的问题!显然,对于R来说,实际上没有任何类型的东西可供使用.有些尝试在不同的网站上做类似的事情(例如,瀑布图),但它们都没有完全达到目的. Soooo ……我用
data.table
ggplot制作了一个小周末项目.

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 = "")

《R的Renko图表》

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

《R的Renko图表》

数据

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
点赞