Stock market data analysis using Python code example

Example 1: python get stock data

import yfinance as yf
import matplotlib.pyplot as plt
# Get the data for the stock Apple by specifying the stock ticker, start date, and end date
data = yf.download('AAPL','2016-01-01','2018-01-01') 
# Plot the close prices
data.Close.plot()
plt.show()

Example 2: live stock market data python

import urllib.request import json  class GoogleFinanceAPI:     def __init__(self):         self.prefix = "http://finance.google.com/finance/info?client=ig&q="          def get(self,symbol,exchange):         url = self.prefix+"%s:%s"%(exchange,symbol)         u = urllib.request.urlopen(url)         content = u.read().decode('utf-8')         obj = json.loads(content[3:])         return obj[0]                   if __name__ == "__main__":     c = GoogleFinanceAPI()     quote = c.get("RELIANCE","NSE")     print(quote)

Example 3: python stock prediction code

# Make sure that you have all these libaries available to run the code successfully
from pandas_datareader import data
import matplotlib.pyplot as plt
import pandas as pd
import datetime as dt
import urllib.request, json
import os
import numpy as np
import tensorflow as tf # This code has been tested with TensorFlow 1.6
from sklearn.preprocessing import MinMaxScaler