计算您的净资产
现在,您已经在考虑职业发展和通胀的前提下,对一段时间内的工资和储蓄进行了预测。这样就构建了一个时间序列,您可以像第 1 章那样用它来计算现金流。
在这个示例中,您只需要用预测的每月工资减去预测的每月支出。每个月剩余的现金流将直接进入您的储蓄账户。
您希望预测随时间推移的累计储蓄,以评估在这些预测下预算流程的效果。
之前练习中的 salary_forecast 和 expenses_forecast 已可用。
本练习是课程的一部分
Python 金融概念入门
练习说明
- 使用对支出和每月工资的预测来计算每月储蓄。
- 计算随时间变化的累计储蓄。
- 打印坚持储蓄 15 年后,您储蓄账户中的金额。
交互式实操练习
通过完成这段示例代码来试试这个练习。
import numpy as np
# Calculate your savings for each month
savings_forecast = ____
# Calculate your cumulative savings over time
cumulative_savings = ____
# Print the final cumulative savings after 15 years
final_net_worth = ____
print("Your final net worth: " + str(round(final_net_worth, 2)))
# Plot the forecasted savings
plt.plot(cumulative_savings, color='blue')
plt.show()