Last Updated on April 22, 2023 by mishou

Work in progress.

I. Retriveing the data

Let’s load the historical data of NASDAQ Composite, Dow Jones Industrial Average, and S&P 500 using yfinance and create a dictionary of the tickers and their corresponding data frames.

!pip install yfinanc
import yfinance as yf
import pandas as pd
import datetime
# set the start and end dates
start_date = '2022-01-03'
end_date ='%Y-%m-%d')
# load the data and create a dictionary
# list the ticker symbols
ticker_ls = ["^IXIC", "^DJI", "^GSPC"]
# create a dictionary for each df
dic_df = {}
for ticker in ticker_ls:
    dic_df[ticker] = = ticker, start = start_date, end = end_date, interval = "1d")

II. visualize missing values

Let’s create a heatmap for showing missing values.

# visualize missing values in yellow
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize = (10, 7))
sns.set(font_scale = 1.4)
sns.heatmap(stocks.isnull(), yticklabels=False, cbar=False, cmap='viridis'

III. Moving averages and backtesting the strategies

You can learn the code for Hull Moving Averages and backtesting the strategies from the tutorial linked below:

Hull Moving Average (HMA) Using Python

You can see the code on Google Colaboratory:

This is how to change tickers for creating charts on Google Colaboratory using Find and replace:

On Google colab
on Google colab

You can also learn from the following tutorial:

Reducing Lag in Data — The Hull Moving Average as a Trend Reversal Indicator

IV. Algorithmic trading

RNNs for Algorithmic Trading: Simplified Theory and Python Implementation

By mishou

Leave a Reply

Your email address will not be published. Required fields are marked *