{ "cells": [ { "cell_type": "markdown", "id": "fa2934b4", "metadata": {}, "source": [ "## Exercise 09\n", "\n", "\n", "* Set a ticker symbol (e.g. EDP.LS) and download the stock data for that ticker between the range of start and end date. As a result, it returns the stock data as a Pandas dataframe.\n", "\n", "* Calculate the daily percentage change of the stock adjusted close price and assign the values to a new column, \"Returns\", in the dataframe.\n", "\n", "* Create a histogram to visualize the distribution of the returns.\n", "\n", "* Calculate the mean of the daily returns and its annualized average returns.\n", "\n", "* calculate the variance of returns to measure volatility of the stock price (risk). Use Numpy std to calculate the standard deviation of the \"Returns\" column. Next, presume there are 252 trading days in a year and then apply the following formula to calculate the annual standard deviation of stock returns. Calculate the variances of daily return and annual return by squaring the daily & annual standard deviation, respectively.\n" ] }, { "cell_type": "code", "execution_count": null, "id": "44e2aedc", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import yfinance as yf\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "id": "4255ec3c", "metadata": {}, "outputs": [], "source": [ "ticker= \"EDP.LS\"\n", "data = yf.download(ticker, start=\"2000-01-01\", end=\"2021-10-31\")" ] }, { "cell_type": "code", "execution_count": null, "id": "cbc1047a", "metadata": { "scrolled": true }, "outputs": [], "source": [ "data" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 5 }