<jupyter_start><jupyter_text><jupyter_code>pip install ta
import pandas as pd
from ta.utils import dropna
from ta.volatility import BollingerBands
from ta.momentum import RSIIndicator
from ta.trend import EMAIndicator
from ta.trend import MACD
from ta.volume import ForceIndexIndicator
import pandas_datareader as web
import numpy as np
import datetime
import matplotlib.pyplot as plt
# Get the stock quote
df = web.DataReader('AAPL', data_source='yahoo',start='2010-01-01', end='2021-03-01')
df
# Initialize Bollinger Bands Indicator
indicator_bb = BollingerBands(close=df["Close"], window=20, window_dev=2)

# Add Bollinger Bands features
df['bb_bbm'] = indicator_bb.bollinger_mavg()
df['bb_bbh'] = indicator_bb.bollinger_hband()
df['bb_bbl'] = indicator_bb.bollinger_lband()

df
# Relative Strength Index (RSI)
Relative_Strength_Index = RSIIndicator(close=df["Close"], window = 14, fillna = False)
df['RSI'] = Relative_Strength_Index.rsi() 
df
# EMA - Exponential Moving Average
ema = EMAIndicator(close=df["Close"], window = 14, fillna = False)
df['EMA'] = ema.ema_indicator() 
df
# Moving Average Convergence Divergence (MACD)
M_A_C_D = MACD(close=df["Close"],window_fast=12, window_slow=26, window_sign=9, fillna = False)
df['MACD'] = M_A_C_D.macd()
df
# Force Index (FI)
FI = ForceIndexIndicator(close = df['Close'], volume = df['Volume'] , fillna = False)
df['FI'] = FI.force_index() 
df
plt.figure(figsize=(16,8))
plt.title ('Adj CLose')
plt.plot(df['Close'])
plt.plot(df['bb_bbh'])
plt.plot(df['bb_bbl'])
plt.plot(df['EMA'])
plt.xlabel('date')
plt.ylabel('USD $')
plt.legend(['Adj Close', 'BB up', 'BB lower', 'EMA'],loc='lower right',)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1459177764910249, 'fraction_numerical': 0.01795020266357846, 'mean_word_length': 5.884462151394422, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '596884', 'license': 'MIT', 'n_tokens_mistral': 684, 'n_tokens_neox': 652, 'n_words': 145, 'path': 'TechnicalAnalysis.ipynb', 'repo_name': 'sergiocabrales/python', 'size': '1727'}