{"id":1328,"date":"2021-01-14T00:09:40","date_gmt":"2021-01-14T00:09:40","guid":{"rendered":"http:\/\/lucylabs.gatech.edu\/ml4t\/?page_id=1328"},"modified":"2021-01-14T09:33:55","modified_gmt":"2021-01-14T09:33:55","slug":"project-5","status":"publish","type":"page","link":"https:\/\/lucylabs.gatech.edu\/ml4t\/spring2021\/project-5\/","title":{"rendered":"Project 5"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.4.5&#8243; header_font=&#8221;|700||on|||||&#8221;]<\/p>\n<h1 style=\"text-align: center;\">Project 5: Marketsim<\/h1>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.8.0&#8243; header_2_font=&#8221;|||on|on||||&#8221; hover_enabled=&#8221;0&#8243; sticky_enabled=&#8221;0&#8243;]<\/p>\n<h2>Due Date<\/h2>\n<p><span>03\/07\/2021 11:59 PM <\/span><a rel=\"nofollow noopener noreferrer\" class=\"external text\" target=\"_blank\" href=\"https:\/\/www.timeanddate.com\/time\/zones\/aoe\">Anywhere on Earth time<\/a><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.4.5&#8243; header_2_font=&#8221;|||on|on||||&#8221;]<\/p>\n<h2>Revisions<\/h2>\n<p><span>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.<\/span><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.8.0&#8243; header_2_font=&#8221;|||on|on||||&#8221;]<\/p>\n<h2>Overview<\/h2>\n<h3><span style=\"color: #ff0000;\">This assigment counts towards 10% of your overall grade.<\/span><\/h3>\n<p><span>In this project you will create a market simulator that accepts trading orders and keeps track of a portfolio&#8217;s value over time and then assesses the performance of that portfolio.<\/span><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.8.0&#8243; header_2_font=&#8221;|||on|on||||&#8221;]<\/p>\n<h2>Template<\/h2>\n<p>Instructions:<\/p>\n<ul>\n<li>Download the appropriate zip file <a href=\"https:\/\/www.dropbox.com\/s\/9jedlhoww19ankp\/marketsim_2021Spring.zip?dl=1\" target=\"_blank\" rel=\"noopener noreferrer\">File:Marketsim_2021Spring.zip<\/a><\/li>\n<li>Implement the <tt>compute_portvals()<\/tt> function in the file <tt>marketsim\/marketsim.py<\/tt>.<\/li>\n<li>The grading script is <tt>marketsim\/grade_marketsim.py<\/tt>. For more details see here: <a href=\"http:\/\/lucylabs.gatech.edu\/ml4t\/spring2021\/software-setup\/\" target=\"_blank\" title=\"ML4T Software Setup\" rel=\"noopener noreferrer\">ML4T_Software_Setup<\/a><\/li>\n<\/ul>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.5.6&#8243; header_2_font=&#8221;|||on|on||||&#8221;]<\/p>\n<h2>Tasks<\/h2>\n<h3><span class=\"mw-headline\" id=\"Part_1:_Basic_simulator_.2890_points.29\">Part 1: Basic simulator (90 points)<\/span><\/h3>\n<p>Your job is to implement your market simulator as a function, <tt>compute_portvals()<\/tt> that returns a DataFrame with one column. You should implement it within the file <tt>marketsim.py<\/tt>. It should adhere to the following API:<\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;ZGVmIGNvbXB1dGVfcG9ydHZhbHMob3JkZXJzX2ZpbGUgPSAiLi9vcmRlcnMvb3JkZXJzLmNzdiIsIHN0YXJ0X3ZhbCA9IDEwMDAwMDAsIGNvbW1pc3Npb24gPSA5Ljk1LCBpbXBhY3QgPSAwLjAwNSk6CiAgICAjIFRPRE86IFlvdXIgY29kZSBoZXJlCiAgICByZXR1cm4gcG9ydHZhbHM=&#8221; language=&#8221;python&#8221; _builder_version=&#8221;4.5.6&#8243;]ZGVmIGNvbXB1dGVfcG9ydHZhbHMob3JkZXJzX2ZpbGUgPSAiLi9vcmRlcnMvb3JkZXJzLmNzdiIsIHN0YXJ0X3ZhbCA9IDEwMDAwMDAsIGNvbW1pc3Npb24gPSA5Ljk1LCBpbXBhY3QgPSAwLjAwNSk6CiAgICAjIFRPRE86IFlvdXIgY29kZSBoZXJlCiAgICByZXR1cm4gcG9ydHZhbHM=[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.5.6&#8243;]<\/p>\n<p>The start date and end date of the simulation are the first and last dates with orders in the <tt>orders_file<\/tt>. The arguments are as follows:<\/p>\n<ul>\n<li><tt>orders_file<\/tt> is the name of a file from which to read orders, and<\/li>\n<li><tt>start_val<\/tt> is the starting value of the portfolio (initial cash available)<\/li>\n<li><tt>commission<\/tt> is the fixed amount in dollars charged for each transaction (both entry and exit)<\/li>\n<li><tt>impact<\/tt> is the amount the price moves against the trader compared to the historical data at each transaction. Impact of 0.01 in the API corresponds to an impact of 1%.<\/li>\n<\/ul>\n<p>Return the result (<tt>portvals<\/tt>) as a single-column <tt>pandas.DataFrame<\/tt> (column name does not matter), containing the value of the portfolio for each trading day in the first column from <tt>start_date<\/tt> to <tt>end_date<\/tt>, inclusive.<\/p>\n<p>The files containing orders are CSV files with the following columns:<\/p>\n<ul>\n<li>Date (yyyy-mm-dd)<\/li>\n<li>Symbol (e.g. AAPL, GOOG)<\/li>\n<li>Order (BUY or SELL)<\/li>\n<li>Shares (no. of shares to trade)<\/li>\n<\/ul>\n<p>For example:<\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;RGF0ZSxTeW1ib2wsT3JkZXIsU2hhcmVzCjIwMDgtMTItMyxBQVBMLEJVWSwxMzAKMjAwOC0xMi04LEFBUEwsU0VMTCwxMzAKMjAwOC0xMi01LElCTSxCVVksNTA=&#8221; _builder_version=&#8221;4.5.6&#8243;]RGF0ZSxTeW1ib2wsT3JkZXIsU2hhcmVzCjIwMDgtMTItMyxBQVBMLEJVWSwxMzAKMjAwOC0xMi04LEFBUEwsU0VMTCwxMzAKMjAwOC0xMi01LElCTSxCVVksNTA=[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.4.5&#8243;]<\/p>\n<p><span>Your simulator should calculate the total value of the portfolio for each day using <\/span><b>adjusted closing prices<\/b><span>. The value for each day is cash plus the current value of equities. The resulting data frame should contain values like this:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;MjAwOC0xMi0zIDEwMDAwMDAKMjAwOC0xMi00IDEwMDAwMTAKMjAwOC0xMi01IDEwMDAyNTAKLi4u&#8221; _builder_version=&#8221;4.5.6&#8243;]MjAwOC0xMi0zIDEwMDAwMDAKMjAwOC0xMi00IDEwMDAwMTAKMjAwOC0xMi01IDEwMDAyNTAKLi4u[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.5.6&#8243;]<\/p>\n<h4><span class=\"mw-headline\" id=\"How_It_Should_Work\">How It Should Work<\/span><\/h4>\n<p>Your code should keep account of how many shares of each stock are in the portfolio on each day and how much cash is available on each day. Note that negative shares and negative cash are possible. Negative shares mean that the portfolio is in a short position for that stock. Negative cash means that you&#8217;ve borrowed money from the broker.<\/p>\n<p>When a BUY order occurs, you should add the appropriate number of shares to the count for that stock and subtract the appropriate cost of the shares from the cash account. The cost should be determined using the adjusted close price for that stock on that day.<\/p>\n<p>When a SELL order occurs, it works in reverse: You should subtract the number of shares from the count and add to the cash account.<\/p>\n<h4><span class=\"mw-headline\" id=\"Evaluation\">Evaluation<\/span><\/h4>\n<p>We will evaluate your code by calling <tt>compute_portvals()<\/tt> with multiple test cases. No other function in your code will be called by us, so do not depend on &#8220;main&#8221; code being called. Do not depend on global variables.<\/p>\n<p>For debugging purposes, you should write your own additional helper function to call <tt>compute_portvals()<\/tt> with your own test cases. We suggest that you report the following factors:<\/p>\n<ul>\n<li>Plot the price history over the trading period.<\/li>\n<li>Sharpe ratio (Always assume you have 252 trading days in a year. And risk-free rate = 0) of the total portfolio<\/li>\n<li>Cumulative return of the total portfolio<\/li>\n<li>Standard deviation of daily returns of the total portfolio<\/li>\n<li>Average daily return of the total portfolio<\/li>\n<li>Ending value of the portfolio<\/li>\n<\/ul>\n<h3><span class=\"mw-headline\" id=\"Part_2:_Transaction_Costs_.2810_points.29\">Part 2: Transaction Costs (10 points)<\/span><\/h3>\n<p>Note: We strongly encourage you to get the basic simulator working before you implement the transaction cost and market impact components of this project. Ok, now on to transaction costs.<\/p>\n<p>Transaction costs are an important consideration for investing strategy. Transaction costs include things like commissions, slippage, market impact and tax considerations. High transaction costs encourage less frequent trading, and accordingly a search for strategies that pay out over longer periods of time rather than just intraday or over several days. For this project we will consider two components of transaction cost: Commissions and market impact:<\/p>\n<ul>\n<li>Commissions: For each trade that you execute, charge a commission according to the parameter sent. Treat that as a deduction from your cash balance.<\/li>\n<li>Market impact: For each trade that you execute, assume that the stock price moves against you according to the <tt>impact<\/tt> parameter. So if you are buying, assume the price goes up before your purchase. Similarly, if selling, assume the price drops 50 bps before the sale. For simplicity treat the market impact penalty as a deduction from your cash balance.<\/li>\n<\/ul>\n<p>Both penalties should be applied for EACH transaction, for instance, depending on the parameter settings, a complete entry and exit will cost 2 * $9.95, plus 0.5% of the entry price and 0.5% of the exit price.<\/p>\n<h3><span class=\"mw-headline\" id=\"Part_3:_Implement_author.28.29_function_.28deduction_if_not_implemented.29\">Part 3: Implement author() function (deduction if not implemented)<\/span><\/h3>\n<p>You should implement a function called <tt>author()<\/tt> that returns your Georgia Tech user ID as a string. This is the ID you use to log into Canvas. It is not your 9 digit student number. Here is an example of how you might implement author():<\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;ZGVmIGF1dGhvcigpOgogICAgICAgIHJldHVybiAndGIzNCcgIyByZXBsYWNlIHRiMzQgd2l0aCB5b3VyIEdlb3JnaWEgVGVjaCB1c2VybmFtZS4=&#8221; language=&#8221;python&#8221; _builder_version=&#8221;4.5.6&#8243;]ZGVmIGF1dGhvcigpOgogICAgICAgIHJldHVybiAndGIzNCcgIyByZXBsYWNlIHRiMzQgd2l0aCB5b3VyIEdlb3JnaWEgVGVjaCB1c2VybmFtZS4=[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.4.5&#8243;]<\/p>\n<p><span>And here&#8217;s an example of how it could be called from a testing program:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;aW1wb3J0IG1hcmtldHNpbSBhcyBtcwpwcmludCBtcy5hdXRob3IoKQ==&#8221; language=&#8221;python&#8221; _builder_version=&#8221;4.5.6&#8243;]aW1wb3J0IG1hcmtldHNpbSBhcyBtcwpwcmludCBtcy5hdXRob3IoKQ==[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.8.0&#8243;]<\/p>\n<p>Check the template code for examples. We are adding those to the repo now, but it might not be there if you check right away. Implementing this method correctly does not provide any points, but there will be a penalty for not implementing it.<\/p>\n<h2><span class=\"mw-headline\" id=\"Example_Tests.2FChecks\">Example Tests\/Checks<\/span><\/h2>\n<h3><span class=\"mw-headline\" id=\"Orders_File_Code_Check_Examples\">Orders File Code Check Examples<\/span><\/h3>\n<p>Example orders files are available in the orders subdirectory.<\/p>\n<p>Here are some additional test cases:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.dropbox.com\/s\/vkvpo3kas8ona25\/testcases_mc2p1.zip?dl=1\" class=\"internal\" title=\"Testcases mc2p1.zip\" target=\"_blank\" rel=\"noopener noreferrer\">testcases_mc2p1.zip<\/a><\/li>\n<li><a href=\"https:\/\/www.dropbox.com\/s\/duene6lrebwq3wo\/additional_orders.zip?dl=1\" class=\"internal\" title=\"Additional orders.zip\" target=\"_blank\" rel=\"noopener noreferrer\">additional_orders.zip<\/a><\/li>\n<\/ul>\n<h3><span class=\"mw-headline\" id=\"Short_Code_Check_Example\">Short Code Check Example<\/span><\/h3>\n<p>Here is a very very short example that you can use to check your code. Starting conditions:<\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;c3RhcnRfdmFsID0gMTAwMDAwMA==&#8221; _builder_version=&#8221;4.5.6&#8243;]c3RhcnRfdmFsID0gMTAwMDAwMA==[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.4.5&#8243;]<\/p>\n<p><span>For the orders file <\/span><tt>orders-short.csv<\/tt><span>, the orders are:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;RGF0ZSxTeW1ib2wsT3JkZXIsU2hhcmVzCjIwMTEtMDEtMDUsQUFQTCxCVVksMTUwMAoyMDExLTAxLTIwLEFBUEwsU0VMTCwxNTAw&#8221; _builder_version=&#8221;4.5.6&#8243;]RGF0ZSxTeW1ib2wsT3JkZXIsU2hhcmVzCjIwMTEtMDEtMDUsQUFQTCxCVVksMTUwMAoyMDExLTAxLTIwLEFBUEwsU0VMTCwxNTAw[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.4.5&#8243;]<\/p>\n<p><span>The daily value of the portfolio (spaces added to help things line up):<\/span><\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;MjAxMS0wMS0wNSAgICAgOTk3NDk1Ljc3NQoyMDExLTAxLTA2ICAgICA5OTcwOTAuNzc1CjIwMTEtMDEtMDcgICAgMTAwMDY2MC43NzUKMjAxMS0wMS0xMCAgICAxMDEwMTI1Ljc3NQoyMDExLTAxLTExICAgIDEwMDg5MTAuNzc1CjIwMTEtMDEtMTIgICAgMTAxMzA2NS43NzUKMjAxMS0wMS0xMyAgICAxMDE0OTQwLjc3NQoyMDExLTAxLTE0ICAgIDEwMTkxMjUuNzc1CjIwMTEtMDEtMTggICAgMTAwNzQyNS43NzUKMjAxMS0wMS0xOSAgICAxMDA0NzI1Ljc3NQoyMDExLTAxLTIwICAgICA5OTMwMzYuMzc1&#8243; _builder_version=&#8221;4.5.6&#8243;]MjAxMS0wMS0wNSAgICAgOTk3NDk1Ljc3NQoyMDExLTAxLTA2ICAgICA5OTcwOTAuNzc1CjIwMTEtMDEtMDcgICAgMTAwMDY2MC43NzUKMjAxMS0wMS0xMCAgICAxMDEwMTI1Ljc3NQoyMDExLTAxLTExICAgIDEwMDg5MTAuNzc1CjIwMTEtMDEtMTIgICAgMTAxMzA2NS43NzUKMjAxMS0wMS0xMyAgICAxMDE0OTQwLjc3NQoyMDExLTAxLTE0ICAgIDEwMTkxMjUuNzc1CjIwMTEtMDEtMTggICAgMTAwNzQyNS43NzUKMjAxMS0wMS0xOSAgICAxMDA0NzI1Ljc3NQoyMDExLTAxLTIwICAgICA5OTMwMzYuMzc1[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.4.5&#8243;]<\/p>\n<p><span>For reference, here are the <\/span><b>adjusted close<\/b><span> values for AAPL on the relevant days:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;ICAgICAgICAgICAgICBBQVBMCjIwMTEtMDEtMDUgIDMzMi41NwoyMDExLTAxLTA2ICAzMzIuMzAKMjAxMS0wMS0wNyAgMzM0LjY4CjIwMTEtMDEtMTAgIDM0MC45OQoyMDExLTAxLTExICAzNDAuMTgKMjAxMS0wMS0xMiAgMzQyLjk1CjIwMTEtMDEtMTMgIDM0NC4yMAoyMDExLTAxLTE0ICAzNDYuOTkKMjAxMS0wMS0xOCAgMzM5LjE5CjIwMTEtMDEtMTkgIDMzNy4zOQoyMDExLTAxLTIwICAzMzEuMjY=&#8221; _builder_version=&#8221;4.5.6&#8243;]ICAgICAgICAgICAgICBBQVBMCjIwMTEtMDEtMDUgIDMzMi41NwoyMDExLTAxLTA2ICAzMzIuMzAKMjAxMS0wMS0wNyAgMzM0LjY4CjIwMTEtMDEtMTAgIDM0MC45OQoyMDExLTAxLTExICAzNDAuMTgKMjAxMS0wMS0xMiAgMzQyLjk1CjIwMTEtMDEtMTMgIDM0NC4yMAoyMDExLTAxLTE0ICAzNDYuOTkKMjAxMS0wMS0xOCAgMzM5LjE5CjIwMTEtMDEtMTkgIDMzNy4zOQoyMDExLTAxLTIwICAzMzEuMjY=[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.4.5&#8243;]<\/p>\n<p><span>The full results:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;RGF0YSBSYW5nZTogMjAxMS0wMS0wNSAwMDowMDowMCB0byAyMDExLTAxLTIwIDAwOjAwOjAwCgpTaGFycGUgUmF0aW8gb2YgRnVuZDogLTEuMDAwMTUwMjUzNjMKU2hhcnBlIFJhdGlvIG9mICRTUFg6IDAuODgyMTY4Njc5Nzc2CgpDdW11bGF0aXZlIFJldHVybiBvZiBGdW5kOiAtMC4wMDQ0NzA1OTUzNzY3MQpDdW11bGF0aXZlIFJldHVybiBvZiAkU1BYOiAwLjAwMjg5ODQxNDQ4ODk0CgpTdGFuZGFyZCBEZXZpYXRpb24gb2YgRnVuZDogMC4wMDY3ODA3MzI3NDQ1OApTdGFuZGFyZCBEZXZpYXRpb24gb2YgJFNQWDogMC4wMDU0NDkzMzUyMTk5MQoKQXZlcmFnZSBEYWlseSBSZXR1cm4gb2YgRnVuZDogLTAuMDAwNDI3MjEwMTkzMzA4CkF2ZXJhZ2UgRGFpbHkgUmV0dXJuIG9mICRTUFg6IDAuMDAwMzAyODI3MjA1NTQ3CgpGaW5hbCBQb3J0Zm9saW8gVmFsdWU6IDk5MzAzNi4zNzU=&#8221; _builder_version=&#8221;4.5.6&#8243;]RGF0YSBSYW5nZTogMjAxMS0wMS0wNSAwMDowMDowMCB0byAyMDExLTAxLTIwIDAwOjAwOjAwCgpTaGFycGUgUmF0aW8gb2YgRnVuZDogLTEuMDAwMTUwMjUzNjMKU2hhcnBlIFJhdGlvIG9mICRTUFg6IDAuODgyMTY4Njc5Nzc2CgpDdW11bGF0aXZlIFJldHVybiBvZiBGdW5kOiAtMC4wMDQ0NzA1OTUzNzY3MQpDdW11bGF0aXZlIFJldHVybiBvZiAkU1BYOiAwLjAwMjg5ODQxNDQ4ODk0CgpTdGFuZGFyZCBEZXZpYXRpb24gb2YgRnVuZDogMC4wMDY3ODA3MzI3NDQ1OApTdGFuZGFyZCBEZXZpYXRpb24gb2YgJFNQWDogMC4wMDU0NDkzMzUyMTk5MQoKQXZlcmFnZSBEYWlseSBSZXR1cm4gb2YgRnVuZDogLTAuMDAwNDI3MjEwMTkzMzA4CkF2ZXJhZ2UgRGFpbHkgUmV0dXJuIG9mICRTUFg6IDAuMDAwMzAyODI3MjA1NTQ3CgpGaW5hbCBQb3J0Zm9saW8gVmFsdWU6IDk5MzAzNi4zNzU=[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.4.5&#8243;]<\/p>\n<h3><span class=\"mw-headline\" id=\"More_Comprehensive_Examples\">More Comprehensive Examples<\/span><\/h3>\n<h4><span class=\"mw-headline\" id=\"orders.csv\"><tt>orders.csv<\/tt><\/span><\/h4>\n<p>We provide an example, <tt>orders.csv<\/tt> that you can use to test your code, and compare with others. All of these runs assume a starting portfolio of 1000000 ($1M).<\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;RGF0YSBSYW5nZTogMjAxMS0wMS0xMCAwMDowMDowMCB0byAyMDExLTEyLTIwIDAwOjAwOjAwCgpTaGFycGUgUmF0aW8gb2YgRnVuZDogMC45OTc2NTQ1MjE4NzgKU2hhcnBlIFJhdGlvIG9mICRTUFg6IDAuMDE4MzM4OTgwNzQ0MwoKQ3VtdWxhdGl2ZSBSZXR1cm4gb2YgRnVuZDogMC4xMDg4NzI2OTg1NDQKQ3VtdWxhdGl2ZSBSZXR1cm4gb2YgJFNQWDogLTAuMDIyNDA1OTg1NDMwMgoKU3RhbmRhcmQgRGV2aWF0aW9uIG9mIEZ1bmQ6IDAuMDA3MzA1MDk5MTY4MzUKU3RhbmRhcmQgRGV2aWF0aW9uIG9mICRTUFg6IDAuMDE0OTcxNjA5MTUyMgoKQXZlcmFnZSBEYWlseSBSZXR1cm4gb2YgRnVuZDogMC4wMDA0NTkwOTg2NTU0OTMKQXZlcmFnZSBEYWlseSBSZXR1cm4gb2YgJFNQWDogMS43Mjk1OTA5NTM0ZS0wNQoKRmluYWwgUG9ydGZvbGlvIFZhbHVlOiAxMTA2MDI1LjgwNjU=&#8221; _builder_version=&#8221;4.5.6&#8243;]RGF0YSBSYW5nZTogMjAxMS0wMS0xMCAwMDowMDowMCB0byAyMDExLTEyLTIwIDAwOjAwOjAwCgpTaGFycGUgUmF0aW8gb2YgRnVuZDogMC45OTc2NTQ1MjE4NzgKU2hhcnBlIFJhdGlvIG9mICRTUFg6IDAuMDE4MzM4OTgwNzQ0MwoKQ3VtdWxhdGl2ZSBSZXR1cm4gb2YgRnVuZDogMC4xMDg4NzI2OTg1NDQKQ3VtdWxhdGl2ZSBSZXR1cm4gb2YgJFNQWDogLTAuMDIyNDA1OTg1NDMwMgoKU3RhbmRhcmQgRGV2aWF0aW9uIG9mIEZ1bmQ6IDAuMDA3MzA1MDk5MTY4MzUKU3RhbmRhcmQgRGV2aWF0aW9uIG9mICRTUFg6IDAuMDE0OTcxNjA5MTUyMgoKQXZlcmFnZSBEYWlseSBSZXR1cm4gb2YgRnVuZDogMC4wMDA0NTkwOTg2NTU0OTMKQXZlcmFnZSBEYWlseSBSZXR1cm4gb2YgJFNQWDogMS43Mjk1OTA5NTM0ZS0wNQoKRmluYWwgUG9ydGZvbGlvIFZhbHVlOiAxMTA2MDI1LjgwNjU=[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.5.6&#8243;]<\/p>\n<h4><span class=\"mw-headline\" id=\"orders2.csv\"><tt>orders2.csv<\/tt><\/span><\/h4>\n<p>The other sample file is <tt>orders2.csv<\/tt> that you can use to test your code and compare with others.<\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;RGF0YSBSYW5nZTogMjAxMS0wMS0xNCAwMDowMDowMCB0byAyMDExLTEyLTE0IDAwOjAwOjAwCgpTaGFycGUgUmF0aW8gb2YgRnVuZDogMC41NTI2MDQ5MDc5ODcKU2hhcnBlIFJhdGlvIG9mICRTUFg6IC0wLjE3NzIwMzAxOTkwNgoKQ3VtdWxhdGl2ZSBSZXR1cm4gb2YgRnVuZDogMC4wNTM4NDExMTk2OTUxCkN1bXVsYXRpdmUgUmV0dXJuIG9mICRTUFg6IC0wLjA2Mjk1ODE1MTYxOTIKClN0YW5kYXJkIERldmlhdGlvbiBvZiBGdW5kOiAwLjAwNzI4MTcyOTEwMzIzClN0YW5kYXJkIERldmlhdGlvbiBvZiAkU1BYOiAwLjAxNTA1NjQ4NTU3MjQKCkF2ZXJhZ2UgRGFpbHkgUmV0dXJuIG9mIEZ1bmQ6IDAuMDAwMjUzNDgzMDg1ODk4CkF2ZXJhZ2UgRGFpbHkgUmV0dXJuIG9mICRTUFg6IC0wLjAwMDE2ODA3MTY0ODkwMgoKRmluYWwgUG9ydGZvbGlvIFZhbHVlOiAxMDUxMDg4LjA5MTU=&#8221; _builder_version=&#8221;4.5.6&#8243;]RGF0YSBSYW5nZTogMjAxMS0wMS0xNCAwMDowMDowMCB0byAyMDExLTEyLTE0IDAwOjAwOjAwCgpTaGFycGUgUmF0aW8gb2YgRnVuZDogMC41NTI2MDQ5MDc5ODcKU2hhcnBlIFJhdGlvIG9mICRTUFg6IC0wLjE3NzIwMzAxOTkwNgoKQ3VtdWxhdGl2ZSBSZXR1cm4gb2YgRnVuZDogMC4wNTM4NDExMTk2OTUxCkN1bXVsYXRpdmUgUmV0dXJuIG9mICRTUFg6IC0wLjA2Mjk1ODE1MTYxOTIKClN0YW5kYXJkIERldmlhdGlvbiBvZiBGdW5kOiAwLjAwNzI4MTcyOTEwMzIzClN0YW5kYXJkIERldmlhdGlvbiBvZiAkU1BYOiAwLjAxNTA1NjQ4NTU3MjQKCkF2ZXJhZ2UgRGFpbHkgUmV0dXJuIG9mIEZ1bmQ6IDAuMDAwMjUzNDgzMDg1ODk4CkF2ZXJhZ2UgRGFpbHkgUmV0dXJuIG9mICRTUFg6IC0wLjAwMDE2ODA3MTY0ODkwMgoKRmluYWwgUG9ydGZvbGlvIFZhbHVlOiAxMDUxMDg4LjA5MTU=[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.5.6&#8243;]<\/p>\n<h3><span class=\"mw-headline\" id=\"Hints_.26_Resources\">Hints &amp; Resources<\/span><\/h3>\n<p>Here is a video outlining an approach to solving this problem [<a rel=\"nofollow noopener noreferrer\" class=\"external text\" target=\"_blank\" href=\"https:\/\/www.youtube.com\/watch?v=TstVUVbu-Tk\">youtube video<\/a>].<\/p>\n<p>Hint, use code like this to read in the orders file:<\/p>\n<p>[\/et_pb_text][et_pb_dmb_code_snippet code=&#8221;b3JkZXJzX2RmID0gcGFuZGFzLnJlYWRfY3N2KG9yZGVyc19maWxlLCBpbmRleF9jb2w9J0RhdGUnLCBwYXJzZV9kYXRlcz1UcnVlLCBuYV92YWx1ZXM9WyduYW4nXSk=&#8221; language=&#8221;python&#8221; _builder_version=&#8221;4.5.6&#8243;]b3JkZXJzX2RmID0gcGFuZGFzLnJlYWRfY3N2KG9yZGVyc19maWxlLCBpbmRleF9jb2w9J0RhdGUnLCBwYXJzZV9kYXRlcz1UcnVlLCBuYV92YWx1ZXM9WyduYW4nXSk=[\/et_pb_dmb_code_snippet][et_pb_text _builder_version=&#8221;4.4.5&#8243;]<\/p>\n<p><span>In terms of execution prices, you should assume you get the <\/span><b>adjusted close<\/b><span> price for the day of the trade.<\/span><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.8.0&#8243; header_2_font=&#8221;|||on|on||||&#8221;]<\/p>\n<h2>What To Turn In<\/h2>\n<h3>Gradescope:<\/h3>\n<ul>\n<li>(SUBMISSION) Project 5: Marketsim\n<ul>\n<li>Your code as <tt>marketsim.py\u00a0(only the function <tt>compute_portvals()<\/tt> will be tested)<\/tt><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Do not submit any other files.<\/p>\n<p>You are only allowed 3 submissions to <strong>(SUBMISSION) Project 5: Marketsim<\/strong>\u00a0but\u00a0unlimited resubmissions are allowed on <strong>(TESTING) Project 5: Marketsim.<\/strong><\/p>\n<p>Note that Gradescope does <strong>not<\/strong> grade your assignment live; instead, it pre-validates that it will run against our batch autograder that we will run after the deadline. There will be <strong>no<\/strong> credit given for coding assignments that do not pass this pre-validation.<\/p>\n<p>Refer to the\u00a0<a href=\"http:\/\/lucylabs.gatech.edu\/ml4t\/spring2021\/gradescope\/\" target=\"_blank\" rel=\"noopener noreferrer\">Gradescope Instructions<\/a>\u00a0for more information.<\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.8.0&#8243; header_2_font=&#8221;|||on|on||||&#8221;]<\/p>\n<h2>Rubric<\/h2>\n<h3>Report<\/h3>\n<p>No report<\/p>\n<h3>Code<\/h3>\n<p>See auto-grader<\/p>\n<h3>Auto-Grader<\/h3>\n<p>Out of a total of 100 points:<\/p>\n<ul>\n<li>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:\n<ul>\n<li>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).<\/li>\n<li>5.0: Correct portfolio value on the last day +-0.1%<\/li>\n<li>1.0: Correct Sharpe Ratio +-0.1%<\/li>\n<li>1.0: Correct average daily return +-0.1%<\/li>\n<\/ul>\n<\/li>\n<li>Transaction costs: 10 points: 5 test cases: We will test your code against 5 cases as follows:\n<ul>\n<li>2.0: Two test cases that evaluate commissions only (impact = 0)<\/li>\n<li>2.0: Two test cases that evaluate impact only (commission = 0)<\/li>\n<li>1.0: One test case with non-zero commission and impact.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4><span class=\"mw-headline\" id=\"Legacy_Test_Cases\">Legacy Test Cases<\/span><\/h4>\n<p>Here are the test cases we used while grading. These are updated each semester but can be used as additional checks.<\/p>\n<ul>\n<li><a href=\"http:\/\/lucylabs.gatech.edu\/ml4t\/mc2-project-1-test-cases-spr2016\/\" target=\"_blank\" title=\"MC2-Project-1-Test-Cases-spr2016\" rel=\"noopener noreferrer\">MC2-Project-1-Test-Cases-spr2016<\/a><\/li>\n<\/ul>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.5.6&#8243; header_2_font=&#8221;|||on|on||||&#8221;]<\/p>\n<h2>Required, Allowed &amp; Prohibited<\/h2>\n<h3><span class=\"mw-headline\" id=\"Required\">Required<\/span><\/h3>\n<ul>\n<li>Your project must be coded in Python 3.6.x.<\/li>\n<li>Your code must run on Gradescope.<\/li>\n<li>When utilizing any of the example orders files code must run in less than 10 seconds.<\/li>\n<li>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.<\/li>\n<\/ul>\n<h3><span class=\"mw-headline\" id=\"Allowed\">Allowed<\/span><\/h3>\n<ul>\n<li>You can develop your code on your personal machine, but it must also run successfully on Gradescope.<\/li>\n<li>Your code may use standard Python libraries.<\/li>\n<li>Unladen African swallows.<\/li>\n<li>You may use the NumPy, SciPy, matplotlib and Pandas libraries. Be sure you are using the correct versions.<\/li>\n<li>Code provided by the instructor, or allowed by the instructor to be shared.<\/li>\n<li>To read in orders files pandas.read_csv() is allowed.<\/li>\n<\/ul>\n<h3><span class=\"mw-headline\" id=\"Prohibited\">Prohibited<\/span><\/h3>\n<ul>\n<li>Global variables.<\/li>\n<li>Reading in data by any means other than the API functions in util.py or pandas.read_csv()<\/li>\n<li>Any libraries or modules not listed in the &#8220;allowed&#8221; section above.<\/li>\n<li>Any code you did not write yourself.<\/li>\n<li>Code that takes longer than 10 seconds to run.<\/li>\n<li>Any Classes (other than Random) that create their own instance variables for later use (e.g., learners like kdtree).<\/li>\n<li>Absolute import statements of the <strong>current<\/strong> project folder such as <code>from marketsim import XXXX or import marketsim.XXXX<\/code><\/li>\n<li>Extra directories (manually or code created)<\/li>\n<li>Extra files not listed in \u201cWHAT TO TURN IN\u201d<\/li>\n<\/ul>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.4.5&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.4.5&#8243;][et_pb_text _builder_version=&#8221;4.4.5&#8243; header_2_font=&#8221;|||on|on||||&#8221;]<\/p>\n<h2>FAQ<\/h2>\n<ul>\n<li><span><b>Q:<\/b><\/span> How can I be sure that my function is returning a DataFrame? <br \/><span><b>A:<\/b><\/span> Check the type of the returned item foo with <tt>type(foo)<\/tt><\/li>\n<\/ul>\n<ul>\n<li><span><b>Q:<\/b><\/span> Do we have to reject the order if the stock is not trading on that day? <br \/><span><b>A:<\/b><\/span> 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.<\/li>\n<\/ul>\n<ul>\n<li><span><b>Q:<\/b><\/span> Is it true that the orders might not be in order in the csv? <br \/><span><b>A:<\/b><\/span> Yes.<\/li>\n<\/ul>\n<ul>\n<li><span><b>Q:<\/b><\/span> Are we supposed to sort the date column after? <br \/><span><b>A:<\/b><\/span> Yes.<\/li>\n<\/ul>\n<ul>\n<li><span><b>Q:<\/b><\/span> If we were to sort, we can assume that multiple orders on the same date won&#8217;t have any side-effect if they are executed in random orders? <br \/><span><b>A:<\/b><\/span> Yes.<\/li>\n<\/ul>\n<ul>\n<li><span><b>Q:<\/b><\/span> Should we assume the prices stay the same the whole day? <br \/><span><b>A:<\/b><\/span> Assume execution prices are adjusted close.<\/li>\n<\/ul>\n<ul>\n<li><span><b>Q:<\/b><\/span> Do we return portvals daily for the entire periods including weekends, holidays and non-trading days? <br \/><span><b>A:<\/b><\/span> Only consider trading days. This should happen for you automatically when using get_data() from util.py<\/li>\n<\/ul>\n<ul>\n<li><span><b>Q:<\/b><\/span> It seems like my avg_daily_returns and std are off compared to the wiki&#8217;s because of this. If not, do we count trading days only for when list of symbols (or SPY) are traded <br \/><span><b>A:<\/b><\/span> Assume the market was open iff SPY was traded.<\/li>\n<\/ul>\n<ul>\n<li><b><span>Q:<\/span> Is it okay to have NaNs in the final portfolio values that the function outputs? <br \/><span>A:<\/span> No, you should have a real number value for every date in the final portfolio value.<\/b><\/li>\n<\/ul>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Project 5: MarketsimDue Date 03\/07\/2021 11:59 PM 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 This assigment counts towards 10% of your overall grade. In this project you will create [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":1316,"menu_order":10,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"class_list":["post-1328","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/comments?post=1328"}],"version-history":[{"count":6,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1328\/revisions"}],"predecessor-version":[{"id":1940,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1328\/revisions\/1940"}],"up":[{"embeddable":true,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1316"}],"wp:attachment":[{"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/media?parent=1328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}