Chapter 1. Importing and Processing Financial Data in Python
This chapter is dedicated to laying the foundation needed to analyze financial data through coding. This requires some preparation, such as downloading the right software and creating an algorithm that fetches historical data automatically.
By the end of the chapter, you should know how to automatically import historical financial data using Python, a skill that should save you time. So let’s get started.
Installing the Environment
The first step is to prepare the environment and everything else necessary for the success of the algorithms. For this, you need two programs:
- A Python interpreter that you use to write and execute code
- Charting and financial software that you use as a database
Let’s start with the Python interpreter. I use a software called SPYDER. Some people may be more familiar with other software such as Jupyter and PyCharm, but the process is the same. You can download SPYDER from the official website or, even better, download it as part of a bigger package called Anaconda, which facilitates installation and offers more tools. Note that it is open source, free-to-use software.
SPYDER’s interface is split into three windows, as you can see in Figure 1-1. The window on the left is used to write the code that is later executed (the algorithm is told to run and apply the code). Typically, you will see multiple lines of code in that area.
The window on the upper right is the variable explorer. Every time ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access