🏠
シミュ: 賃貸🆚持ち家
元ネタ:
上記の記事が非常に興味深かったので、勝手に拡張して複数シナリオを一覧してみた。
暗黙の前提
- 賃貸派:
- 初動は不動産の代わりに金融資産に投資する。
- 引退後は家賃コストがかかる。
- 家賃にコストがかかる。
- 持ち家派:
- 初動は金融資産の代わりに不動産に投資する。
- 引退後に家賃コストがかからない。
- 家賃の代わりにローン返済の費用がかかる。
- どちらも引退後は金融資産の配当を収入にする。
- 不動産の上昇益はない。
コード
from typing import NamedTuple
STOCK_TAX_RATE = 0.20315
class Scenario(NamedTuple):
"""holding simulation parameters
stock_tax_rate: キャピタルゲイン税および配当税
initial_value: 単位(万円)
monthly_surplus: 単位(万円)
initial_monthly_rent: 単位(万円)
"""
name: str
growth_rate: float = 0.08
dividend_rate: float = 0.0116
rent_inflation_rate: float = 1.0
stock_tax_rate: float = STOCK_TAX_RATE
initial_value: int = 1000
monthly_surplus: int = 21
initial_monthly_rent: int = 12
years_until_retire: int = 30
dividend_rate_after_retire: float = 0.04
def get_tax_deducted_rate(self):
return 1 - self.stock_tax_rate
def get_actual_dividend_rate(self):
return self.dividend_rate * self.get_tax_deducted_rate()
class Result(NamedTuple):
name: str
rent_inflation_rate: float
total_investment: float
monthly_income: float
inflated_monthly_rent: float
def __str__(self):
return (
f"= {self.name} =\n"
f"Rent Inflation Rate:\t{self.rent_inflation_rate:0.3f}\n"
f"Monthly income:\t{self.monthly_income:0.4f}\n"
f"Inflated monthly rent:\t{self.inflated_monthly_rent:0.4f}\n"
f"Total amount of the investment:\t{self.total_investment:0.4f}\n"
)
def simulate_income_after_retirement(scenario: Scenario):
# init
s = scenario
earning = 0
total = s.initial_value
inflated_monthly_rent = s.initial_monthly_rent
# run
for i in range(s.years_until_retire):
growth = total * s.growth_rate
earning += growth
total += growth
dividend = total * s.get_actual_dividend_rate()
total += dividend
monthly_surplus = s.monthly_surplus - inflated_monthly_rent
total += monthly_surplus * 12
# ending
inflated_monthly_rent *= s.rent_inflation_rate
# result
tax = earning * s.stock_tax_rate
capital_gain = total - tax
dividend_rate = s.dividend_rate_after_retire * s.get_tax_deducted_rate()
yearly_income = capital_gain * dividend_rate
return Result(
s.name, s.rent_inflation_rate,
total, yearly_income / 12, inflated_monthly_rent)
if __name__ == "__main__":
scenarios = [
Scenario("-0.5%", rent_inflation_rate=0.995),
Scenario("±0.0%"),
Scenario("+0.5%", rent_inflation_rate=1.005),
Scenario("+1.0%", rent_inflation_rate=1.010),
Scenario("+1.5%", rent_inflation_rate=1.015),
Scenario("+0.5%, tax=30%", rent_inflation_rate=1.005,
stock_tax_rate=0.3),
Scenario("buy house", rent_inflation_rate=1.005,
initial_value=0, initial_monthly_rent=16),
]
for s in scenarios:
print(simulate_income_after_retirement(s))
結果
= -0.5% =
Rent Inflation Rate: 0.995
Total amount of the investment: 28322.6544
Monthly income: 62.6986
Inflated monthly rent: 10.3765
= ±0.0% =
Rent Inflation Rate: 1.000
Total amount of the investment: 27509.2062
Monthly income: 60.8090
Inflated monthly rent: 12.0000
= +0.5% =
Rent Inflation Rate: 1.005
Total amount of the investment: 26636.4353
Monthly income: 58.7776
Inflated monthly rent: 13.8675
= +1.0% =
Rent Inflation Rate: 1.010
Total amount of the investment: 25699.0447
Monthly income: 56.5916
Inflated monthly rent: 16.0140
= +1.5% =
Rent Inflation Rate: 1.015
Total amount of the investment: 24691.2206
Monthly income: 54.2367
Inflated monthly rent: 18.4798
= +0.5%, tax=30% =
Rent Inflation Rate: 1.005
Total amount of the investment: 25952.1948
Monthly income: 45.3142
Inflated monthly rent: 13.8675
= buy house =
Rent Inflation Rate: 1.005
Total amount of the investment: 6900.2097
Monthly income: 15.4103
Inflated monthly rent: 18.4900
ref
class typing.NamedTuple
Discussion