We're the top company on Modern Data Stack! Give us an upvote here.
bubbles svg

UK Property Affordability Calculator ✨

UK Property Affordability Calculator

Looking to leap into the UK property market? Discover your buying power with our intuitive Affordability Calculator, designed specifically for the UK housing landscape. Whether you’re a first-time buyer or considering your next property adventure, our tool demystifies the numbers for you.

Just enter your salary, savings, and monthly outgoings, and let our calculator do the rest. It will factor in the typical lending criteria, giving you an instant estimate of what you could afford. No need to wonder about mortgage multipliers or sift through your finances – we’ve streamlined the process.

With our Affordability Calculator, embark on your property search with confidence, knowing exactly where you stand. Dive in, it’s the first step to unlocking the door to your new home!

 

👩‍💻 Scroll down to copy the function

 

 

 

 


create or replace function calculate_property_affordability(salary int, savings int, existing_property_value int, monthly_outgoings int, salary_multiplier float, is_first_time_buyer boolean) /* YOU MAY WISH TO CHANGE THE INPUT FIELD DATA TYPE, TO SUIT THE OUTPUT */
returns string
language python
runtime_version = 3.9
handler = 'calculate_property_affordability'
--packages = ('pandas','pandas')
as  
$$

def calculate_property_affordability(salary, savings, existing_property_value=0, monthly_outgoings=0, salary_multiplier=4.45, is_first_time_buyer=False):
                    def stamp_duty(property_value):
                        if is_first_time_buyer:
                            thresholds = [425000, 925000, 1500000]
                            rates = [0.05, 0.10, 0.12]
                        else:
                            thresholds = [250000, 925000, 1500000]
                            rates = [0.05, 0.10, 0.12]
                
                        duty = 0
                        remaining_value = property_value
                
                        for i in range(len(thresholds)):
                            if remaining_value <= thresholds[i]:
                                break
                            taxable_value = min(remaining_value - thresholds[i], thresholds[i+1] - thresholds[i] if i+1 < len(thresholds) else float('inf')) duty += taxable_value * rates[i] remaining_value -= taxable_value if remaining_value > thresholds[-1]:
                            duty += (remaining_value - thresholds[-1]) * rates[-1]
                
                        return duty
                
                    loan_amount = salary * salary_multiplier
                    total_affordability = loan_amount + savings + existing_property_value - (monthly_outgoings * 12)
                
                    # Estimate property value by iteratively subtracting stamp duty until the value converges
                    estimated_value = total_affordability
                    while True:
                        sdlt = stamp_duty(estimated_value)
                        new_estimated_value = total_affordability - sdlt
                        if abs(new_estimated_value - estimated_value) < 1: # Convergence threshold
                            break
                        estimated_value = new_estimated_value
                
                    return estimated_value, stamp_duty(estimated_value)
                
$$;
            

 

 

 

Tables
Controls
Snowpark

More Data Apps like this