0% found this document useful (0 votes)
67 views

Python Stock Live Pandas

The document imports necessary Python libraries for financial analysis and data visualization. It retrieves stock price data for Apple (AAPL) from Yahoo Finance and plots the data using cufflinks, adding Bollinger bands and MACD indicators. Required modules include Pandas, Pandas datareader, and scikit-learn for retrieving and analyzing stock market data from sources like Morningstar. Tesla (TSLA) stock data is retrieved from 2015 to present, with date set as the index and symbol column dropped.

Uploaded by

david_windarto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Python Stock Live Pandas

The document imports necessary Python libraries for financial analysis and data visualization. It retrieves stock price data for Apple (AAPL) from Yahoo Finance and plots the data using cufflinks, adding Bollinger bands and MACD indicators. Required modules include Pandas, Pandas datareader, and scikit-learn for retrieving and analyzing stock market data from sources like Morningstar. Tesla (TSLA) stock data is retrieved from 2015 to present, with date set as the index and symbol column dropped.

Uploaded by

david_windarto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1 import pandas as pd

2 from yahoo_fin import stock_info


3 from plotly.offline import plot, init_notebook_mode
4 init_notebook_mode()
5 import cufflinks as cf
6 cf.set_config_file(offline=True)

1 data = {}
2 data['AAPL'] = stock_info.get_data('AAPL', start_date='08-01-2020',
end_date='08-22-2020')
3 print(data['AAPL'].head())
4 print(data["AAPL"])

Plotting the Data


1 qf = cf.QuantFig(data["AAPL"])
2 qf.add_bollinger_bands()
3 qf.add_macd()
4 qf.iplot()

=================
Required Modules to start:
1.Numpy
2.Matplotlib
3.Pandas
4.Pandas-datareader
5.BeautifulSoup4
6.scikit-learn / sklearn

import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web

style.use('ggplot')

start = dt.datetime(2015, 1, 1)
end = dt.datetime.now()

df = web.DataReader("TSLA", 'morningstar', start, end)

print(df.head())

df.reset_index(inplace=True)
df.set_index("Date", inplace=True)
df = df.drop("Symbol", axis=1)

print(df.head())

import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
style.use('ggplot')

start = dt.datetime(2015, 1, 1)
end = dt.datetime.now()
df = web.DataReader("TSLA", 'morningstar', start, end)
df.reset_index(inplace=True)
df.set_index("Date", inplace=True)
df = df.drop("Symbol", axis=1)

print(df.head())

You might also like