Difference between revisions of "MC1-Project-1"

From Quantitative Analysis Software Courses
Jump to navigation Jump to search
(Created page with "==Overview== The purpose of this assignment is to * Introduce you to historical equity data * Introduce you to Pandas * Give you a first look at portfolio assessment ==Task=...")
 
Line 66: Line 66:
 
==What to turn in==
 
==What to turn in==
  
* Your report: report.pdf, including
+
Via t-square turn in attachments only:
** The output of the two command lines above
+
 
** Details about any of the extra credit components you attempted, include results and commentary.
+
* Your code as <tt>submission.py</tt>
* Your code: optimizer.py
+
* Your chart as <tt>chart.pdf</tt>
* Additional code that supports your extra credit components.
 

Revision as of 23:07, 16 April 2015

Overview

The purpose of this assignment is to

  • Introduce you to historical equity data
  • Introduce you to Pandas
  • Give you a first look at portfolio assessment

Task

Write a Python function named assess_portfolio() that can simulate and assess the performance of a 4 stock portfolio.

Inputs to the function include:

  • Start date
  • End date
  • Symbols for for equities (e.g., GOOG, AAPL, GLD, XOM)
  • Allocations to the equities at the beginning of the simulation (e.g., 0.2, 0.3, 0.4, 0.1)

The function should return:

  • Standard deviation of daily returns of the total portfolio
  • Average daily return of the total portfolio
  • Sharpe ratio of the total portfolio (Assume you have 252 trading days in an year. And risk free rate = 0)
  • Cumulative return of the total portfolio

An example of how the function would be called:

vol, daily_ret, sharpe, cum_ret = assess_portfolio(startdate, enddate, ['GOOG','AAPL','GLD','XOM'], [0.2,0.3,0.4,0.1])

Also, create a chart that illustrates the value of your portfolio over the year and compares it to SPY. The portfolio and SPY should be normalized to 1.0 at the beginning of the period.

todo: include example chart here

Suggestions

Here is a suggested outline for your code:

  • Read in adjusted closing prices for the 4 equities.
  • Normalize the prices according to the first day. The first row for each stock should have a value of 1.0 at this point.
  • Multiply each column by the allocation to the corresponding equity.
  • Sum each row for each day. That is your cumulative daily portfolio value.
  • Compute statistics from the total portfolio value.

Here are some notes and assumptions:

  • When we compute statistics on the portfolio value, we do not include the first day.
  • We assume you are using the data provided. If you use other data your results may turn out different from ours. Yahoo's online data changes every day. We could not build a consistent "correct" answer based on "live" Yahoo data.
  • Assume 252 trading days/year.

Make sure your assess_portfolio() function gives correct output. Check it against the examples below.

Example output

Here's an example output for your function. These are actual correct examples that you can use to check your work.

todo:example 1

todo:example 2

Start Date: January 1, 2010
End Date: December 31, 2010
Symbols: ['AXP', 'HPQ', 'IBM', 'HNZ']
Optimal Allocations:  [0.0, 0.0, 0.0, 1.0]
Sharpe Ratio: 1.29889334008
Volatility (stdev of daily returns): 0.00924299255937
Average Daily Return: 0.000756285585593
Cumulative Return: 1.1960583568

Minor differences in float values may arise due to different implementations.

What to turn in

Via t-square turn in attachments only:

  • Your code as submission.py
  • Your chart as chart.pdf