Difference between revisions of "MC1-Project-1"

From Quantitative Analysis Software Courses
Jump to navigation Jump to search
 
(60 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
==Revisions==
 +
 +
'''2017-1-16'''
 +
 +
* API revised to allow for variable length input.  For instance, we might ask you to calculate statistics for a 2 asset portfolio or a 10 asset portfolio.
 +
* Be alert that the test suite on the buffet machines does not yet test these cases.  That does not mean that you don't have to support them.
 +
 
==Overview==
 
==Overview==
  
A ''portfolio'' is a collection of stocks (or other investment options) and corresponding allocations of money to each of them. In order to evaluate and compare different portfolios, we first need to compute certain metrics, based on available historical data.
+
A ''portfolio'' is a collection of stocks (or other assets) and corresponding allocations of funds to each of them. In order to evaluate and compare different portfolios, we first need to compute certain metrics, based on available historical data.
  
 
The primary goal of this assignment is to introduce you to this form of portfolio analysis. You will use [[pandas]] for reading in data, calculating various statistics and plotting a comparison graph.
 
The primary goal of this assignment is to introduce you to this form of portfolio analysis. You will use [[pandas]] for reading in data, calculating various statistics and plotting a comparison graph.
  
 
==Task==
 
==Task==
 +
 +
First, if you haven't yet set up your software environment, follow the instructions here: [[ML4T_Software_Setup]].  Now, for this assignment: Create a function called <tt>assess_portfolio()</tt> that takes as input a description of a portfolio and computes important statistics about it. 
  
 
You are given the following inputs for analyzing a portfolio:
 
You are given the following inputs for analyzing a portfolio:
* A date range to select the historical data to use (specified by a start and end date)
+
* A date range to select the historical data to use (specified by a start and end date).  You should consider performance from close of the start date to close of the end date.
* Symbols for equities (e.g., GOOG, AAPL, GLD, XOM)
+
* Symbols for equities (e.g., GOOG, AAPL, GLD, XOM). Note: You should support any symbol in the data directory.
* Allocations to the equities at the beginning of the simulation (e.g., 0.2, 0.3, 0.4, 0.1)
+
* Allocations to the equities at the beginning of the simulation (e.g., 0.2, 0.3, 0.4, 0.1), should sum to 1.0.
 
* Total starting value of the portfolio (e.g. $1,000,000)
 
* Total starting value of the portfolio (e.g. $1,000,000)
  
 
Your goal is to compute the daily portfolio value over given date range, and then the following statistics for the overall portfolio:
 
Your goal is to compute the daily portfolio value over given date range, and then the following statistics for the overall portfolio:
 
* Cumulative return
 
* Cumulative return
* Average daily return
+
* Average period return (if sampling frequency == 252 then this is average daily return)
 
* Standard deviation of daily returns
 
* Standard deviation of daily returns
 
* Sharpe ratio of the overall portfolio, given daily risk free rate (usually 0), and yearly sampling frequency (usually 252, the no. of trading days in a year)
 
* Sharpe ratio of the overall portfolio, given daily risk free rate (usually 0), and yearly sampling frequency (usually 252, the no. of trading days in a year)
 +
* Ending value of the portfolio
  
Your program will include a helper function to specify the portfolio data, then your function should calculate and return the portfolio statistics.  Be sure to include all necessary code in your submitted Python code. For grading purposes, we will test ONLY the function that computes statistics.  You should implement the following API EXACTLY, if you do not your submission will be penalized at least 20%.
+
Your program should include a helper function to specify the portfolio data, then your function should calculate and return the portfolio statistics.  Be sure to include all necessary code in your single submitted Python file.
 +
 
 +
==API specification==
 +
 
 +
For grading purposes, we will test ONLY <tt>assess_portfolio()</tt> the function that computes statistics.  You should implement the following API EXACTLY, if you do not, your submission will be penalized at least 20%.
  
 
<PRE>
 
<PRE>
Line 27: Line 41:
 
     syms=['GOOG','AAPL','GLD','XOM'], \
 
     syms=['GOOG','AAPL','GLD','XOM'], \
 
     allocs=[0.1,0.2,0.3,0.4], \
 
     allocs=[0.1,0.2,0.3,0.4], \
     sv=1000000, rfr=0, sf=252)
+
     sv=1000000, rfr=0.0, sf=252.0, \
 +
    gen_plot=False)
 
