Awesome Open Source
Awesome Open Source

Simple Stock Analysis in Python

This is tutorial for Simple Stock Analysis in jupyter and python. There are two versions for stock tutorial. One is jupyter version and the other one is python. Jupyter also makes jupyter notebooks, which used to be called iPython notebooks. However, Python is an interpreted high-level programming language. It is very simple and easy to understand for beginners that wants to learn about stock analysis and wants to become a quant. In addition, this tutorial is for people that want to learn coding in python to analyze the stock market. However, if you already know about stock analyzing or coding in python this will not be for you. You can check out more advance coding: https://awesomeopensource.com/project/LastAncientOne/Stock_Analysis_For_Quant.

The order is from #1 through #26.

You learn number 1 first and you go in order. Once you finished, you will know how to write codes in python and understand finance and stock market. ㊗️

Prerequistes

Python 3.5+
Jupyter Notebook Python 3

Dependencies

  • fix_yahoo_finance or yfinance
  • TensorFlow 1.10.0
  • Pandas
  • Numpy
  • ta-lib
  • matlibplot
  • sklearn

How to install library

conda install -c ranaroussi yfinance

pip install yfinance --upgrade --no-cache-dir

Input

Pick a symbol, you want to analyze.

symbol = '...' <-- ... input a symbol

Pick a 'start' date and 'end' date for certain time frame to analyze.

start = '...' & end = '...' <-- input a date


Examples

# Libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

import warnings
warnings.filterwarnings("ignore")

# fix_yahoo_finance is used to fetch data 
import fix_yahoo_finance as yf
yf.pdr_override()

# input
symbol = 'AAPL' # Apple Company
start = '2018-01-01'
end = '2019-01-01'

# Read data 
df = yf.download(symbol,start,end)

# View Columns
df.head()

Example Stock Charts:

Example Stock Scripts

In command DOS drive 'C:\ '

Find where you put the code .py in?

How to run python scripts in command prompt(cmd) or Windows PowerShell?

Type: python SimpleStockChartScripts.py

🍎 List of questions for simple stock tutorial in python:


  1. How to get data from yahoo, quandl, or other sites?
  2. How to scrape historical data, fundamental data, and news data?
  3. How to analyze the stock data?
  4. How to make a trendlines?
  5. How to use Technical Analysis and Fundamental Analysis?
  6. How to add and save to csv file?
  7. How to customize table and make beautiful plot?
  8. How to create class and function for stock?
  9. How to create and run scripts?
  10. How to applied statistics and timeseries for stock?
  11. How to create buy and sell signals?
  12. How to create stock prediction in machine learning and deep learning?
  13. How to create simple stock strategy?
  14. Example of python libraries for Technical Analysis and fetching historical stock prices.

❌ If the code does not load or reload, click here: 👉 https://nbviewer.jupyter.org/
Paste the link in the box.

I tried to make it simple as possible to understand finance data and how to analyze the data by using python language.

If you want to learn different simple function for stock analysis, go to: https://awesomeopensource.com/project/LastAncientOne/100_Day_Challenge

If you want to learn more advance stock analysis or different language in finance, go to: https://awesomeopensource.com/project/LastAncientOne/Stock_Analysis_For_Quant

If you into deep learning or machine learning for finance, go to: https://awesomeopensource.com/project/LastAncientOne/Deep-Learning-Machine-Learning-Stock

If you want to learn about Mathematics behind deep learning or machine learning, go to: https://awesomeopensource.com/project/LastAncientOne/Mathematics_for_Machine_Learning

Reading Material

https://www.investopedia.com/terms/s/stock-analysis.asp (Basic Stock Analysis)

https://www.investopedia.com/articles/investing/093014/stock-quotes-explained.asp (Understand Stock Data)

https://www.investopedia.com/terms/t/trendline.asp (Understand Trendline)

Authors

  • Tin Hang

Disclaimer

🔻 Do not use this code for investing or trading in the stock market. Stock market is unpredictable. 📈 📉 However, if you are interest in the stock market, you should read many 📚 books that relate to the stock market, investment, or finance. The more books you read, the more you will understand and the more knowledge you gain. On the other hand, if you are into quant or machine learning, read books about 📘 finance engineering, machine trading, algorithmic trading, and quantitative trading.

This is not get rich quick and is for researching and educational purposes.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Jupyter Notebook (230,760) 
Python3 (32,410) 
Time Series (1,878) 
Time Series (1,878) 
Stock (1,271) 
Stock Market (890) 
Time Series Analysis (563) 
Financial Analysis (230) 
Financial Data (230) 
Technical Analysis (220) 
Stock Data (214) 
Stock Prices (185) 
Stock Trading (151) 
Stock Analysis (146) 
Related Projects
Advertising 📦 9
All Projects
Application Programming Interfaces 📦 120
Applications 📦 181
Artificial Intelligence 📦 72
Blockchain 📦 70
Build Tools 📦 111
Cloud Computing 📦 79
Code Quality 📦 28
Collaboration 📦 30
Command Line Interface 📦 48
Community 📦 81
Companies 📦 60
Compilers 📦 60
Computer Science 📦 74
Configuration Management 📦 39
Content Management 📦 167
Control Flow 📦 197
Data Formats 📦 77
Data Processing 📦 266
Data Storage 📦 132
Economics 📦 60
Frameworks 📦 198
Games 📦 122
Graphics 📦 103
Hardware 📦 148
Integrated Development Environments 📦 47
Learning Resources 📦 147
Legal 📦 28
Libraries 📦 119
Lists Of Projects 📦 21
Machine Learning 📦 336
Mapping 📦 61
Marketing 📦 15
Mathematics 📦 55
Media 📦 228
Messaging 📦 97
Networking 📦 304
Operating Systems 📦 84
Operations 📦 120
Package Managers 📦 52
Programming Languages 📦 229
Runtime Environments 📦 96
Science 📦 42
Security 📦 375
Social Media 📦 26
Software Architecture 📦 70
Software Development 📦 68
Software Performance 📦 57
Software Quality 📦 127
Text Editors 📦 45
Text Processing 📦 131
User Interface 📦 310
User Interface Components 📦 465
Version Control 📦 29
Virtualization 📦 68
Web Browsers 📦 38
Web Servers 📦 25
Web User Interface 📦 194