Using Python to Analyze Real Estate Investments

Anthony Morast
Level Up Coding
Published in
8 min readApr 7, 2021

--

Real estate is an imperishable asset, ever increasing in value. It is the most solid security that human ingenuity has devised. It is the basis of all security and about the only indestructible security.

— Russell Sage

Buy and hold real estate investing can be very satisfying and, oftentimes, very lucrative. In his book, One Up on Wall Street, even legendary stock picker Peter Lynch recommends buying a home before picking individual stocks in the stock market due to its investment potential (although some of his message comes off slightly sarcastic). Unlike with stocks and bonds purchasing real estate allows you to use a large amount of leverage with most investments requiring 20–25% as a down payment (this is a majority of the cash required to close the deal with the smaller portion being closing costs). Using 20% as a down payment allows you to purchase an asset worth 5x the amount you actually have to spend so a 2% increase in the home’s value results in a 10% return on the cash you have invested (in the ideal case). Furthermore, unlike the leverage available for stocks and bonds, your mortgage servicer isn’t going to be calling you and demanding more cash if the price of your real estate fluctuates due to market conditions. I’m not saying to avoid stocks and bonds as I’m an avid investor myself, but I think real estate investing is certainly worth a look.

One key to success in real estate investing (as with any type of investing) is learning how to determine a good deal from a bad deal. For real estate, the property’s condition, location, and other qualitative factors largely affect the potential income of a property. To accurately determine these factors knowledge and experience in a specific market is usually required. However, some aspects that are under the control of novice and experienced real estate investors alike involve the numbers. Quantitative factors such as determining the maximum amount to pay for a property, the potential cash flow, and the returns on the cash invested can easily be determined with the use of a calculator. In this post, Python will be used to analyze real estate deals to help weed out the good deals from the bad deals.

Real Estate Return Metrics

--

--

I am a professional software engineer and an amateur mathematician. My main interests are programming, machine learning, fluid dynamics, and a few others.