Programming/Technical Skills for Finance: SQL and Python

I find that there are a lot of skeptics on WSO as to whether or not programming abilities are useful in finance. Believe it or not, it's more than just for developers and quants. These skills are definitely in high demand and will continue to be for many years to come.

Finance and Programming

In this post, I will give a few basic reasons for learning and using two programming languages (if you want to call them that) in the finance industry: SQL and Python.

best programming language for finance: SQL

The ability to store countless bytes of data in physical drives and (more recently) the cloud has changed the ways that many of today's industries function. You can keep records of what you've done, analyze what others have done, move data from one location to another, the possibilities are endless. All this data is stored in databases and unfortunately, SQL is the main method used to harvest this data.

I say "unfortunately" because SQL is not a great programming language because it's not powerful (see Python below). In finance, where so many decisions are driven by analytics, it still shocks me how many people don't know or don't want to learn SQL.

How did learning SQL help me? You can retrieve the data you want to make an argument. This is especially important if you're junior and your boss (like many senior people in finance) isn't very technical. No intelligent manager would argue with data, and if he does, maybe it's time to find a new job. All the trades of a particular security between certain prices on a given date? Easy. Every company with a multiple higher than 20 that trades on the NYSE? Done. Of course, this is all assuming that your workplaces has the databases that you need to do your work.

And if they don't, maybe you can start a good habit by writing and editing data. In any job, if you want to keep track of something and perform analysis on it some time down the road, SQL may help you get there. One can easily write a script to add to a table daily, and you only have to press "F5" (or "Ctrl+Enter", if you prefer) every morning to get the job done. As Bill Gates put it, "I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it."

Finance with Python

In my opinion, Python is the ultimate flexible programming language today. While it may not be the fastest, it's one of the easiest to learn in that you don't have to memorize weird syntax rules that don't make sense. You don't have to worry about building or compiling code; you can literally type print "Hello World" and click run and it'll work. The open source libraries for Python have tremendous breadth and depth.

How is Python Used in Finance

But how is it useful in finance? Here's a partial list:

  • Financial modeling: If Excel/VBA can do it, Python certainly can (and can probably do more) since it's a full-fledged programming language. Except you're not limited by how much data you can see on your screen and you can run more scenarios efficiently with a few lines of code.
  • Backtesting trades: You can easily code an algorithm in Python and run it on data to see how well your strategy performs. Honestly, it's much easier than coding it in a language that HFT algorithms actually use (like C++).
  • Analyzing data: Remember our friend SQL? Well it's not exactly the most adept at analyzing data; it only retrieves and organizes it. Good thing that Python, with a few packages, allows you to directly import SQL queries and work with the data that it returns in more complex ways.

Again, I could go on, but I'm not even that great at Python. I only picked it up in the last few months to do all of the above. If you have any other programming experience, Python will be a breeze to learn.

tl;dr Give Python and SQL a chance to improve your efficiency at work. Doing the hard things now will make your life easier down the road.

Additional Thoughts on Programming

User @EURCHF parity" shared a detailed post about SQL, Python, Haskell:

EURCHF:
SQL is actually an awesome language. Fully declarative, and with enormous work having gone into the backend (such that your queries can run very fast). You can do a lot more than just select with a few filters. I would really recommend reading up on advanced SQL, query tuning, etc. to get the most out of it.

Python is very easy to get things drafted in, but you will find as you get more experienced that it is messy, buggy and comparatively less well built than other languages like Common Lisp or Haskell. The Python Pandas library was born out of the financial world to add serious performance to R style array languages. Python Pandas is equivalent to R and Octave/Matlab, but R, whilst slower, has enormously more libraries, a really nice easy to use environment in R studio for the beginner, can be programmed like a lisp as you get more advanced, and is completely free. If you would like to invest in one language for data manipulation purposes R is a safe bet. Of course Python is much superior to Java, where "it takes so long to get so little done". Java is banned in my team.

Personally I love Haskell for its power, proximity to mathematics, extraordinary compiler (now faster than C and as fast as well tuned Assembler) and top notch community. Learning Haskell directly (e.g. from LYAH coupled, perhaps, with SICP) will be easier than shifting from an imperative language like Python to the functional paradigm; syntactically it is the cleanest and easiest to pick up vs Scala or Clojure (although Clojure as a lisp is closer to Scheme which you would encounter in SICP; if you are going the lisp way, CL is still a safer bet than Clojure).

As for resources, there is ample available for free on the net. Andrew Ng's Machine Learning course on Coursera is pretty good for a beginner, although in Octave (you can easily rewrite it in R, less easily but more interestingly in Haskell). Other than that, the best is to start 3-4 of what appear to be the top tutorials in your tech stack of choice, and keep going with the best one.

