今回は今話題のFIREについて
検証用のプログラムを作ってみました。

解説動画はこちら




三度の飯よりお金が好きな
乙pyです。

今話題のFIREとは?

Financial Independence , Retire Early
経済的自立と早期リタイアという
訳になると思いますが
資産を手に入れて経済的な自立を
手に入れようというものです。


FIREの目安

月々の生活費の25倍の資産を持つのが目安で
利率4%(5%運用で1%税引き)で運用すれば
生活費=運用益なので資産が減らなくなります。

そうすれば働かなくても
生活費を賄うことができます。

今回はFIREをしたいなと思いましたので
シミュレーターで検証してみましょう。

プログラムはGoogle Colabなどで
利用できるので試してみて下さい。
from matplotlib import pyplot as plt
import numpy as np
import ipywidgets as widgets
from IPython.display import display

out_text = '最終金額 : {0:,} ,年間生活費 : {1:,} \n年間利息 : {2:,} , FIRE倍率 : {3}\n'

# FIREシミュレーター
def show_widgets():
    button = widgets.Button(description='シミュレーション')
    s0 = widgets.IntSlider(value=200000  , min=10000  , max=1000000, step=10000 , description='月の生活費:')
    s1 = widgets.IntSlider(value=2000000, min=0 , max=10000000, step=100000 , description='初期金額:')
    s2 = widgets.IntSlider(value=200000  , min=0 , max=1000000  , step=10000   , description='月の積立金:')
    s3 = widgets.FloatSlider(value=4.0, min=0.1, step=0.1, max=20.0, description='利率:')
    s4 = widgets.IntSlider(value=10  , min=1 , max=50  , step=1 , description='年数:')
    output0 = widgets.Output(layour={'border': '1px solid black'})
    output1 = widgets.Output()
    ax = plt.gca()
    
    def on_click(b: widgets.Button) -> None:
        ax.clear()
        cost = s0.value
        initial = s1.value
        reserve = s2.value
        rate = s3.value
        year = s4.value
        rand_x = []
        money = initial
        for i in range(1,year):
            money += reserve * 12
            money = int(money*(1+rate/100))
            rand_x.append(money)
        f_rate = money / (cost * 12)
        result = '{0:.4}倍'.format(f_rate)
        Interest = int(money*(rate/100))
        ax.plot(list(range(1,len(rand_x)+1)),rand_x)
        ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, loc: "{:,}".format(int(x))))
        with output0:
            output0.clear_output(wait=True)
            out = out_text.format(money, cost * 12 , Interest , result)
            if f_rate>25:
              out += 'FIRE達成しました!!'
            print(out)
        with output1:
            output1.clear_output(wait=True)
            display(ax.figure)
            
    button.on_click(on_click)
    box1 = widgets.Box([s0,s1])
    box2 = widgets.Box([s2,s3])
    box3 = widgets.Box([s4,button])
    display(box1 , box2 , box3 , output0,output1)
    plt.close()
    button.click()
    
show_widgets()

実行すると


スクリーンショット 2022-02-19 16.17.10

こんな感じでスライダーが出てきます。

月の生活費
初期金額
月の積立金
利率
年数
これを変えてシミュレーションボタンを押すと
結果が下にでます。

最終金額
年間生活費 
年間利息
FIRE倍率
これが出ます。

FIRE倍率25倍を越すと達成の表示が出ます。

これを使う際は
生活費や積み立て金を決めて何年経つと
資産がどれくらいになるか・とか

XX年でFIREするには積み立てや利率を
どうすれば良いか・・みたいなのを
シミュレーションできますんで
色々変えて遊んでみて下さい。

手取りで40万くらいないと
月々20万円を運用に回すの厳しいなー
こりゃあしんどい!!!!

というわけで
FIRE結構大変そうですね!
是非遊んでみて下さい

それでは。