今回は15年間の積立投資シミュレーションです。

SP500とオルカンを毎月10万円15年間
積み立てたらどうなるかをシミュレーションします。


解説動画はこちら




S&P500 VS オールカントリー

今回は積立投資のシミュレーションです。

15年間積立投資を続けていたら、いくらになるのか
レバレッジかけた場合も合わせて検証してみます。


Yファイナンスの株価データを元に
シミュレーションしていきます。

Yファイナンスでの取得コードは
オルカン(ACWI)
S$P500(^GSPC)
となっているので、簡単にデータを取得できます。

シミュレーション条件は
2010年9月から2025年9月までの
15年間分(180ヶ月)のデータで
毎月10万円(新NISAの1800万円分)

という条件で行きたいと思います。

レバレッジは2倍と3倍のも
追加して検証していきます。



Yファイナンスの株価データを取得する


Google ColabではYファイナンスのライブラリで
簡単に株価を取得できるようになっています。

早速データを取得していきましょう。
import yfinance as yf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

# オルカン(All Country World Index)
acwi_ticker = "ACWI"

# S&P 500
sp500_ticker = "^GSPC"

# 過去15年間の株価データを取得
acwi = yf.download(acwi_ticker, start="2010-09-01", end="2025-09-05")
sp500 = yf.download(sp500_ticker, start="2010-09-01", end="2025-09-05")
acwi_close = acwi["Close"]
sp500_close = sp500["Close"]
acwi_monthly = acwi_close.resample("MS").first()
sp500_monthly = sp500_close.resample("MS").first()
取得用の株価コードは
オルカン : ACWI
S$P500 : ^GSPC
となっていて

株価コード、開始日、終了日を
指定するだけで簡単にデータ取得できます。



株価推移をプロット


この15年間の両者の株価をプロットしてみます。
# オルカン
plt.figure(figsize=(14, 3))
plt.plot(acwi_close, label="ACWI")
plt.title("ACWI - Past 15 Years")
plt.ylabel("Closing Price")
plt.legend()
plt.grid(True)
plt.show()
# S&P500
plt.figure(figsize=(14, 3))
plt.plot(sp500_close, label="S&P 500")
plt.title("S&P 500 - Past 15 Years")
plt.ylabel("Closing Price")
plt.legend()
plt.grid(True)
plt.show()

download-2
download-3

株価が違いすぎるので、一緒にプロットできないので
正規化して、同じプロット内で表示してみましょう。
# 正規化
acwi_norm = acwi_close / acwi_close.iloc[0]
sp500_norm = sp500_close / sp500_close.iloc[0]

# グラフの作成
plt.figure(figsize=(14, 5))
plt.plot(acwi_norm, label="ACWI")
plt.plot(sp500_norm, label="S&P 500")
plt.title("ACWI vs S&P 500 - Past 15 Years")
plt.ylabel("Norm Price")
plt.legend()
plt.grid(True)
plt.show()
download-1

この15年で株価は何倍になっています。

このデータを用いてシミュレーションしていきます。


積み立てシミュレーション


これが今回のシミュレーション用の関数です。
# --- シミュレーション関数 ---
def simulate_investment(prices, monthly_invest=100000, leverage=1.0):
    returns = prices.pct_change().dropna()
    shares = 0.0
    portfolio = []

    for i, r in enumerate(returns):
        # 毎月積立で購入
        shares += monthly_invest / prices.iloc[i]
        shares *= (1 + r * leverage)  # レバレッジ調整後の値動き
        portfolio.append(shares * prices.iloc[i+1])  # 翌月末時点の評価額

    portfolio = pd.Series(portfolio, index=returns.index)
    return portfolio

実際にシミュレーションするコードはこちら
毎月の投資額を入力すると計算、可視化できます。
# データの結合
df = pd.concat([acwi_monthly,sp500_monthly],axis=1)
# 毎月の投資額
monthly_invest = 100000

# 直近のみに絞るならコメントアウト外す
#df = df.tail(60)

df_assets = pd.DataFrame({
    "S&P500_1x": simulate_investment(df["^GSPC"], monthly_invest, leverage=1.0),
    "S&P500_2x": simulate_investment(df["^GSPC"], monthly_invest, leverage=2.0),
    "S&P500_3x": simulate_investment(df["^GSPC"], monthly_invest, leverage=3.0),
    "ACWI_1x": simulate_investment(df["ACWI"], monthly_invest, leverage=1.0),
    "ACWI_2x": simulate_investment(df["ACWI"], monthly_invest, leverage=2.0),
    "ACWI_3x": simulate_investment(df["ACWI"], monthly_invest, leverage=3.0)
})
df_assets["Input_Amount"] = [(i+1) * monthly_invest for i in range(len(df_assets))]
# プロット
plt.figure(figsize=(14, 5))
plt.plot(df_assets.index, df_assets["S&P500_1x"], label="S&P500 (1x)", color="orange")
plt.plot(df_assets.index, df_assets["ACWI_1x"], label="ACWI (1x)", color="blue")
plt.plot(df_assets.index, df_assets["S&P500_2x"], label="S&P500 (2x)", color="orange", linestyle="-.")
plt.plot(df_assets.index, df_assets["ACWI_2x"], label="ACWI (2x)", color="blue", linestyle="-.")
plt.plot(df_assets.index, df_assets["S&P500_3x"], label="S&P500 (3x)", color="orange", linestyle="--")
plt.plot(df_assets.index, df_assets["ACWI_3x"], label="ACWI (3x)", color="blue", linestyle="--")
plt.plot(df_assets.index, df_assets["Input_Amount"], label="Input Amount", color="black")
plt.title("S&P500 vs ACWI leverage simulation")
plt.ylabel("Asset amount")
plt.grid(True)
plt.legend()
ax = plt.gca()
ax.yaxis.set_major_formatter(ticker.ScalarFormatter(useOffset=False))
ax.ticklabel_format(style="plain", axis="y")
plt.show()
download-4

直近5年に絞り込むには
df のコメントアウトの部分を外して
直近分に絞り込みするとできます。

download

どれもこれも、ずっと持ち続けていたら
資産はすごいことになっていたでしょうね。

レバレッジをかけた商品の場合
上下動が激しすぎて
途中で手放してしまった
なんてこともありそうです。

ずっと持ち続けていたら
投資額を上回っていた、ということにはなります。

この株価のデータは今後も同じ動きをするわけではないので
再現性は0ですが、積立投資自体は
悪い選択肢ではないかなと思っています。

今後両者がどのような動きをするかは
気になるところです。

今回は
SP500とオルカンの
積立投資シミュレーションでした。

それでは。