Python is the big thing in finance at the moment. If you’re a trader and you’ve never coded before, the big question is how much Python do you need to know? - Do you really need to give up evenings and weekends to become a proficient coder?
Well, no matter what you’ll be coding, it’s important to know the basics and these concepts will be similar across various programming languages. You'll need to be able to answer questions like, 'What’s a variable?, What are data types?, What are 'if' statements?, What’s a function?'
For trading, specifically, you will need to know how to download market data from sources like Bloomberg and Quandl in Python. There are libraries which make that easy to do, like findatapy (Disclaimer: Yes, I’ve written it, but it’s free and open source).
Then you’ll want start number crunching market data. Pandas is a great tool to learn for this. If you want to dip your toes into machine learning, there’s also scikit-learn. However, personally, I’d recommend trying to understand the basics behind the various machine learning techniques, rather than simply learning how to call functions in scikit-learn.
Once you've learned how to code a script that can analyse the market, you'll need some new skills. - You'll want to plot your output. My favourite tools for visualisation in Python are matplotlib and plotly, and you’ll need to learn at least one of these.
Is that enough Python to get you going as a trader? Well it depends what you want to do! If you’re the only person using the Python code, and it’s not mission critical then that’s a good start already. However, if you want to start giving your code to other folks on the trading desk, you need to get happy with the “engineering” bit of Python. This means learning about software design and making your code reusable (copy and paste is not the code reuse I have in mind!). Also don’t forget about unit tests to make the code less brittle in production. It means understanding how to fetch data and store it in databases.
If you're taking your coding to this level, you'll also need to know how to make your computation more efficient and be able to distribute it. That way it will be able to run in parallel, making it much quicker. This is especially important if you’re dealing with high frequency data.
You may also want to make it easier for users to interact with the code, without needing to know Python. Key to this will be creating an Excel interface (every trader likes Excel!), using a Python tool like xlwings or a web GUI using the flask and dash Python libraries.
My experience is that all the “engineering” bits can often take more time to code than the numerical “calculation” parts. I’ve spent nearly two years developing a Python library for transaction cost analysis, and the number of lines of code for the numerical calculations, have ended up being a tiny proportion of the codebase compared with those parts for data loading, visualisations etc.
It can be pretty daunting to learn Python if you’ve never coded before, but it is doable if you put in the time and in the long run. One way to get a head start is to do a crash course in Python which covers a number of different topics we’ve discussed. But you'll then need to put this into practice, by sitting down and coding yourself.
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.