Skip to content
Stock Analysis Tutorial in Python
Branch: master
Clone or download
Latest commit a471fb3 Apr 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
01_SimpleFetchStockData.ipynb Rename 1_SimpleFetchStockData.ipynb to 01_SimpleFetchStockData.ipynb Apr 21, 2019
02_SimpleStockDate.ipynb Rename 2_SimpleStockDate.ipynb to 02_SimpleStockDate.ipynb Apr 21, 2019
03_SimpleStockCharts.ipynb Rename 3_SimpleStockCharts.ipynb to 03_SimpleStockCharts.ipynb Apr 21, 2019
04_SimpleTechnicalAnalysisLibrary.ipynb Rename 4_SimpleTechnicalAnalysisLibrary.ipynb to 04_SimpleTechnicalAn… Apr 21, 2019
05_SimpleStockCSV.ipynb Rename 5_SimpleStockCSV.ipynb to 05_SimpleStockCSV.ipynb Apr 21, 2019
06_SimpleStockStyleTable.ipynb Add files via upload Apr 21, 2019
07_SimpleYahooStockScrape.ipynb Add files via upload Apr 21, 2019
08_SimpleFinanceNewsScrape.ipynb Rename 8_SimpleFinanceNewsScrape.ipynb to 08_SimpleFinanceNewsScrape.… Apr 21, 2019
09_SimpleScrapeWikiSP500.ipynb Add files via upload Apr 21, 2019
10_SimpleStockMultiIndex.ipynb Rename SimpleStockMultiIndex.ipynb to 10_SimpleStockMultiIndex.ipynb Apr 21, 2019
11_SimpleFundamentalAnalysis.ipynb Rename 10_SimpleFundamentalAnalysis.ipynb to 11_SimpleFundamentalAnal… Apr 21, 2019
12_SimpleStockStatistics.ipynb Rename 11_SimpleStockStatistics.ipynb to 12_SimpleStockStatistics.ipynb Apr 21, 2019
13_SimpleStockChartScripts.py Rename SimpleStockChartScripts.py to 13_SimpleStockChartScripts.py Apr 21, 2019
14_SimpleStockClasses.ipynb Rename SimpleStockClasses.ipynb to 14_SimpleStockClasses.ipynb Apr 21, 2019
15_SimpleStockAnalysis_Final.ipynb Rename 13_SimpleStockAnalysis_Final.ipynb to 15_SimpleStockAnalysis_F… Apr 21, 2019
16_SimpleStockIndicators.ipynb Rename SimpleStockIndicators.ipynb to 16_SimpleStockIndicators.ipynb Apr 21, 2019
17_SimplePivotPoint.ipynb Rename SimplePivotPoint.ipynb to 17_SimplePivotPoint.ipynb Apr 21, 2019
18_SimpleStockVWAP.ipynb Rename SimpleStockVWAP.ipynb to 18_SimpleStockVWAP.ipynb Apr 21, 2019
19_SimpleStockTrendlines.ipynb Add files via upload Apr 21, 2019
20_SimpleStockSignals.ipynb Rename SimpleStockSignals.ipynb to 20_SimpleStockSignals.ipynb Apr 21, 2019
21_SimpleStockSignalsRSI.ipynb Rename SimpleStockSignalsRSI.ipynb to 21_SimpleStockSignalsRSI.ipynb Apr 21, 2019
22_SimpleStockBacktesting.ipynb Rename SimpleStockBacktesting.ipynb to 22_SimpleStockBacktesting.ipynb Apr 21, 2019
23_SimpleTimeseries.ipynb Rename SimpleTimeseries.ipynb to 23_SimpleTimeseries.ipynb Apr 21, 2019
24_Simple_Kelly_Criterion.ipynb Rename Simple_Kelly_Criterion.ipynb to 24_Simple_Kelly_Criterion.ipynb Apr 21, 2019
25_SimpleStockPredictionMachineLearning.ipynb Rename SimpleStockPredictionMachineLearning.ipynb to 25_SimpleStockPr… Apr 21, 2019
26_SimpleStockPredictionTensorFlow.ipynb Rename SimpleStockPredictionTensorFlow.ipynb to 26_SimpleStockPredict… Apr 21, 2019
README.md Update README.md Apr 21, 2019
stock_chart.png Add files via upload Apr 2, 2019

README.md

Simple Stock Analysis in Python

This is tutorial for Simple Stock Analysis. 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 for people that want to learn python for stock analysis.

The order is from #1 through #26. You learn number 1 first and you go in order.

Prerequistes

Python 3.5+

Jupyter Notebook Python 3

Dependencies

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

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.

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://github.com/LastAncientOne/100_Day_Challenge

If you want to learn more advance stock analyze or different language in finance, go to: https://github.com/LastAncientOne/Stock-Analysis

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

If you want to learn about Mathematics behind deep learning or machine learning, go to: https://github.com/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

Authors

  • Tin Hang

Disclaimer

Do not use this code for investing or trading in the stock market. However, if you are interest in the stock market, you should read books that relate to stock market or finance.

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

You can’t perform that action at this time.