You are here
Home > Industry > Technology > Coding and Finance

Coding and Finance

Gone are the days where the computer science types are relegated to the back office or equities in Dallas. Having an understanding of computer science and coding is now advantageous in many business careers, including finance and consulting. Granted, writing programs in C++ is still quite rare in front office jobs like investment banking or fixed income sales, but rudimentary coding knowledge is becoming essential in many other finance functions. For example, large portions of trading and origination are being automated with Python, and hiring prioritizes computer science or math majors, or at least business majors with coding experience. On the buy-side, many funds stand to benefit from analytics, with funds looking for more alternative data to gain an edge on the market. Even if you are looking to land traditional front office banking or strategy consulting positions, being able to converse in computer science language can help your career progress faster. Technology and data is becoming increasingly integrated with all jobs, and an understanding of how they work beneath the hood can only do you good.

Coding Basics for Finance

Now I am not a computer scientist, so the terminologies I’ll be using may not be the most orthodox, but if you are a computer scientist you shouldn’t be reading this anyway. In essence, coding involves writing a set of instructions, much like excel functions, that tell your computer what to do. For example, if you want to do some calculations and display the results, you can write print(3*4), and the python interpreter will translate that into machine code which tells the computer (CPU) to make that calculation and print it out. You can think of it as an amped out Excel with more functionalities, but a less intuitive user interface. Building up from these instructions or rules, you can create complex applications like games, social media platforms, and hot dog detection apps.

Some programming purists would tell you that Excel is bad and coding is good, but the truth is that they are all tools, and every tool has its use case. Excel has its own benefits, with its intuitive interface, interoperability, and short learning curve. In general, if the data you’re working with is not too big (more than 100,000 rows), or the analysis you’re running is not too complex, Excel is often sufficient. Where programming really shines is with large sets of data and/or complex analysis that goes beyond linear regression.

Coding in Finance

In finance, coding is typically used for data analysis, rather than making a complete application. For example, you would pull data from some source(s), which could be S&P Capital IQ and/or other alternative data sources, and run analysis to drive some sort of investment thesis or decision. Popular alternative data sources are satellite images and social media data, where there are huge troves of information that could help you get an edge over the markets. The typical workflow is Extract, Clean, Transform, and Analyze, we’ll use a Peloton example since we’re trendy.

Extract Data for Finance

In the example above, you are extracting financial data from S&P Capital IQ and sentiment information from Twitter and Instagram. You can interact with these sources through Application Programming Interfaces (APIs), which are basically web pages for programs. The data would be pulled in a structured format, possibly XML or JSON, which are readily convertible into CSV/Excel. Some data, particularly free data such as social media, can be unstructured, meaning it is not in columns and rows. In this case, you would have to clean the data, which is both critical yet incredibly boring and frustrating.

Clean Data for Finance

When the data is unstructured, say it comes from Twitter, you are getting a blast of text or numbers which you cannot analyze until you get it to a structured format. This step is called cleaning, and it is the most time consuming yet important part of any data analysis workflow. Certainly, this step can be outsourced to cheaper countries or interns, but oftentimes how the data is cleaned will have a profound impact on the subsequent analysis, and the accuracy of the prediction. Cleaning the data yourself is highly recommended, at least for the first time you are doing the analysis.

Say you want to understand the public sentiment of a new product that Peloton introduced, you would pull from Twitter anything that’s #peloton. However, you would get a ton of off-topic tweets as well as misspellings. You would want to establish some sort of rule that filters out any unrelated tweets, should they bias your dataset, and align all the misspellings. There are Python libraries that help you with the misspellings, but relevance detection will require context and insight, both of which are difficult to automate.

Analyze Data for Finance

Now that you have a clean set of data, say for example a set of tweets about Peloton’s new product and their subsequent interactions, you can get to the fun part, data analysis. Data analysis can be split into unsupervised and supervised learning.

Unsupervised Learning

Unsupervised learning takes a set of data and find commonalities within the data, typically with some sort of clustering method. It’s called unsupervised as the human does not need to intervene. For example, if you want to group the tweets by the archetype of people tweeting, eg. students, single adults, married adults, etc., you can use k-nearest neighbors (KNN) provided you have data on the demographics of the people making the tweets.

Supervised learning

Supervised learning typically comes after unsupervised learning, they are your linear regressions or neural networks. Supervised learning allows you to find correlations and make predictions from your inputs. For example, if you want to predict sales of the new Peloton product, you can use natural language processing (NLP), a form of supervised learning, to quantify consumer sentiment from tweets. After which you can use multivariate regression to uncover the relationship between consumer sentiment within the various customer archetypes and the sales of their previous products, to make a prediction on the sales of their new product.

Regardless of what unsupervised and supervised techniques you are using, the essence is the same: with a set of inputs, you are trying to predict an output of which there is business value.

What Programming Language Should You Learn?

Given the context, there are two best in class programming languages: Python and R. These languages are high-level scripting languages, which means they are easy to learn and great for fast prototypes. The trade-off is speed, but you are not going to need that much speed unless you’re working for specific quant shops, in which case you are probably a physics Ph.D. that finds this topic trivial. The distribution of Python you would want to download is Anaconda, which comes with a set of libraries designed specifically for data analysis and machine learning. The most important libraries to learn are Pandas and Numpy, if you want to use machine learning then Tensorflow. Youtube has great tutorials, and if you need help there’s always Stackoverflow.

2 thoughts on “Coding and Finance”

  1. This is a great article for finance area. By the way, in the Clean Data for Finance section, have you tried to analyse it with NLTK library? They have a way to do sentiment analysis.

    1. Hey Ray, good call, there are definitely great libraries that can speed up the cleaning process, I’ll include some common libraries for Natural Language Processing, Machine Vision etc. Which ones do you use?

Leave a Reply

Top