# Importing Required Libraries
import pandas as pd
import yfinance as yf
import cufflinks as cf
import plotly.offline
cf.go_offline()
cf.set_config_file(offline=False, world_readable=True)
# Define the Ticker Symbol
ticker_symbol = "BAC"
# Get the data on this ticker
ticker_data = yf.Ticker(ticker_symbol)
# Get the historical prices for the specified period
ticker_df = ticker_data.history(period="1d", start="2023-1-1", end="2023-07-07")
# Calculate Exponential Moving Averages
ticker_df["EMA12"] = ticker_df["Close"].ewm(span=12, adjust=False).mean()
ticker_df["EMA26"] = ticker_df["Close"].ewm(span=26, adjust=False).mean()
# Plot the chart
ticker_df.iplot(
title="Exponential Moving Averages of " + ticker_symbol,
xTitle="Date",
yTitle="Price",
theme="pearl",
)