Last active
February 24, 2020 12:46
-
-
Save brishtiteveja/8b0cb14fe7b5a765fdcfe71fd7632f8c to your computer and use it in GitHub Desktop.
Thrivecash Balance Calculation/Loan Repayment
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
# Thrivecash lending app | |
print("Thrivecash lending app balance calculation.") | |
print() | |
print ("What's the APR(Annual percentage rate %) I am paying for this loan? Is it better than the traditional credit card or personal loans?") | |
print() | |
print("Links for further info on Quora: https://www.quora.com/What-is-ThriveCash") | |
print() | |
# Money you borrowed | |
Bini = 5000 | |
print("1. I borrowed ", Bini, "$ from Thrivecash.") | |
# number of installment you want to pay it back | |
n = 8 | |
print("2. I want to pay back in", n, "installments.") | |
# Total Extra to be paid to Thrivecash | |
E = 339.68 | |
print("3. Thrive cash is charging me extra", E, "$") | |
# Total to be paid to Thrivecash | |
T = Bini + E | |
print("4. I am in total paying", T, "$ to Thrivecash for this loan.") | |
# Delayed payment (How many initial month you can wait to pay to Thrivecash?) | |
w = 5 | |
print("5. I am taking this loan because I want to delay my payment for", w, "months during this period of transition from school life to worklife.") | |
# Put the first 5 months when you are not paying | |
months_delayed = ["Feb", "Mar", "Apr", "May", "Jun"] | |
rest_of_months_in_a_year = ["Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan"] | |
months = months_delayed + rest_of_months_in_a_year | |
days_in_months = {} | |
days_in_months["Jan"] = 31 | |
days_in_months["Feb"] = 28 | |
days_in_months["Mar"] = 31 | |
days_in_months["Apr"] = 30 | |
days_in_months["May"] = 31 | |
days_in_months["Jun"] = 30 | |
days_in_months["Jul"] = 31 | |
days_in_months["Aug"] = 31 | |
days_in_months["Sep"] = 30 | |
days_in_months["Oct"] = 31 | |
days_in_months["Nov"] = 30 | |
days_in_months["Dec"] = 31 | |
days_passed = 0 | |
for m in months_delayed: | |
days_passed += days_in_months[m] | |
B = [Bini for i in range(w+1 + n)] | |
print("") | |
for i in range(w): | |
print("My balance on", i,"-th month (", months[i] , ")", "is", "B[", i, "]: ", B[i]) | |
# APR (Annual percentage rate) | |
apr = 12/100 # 12% | |
k = 5 | |
print("") | |
print("Days passed before loan payment starts = ", days_passed) | |
# Monthly payment (k-th Month after w) (k > 5) | |
M_k = T/n | |
print("") | |
print("6. My Monthly payment from 6-th month will be", M_k, "$") | |
print("") | |
days_in_year = 365 | |
B[k] = B[k-1] + B[k-1] * apr * days_passed/days_in_year - M_k | |
m_k = k % 12 | |
p_i = 1 | |
print("My Payment No. ", p_i) | |
print("My current balance on", k,"-th month (", months[m_k] , ")", "is", "B[", k, "]: ", B[k]) | |
print("") | |
for i in range(n-1): | |
k = (w+1) + i | |
p_i += 1 | |
print("My Payment No. ", p_i, ":", M_k, "paid to Thrivecash.") | |
m_k = k % 12 | |
days_passed = days_in_months[months[m_k]] | |
print("days passed since last payment = ", days_passed) | |
B[k] = B[k-1] + B[k-1] * apr * days_passed/days_in_year - M_k | |
print("My current balance on", k,"-th month (", months[m_k] , ")", "is", "B[", k, "]: ", B[k]) | |
print("") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Program Output with 9.5% APR:
Thrivecash lending app balance calculation.
What's the APR(Annual percentage rate %) I am paying for this loan? Is it better than the traditional credit card or personal loans?
Links for further info on Quora: https://www.quora.com/What-is-ThriveCash
My balance on 0 -th month ( Feb ) is B[ 0 ]: 5000
My balance on 1 -th month ( Mar ) is B[ 1 ]: 5000
My balance on 2 -th month ( Apr ) is B[ 2 ]: 5000
My balance on 3 -th month ( May ) is B[ 3 ]: 5000
My balance on 4 -th month ( Jun ) is B[ 4 ]: 5000
Days passed before loan payment starts = 150
My Payment No. 1
My current balance on 5 -th month ( Jul ) is B[ 5 ]: 4527.7454794520545
My Payment No. 2 : 667.46 paid to Thrivecash.
days passed since last payment = 31
My current balance on 6 -th month ( Aug ) is B[ 6 ]: 3896.817562841058
My Payment No. 3 : 667.46 paid to Thrivecash.
days passed since last payment = 30
My current balance on 7 -th month ( Sep ) is B[ 7 ]: 3259.7847684687213
My Payment No. 4 : 667.46 paid to Thrivecash.
days passed since last payment = 31
My current balance on 8 -th month ( Oct ) is B[ 8 ]: 2618.626319545818
My Payment No. 5 : 667.46 paid to Thrivecash.
days passed since last payment = 30
My current balance on 9 -th month ( Nov ) is B[ 9 ]: 1971.6131277943268
My Payment No. 6 : 667.46 paid to Thrivecash.
days passed since last payment = 31
My current balance on 10 -th month ( Dec ) is B[ 10 ]: 1320.0610748117358
My Payment No. 7 : 667.46 paid to Thrivecash.
days passed since last payment = 31
My current balance on 11 -th month ( Jan ) is B[ 11 ]: 663.25197855234
My Payment No. 8 : 667.46 paid to Thrivecash.
days passed since last payment = 28
My current balance on 12 -th month ( Feb ) is B[ 12 ]: 0.6255409165844412