码迷,mamicode.com
首页 > 其他好文 > 详细

房贷方式与投资估算

时间:2018-07-31 22:04:26      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:nbsp   exp   actor   划算   rate   不用   ons   ota   range   

 1 #!/usr/bin/env python
 2 # -*- coding: utf-8 -*-
 3 # @Time    : 2018/07/31 16:24
 4 import math
 5 from itertools import izip, izip_longest
 6 
 7 
 8 total_mort = 182.0  # * 100k
 9 
10 ir_sd = 4.9 / 100.0
11 ir_gjj = 3.25 / 100.0
12 
13 ir_ivst = 15.0 / 100.0
14 
15 
16 cf10k_sd = 53.0726  # 30 year
17 cf10k_gjj = 70.2668   # 15 year
18 
19 
20 yf_month = 1.0/12.0
21 
22 
23 def print_cfs(name, cfs):
24     print === {} cfs: ===.format(name)
25     for idx, cf in enumerate(cfs):
26         print cf,  ,
27         if 0 == (1 + idx) % 12:
28             print \n
29     print \n
30 
31 
32 def gjj_mort2cfs(gjj_mort):
33     sd_mort = total_mort - gjj_mort
34     print gjj_mort, gjj_mort
35     print sd_mort, sd_mort
36     gjj_cfs = 15 * 12 *[cf10k_gjj * gjj_mort]
37     sd_cfs = 30 * 12 * [cf10k_sd * sd_mort]
38     # print_cfs(‘gjj‘, gjj_cfs)
39     # print_cfs(‘sd‘, sd_cfs)
40     return gjj_cfs, sd_cfs
41 
42 
43 def gen_yfs2now(month_amt):
44     return [m * yf_month for m in xrange(1, month_amt + 1)]
45 
46 
47 def gen_yfs2future(month_amt):
48     return [m * yf_month for m in xrange(month_amt - 1, -1, -1)]
49 
50 
51 def disc_factor(yf, ir):
52     return math.exp(-1.0 * yf * ir)
53 
54 
55 def compound_factor(yf, ir):
56     return math.exp(1.0 * yf * ir)
57 
58 
59 def pv_of_cfs(cfs):
60     yfs = gen_yfs2now(len(cfs))
61     return sum([cf * disc_factor(yf, ir_sd) for cf, yf in izip(cfs, yfs)])
62 
63 
64 def fv_of_cfs(cfs):
65     yfs = gen_yfs2future(len(cfs))
66     return sum([cf * compound_factor(yf, ir_ivst) for cf, yf in izip(cfs, yfs)])
67 
68 
69 if __name__ == __main__:
70     for x in range(3):
71         gjj_mort = x * 50.0
72         print ===== gjj_mort =====, gjj_mort
73 
74         gjj_cfs, sd_cfs = gjj_mort2cfs(gjj_mort)
75         cfs = [gjj_cf + sd_cf for gjj_cf, sd_cf in izip_longest(gjj_cfs, sd_cfs, fillvalue=0.0)]
76         # print_cfs(‘mortgage‘, cfs)
77         print pv:, pv_of_cfs(cfs)
78         ivst_const = 11378.6333
79         ivst_cfs = [ivst_const - cf for cf in cfs]
80         # print_cfs(‘ivst‘, ivst_cfs)
81         fv_invst = fv_of_cfs(ivst_cfs)
82         print fv_invst:, fv_invst
83 
84         invst_cfs_tmp = [0.0] * len(cfs)
85         invst_cfs_tmp[-1] = fv_invst
86         # print_cfs(‘invst_cfs_tmp‘, invst_cfs_tmp)
87         print pv_invst:, pv_of_cfs(invst_cfs_tmp)

 

结论是:当投资收益水平低于年化7.5%时,用足公积金更划算,当投资收益水平高于7.5%时,不用公积金收益更高。

房贷方式与投资估算

标签:nbsp   exp   actor   划算   rate   不用   ons   ota   range   

原文地址:https://www.cnblogs.com/tlz888/p/9397570.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!