ドルコスト平均法のご利益をRで理解する

掲題の件、そういう時あると思います。

結論

まあ、ちょっと考えれば自明なんだが、以下です。

  • ドルコスト平均法は平均的なリターンを押し下げる(儲かる投資なら!)効果があるので嬉しくはない
  • ドルコスト平均法は最終的な儲けのバラツキ(標準偏差)を押し下げる効果があるので、これは不確実性を削減出来ているという意味で嬉しい

状況と結果

投資戦略①

①全期間(250日間)において毎日一定金額(1円)を投資した場合の最終的な儲けとそのバラツキ

> performance(s1)
[1] 258.46619  30.96698

投資戦略②

②初日に全額(250円)を投資した場合の最終的な儲けとそのバラツキ

> performance(s2)
[1] 266.92645  53.44526

それぞれのシミュレーションを複数回実行した際の密度描画(①=黒線、②=赤線)。 初日に全額ブチ込んだ戦略のほうが標準偏差がデカイ(当たり前)。 f:id:teramonagi:20211016151327p:plain

Code

library("purrr")
# Simulate Investment
simulate <- function(strategy, return){
  x <- 0
  for(i in seq_len(T)){
    x <- x + strategy[i]
    x <- (1 + return[i]) * x
  }
  x
}
performance <- function(s){
  c(mean(s), sd(s))
}

# Invenstment horizon (days)
horizon <- 250
# Mean Growth rate (/250 means Annualy -> Daily)
mean <- 0.07 / 250
# Volatility (/sqrt(250) means Annualy -> Daily)
vol <- 0.2 / sqrt(250)
size <- 10^3
# Generate return series
xs <- purrr::map(seq_len(size), ~ rnorm(horizon, mean=mean, sd = vol))

# Check the performance of different strategies
s1 <- purrr::map_dbl(xs, ~ simulate(rep(1, horizon), .x))
s2 <- purrr::map_dbl(xs, ~ simulate(c(horizon, rep(0, horizon-1)), .x))
performance(s1)
performance(s2)

plot(density(s1), col=1)
lines(density(s2), col=2)