• Stars
    star
    335
  • Rank 125,435 (Top 3 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created over 6 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Teaches step-by-step to analysis stock data in python.

Contributors Forks Stargazers Issues MIT License LinkedIn

Buy Me A Coffee

Simple Stock Analysis in Python

This is a tutorial for Simple Stock Analysis in jupyter and python. There are two versions for tutorials. One is a jupyter version and the other one is a 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 want to learn about stock analysis and want 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 advanced coding: https://github.com/LastAncientOne/Stock_Analysis_For_Quant.

The order is from #1 through #26.

You learn number 1 first and you go in order. Once you have finished, you will know how to write code in python and understand finance and the 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://github.com/LastAncientOne/100_Day_Challenge

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

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 (Understand Trendline)

Buy Me A Coffee

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.

More Repositories

1

Stock_Analysis_For_Quant

Various Types of Stock Analysis in Excel, Matlab, Power BI, Python, R, and Tableau
Jupyter Notebook
1,632
star
2

Deep_Learning_Machine_Learning_Stock

Deep Learning and Machine Learning stocks represent promising opportunities for both long-term and short-term investors and traders.
Jupyter Notebook
1,191
star
3

Mathematics_for_Machine_Learning

Learn the mathematics behind machine learning and explore various mathematical concepts within machine learning.
Jupyter Notebook
39
star
4

Trading-Strategies-in-Emerging-Markets-Coursera

Design your own Trading Strategy
Jupyter Notebook
34
star
5

Data-Science

Utilizing Kaggle Data and Real-World Data for Data Science and Prediction in Python, R, Excel, Power BI, and Tableau.
Jupyter Notebook
23
star
6

Beverages_Long_Term_Investment

Long-Term Investment in the Beverage Industry
Jupyter Notebook
15
star
7

SimpleStockAnalysisR

Tutor step-by-step on how to analyze stock data using the R language.
Jupyter Notebook
14
star
8

100_Day_Challenge

100 day Challenge writing codes daily
Jupyter Notebook
13
star
9

LastAncientOne

My personal repository
8
star
10

Scrape_Data

Scrape Data from Twitter, Facebook, Yahoo, and other websites
Jupyter Notebook
6
star
11

Home_Improvement_Retail_Investment

Select the optimal investment for housing and home construction.
Jupyter Notebook
5
star
12

Technology_Investment

Analyzing and investing Technology Stocks
R
4
star
13

GDP_Project

GDP Forcasting
4
star
14

ASL_Signing

Jupyter Notebook
2
star
15

Covid-19_Vaccines_Investment

Find the best investment opportunity among vaccine companies.
Jupyter Notebook
2
star
16

Electric_Cars_Investment

Investing in the Long-Term Future of Electric Cars
Jupyter Notebook
1
star
17

AMD-vs-NVDA

Analyzing 2 technology stocks using Master Analyst Program (MAP).
Jupyter Notebook
1
star