Setting things Up

Algorithmic trading, also known as algo trading, is the use of computer programs to follow a defined set of instructions for placing trades. It is a form of automated trading that allows traders to execute orders with speed and precision. Algo trading helps traders to identify and react to market opportunities faster, reduces emotions, and increases discipline. It also allows traders to track multiple accounts and multiple markets simultaneously.

In this post/video, we will get started with foundational code in python and cover the following introductory material.

• Setting up yfinance library

• Basic Operations and Plotting

• SMA, EMA, Bollinger Bands

• Simple Strategy based on SMA

Python is a popular language for algorithmic trading. It has many libraries and tools for performing data analysis, backtesting, and paper trading. It is also used for developing trading strategies and optimizing them for different markets. Python has many libraries for performing data analysis, backtesting, and paper trading. The most popular libraries include Pandas, Numpy, Scipy, Matplotlib, Scikit-learn, and Statsmodels.


Simple Moving Average : A simple moving average (SMA) calculates the average of a selected range of prices, usually closing prices, by the number of periods in that range.


Exponential Moving Average : An exponential moving average (EMA) is a type of moving average (MA) that places a greater weight and significance on the most recent data points. The exponential moving average is also referred to as the exponentially weighted moving average. An exponentially weighted moving average reacts more significantly to recent price changes than a simple moving average simple moving average (SMA), which applies an equal weight to all observations in the period.


Bollinger Band : A Bollinger Band® is a technical analysis tool defined by a set of trendlines. They are plotted as two standard deviations, both positively and negatively, away from a simple moving average (SMA) of a security's price and can be adjusted to user preferences.


To get started with algorithmic trading, one needs to understand the different strategies and how to implement them. Strategies include mean reversion, momentum, arbitrage, market making, pair trading, and volatility trading. Mean reversion is the theory that suggests that prices tend to revert to their mean or average. Momentum is the theory that suggests that prices move in the same direction for a period of time. Arbitrage is the strategy of taking advantage of differences in prices of the same security in different markets. Market making is a strategy of providing liquidity to the market by buying and selling the same security. Pair trading is the strategy of buying and selling two correlated securities. Volatility trading is the strategy of trading on the volatility of the market.