Spring 2020 Project 5: Marketsim

From Quantitative Analysis Software Courses
Revision as of 21:28, 5 February 2020 by Jfox44 (talk | contribs)
Jump to navigation Jump to search

Due Date

03/08/2020 11:59PM Anywhere on Earth time

Revisions

This assignment is subject to change up until 3 weeks prior to the due date. We do not anticipate changes; any changes will be logged in this section.

Overview

In this project you will create a market simulator that accepts trading orders and keeps track of a portfolio's value over time and then assesses the performance of that portfolio.

Template

Instructions:

Tasks

Part 1: Basic simulator (90 points)

How It Should Work

Evaluation

Part 2: Transaction Costs (10 points)

Part 3: Implement author() function (deduction if not implemented)

Short Code Check Example

More Comprehensive Examples

Hints

What to turn in

Be sure to follow these instructions diligently!

Via Canvas, submit as attachment (no zip files; refer to schedule for deadline):

  • Project 5: Marketsim
    • Your code as marketsim.py (only the function compute_portvals() will be tested)

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

Rubric

Report

No report

Code

Out of a total of 100 points:

  • Basic simulator: 90 points: 10 test cases: We will test your code against 10 cases (9 points per case) without transaction costs. Points per case are allocated as follows:
    • 2.0: Correct number of days reported in the dataframe (should be the number of trading days between the start date and end date, inclusive).
    • 5.0: Correct portfolio value on the last day +-0.1%
    • 1.0: Correct Sharpe Ratio +-0.1%
    • 1.0: Correct average daily return +-0.1%
  • Transaction costs: 10 points: 5 test cases: We will test your code against 5 cases as follows:
    • 2.0: Two test cases that evaluate commissions only (impact = 0)
    • 2.0: Two test cases that evaluate impact only (commission = 0)
    • 1.0: One test case with non-zero commission and impact.

Legacy Test Cases

Here are the test cases we used while grading. These are updated each semester but can be used as additional checks.

Required, Allowed & Prohibited

Required:

  • Your project must be coded in Python 3.6.x.
  • Your code must run on one of the university-provided computers (e.g. buffet0.cc.gatech.edu).
  • When utilizing any of the example orders files code must run in less than 10 seconds on one of the university-provided computers.
  • To read in stock data, use only the functions in util.py. Only use the API methods provided here. Do NOT modify this file. For grading, we will use our own unmodified version.

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.
  • Unladen African swallows.
  • You may use the NumPy, SciPy, matplotlib and Pandas libraries. Be sure you are using the correct versions.
  • Code provided by the instructor, or allowed by the instructor to be shared.
  • To read in orders files pandas.read_csv() is allowed.

Prohibited:

  • Global variables.
  • Reading in data by any means other than the API functions in util.py or pandas.read_csv()
  • Any libraries or modules not listed in the "allowed" section above.
  • Any code you did not write yourself.
  • Code that takes longer than 10 seconds to run.
  • Any Classes (other than Random) that create their own instance variables for later use (e.g., learners like kdtree).

FAQs

  • Q: How can I be sure that my function is returning a DataFrame? A: Check the type of the returned item foo with type(foo)
  • Q: Do we have to reject the order if the stock is not trading on that day? A: You should fill orders for any day the market is open, and reject orders for any day the market is closed. Suggested operation: Drop days when the market is not open (check by looking at SPY), fill forward, then fill back.
  • Q: Is it true that the orders might not be in order in the csv? A: Yes.
  • Q: Are we supposed to sort the date column after? A: Yes.
  • Q: If we were to sort, we can assume that multiple orders on the same date won't have any side-effect if they are executed in random orders? A: Yes.
  • Q: Should we assume the prices stay the same the whole day? A: Assume execution prices are adjusted close.
  • Q: Do we return portvals daily for the entire periods including weekends, holidays and non-trading days? A: Only consider trading days. This should happen for you automatically when using get_data() from util.py
  • Q: It seems like my avg_daily_returns and std are off compared to the wiki's because of this. If not, do we count trading days only for when list of symbols (or SPY) are traded A: Assume the market was open iff SPY was traded.
  • Q: Is it okay to have NaNs in the final portfolio values that the function outputs? A: No, you should have a real number value for every date in the final portfolio value.