Warren Buffet once advised investors to be “fearful when others are greedy, and greedy when others are fearful.” Today, according to fund manager Guy De Blonay, eighty percent of daily moves in the U.S. are done by machines (CNBC). Investors rarely face human competition anymore, therefore cannot benefit from the extortion of another’s fear or greed. Luckily, the market is a see-saw. It’s our job to be fearful or greedy, but we need pure logic to help us decide how to feel. When we leverage what our computers were built to do, it allows us to lean into our one asset that cannot be replaced: humanity.

Another (CNBC article) reinforces the same idea: “It’s no secret that machines are taking up a bigger and bigger share of investing, but the extent of their influence is approaching shocking proportions.”

Below, I have outlined a coding process to completely automate daily algorithmic-based analysis and deliver the day’s top-10 highest and lowest stock options right to your inbox. Automating this analysis process allows lone investors more time to reason through sentiment, giving us an advantage over the increasingly robotic trading in today’s market.


Automating Stock Analysis Using Python

In an effort to make this automation process doable for people with little to no programming experience, I will review the code from top to bottom and offer further resources. If you are completely new to Python, I recommend reading this article for a simple walk-through of the installation and startup process. Pay extra attention to the comments in the code below to gain a better understanding of the what each line of code does.

Programming is a skill best acquired by practice rather than from books. — Alan Turing


Importing Necessary Libraries

In order to make use of existing functions when automating our stock analysis, we must first import the necessary libraries. We can do this with a couple simple lines of code.

# Necessary Libraries
	import yfinance as yf, pandas as pd, shutil, os, time, glob, smtplib, ssl
	from get_all_tickers import get_tickers as gt

Import the necessary libraries.

Here is a breakdown of the use-case for each library:

  • Yfinance: Gather historical/ relevant data on each stock.
  • Pandas: Work with large sets of data.
  • ShutilGlob, and OS: Accessing folders/files on the computer.
  • Time: Forcing the program to pause for a period of time.
  • Smtplib and SSL: Sending a report over email.
  • Get_All_Tickers: Filter through all stocks to get the list you desire.

#python #automation #data-science #stock-market #analysis

A Guide to Automating Your Stock Analysis With Python
73.05 GEEK