COMMENT: Which version of Python should you learn for finance jobs?

eFC logo

In recent years, Python has become one of the main languages for data science, alongside R. Python's preeminence has been helped by the fact that there is a massive ecosystem of libraries for dealing with basic data operations, from NumPy for matrices to pandas for time series. Then you have many of the machine learning libraries like scikit-learn, TensorFlow and PyTorch.

However, not all Python is the same. When you’re getting in Python, it’s worth noting that like any computer language, there are different versions that you could end up using. Here we’ll explain the differences between the various versions.

What is Python 2?

Python 2.0 was first released in 2008 and the last major update was 2.7 in 2010. Python 3.0 was released in 2008. The latest version 3.7 was released last summer.

If you're still using 2.0 now, you're out of date. According to JetBrains Python Developers Survey (from 2018), the vast majority of users (84%) have switched over to Python 3. Of these 54% are using Python 3.6, and 30% are using Python 3.7. The vast majority of Python 2 users, are using 2.7. I expect if a similar survey were done today, it would be even more in favour of Python 3.

It seems pretty obvious, that you should just use Python 3, given it’s the future! After all, it has more features, such as static type checking. New versions of libraries like pandas only support Python 3. Official support for Python 2 is also ending next year.

However, it’s not that simple. The version of Python you use depends on what your firm is using. There are still quite a few banks and financial firms out there who are still using Python 2.7, which means there can still be an advantage to becoming a Python 2 expert. The good news, is that you can generally write a codebase which will for example work with both Python 2.7 and Python 3.7. The code will generally look very similar, so they aren’t totally different languages. In practice the differences in syntax are fairly subtle, such as how print statements are used or the way integer division. However, you have to be aware of these differences.

The bad news is that if you're learning Python 2 you'll find that you can’t use some of the new language features in Python 3. Nor will you be able to use any of the libraries which no longer support Python 2. It’ll take extra time to write the additional code necessary to support both versions. And you’ll have to make sure that any unit tests work with both Python 2 and 3. All these tasks, are an additional time burden. Maintaining code to work in two different environments is never fun and is time taken away from other tasks.

The good news is that if you're learning Python 2, there are some libraries that can be used in Python 2.7 to help you write Python 3 like-code. There's even an automated 2to3 code translator for converting code.

The move to Python 3 in finance has been a long time coming, given that it’s been over a decade since Python 3 has been launched! Perhaps inevitably, firms have been trying to avoid the upgrade given the cost involved in making sure their codebases work with the new version. Most are at least keen to embrace Python 3, even if they haven't yet. I guess we’ll be having the exact same discussion when Python 4 comes along!

Saeed Amen is the founder of Cuemacro. Over the past decade and a half, Saeed Amen has developed systematic trading strategies at major investment banks including Lehman Brothers and Nomura. He is the author of Trading Thalesians: What the ancient world can teach us about trading today (Palgrave Macmillan) and is currently co-authoring The Book of Alternative Data (Wiley) with Alex Denev. Through Cuemacro, he now consults and publishes research for clients in the area of systematic trading. He has developed many Python libraries including finmarketpy and tcapy for transaction cost analysis. His clients have included major quant funds and data companies such as Bloomberg. He has presented his research at many conferences and institutions including the ECB and the Fed. He is also a co-founder of the Thalesians.

Have a confidential story, tip, or comment you’d like to share? Contact: in the first instance. Whatsapp/Signal/Telegram also available.

Bear with us if you leave a comment at the bottom of this article: all our comments are moderated by human beings. Sometimes these humans might be asleep, or away from their desks, so it may take a while for your comment to appear. Eventually it will – unless it’s offensive or libelous (in which case it won’t.)

Related articles