So you want to learn how to setup Python for Finance? Here’s your simple, step-by-step guide.
Note – this process can take quite a lot of time, and is actually a tad bit frustrating.
BUT, it’ll help build some important fundamentals, which will hold you in really good stead later on.
There is another way to start coding in Python for Finance without any setup whatsoever, but I wouldn’t recommend it if you’re just starting out. But if you still want the shortcut, just head over to http://colab.research.google.com and that should allow you to start coding without any setup whatsoever.
Step 1: Install Python
First and foremost, you want to download and install Python by heading over to https://www.python.org then hover over ‘Downloads’ and download the latest version from there.
Step 2: Install Anaconda
Next, head over to Anaconda.com and download and install the latest version of the Anaconda Distribution System
Anaconda will likely take a while to install, so make sure you have a good cup of tea while you wait!
Step 3: Install Jupyter and iPython
Once that’s installed, open up your terminal / command prompt. If you’re on a Mac, just open spotlight (cmd + space), type “terminal”, and hit enter. That’ll then open up your terminal window. If you’re on a PC, hit the Windows key and then search for “command prompt”, and hit enter. That’ll then open up your command prompt.
Once you’re in, type:
pip3 install --upgrade pip
pip3 install jupyter
pip install ipython
Step 4: Install the essential packages for Python for Finance
Now that you’ve got everything setup, all you need to do is install the most important / essential Python packages for Financial applications. To be fair, a lot of these might already be installed thanks to Anaconda. I personally still run a “pip install” nevertheless and think you’ll be better off doing this, too.
Head over to your terminal and “pip install” all these packages:
To install it, just use the following code by replacing “package_name” with the relevant package above.
pip install package_name
So, to install pandas you’d type:
pip install pandas
Step 5: Choose your “development environment”
You’re pretty much setup now! All you need to do is choose whether you want to work / code in a Notebook environment, or in an “Integrated Development Environment” (IDE) / using a TextEditor.
If you want to work in a “notebook” environment, then just go to your terminal and type:
That’ll then open up a Jupyter Notebook and you’ll be all set to start coding!
If you’d rather work with a TextEditor, then you’ll want to choose one that works well for you. The most common / popular ones are:
The choice of a TextEditor is a very personal one indeed. I personally work with Atom and really enjoy coding in it. Many others prefer SublimeText, and increasingly, Visual Studio.