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

Assignment 1 Stock Market Analysis

This document provides instructions for an assignment to analyze stock market data. Students are asked to: 1) Download 1 year of historical stock price data from Yahoo Finance. 2) Format and organize the data in an Excel spreadsheet, including calculating basic statistics like daily returns and volatility. 3) Perform a relative strength index (RSI) analysis on the stock to identify if it is overbought or oversold. The assignment aims to help students practice retrieving, formatting, and analyzing financial data.

Uploaded by

Thái Triệu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

Assignment 1 Stock Market Analysis

This document provides instructions for an assignment to analyze stock market data. Students are asked to: 1) Download 1 year of historical stock price data from Yahoo Finance. 2) Format and organize the data in an Excel spreadsheet, including calculating basic statistics like daily returns and volatility. 3) Perform a relative strength index (RSI) analysis on the stock to identify if it is overbought or oversold. The assignment aims to help students practice retrieving, formatting, and analyzing financial data.

Uploaded by

Thái Triệu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

COMPSCI 2034b / DIGIHUM 2144b

Data Analytics: Principles and Tools

Assignment #1
Market Analysis

Posted: January 22nd 2024


Due: February 7th 2023 11:55PM
Total: 100 Points (7% of Final Grade)
CS2034 - Data Analytics: Principles and Tools Assignment #1

Learning Outcomes
By completing this assignment, you will gain and demonstrate skills relating to:
ˆ Retrieving web data.
ˆ Formatting spreadsheets.
ˆ Computing basic statistics using Excel.
ˆ Using conditional statements in Excel formulas.
ˆ Performing an RSI Analysis.

Instructions
In this assignment, you will download historical stock market data from Yahoo Finance and
import it into Excel. You will then format the data, perform a series of calculations on the
data and a Relative Strength Index (RSI) Analysis.

You are required to follow each step in this assignment and submit an Excel .xlsx copy of
your assignment. You must assume that the data in your sheet can change (i.e. you may
not hardcode your answers). Each step must be followed precisely including the file naming
convention given in Part 9. You will be assessed on the following:
ˆ Retrieving the correct data.
ˆ Your formatting of the spreadsheet.
ˆ Your Excel formulas.
ˆ Your final analysis.
ˆ Completion of each task correctly.
ˆ Assignment submission via OWL.

Tasks
1. Get The Historical Data For Your Stock (5 Marks)

Yahoo Finance provides historical stock data for most stocks trading on the New York Stock
Exchange (NYSE), Toronto Stock Exchange, as well as many other markets including some
cryptocurrencies. Visit the following link and select a stock of your choosing that has at
least one year of historical data (you can not pick Telus as it is used in the examples
in this assignment). For example you could pick IBM (for International Business Machines
Corporation (IBM)), SHOP.TO (for Shopify Inc.), TSLA (for Tesla), or AMZN (for Amazon).
The choice is up to you and it can be any stock (except for Telus) on Yahoo Finance with
at least 1 year of historical data. It can not be a cryptocurrency, bond, Exchange-Traded
Fund (ETF), or any security other than a stock.

https://ca.finance.yahoo.com/

1 of 9
CS2034 - Data Analytics: Principles and Tools Assignment #1

Enter the company name or stock symbol into the search bar and then select the historical
data tab as shown below:

Make sure you have a years worth of data selected (for example, Jan 22 2023 to Jan 22 2024)
and click the Apply button. Then select ”Download” to get a Comma-Separated Value
(CSV) export of the data.

Open the downloaded CSV file in Excel and immediately save it as an Excel Workbook
(*.xlsx) file. Failing to save as a .xlsx file and continuing to work on the file as a .csv file
can lead to data loss.

2. Sort the Data by Date

Highlight all of the data (including headers) in your table, right click on the “Sort” button
on the Data tab. It should look like this:

2 of 9
CS2034 - Data Analytics: Principles and Tools Assignment #1

Sort the data by date from oldest to newest. Make sure you have “My data has headers”
checked.

3. Format the Data Nicely

Adjust the column widths so that all data is visible, i.e. there are no cells showing “#####”.
Adjust the precision of all the cells in the “Open”, “High”, “Low”, “Close”, and “Adj Close”
columns to show two decimal places and format them as currency. Format the dates to be in
“Month Day, Year” style (e.g. January 1st, 2023 for 2023-01-01). Format the column headers
by making them centered, in bold, with a grey background. Put black grid lines around the
entries in the table. Insert 6 blank lines above the table and 1 new column before
column A.

Add a title in cell A1 with the text “[Stock] RSI Analysis by [Your Name]” in a large font
and bold. Of course “[Your Name]” should be replaced with your name, and [Stock] should
be replaced with the name of the stock you are exploring. For example, if you name is Daniel
Servos and the stock is Telus your title would be “Telus RSI Analysis by Daniel Servos”.
Merge and center A1 with cells A1 to R1 to make the title centred across the first row.

Make the title bold, italic, blue, any font other than the default, and font size 18.

It should look something like the following screen shot:

3 of 9
CS2034 - Data Analytics: Principles and Tools Assignment #1

4. Compute the Range

