DEV Community

Cover image for Calculating the impact of loan discounts with Python
Vini Pereira
Vini Pereira

Posted on • Originally published at dev.to

Calculating the impact of loan discounts with Python

As a self-proclaimed newbie in the wild world of Python (and blogging, for that matter), I recently completed the Introduction to Programming module on Codecademy. It was a wild ride filled with more syntax errors than I care to admit and a fair share of "What does this error message even mean?" moments. But hey, we all start somewhere, right?

During my Codecademy escapades, I dabbled in fundamental programming concepts like object-oriented programming and even managed to string together my first lines of code in Python. While Codecademy's end-of-module project suggestions were all fun and games (literally, with tick-tack-toe and battleship), I craved something a bit more... practical.

Despite being a fledgling Pythonista, I'm already donning the hat of Lead Developer in a Fintech in Australia. Yep, you heard that right. In our team, we're all about developing technology using a no-code first approach with our main platform being Bubble.io.

At Salt&Lime, our mission is as noble as it gets: We want to empower individuals to take control of their finances and domino their debts. We offer socially responsible loans with lower rates and zero fees to help people avoid the pitfalls of the debt cycle spiral, which is a major issue here in Australia.

ABC News: More Australians in debt spiral as buy now, pay later loans increase to cover daily basics

We also support financial education by sending modules to our customers that if completed give them a sweet discount ranging from 0.25% to 0.50% in their loan interest rate. With 12 education modules at the moment, we offer up to a 3.5% discount. But let's be real, visualizing the real impact of these discounts can be as daunting as deciphering a Rubik's Cube blindfolded. Is a measly 0.25% discount enough to get you hyped about financial literacy? Probably not. But what about a cheeky $200 saving? Hold my beer...

This challenge drove the inception of DiscountRunner, a small terminal-based proof of concept aimed at helping us understand the impact of interest rate discounts on loan repayments.

Here's a quick demo:

Calculating discounts: From bytes to bucks

DiscountRunner is a program that uses Python to calculate loan repayments and interest rate discounts intuitively and insightfully. The loan details are encapsulated within a cohesive Loan class, which provides a structured framework for input, analysis, and visualization of repayment scenarios. The program also employs external libraries such as tabulate for table formatting, ensuring accuracy and clarity in presenting financial data.

I used the tabulate library to transform this:

{
    'id': 1,
    'date': '01/03/2024',
    'opening_balance': 5000.00,
    'repayment': 550.00,
    'interest_rate': '3.50%',
    'interest': 100.00,
    'principal': 450.00,
    'closing_balance': 4550.00
}

Enter fullscreen mode Exit fullscreen mode

Into this:
Data tabulated into a fancy terminal table

The program's core functionality lies in its ability to dynamically recalculate loan scenarios based on user-defined discounts, showing the impact of these discounts in the form of interest savings. In the video, I demonstrated how only 5 module discounts applied during the first year of a $20,000 5-year loan can result in almost $900 saved for the borrower. If the same 5 modules were completed during the last year of the loan, the total discount would be less than $25.

Compound interest is really the 8th wonder of the world when used in our favour. This example shows how important it is to provide tools like DiscountRunner to help our customers visualise how informed financial decisions can change their lives, in this case, help them save enough money to buy tickets for holidays in Thailand.

DiscountRunner - Loan interest rate discounts calculator

DiscountRunner is a program that uses Python to calculate loan repayments and interest rate discounts intuitively and insightfully. The loan details are encapsulated within a cohesive Loan class, which provides a structured framework for input, analysis, and visualization of repayment scenarios. The program also employs external libraries such as tabulate for table formatting, ensuring accuracy and clarity in presenting financial data. The program's core functionality lies in its ability to dynamically recalculate loan scenarios based on user-defined discounts, showing the impact of these discounts in the form of interest savings.

What's next?

DiscountRunner is a perfect culmination of theoretical learning and practical application, reflecting the essence of the journey in Computer Science. As I delve deeper into programming and problem-solving, DiscountRunner stands as proof of technology's potential to address real-world challenges.

At Salt&Lime, we remain committed to our mission of enabling individuals to achieve financial freedom. In our roadmap we have an enhanced version of DiscountRunner to be implemented as a feature for our customer app, hopefully providing our users to make informed financial decisions, break free from debt and secure that trip to Thailand next summer.

As I reflect on the journey that led to the creation of this small project, I am reminded of technology's immense potential to drive positive change and empower individuals to shape their destinies, which includes taking control of their finances.

All of a sudden you realise that you are the person who has control of your life. - Jim Henson

These are my personal views and do not necessarily reflect those of my employer.

Cover image by pvproductions on Freepik

Top comments (0)