CompInvestI Homework 2

From Quantwiki
Jump to: navigation, search

Overview

The purpose of this assignment is to introduce you to

  • Event studies based on historical information.
  • Reading in and processing different types of historical data.
  • Assessing the results of an event study.

In this homework you will conduct "event studies" to assess the impact of stock price events (information) on future prices. We will use the Event Profiler that is distributed with QSTK. You can learn about the Event Profiler here: QSTK_Tutorial_9.

To do

There are four major parts to the project:

Part 1: Review and understand QSTK_Tutorial_9.

Part 2: Create an event study profile of a specific "known" event on S&P 500 stocks, and compare its impact on two groups of stocks.

The event is defined as when the actual close of the stock price drops below $5.00, more specifically, when:

  • price[t-1] >= 5.0
  • price[t] < 5.0

an event has occurred on date t. Note that just because the price is below 5 it is not an event for every day that it is below 5, only on the day it first drops below 5.

Evaluate this event for the time period January 1, 2008 to December 31, 2009. Compare the results using two lists of S&P 500 stocks: A) The stocks that were in the S&P 500 in 2008 (sp5002008.txt), and B) the stocks that were in the S&P 500 in 2012 (sp5002012.txt). These equity lists are in the directory QSData/Yahoo/Lists. You can read them in using the QSTK call

dataobj = da.DataAccess('Yahoo')
symbols = dataobj.get_symbols_from_list("sp5002008")
symbols.append('SPY')

If the performance of the event seems to depend on which list of equities you use, please consider why that is. We will talk about it "in class (videos)."


IMPORTANT : It it always important to remove NAN from price data, specially for the S&P 500 from 2008. Use the code below after reading the data to get the correct results.

    for s_key in ls_keys:
        d_data[s_key] = d_data[s_key].fillna(method = 'ffill')
        d_data[s_key] = d_data[s_key].fillna(method = 'bfill')
        d_data[s_key] = d_data[s_key].fillna(1.0)

Part 3: Create your own event and experiment with it using the Event Profiler. Consider these questions:

  • Is it possible to make money using your event?
  • If it is possible, what investing strategy would you use? Think about details of entry (buy) and exit (sell), how many days would you hold?
  • Is this a risky strategy?
  • How much do you expect to make on each trade?
  • How many times do you expect to be able to act on this opportunity each year?
  • Is there some way to reduce the risk?

Part 4: Make sure the output of your program matches the example outputs below. If you have any questions, please do not hesitate to ask on the forums.

Example output

  • For the $5.0 event with S&P500 in 2012, we find 176 events. Date Range = 1st Jan,2008 to 31st Dec, 2009.
  • For the $5.0 event with S&P500 in 2008, we find 326 events. Date Range = 1st Jan,2008 to 31st Dec, 2009.

The PDF chart will report fewer events than you might count in your code because the events at the very beginning and end cannot be part of the results as there will be missing data.

Implementation suggestions & assumptions

IMPORTANT : It it always important to remove NAN from price data, specially for the S&P 500 from 2008. Use the code below after reading the data to get the correct results.

    for s_key in ls_keys:
        d_data[s_key] = d_data[s_key].fillna(method = 'ffill')
        d_data[s_key] = d_data[s_key].fillna(method = 'bfill')
        d_data[s_key] = d_data[s_key].fillna(1.0)

We will talk about other methods for "scrubbing" data later on in the course.

The PDF chart will report fewer events than you might count in your code, because the events at the very beginning and end cannot be part of the results as there will be missing data.

What to expect when you turn in your assignment (Coursera)

For your evaluation on this project, you will take a "quiz" where we will ask you to run an Event Profile using parameters similar to Part 1 above, but using different time periods or thresholds. If you created the code properly for Part 1, this should be easy for you to do. You will enter numerical answers to the questions.

You will also be asked one or two questions about the difference between the event study results for the two different data sets. Have both charts ready and be prepared to answer questions about them.

Deliverables for on campus GT students

To do:

  1. Run your code for the $5 event on the two sets of stocks listed above (SP500 2008 and SP500 2012). Include these two charts in your report.
  2. Create your own event and experiment with it using the Event Profiler. Run that event on the SP500 2012 data and include it's chart in your report.

To turn in:

  • The code for your event, in myevent.py
  • A report, report.pdf that includes:
    • The 2 charts for the $5 event using 2008 and 2012 members of the S&P 500. Answer the following questions about them:
      • Consider the similarities and differences between the two charts. In what ways are they different? To what do you believe we could attribute the differences?
    • Include at least 1 chart illustrating "your event"
    • Include a description and motivation for your event.
    • Answer the following questions about your event:
      • Is it possible to make money using your event?
      • If it is possible, what investing strategy would you use? Think about details of entry (buy) and exit (sell), how many days would you hold?
      • Is this a risky strategy?
      • How much do you expect to make on each trade?
      • How many times do you expect to be able to act on this opportunity each year?
      • Is there some way to reduce the risk?

Extra challenges

If you felt that this assignment was "too easy" try these additional challenges. Sorry, but we don't offer extra credit:

  • For the time period listed above explore different price events. Is there a particular price transition that seems "optimal?"