Of course, all this should be done from a linux environment. Dual boot or VM yourself Ubuntu (yes, yes, no geek cred, but it's the most user friendly with the most stuff already written and debugged; BSD is a bit hardcore). Learn to use the command line (takes half an hour).

As for the value in the financial world, I am not 100% sure. I think as you mature as a banker or trader, your instinct and ability to understand humans becomes much more important than your ability to look at data, even in a complex manner. Working on CS knowledge will improve your ability to think quantitatively, certainly, and might also teach you the value of knowing that data is often messed up (and cannot be relied upon).

Decided to Pursue a Wall Street Career? Learn How to Network like a Master.

Inside the WSO Finance networking guide, you'll get a comprehensive, all-inclusive roadmap for maximizing your networking efforts (and minimizing embarrassing blunders). This info-rich book is packed with 71 pages of detailed strategies to help you get the most of your networking, including cold emailing templates, questions to ask in interviews, and action steps for success in navigating the Wall Street networking process.

Networking Guide

 
Best Response

SQL is actually an awesome language. Fully declarative, and with enormous work having gone into the backend (such that your queries can run very fast). You can do a lot more than just select with a few filters. I would really recommend reading up on advanced SQL, query tuning, etc. to get the most out of it.

Python is very easy to get things drafted in, but you will find as you get more experienced that it is messy, buggy and comparatively less well built than other languages like Common Lisp or Haskell. The Python Pandas library was born out of the financial world to add serious performance to R style array languages. Python Pandas is equivalent to R and Octave/Matlab, but R, whilst slower, has enormously more libraries, a really nice easy to use environment in R studio for the beginner, can be programmed like a lisp as you get more advanced, and is completely free. If you would like to invest in one language for data manipulation purposes R is a safe bet. Of course Python is much superior to Java, where "it takes so long to get so little done". Java is banned in my team.

Personally I love Haskell for its power, proximity to mathematics, extraordinary compiler (now faster than C and as fast as well tuned Assembler) and top notch community. Learning Haskell directly (e.g. from LYAH coupled, perhaps, with SICP) will be easier than shifting from an imperative language like Python to the functional paradigm; syntactically it is the cleanest and easiest to pick up vs Scala or Clojure (although Clojure as a lisp is closer to Scheme which you would encounter in SICP; if you are going the lisp way, CL is still a safer bet than Clojure).

As for resources, there is ample available for free on the net. Andrew Ng's Machine Learning course on Coursera is pretty good for a beginner, although in Octave (you can easily rewrite it in R, less easily but more interestingly in Haskell). Other than that, the best is to start 3-4 of what appear to be the top tutorials in your tech stack of choice, and keep going with the best one.

Of course, all this should be done from a linux environment. Dual boot or VM yourself Ubuntu (yes, yes, no geek cred, but it's the most user friendly with the most stuff already written and debugged; BSD is a bit hardcore). Learn to use the command line (takes half an hour).

As for the value in the financial world, I am not 100% sure. I think as you mature as a banker or trader, your instinct and ability to understand humans becomes much more important than your ability to look at data, even in a complex manner. Working on CS knowledge will improve your ability to think quantitatively, certainly, and might also teach you the value of knowing that data is often messed up (and cannot be relied upon); however, if you are already working 20h days, better suck up to your boss and make sure you are promoted instead of spending your free time learning to code.

Lastly, there are exceptional coders out there and they have the cool jobs which are very underpaid vs value added, due to the ample supply of smart people and short supply of good jobs. So don't hope to lateral into programming unless you are really good.

Career Advancement Opportunities

May 2024 Investment Banking

  • Jefferies & Company 02 99.4%
  • Perella Weinberg Partners New 98.9%
  • Lazard Freres 01 98.3%
  • Harris Williams & Co. 24 97.7%
  • Goldman Sachs 16 97.1%

Overall Employee Satisfaction

May 2024 Investment Banking

  • Harris Williams & Co. 18 99.4%
  • JPMorgan Chase 10 98.9%
  • Lazard Freres 05 98.3%
  • Morgan Stanley 05 97.7%
  • Perella Weinberg Partners New 97.1%

Professional Growth Opportunities

May 2024 Investment Banking

  • Lazard Freres 01 99.4%
  • Jefferies & Company 02 98.9%
  • Perella Weinberg Partners 18 98.3%
  • Goldman Sachs 16 97.7%
  • Moelis & Company 06 97.1%

Total Avg Compensation

May 2024 Investment Banking

  • Director/MD (5) $648
  • Vice President (21) $373
  • Associates (91) $259
  • 3rd+ Year Analyst (14) $181
  • Intern/Summer Associate (33) $170
  • 2nd Year Analyst (68) $168
  • 1st Year Analyst (205) $159
  • Intern/Summer Analyst (148) $101
notes
16 IB Interviews Notes

“... there’s no excuse to not take advantage of the resources out there available to you. Best value for your $ are the...”

Leaderboard

1
redever's picture
redever
99.2
2
Secyh62's picture
Secyh62
99.0
3
Betsy Massar's picture
Betsy Massar
99.0
4
BankonBanking's picture
BankonBanking
99.0
5
kanon's picture
kanon
98.9
6
CompBanker's picture
CompBanker
98.9
7
dosk17's picture
dosk17
98.9
8
GameTheory's picture
GameTheory
98.9
9
bolo up's picture
bolo up
98.8
10
Jamoldo's picture
Jamoldo
98.8
success
From 10 rejections to 1 dream investment banking internship

“... I believe it was the single biggest reason why I ended up with an offer...”