2012Fall7646 Project 1
Part 1: Create a market simulation tool, marketsim.py that takes a command line like this:
python marketsim.py 1000000 orders.csv values.csv
Where the number represents starting cash and orders.csv is a file of orders organized like this:
- BUY or SELL
- Number of Shares
2008, 12, 3, AAPL, BUY, 130 2008, 12, 8, AAPL, SELL, 130 2008, 12, 5, IBM, BUY, 50
Your simulator should calculate the total value of the portfolio for each day using adjusted closing prices (cash plus value of equities) and print the result to the file values.csv. The contents of the values.csv file should look something like this:
2008, 12, 3, 1000000 2008, 12, 4, 1000010 2008, 12, 5, 1000250 ...
Part 2: Create a portfolio analysis tool, analyze.py, that takes a command line like this:
python analyze.py values.csv $SPX
The tool should read in the daily values (cumulative portfolio value) from values.csv and plot them. It should use the symbol on the command line as a benchmark for comparison (in this case $SPX). Using this information, analyze.py should:
- Plot the price history over the trading period.
- Print out measures of the portfolio and the benchmark of:
- Sharpe Ratio
- Total Return
- Standard deviation of daily return
We will provide an example orders.csv that you can use to test your code, and compare with others. We will also provide (just before the due date) a "final" orders.csv file for you to run your code on to generate results to hand in.
In terms of execution prices, you should assume you get the adjusted close price for the day of the trade.
- Turn in files as attachments by t-square. Please do not "zip" your files together first; just submit separate files as named below:
- results.txt the text output of analyze.py when run on the "final" orders.csv file
- chart.pdf the chart showing your portfolio's performance
- values.csv the daily portfolio values
How to submit
Go to the t-square site for the class, then click on the "assignments" tab. Click on "add attachment" to add your three files. Once you are sure you've added both files, click "submit."
Will add them as they become relevant.