Day 4: Deep study of Python List – Essential Data Structure for Algo Trading
Welcome to Day 4! In our “100 Days of Hell with Python Algorithmic Trading” journey, today we will talk about Python List, which is a very important and flexible data structure. It plays a special role in quantitative trading and algorithmic analysis.
What is Python List?
A Python List is a data type that allows you to store multiple items under the same name. It works like a dynamic array, meaning you can add or remove data from it at runtime.
For example:
trade_logs = [109, “Apple”, 111.6, True]
In this, we have stored all four types of data types – integer, string, float and boolean – in a single list – which makes it extremely flexible.
List vs Array: What is the difference?
1. Dynamic vs Fixed Size
- When creating an array, its size has to be fixed in advance.
- There is no such restriction in List, you can add items as you want.
2. Homogeneous vs Heterogeneous
- Array stores the same type of data types (such as all integers or all strings).
- You can store data of different types together in a list.
3. Ease of Use
- In Python, it can be more difficult to manage arrays than lists because arrays may require a module like numpy.
- Lists are an inbuilt and simple option of Python.
How are Python lists stored in memory?
Python lists are a kind of collection of objects, and every item has a reference. This means that if you change a value in a list, it only updates the memory reference of that value.
Because of this, lists are not very memory-efficient, but they are great in terms of flexibility.
Important Characteristics of Python Lists

1. Ordered Structure
Items in lists are stored in a sequence, and their order remains.
2. Mutable
The most special thing about a list is that you can change its items – this is called mutable.
3. Allow Duplicates
You can also keep duplicate items in the list.
4. Heterogeneous Support
List supports different types of data simultaneously – like int, str, float, bool, etc.
Operations of Python Lists
You can perform many types of operations on Python Lists:
Append: my_list.append(“BTC”)
Insert: my_list.insert(1, “ETH”)
Remove: my_list.remove(“BTC”)
Pop: my_list.pop()
Sort / Reverse: Sorting or reversing the list is also easy.
Use of Python Lists in Algo Trading
Storing Trading Data
You can store the log of trades, opening and closing prices, timestamps, etc. in the list.
For Backtesting
By storing old data in the list, you can backtest your trading strategies.
Indicator Calculations
Lists are also used in the calculation of indicators like Moving Average, RSI.
Disadvantages of Python Lists
- Low Performance: Lists have a separate reference for each item, which leads to lower performance than arrays.
- Memory Inefficient: Occupies more memory space due to heterogeneous support and mutability.
- Less Structured: For large datasets, they are not as structured as numpy arrays or pandas dataframes.
Three-Step Learning Strategy
In this course, we have a three-step process:
- Learning Concepts – Understand each concept thoroughly as per today.
- MCQs and Tasks – We have specially curated questions that will further strengthen your understanding.
- Mini Projects – There are mini projects on each topic so that you can implement in real time.
Watch this Day 4 video tutorial
Day 4: Python Lists