Sign in

Written by: Ankush Garg

Logo: Ai4Markets


In this python notebook I have pulled daily end of day matket data from yahoo finance using yfinance API


  1. I created separate python script to pull list of all 500 stocks in S&P500 Index. Link to notebook: Github link, Medium link, LinkedIn Post
  2. List of S&P500 stocks are saved as csv file by name: ‘S&P500Tickers.csv’
  3. Kindly note that the file location of this python script and S&P500 stock list should be same
  1. This notebook pulls daily closing price of each stock starting from the day of its listing on the Exchange
  2. Daily run of this file…

Ai4Markets Logo

In this article I will cover how we can pull list of 500 S&P stocks from Wikipedia and save it in csv file.

Step 1: Get the wikipedia link for S&P 500 stocks

Step 2: use ‘read_html’ pandas built-in function to read the html page. If pandas is not present then install using the command pip install pandas

Step 3: Drop the column ‘SEC filings’ as this column contains link to SEC filing reports. When we write to csv these link will not function. That is why I am deleting this column

Step 4: Sort the list on Symbol (Ticker)…

Logo: Ai4Markets

Written by: Ankush Garg

In this article I will be covering how automation can be done to source daily S&P500 stock prices. I am doing automation on AWS EC2 instance sing Cron Jobs.

Step 1: Setup EC2 instance. Refer to my articles on link: Medium, LinkedIn, GitHub

Step 2: Create python script to source daily stock prices (Open, High, Low, Close and Volume). Refer to my articles link: Medium, LinkedIn, Github

Step 3: Pull S&P500 list of stocks. Refer to article link: Medium, LinkedIn, Github

Step 4: Windows: Copy files from your local machine to EC2 Instance. …

Steps below are more relevant for windows but will work for Mac and Linux. Just select Lunix or Mac installer instead of windows.

R Installation

  1. Go to R-official site:
  2. Click on “download R” or “CRAN” hyperlinks in the page

3. Select the mirror that is closest to your location

Ankush Garg

15 years of professional work experience. I am passionate about latest technologies (Data Analytics, Machine Learning and Artificial Intelligence).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store