Is coding in Python useful for traders?

Years ago, coding was not seen as a necessary universal skill in banks. The people who coded in banks, were developers. On a trading desk, unless you were one of those quants pricing exotic options or working in electronic trading, it was likely that Excel was your main analytic tool of choice. However, today, it seems increasingly the case that everyone wants to learn to trade, not just the quants and developers in banks. Why is that the case? Excel is a useful tool. However, it struggles under large amounts of data. Spreadsheets which were usable, become brittle under the weight of calculations which they were never designed for. The first step to coding was often VBA to try to automate spreadsheets. You can do a lot with VBA, but equally it can be limiting.


These days, I get a lot of questions from traders about Python (and somewhat inspired by this, I decided to write this article). In particular, they’re thinking about learning Python. Is coding in Python useful for traders? I would say almost certainly yes, if you want to spend the time to learn it. Whilst Python is one of the easier programming languages out there, it still takes time to get good at it and requires an investment of time. Reading books can help, but ultimately, hours spend tinkering with code and developing stuff yourself is what will make you learn. Ultimately the benefit of learning Python for a trader, is that they can apply their domain knowledge using coding as a way to solve problems. In other words, they are a trader who also has coding skills. That I think is key being able to blend the skills of market insight with coding.


At the same time, I think it’s important to learn Python properly (I would say this applies to coding in general). If a Python script is only going to be used once or twice, then maybe it doesn’t matter that much if it’s not that maintainable. However, if something is going to be run again and again, it becomes important for that code to be written well, with comments and in a reusable way (and no CTRL-C and CTRL-V is not code reuse, as I remember a lecturer telling me many years ago at university!). Please don’t be that person who never puts comments in code because it’s “obvious”. Peppering your code with one letter variables, makes it quicker to read, but somewhat longer to understand!

It’s also key that traders don’t end up simply redoing code available elsewhere in the organisation. That basically ends up reinventing the wheel many time over. Instead, tools developed by quants and tech teams in financial organisations for commonly used financial functions need to be opened up to easily used by the trading desk in their own Python scripts. This could range from option pricing to functions for interpolation of rates curves etc.


So yes, it’s useful for traders to learn to code, it helps to solve some questions quicker, compared to using Excel. However, ultimately, a trader’s first job is, well, trading! Coding should be seen as tool to help with trading (rather than vice-versa) and if you do want to learn to code, it’s worth putting in the time and effort to learn it well.