Financial Analysis using Python- Part 1 (Introduction and basics)

Divya Harshit Jain
5 min readMay 18, 2021
Photo by Paul Calescu on Unsplash

Hey there! Hope you are healthy and safe during these uncertain times. I believe you have logged in here to learn something new today. Keeping up with your expectations we will discuss a few things here:

  • Intro to Python.
  • Setting up (link for detailed setup will be included).
  • What is financial analysis?

By the end of this post, you will have a little knowledge about Python as a programming language and how it is an essential skill for today.

Without any delay, let us get started.

Intro to Python.

Python is a programming language, a sophisticated, easy, and powerful programming language. I can go on and on about its might, and still not be able to fully summarise its value.
In their book “Python for dummies”~ John C. Shovic & Alan Simpson, it is properly illustrated what Python’s might is. I will just borrow a few lines from their book to explain it better:

Python is hot primarily because it has all the right stuff for the kind of software development that’s driving the software development world these days. Machine learning, robotics, artificial intelligence, and data science are the leading technologies today and for the foreseeable future. Python is popular mainly because it already has lots of capabilities in these areas, while many older languages lag behind in these technologies. Just as there are different brands of toothpaste, shampoo, cars, and just about every other product you can buy, there are different brands of programming languages with names such as Java, C, C++ (pronounced C plus plus), and C# (pronounced C sharp).

They’re all programming languages, just like all brands of toothpaste are toothpaste.

The main reasons cited for Python’s current popularity are » Python is relatively easy to learn.

» Everything you need to learn (and do) in Python is free.

» Python offers more ready-made tools for current hot technologies such as data science, machine learning, artificial intelligence, and robotics than most other languages.

I believe that summarises what python is, do check out their book here. This book is really detailed and will most definitely help you get a grasp of this language.

Setting up python.

It is a time-consuming and a little frustrating job to set up python, I would recommend using google colab instead, it is really user-friendly, and the best part is you can use Google’s servers to run the program (best for low end pcs).

So there are two ways to set up python, the easy one and the hard one. I recommend an easy one if you do not perform analysis every day or you use publicly available data. If you use sensitive data then it is better to stick to the 2nd way.

1. Easy way.

Colaboratory, or “Colab” for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser and is especially well suited to machine learning, data analysis, and education.

Step 0. Not essential but highly recommended.
Make a new folder for your collab sheets on your google drive. Go to drive.google.com and create a new folder.

Step 1. Go to colab. you should be greeted with this sort of layout:

Step 3.
Make a new notebook.

Step 4: GET CODING!

2. Hard way.

I use this way because I had become a regular user of python during the lockdown days.
Basically, you need to download a few things and install them.

I won’t get into too much detail here, you can go to this link. He has explained it pretty darn well. Anaconda and Jupyter notebook is the best way to write a program if you are not a CS guy like me.

Remember to organize your files well, you will have a lot of trouble in the future if you don’t. A quick tip, if you have multiple files with the same name and you want to differentiate between the iterations use what developers do with their apps, put a “v*.*.*.*”. Like, if your file is about Pearson Correlation, you can name it Pearson_CO_v1.1.2.1 each stage of development of code can be then saved into a different file, you can make an excel sheet to keep a track of your versions.

What is financial analysis?

Alicia Tuovila defined financial analysis in her Investopedia post.

Financial analysis is used to evaluate economic trends, set financial policy, build long-term plans for business activity, and identify projects or companies for investment. This is done through the synthesis of financial numbers and data. A financial analyst will thoroughly examine a company’s financial statements — the income statement, balance sheet, and cash flow statement. Financial analysis can be conducted in both corporate finance and investment finance settings.

We will take this a little further, and analyze the market data along with other financial data. Market data may include the price history of a company’s share in the share market. Initially, we will be using OHLC (Open High Low Close) prices of specific companies, when we get deeper, we may employ option data and promoter-based data as well.

The best source of this data is the official site of the stock exchange you are working with. In our journey, we will be working with the National Stock Exchange (indices such as Nifty 50, Nifty 500, etc and individual tickers like SBIN, ITC, etc), The Bombay Stock Exchange(indices such as Sensex and individual tickers like SBIN, ITC, etc), The New York Stock Exchange & NASDAQ (National Association of Securities Dealers Automated Quotations) ( S&P 500 as well as individual stock tickers) and the Tokyo Stock Exchange (Nikkei 225).

The data for these exchanges are readily available and is of course free to use. Remember, the methods taught here are limited to your imagination only, do not restrict yourself.

Congratulations! you made it this far, here’s a doggo to lighten you up.

Photo by Undine Tackmann on Unsplash

Conclusion.

In this post, we have discussed a little about the mighty Python. In the coming posts, we will learn a little more. Slowly but surely we will conjure the power to analyze a stock clearly and properly.

In the next post, we will discuss the modules (libraries), a few statistical terms to get started, and write our first line of code to break into the world of financial analysis. It was lovely having you here, (p.s there will be another doggo waiting for you in the next post *wink wink*)

Till then stay safe and learn something new every day to make yourself better than the day before!

--

--

Divya Harshit Jain

Business Administration student | Investment enthusiast | Knows a little programming...