Put the text “Range:” in cell A3. In cell B2 put the text “Low” and in cell C2 put the text
“High”. In cell B3 put a formula that calculates the minimum value from the “Low” column.
In cell C3 put a formula that calculates the maximum value from the “High” column.

Put the text “Range Date:” in cell A4. In cell B4 use the INDEX and MATCH functions to
find the date with the smallest low. In cell C4 use the same functions to find the date with
the largest high. Format the resulting values as dates.

Hint: If you fail to format the cells as dates INDEX and MATCH will return a number
rather than a date.

Center the values in the cells B2 to C4.

5. Measure the Volatility

In column J, compute the Daily Logarithmic Return for each date by using equation 1:

Ci
DailyLogReturn = ln( ) (1)
Ci−1

where Ci is the closing price for the current day, Ci−1 is the closing price for the previous
day and ln is the natural logarithm. There should be no value for the first row as there is
no preceding day. Give this column the header “Daily Return” and format the values as a
percentage with two decimal places. Also add borders as in Step 3 and make the width of
column I about half it’s default size.

In cell E3 put the text “STDev:” and in cell F3 calculate the√ standard deviation of the daily
returns. In cell E4 put the text “Volatility:” and compute days × STDev in cell F4, where
days is the number of days in the year that your stock is traded (make this dynamic based
on the number of dates we have in our data set and not a hardcoded value) and STDev
is a reference to the cell in which we calculated the standard deviation. This gives us the
annualized historical volatility. Format the volatility value as a percentage with two decimal
places.

Volatility is a technical indicator of the amount of uncertainty or risk about the size of
changes in a currency, stock or other security’s value. A higher volatility means the price
is more likely to change dramatically over a short time period. A lower volatility means
the price is more stable and less likely to fluctuate dramatically in a short time period.
For comparison, gold has an average annualized historical volatility of approximately 15%
whereas Bitcoin has a volatility closer to 81%.

4 of 9
CS2034 - Data Analytics: Principles and Tools Assignment #1

6. Relative Strength Index Analysis

Relative Strength Index (RSI) is a technical indicator that compares the magnitude of recent
gains and losses over a set time to give an indication of the momentum of stock, currency or
other security. It is used by traders to identify securities that are potentially overbought or
oversold. In theory, an overbought security is overvalued and prime for a downwards reversal
(the price will drop), likewise an oversold security is undervalued and prime for an upwards
reversal (the price will rise).

The relative strength index is calculated using the following formula:


100
RSI = 100 − (2)
1 + RS

where RS is the relative strength and is calculated as follows:


Average gain of up periods
RS = (3)
Average loss of down periods

6.1. Find the Gains and Losses

To make this calculation in Excel we will use columns K and L to determine the Gain or Loss
for the day. Give column K the header “Loss” and the second (column L) the header “Gain”.
In the gains column enter an equation that will find the gain (today’s closing price minus
yesterday’s closing price) if and only if the daily change is positive, otherwise the result will
be zero. Similarly, in the loss column enter an equation that will find the loss (also based on
today’s and yesterday’s closing price) if and only if the daily change is negative, otherwise
the result will be zero. Make sure both gain and loss are positive numbers.

Hint: You will need to use the Excel IF function.

6.2. Compute the 14-Day Average Gains and Losses

Relative strength is traditionally calculated over a 14 day period, so in the next two columns
(columns M and N) we will find the average loss and gain over a 14 day period. Add the
headers “Avg Loss” and “Avg Gain” to these columns and format them appropriately. As
we are calculating the average for the first 14 days, the first 14 rows in the table will be
blank. In cell M22 find the average of the first 14 losses using the AVERAGE function. In
cell N22 find the average of the first 14 losses using the AVERAGE function.

To calculate the averages for the remaining rows following this formula:

(Last Average × 13) + Today’s Gain or Loss


14 Day Average = (4)
14

5 of 9
CS2034 - Data Analytics: Principles and Tools Assignment #1

6.3. Compute the Relative Strength (RS) and Relative Strength Index (RSI)

Now that we have the average losses and gains we can calculate the relative strength (RS)
by dividing the average gain by the average loss for that day (as shown in Equation 3). In
column O add the header “RS”. In this column find the RS for each day by dividing the
value you calculated for Avg Gain by the value you calculated for Avg Loss on the same
row.

We can now finally compute the 14-day RSI for each date by following Equation 2. In column
P add the header “RSI”. In this column calculate the RSI using Equation 2 and the RS
value you calculated.

6.4. Find the Oversold and Overbought Days

Generally an RSI above 70 is considered to be overbought and a RSI below 30 to be oversold.


In cell J3 enter the text “Oversold:” in cell J4 enter the text “Overbought:”. In cell K3 put
the number 30, this will be the value over which we consider an RSI to indicate oversold. In
cell K4 put the number 70, this will be the value under which we consider an RSI to indicate
overbought.

In column Q add the header “Over Sold or Bought?”. In this column you will enter a formula
that will return the text “Overbought” if the RSI for that row is over or equal to the value
in cell K4 and put the “Oversold” if the RSI for that row is under or equal to the value in
cell K3. Otherwise no value should be printed (Hint: an empty string, ′′′′ , will output no
value). Ensure that your values are not hard coded and that the result will change if the
values in K3, K4 or the original data changes. You should be able to copy and paste (or
drag) your formula into any cell in the column and have it print the correct value.

Hint: You will need to either use nested IF functions or the IFS function.

Make the text in this column (the “Oversold” and “Overbought” outputs) bold, red, and
centered.

7. On-Balance Volume

On-balance volume (OBV) is a technical trading momentum indicator that uses volume flow
to predict changes in stock price. You can read more about it here.

In column R add the header “OBV” and enter the value 0 into cell R8. In this coulmn in
the remaining rows, starting in cell R9 write a formula for OBV using this equation:

volume,
 if close > closeprev
OBV = OBVprev + 0, if close = closeprev (5)

−volume, if close < closeprev

6 of 9
CS2034 - Data Analytics: Principles and Tools Assignment #1

where:

OBV = Current on-balance volume level (for the current day).


OBVprev = Previous on-balance volume level (for the previous day with stock data).
volume = Latest trading volume amount (from column H for the current day).
close = The closing price for the current day (from column F).
closeprev = The closing price for the previous day with stock data.

In simple terms this means you add the volume for the current day if the previous closing
price was lower than today’s and subtract it if it was less than today’s. If they are the same,
there is no change (add zero).

8. Analysis

Name your current worksheet “RSI” and add a new worksheet named ”Analysis”. On this
sheet add a line graph the shows a series for both Closing Price and OBV for each day on the
same graph. The Closing Price and OBV should use different axes and your graph should
include a legend, axis titles, and an overall title. Play around with the different formatting
settings to create a good looking and clear visual.

You may have to research how to add axis titles, legends, series on different axes, etc. This
is intentional and to encourage you to learn how to use the Excel documentation and online
resources. This guide is a good starting point: Present your data in a scatter chart or a line chart.

It should look something like this but for your own data:

7 of 9
CS2034 - Data Analytics: Principles and Tools Assignment #1

Added a second line graph of the RSI for each day. Make sure the graph is properly titled
and the axes are labelled. Add horizontal lines at 70 and 30 on the RSI graph to denote
overbought and oversold levels. Note that this can be difficult in Excel. You may want to
follow the How to add a line to an existing Excel graph tutorial but any way you can get the
lines on the graph is acceptable. In our case we need to add two new columns to our data
that simply contain the Overbought and Oversold values (one for each line) rather than a
target value. The result should look something like this:

Finally, add a text box with your analysis of your stock as an investment. Base your analysis
on the technical indicators we have calculated (namely Volatility, RSI, Overbought/sold, and
OBV) and write a short (one or two paragraph) analysis of your stock as an investment.
At a minimum you should discuss what the volatility means for potential investors, if the
market is currently overbought, oversold or neither and what this could mean. If you are
not familiar with these indicators you may first wish to read about them on Investopedia:

ˆ Historical Volatility
ˆ Relative Strength Index - RSI
ˆ Understanding Momentum Indicators and RSI
ˆ Overbought Or Oversold? Using The RSI To Find Out
ˆ Overbought
ˆ Oversold
ˆ On-Balance Volume (OBV): Definition, Formula, and Uses As Indicator

8 of 9
CS2034 - Data Analytics: Principles and Tools Assignment #1

9. Submission

Failing to follow the submission instructions can lead to a mark penalty. Marks will be
deducted for incorrectly named files, files not submitted to OWL correctly, etc.

Before submitting take a look at the example soultion.pdf file attached to the assignment on
OWL. Make sure your formatting matches this document as closely as possible (fonts and
colours do not have to match exactly but should be close). Note that this solution will have
different data than you. Make sure all headings and columns are formatted as specified in
Step 3 and that all values have a sensible format (currency, percentage, etc.). Also do one
final check to make sure your numbers make sense and that you have not hardcoded any
values that should be dynamic.

Save your Excel file as an .xlsx file and name it “userid assign1.xlsx” where userid is your
user id. For example, if your UWO e-mail was “[email protected]”, the file should be named
“dservos5 assign1.xlsx”.

This must be an .xlsx workbook file created by a current version of Excel included in Office
365. No other file formats will be accepted. Submitting a .csv, pages, or Google Docs file
will result in a zero grade. Also make sure that what you are submitting is a stand alone
Excel workbook and not a link to online copy in OneDrive or Sharepoint. Submitting a link
to a file or a file that is not self contained locally will result in a zero grade.

Make sure you leave enough time before the deadline to account for any technical issues. If
you are having computer issues, the GenLabs computers on campus have Excel installed and
can access OWL. You are required to backup your work (a remote backup on something like
OneDrive is highly recommended). Lost work or technical issues will not be grounds for an
extension.

All assignments are to be your own work. You may not work on this assignment with another
person (including tutors), copy from an on-line source, or use any kind of tool to generate
solutions for you. At no time should you ever share your work with another student or
receive another student’s work. All submissions will be subject to similarity and metadata
analysis.

Submit your work on the Assignments tab on our OWL course site. Submissions
will not be accepted via e-mail or by any other means.

9 of 9

You might also like