Created
January 17, 2020 10:43
-
-
Save mgei/48fabcbf7c82e4bec8674aed6c702238 to your computer and use it in GitHub Desktop.
leveraged etf compounding performance lag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(ggplot2) | |
periods <- 10 | |
trend <- 0 | |
vola <- 0.1 | |
leverage <- 2 | |
ret <- rnorm(10, 0, vola) | |
return.df <- data.frame(ret) %>% | |
mutate(period = row_number(), | |
etf = cumprod(ret+1)-1, | |
letf = cumprod(ret*leverage+1)-1, | |
expected = etf*leverage) %>% | |
pivot_longer(cols = c(etf, letf, expected), names_to = "series") | |
return.df %>% | |
ggplot(aes(x = period, y = value, color = series)) + | |
geom_line() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment