<jupyter_start><jupyter_text>Simple Download Stock Data Site There are many sites you can download or fetch stock historical data or fundamental data such as yahoo, google, alpha vantage, quandl and other sites. Some are free and some you have to paid. Some you will need to sign up and some you do not need to sign up.  1. fix yahoo is the most commonhttps://pypi.org/project/fix-yahoo-finance/<jupyter_code># Libraries
import pandas as pd
import numpy as np

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'
start = '2014-01-01'
end = '2018-01-01'
# Read data 
df = yf.download(symbol,start,end)

# Only keep close columns 
df.head()<jupyter_output><empty_output><jupyter_text>2. pandas_datareaderThis library work sometimes. I recommend not to use to this one.https://pandas-datareader.readthedocs.io/en/latest/<jupyter_code>from pandas_datareader import data as pdr
symbol = 'AAPL'
start = '2014-01-01'
end = '2018-01-01'
data = pdr.get_data_yahoo(symbol, start, end)
data.head()<jupyter_output><empty_output><jupyter_text>3. alpha_vantagehttps://alpha-vantage.readthedocs.io/en/latest/For this one, you will need to sign up and is free. You will get a free api key.https://www.alphavantage.co/support/api-key<jupyter_code>from alpha_vantage.timeseries import TimeSeries
ts = TimeSeries(key='...') # Input your API KEY in ...
# Get json object with the intraday data and another with  the call's metadata
data, meta_data = ts.get_intraday('AAPL')
data.head()<jupyter_output><empty_output><jupyter_text>4. iexfinance<jupyter_code>from iexfinance import Stock
tsla = Stock(symbol)
tsla.get_open()
tsla.get_price()
from datetime import datetime

start = datetime(2014, 1, 1)
end = datetime(2018, 1, 1)

df = get_historical_data("AAPL", start=start, end=end, output_format='pandas')
df.head()<jupyter_output><empty_output><jupyter_text>5. quandl For this one you need to sign up and is very limited.<jupyter_code># import needed libraries
import quandl
token = "..." # Input your token ...
data = quandl.get("WIKI/AAPL", start_date="2014-01-01", end_date="2018-01-01", api_key=token)<jupyter_output><empty_output><jupyter_text>5. Yahoo, Google, or other sites (download csv)This one has historical data and economic data.For example: https://finance.yahoo.com/quote/AAPL/history?p=AAPLYou should see: Download Data and click that icon.<jupyter_code>aapl.to_csv('aapl.csv') # Make sure you have the right directory path
df = pd.read_csv('aapl.csv', header=0, index_col='Date', parse_dates=True)<jupyter_output><empty_output><jupyter_text>6. yahoo-financehttps://github.com/lukaszbanasiak/yahoo-finance<jupyter_code>from yahoo_finance import Share
data = Share('AAPL')
print(data.get_open())
print(data.get_price())
# Get Historical Data
# This one does not show nice dataframe
print(data.get_historical('2014-01-01', '2018-01-01'))<jupyter_output><empty_output><jupyter_text>7. MacrotrendsScrape Datahttps://www.macrotrends.net/<jupyter_code>symbol = 'AAPL'
url = 'https://www.macrotrends.net/assets/php/stock_data_export.php?t=' + symbol
stock_price = pd.read_csv(url, skiprows=10)
stock_price.head()<jupyter_output><empty_output><jupyter_text>8. eoddata-clientThis one is not free. You will need to paid for the service.https://github.com/apologist/eoddata-clienthttp://eoddata.com/<jupyter_code>import os

from eoddata_client import EodDataHttpClient

client = EodDataHttpClient(os.environ['EOD_DATA_LOGIN'],
                           os.environ['EOD_DATA_PASSWORD'])

quotes = client.symbol_history('nasdaq', 'aapl', datetime.date(2014, 1, 1))
quotes['Diff'] = quotes['Close'].shift(1) - quotes['Close']
print(quotes.tail())<jupyter_output><empty_output><jupyter_text>9. yahoo-historicalhttps://pypi.org/project/yahoo-historical/<jupyter_code>from yahoo_historical import Fetcher
data = Fetcher("AAPL", [2014,1,1], [2018,1,1])
print(data.getHistorical())<jupyter_output><empty_output><jupyter_text>10. yahoofinancialsThis one is to get fundamental data.https://github.com/JECSand/yahoofinancials<jupyter_code>from yahoofinancials import YahooFinancials

ticker = 'AAPL'
yahoo_financials = YahooFinancials(ticker)<jupyter_output><empty_output><jupyter_text>11. pandas-finance https://github.com/davidastephens/pandas-finance<jupyter_code>from pandas_finance import Equity
aapl = Equity('AAPL')
aapl.annual_dividend
aapl.dividend_yield
aapl.price
aapl.options
aapl.hist_vol(30)
aapl.rolling_hist_vol(30)<jupyter_output><empty_output><jupyter_text>12. FinanceDataReader https://github.com/FinanceData/FinanceDataReader<jupyter_code>import FinanceDataReader as fdr

# Apple(AAPL), 2017-01-01 ~ Now
df = fdr.DataReader('AAPL', '2017')

# AMAZON(AMZN), 2017
df = fdr.DataReader('AMZN', '2017-01-01', '2017-12-31')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12371346233017702, 'fraction_numerical': 0.03087690407575134, 'mean_word_length': 6.33987915407855, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 13, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '334410', 'license': 'MIT', 'n_tokens_mistral': 1890, 'n_tokens_neox': 1750, 'n_words': 379, 'path': '01_SimpleFetchStockData.ipynb', 'repo_name': 'rogerolowski/SimpleStockAnalysisPython', 'size': '4858'}