</PRE>
 
</PRE>
  
 
Where the returned outputs are:
 
Where the returned outputs are:
 
* cr: Cumulative return
 
* cr: Cumulative return
* adr: Average daily return
+
* adr: Average period return (if sf == 252 this is daily return)
 
* sddr: Standard deviation of daily return
 
* sddr: Standard deviation of daily return
 +
* sr: Sharpe ratio
 
* ev: End value of portfolio
 
* ev: End value of portfolio
  
Line 39: Line 55:
 
* sd: A datetime object that represents the start date
 
* sd: A datetime object that represents the start date
 
* ed: A datetime object that represents the end date
 
* ed: A datetime object that represents the end date
* syms: A list of symbols that make up the portfolio (note that your code should support any symbol in the data directory)
+
* syms: A list of 2 or more symbols that make up the portfolio (note that your code should support any symbol in the data directory)
* allocs: A list of allocations to the stocks, must sum to 1.0
+
* allocs: A list of 2 or more allocations to the stocks, must sum to 1.0
 
* sv: Start value of the portfolio
 
* sv: Start value of the portfolio
* rfr: The risk free rate for the entire period
+
* rfr: The risk free return per sample period that does not change for the entire date range (a single number, not an array).
 
* sf: Sampling frequency per year
 
* sf: Sampling frequency per year
 +
* gen_plot: If False, do not create any output.  If True it is OK to output a plot such as <tt>plot.png</tt>
  
 
==Template==
 
==Template==
  
A template is provided for you to get started with the project: <tt>'''[[Media:mc1_p1.zip|mc1_p1.zip]]'''</tt>
+
A template is provided for you to get started with the project. You will find it in the appropriate subdirectory that you checked out from github.
  
Download and unzip it inside <tt>ml4t/</tt>. It should consist of:
+
You should see the following directory structure:
* <tt>mc1_p1/</tt>: Root directory for the template
+
* <tt>ml4t/</tt>: Root directory for course
** <tt>portfolio/</tt>: Python package with all project-specific code
+
** <tt>data/</tt>: Location of data that you installed earlier
 +
** <tt>mc1_p1/</tt>: Root directory for this project
 
*** <tt>analysis.py</tt>: Main project script with functions you need to implement, as well as test code
 
*** <tt>analysis.py</tt>: Main project script with functions you need to implement, as well as test code
** <tt>output/</tt>: Directory to store all program outputs, including plots
+
*** <tt>output/</tt>: Directory to store all program outputs, including plots
** <tt>util.py</tt>: Utility functions (do not modify these, unless instructed)
+
*** <tt>util.py</tt>: Utility functions (do not modify these, unless instructed)
  
You should change ONLY <tt>analysis.py</tt>.  ALL of your code should be in that one file.  Do not create additional files.  It should always remain in and run from the directory <tt>ml4t/mc1_p1/portfolio</tt>.  If you move it somewhere else and develop your code there, it may not run properly when auto graded.
+
You should change ONLY <tt>analysis.py</tt>.  ALL of your code should be in that one file.  Do not create additional files.  It should always remain in and run from the directory <tt>ml4t/mc1_p1/</tt>.  If you move it somewhere else and develop your code there, it may not run properly when auto graded.
  
 
Notes:
 
Notes:
Line 63: Line 81:
 
* We assume your <tt>data/</tt> directory is one level up, (i.e., ../data/).  That directory should contain all stock data, in CSV files (e.g. <tt>GOOG.csv</tt>, <tt>AAPL.csv</tt>, etc.)
 
* We assume your <tt>data/</tt> directory is one level up, (i.e., ../data/).  That directory should contain all stock data, in CSV files (e.g. <tt>GOOG.csv</tt>, <tt>AAPL.csv</tt>, etc.)
 
* To execute the main script, make sure your current working directory is <tt>mc1_p1/</tt>, then run:
 
* To execute the main script, make sure your current working directory is <tt>mc1_p1/</tt>, then run:
<pre>python -m portfolio.analysis</pre>
+
<pre>python analysis.py</pre>
 
 
This directory structure may seem a little complicated at first, but it will help you organize your code better.
 
 
 
==Instructions==
 
 
 
* Open: <tt>portfolio/analysis.py</tt><br />Function documentation and code comments should help you understand what you need to do. If it is still not clear, read the detailed instructions below.
 
* Look at the function: <tt>test_run()</tt><br /> Here we have set up some sample inputs, which are then passed to the <tt>assess_portfolio()</tt> function:
 
 
 
<pre>start_date = '2010-01-01'
 
end_date = '2010-12-31'
 
symbols = ['GOOG', 'AAPL', 'GLD', 'XOM']
 
allocs = [0.2, 0.3, 0.4, 0.1]
 
start_val = 1000000
 
assess_portfolio(start_date, end_date, symbols, allocs, start_val)</pre>
 
 
 
* Now look at: <tt>assess_portfolio()</tt><br />It first reads historical data for the given date range and symbols, and then uses three helper functions to simulate and assess the performance of the stock portfolio. <tt>assess_portfolio()</tt> is a helper function that is used to exercise your code.  It will NOT be evaluated in the grading process.
 
 
 
* Your job is to implement these functions, with EXACTLY the APIs (inputs and outputs) described below.  DO NOT modify the list of input parameters or output results because they will be tested by the auto grading system:
 
 
 
** <tt>'''get_portfolio_value'''(prices, allocs, start_val)</tt>: Compute daily portfolio value given stock prices, allocations and starting value.<br />Ensure that it returns a pandas <tt>Series</tt> or <tt>DataFrame</tt> (with a single column).
 
** <tt>'''get_portfolio_stats'''(port_val, daily_rf, samples_per_year)</tt>: Calculate statistics on daily portfolio value, given daily risk-free rate and data sampling frequency.<br />This function should return a ''tuple'' consisting of the following statistics (in order): cumulative return, average daily return, standard deviation of daily return, Sharpe ratio<br />Note: The return statement provided ensures this order.
 
** <tt>'''plot_normalized_data'''(df, title, xlabel, ylabel)</tt>: Normalize given stock prices and plot for comparison.<br />This is used to create a chart that illustrates the value of your portfolio over the year and compares it to SPY.<br />Note: Before plotting, portfolio and SPY values should be normalized to 1.0 at the beginning of the period. Also, use the <tt>plot_data()</tt> utility function to generate and show your plot.
 
* Refer to each function's documentation (in triple quotes after the <tt>def</tt> line) for details about the parameters and expected return values.
 
* Implement each function; feel free to modify <tt>test_run()</tt> and <tt>assess_portfolio()</tt> to write additional tests (e.g. to call and inspect the functions individually).
 
* Save the comparison plot as <tt>comparison.png</tt> (you should be able to do this directly from the plot window).
 
* Submit your final <tt>analysis.py</tt> along with <tt>comparison.png</tt> once you are confident that your functions are working as expected.
 
 
 
Note: In order to avoid issues with grading, make sure your functions accept exactly the parameters and return the value(s) that are defined in the respective function documentation. Also, turn off all printing and plotting from within these functions, unless instructed (e.g. <tt>plot_normalized_data()</tt> should generate a plot).
 
  
 
==Suggestions==
 
==Suggestions==
  
Here is a suggested high-level outline for what your script needs to do:
+
Here is a suggested high-level outline for what your code needs to do:
*Read in adjusted closing prices for the 4 equities.
+
*Read in adjusted closing prices for the 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.
 
*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.
 
*Multiply each column by the allocation to the corresponding equity.
Line 102: Line 92:
 
*Sum each row (i.e. all position values for each day). That is your daily portfolio value.
 
*Sum each row (i.e. all position values for each day). That is your daily portfolio value.
 
*Compute statistics from the total portfolio value.
 
*Compute statistics from the total portfolio value.
 +
 +
You will need to reuse some of your code from this project for the next project.  To make that task easier, we suggest that you create a helper function within your code that has the following prototype.  Note that we will not be testing this part of your code directly, so it isn't essential that you follow the API exactly.
 +
 +
<PRE>
 +
cr, adr, sddr, sr = \
 +
    compute_portfolio_stats(prices = df_prices, \
 +
    allocs=[0.1,0.2,0.3,0.4],\
 +
    rfr = 0.0, sf = 252.0)
 +
</PRE>
 +
 +
Where the returned outputs are:
 +
* cr: Cumulative return
 +
* adr: Average daily return
 +
* sddr: Standard deviation of daily return
 +
* sr: Sharpe Ratio
 +
 +
The input parameters are:
 +
* prices is a data frame or an ndarray of historical prices.
 +
