始める無料で始める

累積支払いとホームエクイティ

あなたは毎月きちんと住宅ローンを返済していますが、実際に家のどれだけを自分が所有しているのか、そして長年でどれだけの利息を合計で支払ったのかは分かりにくいものです。

np.cumsum() を使って、時間の経過とともにすべての利息支払いを合計し、元金の支払いも合計して、所有割合がどのように変化していくかを確認しましょう。

np.cumsum() は時系列に沿った累積和を計算し、単一の数値ではなく反復的な合計の系列を返すことを思い出してください。

前の演習で作成した principal_paidinterest_paidhome_valuedown_payment_percent が利用できます。

この演習はコースの一部です

Pythonで学ぶファイナンス入門

コースを見る

演習の手順

  • 元金支払いに np.cumsum() を適用して、時間とともに増える cumulative_home_equity を計算します。
  • 同様にして cumulative_interest_paid を計算します。
  • 時間ごとのホームエクイティの割合を計算します(頭金を加えるのを忘れないでください!)。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

import numpy as np

# Calculate the cumulative home equity (principal) over time
cumulative_home_equity = ____

# Calculate the cumulative interest paid over time
cumulative_interest_paid = ____

# Calculate your percentage home equity over time
cumulative_percent_owned = ____ + (____/____)
print(cumulative_percent_owned)

# Plot the cumulative interest paid vs equity accumulated
plt.plot(cumulative_interest_paid, color='red')
plt.plot(cumulative_home_equity, color='blue')
plt.legend(handles=[interest_plot, principal_plot], loc=2)
plt.show()
コードを編集して実行