Historical data¶

In [1]:
%load_ext autoreload
%autoreload 2
from import_src import *

Data have been taken from http://www.lazyportfolioetf.com .

Stocks¶

  • Russell 2000 - American Small-Cap market ETF
  • VSS - FTSE All-World ex-US Small-Cap ETF
  • EFA - ex-US Large-Cap market ETF tracking EAFE
  • VTI - CRSP US Total Market Index
  • VTV - Vanguard Value linked to the MSCI US Prime Market Value Index
  • VNQ - US REIT ETF
  • VUG - CRSP US Large Cap Growth Index ETF
  • GLD - Gold
  • DBC - Commodities
  • IJS - iShares S&P Small-Cap 600 Value

Bonds¶

  • BND - Vanguard Total Bond Market
  • SHY - iShares 1-3 Year Treasury Bond
  • TIP - iShares TIPS Bond (index composed of inflation-protected U.S. Treasury bonds)

Analytics¶

In [2]:
from src.statistics import get_max_first_year
from src.data.shares import SHARES_DATA

max_first_year = get_max_first_year(SHARES_DATA.values())
print("max_first_year", max_first_year)
max_first_year 1992

Monthly returns plot¶

In [3]:
import numpy as np
import pandas as pd
import plotly.express as px
from src.statistics import get_max_returns_from_same_year, get_max_first_year, calc_returns_amount_list
from src.plot_utils import get_monthly_data_range
from src.data.shares import SHARES_DATA

max_first_year = get_max_first_year(SHARES_DATA.values())
init_amount = 1000
data = [calc_returns_amount_list(init_amount, x) for x in get_max_returns_from_same_year(SHARES_DATA.values())]

df = pd.DataFrame(
    np.array(data).transpose(), columns=list(SHARES_DATA.keys()), index=get_monthly_data_range(max_first_year, 2021)
)

fig = px.line(df, x=df.index, y=df.columns)
fig.show(renderer="notebook+pdf")

Correlations¶

In [4]:
import numpy as np
from src.statistics import get_correlation_table_view, get_stocks_std_view, calc_annual_geometric_mean
from src.data.shares import SHARES_DATA

stock_names = list(SHARES_DATA.keys())
corr_table = get_correlation_table_view(SHARES_DATA)

index = stock_names
columns = ["From year", "Mean ret.", "Std", "|", *stock_names]

splitter_column = ["|"] * len(index)
from_column = [x.first_year for x in SHARES_DATA.values()]
annual_mean_column = [f"{round(calc_annual_geometric_mean(x), 2)}%" for x in SHARES_DATA.values()]
std_column = get_stocks_std_view(SHARES_DATA)

df = pd.DataFrame(
    np.array([from_column, annual_mean_column, std_column, splitter_column, *corr_table]).transpose(),
    columns=columns,
    index=index,
)
df
Out[4]:
From year Mean ret. Std | VTI VTV S&P 500 EAFE VUG Russell 2000 IJS EAFE Small-Cap VNQ (REIT) GLD DBC BND TIP SHY
VTI 1972 10.98% 15.55% | - 94.93% 98.88% 70.62% 96.05% 89.34% 87.45% 73.6% 61.69% 1.88% 17.08% 16.64% 12.02% 4.38%
VTV 1972 11.47% 14.94% | 94.93% - 95.69% 69.5% 85.68% 80.81% 85.77% 71.39% 63.0% -0.55% 17.74% 17.66% 11.27% 6.0%
S&P 500 1972 10.88% 15.18% | 98.88% 95.69% - 69.77% 96.52% 83.2% 82.64% 71.32% 58.45% 0.38% 15.51% 17.7% 13.8% 5.61%
EAFE 1986 7.08% 17.4% | 70.62% 69.5% 69.77% - 65.17% 62.51% 62.86% 85.57% 50.36% 12.83% 32.65% 9.71% 14.7% -8.3%
VUG 1972 11.1% 16.8% | 96.05% 85.68% 96.52% 65.17% - 80.92% 75.98% 66.28% 52.26% 0.84% 12.25% 17.49% 13.74% 5.74%
Russell 2000 1985 10.13% 19.74% | 89.34% 80.81% 83.2% 62.51% 80.92% - 94.13% 71.96% 62.29% -3.13% 24.19% 0.76% 4.25% -19.11%
IJS 1972 14.07% 18.62% | 87.45% 85.77% 82.64% 62.86% 75.98% 94.13% - 71.33% 69.7% -0.74% 18.6% 12.15% 5.26% 2.81%
EAFE Small-Cap 1992 7.95% 16.47% | 73.6% 71.39% 71.32% 85.57% 66.28% 71.96% 71.33% - 57.33% 18.85% 47.89% 5.91% 16.29% -21.97%
VNQ (REIT) 1972 11.48% 17.09% | 61.69% 63.0% 58.45% 50.36% 52.26% 62.29% 69.7% 57.33% - 5.77% 14.96% 18.19% 26.78% 3.73%
GLD 1972 7.6% 19.9% | 1.88% -0.55% 0.38% 12.83% 0.84% -3.13% -0.74% 18.85% 5.77% - 27.34% 7.79% 31.15% 7.08%
DBC 1971 8.21% 18.7% | 17.08% 17.74% 15.51% 32.65% 12.25% 24.19% 18.6% 47.89% 14.96% 27.34% - -3.46% 26.03% -1.32%
BND 1972 6.72% 5.3% | 16.64% 17.66% 17.7% 9.71% 17.49% 0.76% 12.15% 5.91% 18.19% 7.79% -3.46% - 84.43% 87.64%
TIP 1992 6.16% 5.88% | 12.02% 11.27% 13.8% 14.7% 13.74% 4.25% 5.26% 16.29% 26.78% 31.15% 26.03% 84.43% - 61.74%
SHY 1977 5.54% 3.03% | 4.38% 6.0% 5.61% -8.3% 5.74% -19.11% 2.81% -21.97% 3.73% 7.08% -1.32% 87.64% 61.74% -

Monthly returns plot with older data¶

No EAFE, EAFE Small-Cap, Russell 2000, TIP

In [5]:
from collections import OrderedDict
import numpy as np
import pandas as pd
import plotly.express as px
from src.statistics import get_max_returns_from_same_year, get_max_first_year, calc_returns_amount_list
from src.plot_utils import get_monthly_data_range
from src.data.shares import SHARES_DATA

removed_shares = ["EAFE", "EAFE Small-Cap", "Russell 2000", "TIP"]

older_shares_data = OrderedDict(filter(lambda x: x[0] not in removed_shares, SHARES_DATA.items()))

max_first_year = get_max_first_year(older_shares_data.values())
init_amount = 1000
data = [calc_returns_amount_list(init_amount, x) for x in get_max_returns_from_same_year(older_shares_data.values())]

df = pd.DataFrame(
    np.array(data).transpose(),
    columns=list(older_shares_data.keys()),
    index=get_monthly_data_range(max_first_year, 2021),
)

fig = px.line(df, x=df.index, y=df.columns)
fig.show(renderer="notebook+pdf")