* allocs: A list of allocations to the stocks, must sum to 1.0
 +
* rfr: The risk free return per sample period for the entire date range.  We assume that it does not change.
 +
* sf: Sampling frequency per year
  
 
Here are some notes and assumptions:
 
Here are some notes and assumptions:
 
*When we compute statistics on the portfolio value, we do not include the first day.
 
*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.
+
*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 cannot not build a consistent "correct" answer based on "live" Yahoo data.
 
*Assume 252 trading days/year.
 
*Assume 252 trading days/year.
  
Line 160: Line 171:
 
Submit via T-Square as attachments only (no zip files please):
 
Submit via T-Square as attachments only (no zip files please):
 
* Your code as <tt>analysis.py</tt> (please use this EXACT filename)
 
* Your code as <tt>analysis.py</tt> (please use this EXACT filename)
* Your plot of daily portfolio value versus SPY as <tt>comparison.png</tt> (use EXACT filename)<br/>The plot should be generated using the following:, Start Date: 2010-01-01, End Date: 2010-12-31, Symbols: ['GOOG', 'AAPL', 'GLD', 'XOM'], Allocations: [0.2, 0.2, 0.4, 0.2]
+
 
 +
Important: We may test against OTHER symbols and other allocations, so don't hardcode the list of symbols.
  
 
Unlimited resubmissions are allowed up to the deadline for the project.
 
Unlimited resubmissions are allowed up to the deadline for the project.
Line 166: Line 178:
 
==Rubric==
 
==Rubric==
  
* Part 1: Chart is correct
+
10 test cases: We will test your code against 10 cases (10% per case).  Each case will be deemed "correct" if:
** Normalized values start at 1.0 on left (10%)
+
* 5%: Sharpe ratio = reference answer +- 0.001
** Shape of curves are correct (10%)
+
* 2.5%: Average daily return = reference answer +- 0.00001
* Part 2: 10 test cases: We will test your code against 10 cases (8% per case).  Each case will be deemed "correct" if:
+
* 2.5%: Cumulative return = reference answer +- 0.001
** Sharpe ratio = reference answer +- 0.001
+
 
** Average daily return = reference answer +- 0.00001
+
==Test Cases==
** Cumulative return = reference answer +- 0.001
+
 
 +
Here are the test cases we used while grading. These are updated each semester, and released after grading.
 +
* [[MC1-Project-1-Test-Cases-spr2016]]
  
 
==Required, Allowed & Prohibited==
 
==Required, Allowed & Prohibited==
Line 178: Line 192:
 
Required:
 
Required:
 
* Your project must be coded in Python 2.7.x.
 
* Your project must be coded in Python 2.7.x.
* Your code must run on one of the university-provided computers (e.g. buffet02.cc.gatech.edu), or on one of the provided virtual images.
+
* Your code must run on one of the university-provided computers (e.g. buffet02.cc.gatech.edu).
 +
* Use the code for reading in historical data provided in util.py
 
* Your code must run in less than 5 seconds on one of the university-provided computers.
 
* Your code must run in less than 5 seconds on one of the university-provided computers.
  
 
Allowed:
 
Allowed:
 
* You can develop your code on your personal machine, but it must also run successfully on one of the university provided machines or virtual images.
 
* You can develop your code on your personal machine, but it must also run successfully on one of the university provided machines or virtual images.
* Your code may use standard Python libraries.
+
* Your code may use standard Python libraries (except os).
* You may use the NumPy, SciPy and Pandas libraries.
+
* You may use the NumPy, SciPy, matplotlib and Pandas libraries.  Be sure you are using the correct versions.
* Small sections of code (up to 5 lines) that you collected from other students or the internet.
+
* You may reuse sections of code (up to 5 lines) that you collected from other students or the internet.
 
* Code provided by the instructor, or allowed by the instructor to be shared.
 
* Code provided by the instructor, or allowed by the instructor to be shared.
  
 
Prohibited:
 
Prohibited:
 +
* Any use of global variables.
 
* Any libraries not listed in the "allowed" section above.
 
* Any libraries not listed in the "allowed" section above.
 +
* Use of any code other than util.py to read in data.
 +
* Use of Python's os module.
 
* Any code you did not write yourself (except for the 5 line rule in the "allowed" section).
 
* Any code you did not write yourself (except for the 5 line rule in the "allowed" section).
* Any Classes other than Random that create their own instance variables for later use (e.g., learners like kdtree).
+
* Knights who say "neeee."
 +
 
 +
