Created
January 24, 2019 09:29
-
-
Save fortable1999/772d131f8972aca02fb9b1d6f5d7c547 to your computer and use it in GitHub Desktop.
キャッシュフロー・金利計算
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
def cashflow(yield_rate, interest, load_rate, yield_correct=0.01,loan_years=25): | |
f = lambda r: 12 * (r * ((1 + r)** 300)) / ((1+r)**300 - 1) | |
i_rate = f(interest / 12.) | |
return 1.0 * (yield_rate - yield_correct) - load_rate * i_rate | |
def ccr(yield_rate, interest, load_rate, yield_correct=0.01,loan_years=25): | |
cf = cashflow(yield_rate, interest, load_rate, yield_correct=0.01,loan_years=25) | |
return cf / (1.0 - load_rate) | |
def ccr_table(interest_list=[0.022, 0.025, 0.028, 0.03], | |
yield_rate_list=[0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1], | |
load_rate_list=[0, 0.3, 0.5, 0.6, 0.7, 0.8, 0.9]): | |
"""docstring for crr_table""" | |
for interest in interest_list: | |
print("金利 %.1f%%" % (interest * 100.,)) | |
print("-----------") | |
# line = "| 表面利回り: %.1f |" % yield_rate * 100; | |
print("|融資割合\t\t|"+ "".join(["%.1f%%\t|" % (y * 100.) for y in load_rate_list])) | |
for yield_rate in yield_rate_list: | |
line = "|表面利回り: %.2f%%\t|" % (yield_rate * 100.); | |
for load_rate in load_rate_list: | |
line += "%0.3f\t|" % ccr(yield_rate, interest, load_rate) | |
print(line) | |
print("-----------") | |
print(ccr_table()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment