Assignment 4: Using API to gather financial data with Quandl
Name: PUT YOUR NAME HERE
Student ID: PUT YOUR ID HERE
Section: PUT YOUR SECTION (1 or 2)
Grading: This is a pass or fail assignment worth 5% towards your final grade.
You must provide a clean code. Make sure the grader can follow each step of your analysis. Put comments to describe what you are doing (Using MARKDOWN or using #). Remove any lines of code that is not necessary. If you struggle on a question, that is OK, as long you show all the steps that you have taken and describe what is not working. If your code is not clean and it is hard for the grader to understand what you are doing, you will fail.
SUBMISSION of ASSIGNMENT
You must print your code output. Save the Jupyter code in PDF. To do so, click on File->Download as->PDF. Or you can do, File->Print Preview.
— Remove all the sample code. Keep your code only. Make sure you code works fully, from start to finish with no error message. In other words, if you close Jupyter, re-open your code, and press the PLAY button, does your code work fully with no error message?
Additional information
How to install Quandl in Python https://docs.quandl.com/docs/python-installation
When you open Anaconda, click on Environement (left panel)
Press the start button right beside base (root). This will open terminal.
Just type pip install quandl
Make sure you go Bill’s email to make sure you sign-up to Quandl and get your API code.
Documentation on how to use Quandl package for Python:
Get time-series data https://docs.quandl.com/docs/python-time-series
Documentation on the TSX data https://www.quandl.com/data/XTSE-Toronto-Stock-Exchange-Prices/documentation
Earnings announcement data
Earnings (US and CANADA) information https://web.tmxmoney.com/earnings_cal.php
If you use US data
US stock exchange benchmark: SPY
US Government short-term treasury: SHV (Blackrock ETF)
For stock prices, you use the column “adj_close”. This price already adjust for stock splits and dividends.
If you use Canadian data
Canadian stock exchange benchmark: XIU (Blackrock ETF)
Canadian Government short-term treasury: XSB (Blackrock ETF)
For stock prices, you use the column “Close”. This price is already adjusted for stock splits and dividends.
Objectives:
Learn how to get financial data from an API service
Plot subplots
Plot event studies
Construct an equal weighted portfolio
Learn how to test predictability regression
The code below contain the sample codes and sample stocks. You cannot choose the same Canadian stocks.