==Legacy versions==
 +
 
 +
* [[MC1-Project-1-legacy]]
 +
* [[MC1-Project-1-archive]]

Latest revision as of 19:48, 21 May 2017

Revisions

2017-1-16

  • API revised to allow for variable length input. For instance, we might ask you to calculate statistics for a 2 asset portfolio or a 10 asset portfolio.
  • Be alert that the test suite on the buffet machines does not yet test these cases. That does not mean that you don't have to support them.

Overview

A portfolio is a collection of stocks (or other assets) and corresponding allocations of funds to each of them. In order to evaluate and compare different portfolios, we first need to compute certain metrics, based on available historical data.

The primary goal of this assignment is to introduce you to this form of portfolio analysis. You will use pandas for reading in data, calculating various statistics and plotting a comparison graph.

Task

First, if you haven't yet set up your software environment, follow the instructions here: ML4T_Software_Setup. Now, for this assignment: Create a function called assess_portfolio() that takes as input a description of a portfolio and computes important statistics about it.

You are given the following inputs for analyzing a portfolio:

  • A date range to select the historical data to use (specified by a start and end date). You should consider performance from close of the start date to close of the end date.
  • Symbols for equities (e.g., GOOG, AAPL, GLD, XOM). Note: You should support any symbol in the data directory.
  • Allocations to the equities at the beginning of the simulation (e.g., 0.2, 0.3, 0.4, 0.1), should sum to 1.0.
  • Total starting value of the portfolio (e.g. $1,000,000)

Your goal is to compute the daily portfolio value over given date range, and then the following statistics for the overall portfolio:

  • Cumulative return
  • Average period return (if sampling frequency == 252 then this is average daily return)
  • Standard deviation of daily returns
  • Sharpe ratio of the overall portfolio, given daily risk free rate (usually 0), and yearly sampling frequency (usually 252, the no. of trading days in a year)
  • Ending value of the portfolio

Your program should include a helper function to specify the portfolio data, then your function should calculate and return the portfolio statistics. Be sure to include all necessary code in your single submitted Python file.

API specification

For grading purposes, we will test ONLY assess_portfolio() the function that computes statistics. You should implement the following API EXACTLY, if you do not, your submission will be penalized at least 20%.

import datetime as dt
cr, adr, sddr, sr, ev = \
    assess_portfolio(sd=dt.datetime(2008,1,1), ed=dt.datetime(2009,1,1), \
    syms=['GOOG','AAPL','GLD','XOM'], \
    allocs=[0.1,0.2,0.3,0.4], \
    sv=1000000, rfr=0.0, sf=252.0, \
    gen_plot=False)

Where the returned outputs are:

  • cr: Cumulative return
  • adr: Average period return (if sf == 252 this is daily return)
  • sddr: Standard deviation of daily return
  • sr: Sharpe ratio
  • ev: End value of portfolio

The input parameters are:

  • sd: A datetime object that represents the start date
  • ed: A datetime object that represents the end date
  • syms: A list of 2 or more symbols that make up the portfolio (note that your code should support any symbol in the data directory)
  • allocs: A list of 2 or more allocations to the stocks, must sum to 1.0
  • sv: Start value of the portfolio
  • rfr: The risk free return per sample period that does not change for the entire date range (a single number, not an array).
  • sf: Sampling frequency per year
  • gen_plot: If False, do not create any output. If True it is OK to output a plot such as plot.png

Template

A template is provided for you to get started with the project. You will find it in the appropriate subdirectory that you checked out from github.

You should see the following directory structure:

  • ml4t/: Root directory for course
    • data/: Location of data that you installed earlier
    • mc1_p1/: Root directory for this project
      • analysis.py: Main project script with functions you need to implement, as well as test code
      • output/: Directory to store all program outputs, including plots
      • util.py: Utility functions (do not modify these, unless instructed)

You should change ONLY analysis.py. ALL of your code should be in that one file. Do not create additional files. It should always remain in and run from the directory ml4t/mc1_p1/. If you move it somewhere else and develop your code there, it may not run properly when auto graded.

Notes:

  • Ignore any file named __init__.py; they are used to mark directories as Python packages.
  • We assume your data/ directory is one level up, (i.e., ../data/). That directory should contain all stock data, in CSV files (e.g. GOOG.csv, AAPL.csv, etc.)
  • To execute the main script, make sure your current working directory is mc1_p1/, then run:
python analysis.py

Suggestions

Here is a suggested high-level outline for what your code needs to do:

  • Read in adjusted closing prices for the 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.
  • Multiply these normalized allocations by starting value of overall portfolio, to get position values.
  • Sum each row (i.e. all position values for each day). That is your daily portfolio value.
  • Compute statistics from the total portfolio value.

You will need to reuse some of your code from this project for the next project. To make that task easier, we suggest that you create a helper function within your code that has the following prototype. Note that we will not be testing this part of your code directly, so it isn't essential that you follow the API exactly.

cr, adr, sddr, sr = \
    compute_portfolio_stats(prices = df_prices, \
    allocs=[0.1,0.2,0.3,0.4],\
    rfr = 0.0, sf = 252.0)

Where the returned outputs are:

  • cr: Cumulative return
  • adr: Average daily return
  • sddr: Standard deviation of daily return
  • sr: Sharpe Ratio

The input parameters are:

  • prices is a data frame or an ndarray of historical prices.
  • allocs: A list of allocations to the stocks, must sum to 1.0
  • rfr: The risk free return per sample period for the entire date range. We assume that it does not change.
  • sf: Sampling frequency per year

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 cannot 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

These are actual correct examples that you can use to check your work.

Example 1

Start Date: 2010-01-01
End Date: 2010-12-31
Symbols: ['GOOG', 'AAPL', 'GLD', 'XOM']
Allocations: [0.2, 0.3, 0.4, 0.1]
Sharpe Ratio: 1.51819243641
Volatility (stdev of daily returns): 0.0100104028
Average Daily Return: 0.000957366234238
Cumulative Return: 0.255646784534

Example1.png

Example 2

Start Date: 2010-01-01
End Date: 2010-12-31
Symbols: ['AXP', 'HPQ', 'IBM', 'HNZ']
Allocations: [0.0, 0.0, 0.0, 1.0]
Sharpe Ratio: 1.30798398744
Volatility (stdev of daily returns): 0.00926153128768
Average Daily Return: 0.000763106152672
Cumulative Return: 0.198105963655

Example 2.png

Example 3

Start Date: 2010-06-01
End Date: 2010-12-31
Symbols: ['GOOG', 'AAPL', 'GLD', 'XOM']
Allocations: [0.2, 0.3, 0.4, 0.1]
Sharpe Ratio: 2.21259766672
Volatility (stdev of daily returns): 0.00929734619707
Average Daily Return: 0.00129586924366
Cumulative Return: 0.205113938792

What to turn in

Be sure to follow these instructions diligently!

Submit via T-Square as attachments only (no zip files please):

  • Your code as analysis.py (please use this EXACT filename)

Important: We may test against OTHER symbols and other allocations, so don't hardcode the list of symbols.

Unlimited resubmissions are allowed up to the deadline for the project.

Rubric

10 test cases: We will test your code against 10 cases (10% per case). Each case will be deemed "correct" if:

  • 5%: Sharpe ratio = reference answer +- 0.001
  • 2.5%: Average daily return = reference answer +- 0.00001
  • 2.5%: Cumulative return = reference answer +- 0.001

Test Cases

Here are the test cases we used while grading. These are updated each semester, and released after grading.

Required, Allowed & Prohibited

Required:

  • Your project must be coded in Python 2.7.x.
  • Your code must run on one of the university-provided computers (e.g. buffet02.cc.gatech.edu).
  • Use the code for reading in historical data provided in util.py
  • Your code must run in less than 5 seconds on one of the university-provided computers.

Allowed:

  • You can develop your code on your personal machine, but it must also run successfully on one of the university provided machines or virtual images.
  • Your code may use standard Python libraries (except os).
  • You may use the NumPy, SciPy, matplotlib and Pandas libraries. Be sure you are using the correct versions.
  • You may reuse sections of code (up to 5 lines) that you collected from other students or the internet.
  • Code provided by the instructor, or allowed by the instructor to be shared.

Prohibited:

  • Any use of global variables.
  • Any libraries not listed in the "allowed" section above.
  • Use of any code other than util.py to read in data.
  • Use of Python's os module.
  • Any code you did not write yourself (except for the 5 line rule in the "allowed" section).
  • Knights who say "neeee."

Legacy versions