{"id":1338,"date":"2021-01-13T23:45:44","date_gmt":"2021-01-13T23:45:44","guid":{"rendered":"http:\/\/lucylabs.gatech.edu\/ml4t\/?page_id=1338"},"modified":"2021-01-14T02:21:01","modified_gmt":"2021-01-14T02:21:01","slug":"project-2","status":"publish","type":"page","link":"https:\/\/lucylabs.gatech.edu\/ml4t\/spring2021\/code-documentation\/project-2\/","title":{"rendered":"Project 2"},"content":{"rendered":"\n\n\n[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;3.22&#8243;][et_pb_row _builder_version=&#8221;3.25&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_text _builder_version=&#8221;4.5.6&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; hover_enabled=&#8221;0&#8243;]<div class=\"document\">\n<div class=\"documentwrapper\">\n<div class=\"bodywrapper\">\n<div class=\"body\" role=\"main\">\n<div class=\"section\" id=\"module-optimization\">\n<h1 style=\"text-align: center;\">Project 2: Optimize Something Documentation<\/h1>\n<h2><span style=\"text-decoration: underline;\"><\/span><\/h2>\n<p><span style=\"text-decoration: underline;\"><\/span><\/p>\n<h2><span style=\"text-decoration: underline;\">optimization.py<\/span><\/h2>\n<p>&nbsp;<\/p>\n<dl class=\"function\">\n<dt><code class=\"sig-name descname\">optimize_portfolio<\/code><span class=\"sig-paren\">(<\/span><em class=\"sig-param\">sd=datetime.datetime(2008, 1, 1, 0, 0), ed=datetime.datetime(2009, 1, 1, 0, 0), syms=[&#8216;GOOG&#8217;, &#8216;AAPL&#8217;, &#8216;GLD&#8217;, &#8216;XOM&#8217;], gen_plot=False<\/em><span class=\"sig-paren\">)<\/span><\/dt>\n<dd><p>This function should find the optimal allocations for a given set of stocks. You should optimize for maximum Sharpe<br \/> Ratio. The function should accept as input a list of symbols as well as start and end dates and return a list of<br \/> floats (as a one-dimensional numpy array) that represents the allocations to each of the equities. You can take<br \/> advantage of routines developed in the optional assess portfolio project to compute daily portfolio value and<br \/> statistics.<\/p>\n<dl class=\"field-list simple\">\n<dt class=\"field-odd\">Parameters<\/dt>\n<dd class=\"field-odd\">\n<ul class=\"simple\">\n<li><strong>sd<\/strong> (<em>datetime<\/em>) \u2013 A datetime object that represents the start date, defaults to 1\/1\/2008<\/li>\n<li><strong>ed<\/strong> (<em>datetime<\/em>) \u2013 A datetime object that represents the end date, defaults to 1\/1\/2009<\/li>\n<li><strong>syms<\/strong> (<em>list<\/em>) \u2013 A list of symbols that make up the portfolio (note that your code should support any<br \/> symbol in the data directory)<\/li>\n<li><strong>gen_plot<\/strong> (<em>bool<\/em>) \u2013 If True, optionally create a plot named plot.png. The autograder will always call your<br \/> code with gen_plot = False.<\/li>\n<\/ul>\n<\/dd>\n<dt class=\"field-even\">Returns<\/dt>\n<dd class=\"field-even\">A tuple containing the portfolio allocations, cumulative return, average daily returns,<br \/> standard deviation of daily returns, and Sharpe ratio<\/dd>\n<dt class=\"field-odd\">Return type<\/dt>\n<dd class=\"field-odd\">\n<p>tuple<\/p>\n<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<dl class=\"function\">\n<dt id=\"optimization.test_code\"><code class=\"sig-name descname\">test_code<\/code><span class=\"sig-paren\">(<\/span><span class=\"sig-paren\">)<\/span><\/dt>\n<dd>\n<p>This function WILL NOT be called by the auto grader.<\/p>\n<\/dd>\n<\/dl>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><!-- \/divi:html --> <!-- divi:html --><\/p>\n<div class=\"clearer\"><\/div>\n<p><!-- \/divi:html --> <!-- divi:html --><\/p>\n<div class=\"footer\">\u00a92020, ML4T Staff |\u00a0Powered by <a href=\"http:\/\/sphinx-doc.org\/\">Sphinx 2.2.0<\/a> &amp; <a href=\"https:\/\/github.com\/bitprophet\/alabaster\">Alabaster 0.7.12<\/a><\/div>\n<p><!-- \/divi:html --><\/p>\n[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]\n\n\n","protected":false},"excerpt":{"rendered":"<p>Project 2: Optimize Something Documentation optimization.py &nbsp; optimize_portfolio(sd=datetime.datetime(2008, 1, 1, 0, 0), ed=datetime.datetime(2009, 1, 1, 0, 0), syms=[&#8216;GOOG&#8217;, &#8216;AAPL&#8217;, &#8216;GLD&#8217;, &#8216;XOM&#8217;], gen_plot=False) This function should find the optimal allocations for a given set of stocks. You should optimize for maximum Sharpe Ratio. The function should accept as input a list of symbols as well as [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":1342,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"<!-- wp:html -->\n<meta charset=\"utf-8\">\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<title>Project 2: Optimize Something \u2014 ML4T 1.0 documentation<\/title>\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<link rel=\"stylesheet\" href=\"_static\/alabaster.css\" type=\"text\/css\">\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<link rel=\"stylesheet\" href=\"_static\/pygments.css\" type=\"text\/css\">\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<script type=\"text\/javascript\" id=\"documentation_options\" data-url_root=\".\/\" src=\"_static\/documentation_options.js\"><\/script>\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<script type=\"text\/javascript\" src=\"_static\/jquery.js\"><\/script>\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<script type=\"text\/javascript\" src=\"_static\/underscore.js\"><\/script>\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<script type=\"text\/javascript\" src=\"_static\/doctools.js\"><\/script>\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<script type=\"text\/javascript\" src=\"_static\/language_data.js\"><\/script>\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<link rel=\"index\" title=\"Index\" href=\"genindex.html\">\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<link rel=\"search\" title=\"Search\" href=\"search.html\">\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<link rel=\"next\" title=\"Project 3: Assess Learners\" href=\"assess_learners.html\">\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<link rel=\"prev\" title=\"Project 1: Martingale\" href=\"martingale.html\">\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<link rel=\"stylesheet\" href=\"_static\/custom.css\" type=\"text\/css\">\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=0.9, maximum-scale=0.9\">\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<div class=\"document\">\n      <div class=\"documentwrapper\">\n        <div class=\"bodywrapper\">\n          \n\n          <div class=\"body\" role=\"main\">\n            \n  <div class=\"section\" id=\"module-optimization\">\n<span id=\"project-2-optimize-something\"><\/span><h1>Project 2: Optimize Something<a class=\"headerlink\" href=\"#module-optimization\" title=\"Permalink to this headline\">\u00b6<\/a><\/h1>\n<dl class=\"function\">\n<dt id=\"optimization.optimize_portfolio\">\n<code class=\"sig-prename descclassname\">optimization.<\/code><code class=\"sig-name descname\">optimize_portfolio<\/code><span class=\"sig-paren\">(<\/span><em class=\"sig-param\">sd=datetime.datetime(2008, 1, 1, 0, 0), ed=datetime.datetime(2009, 1, 1, 0, 0), syms=['GOOG', 'AAPL', 'GLD', 'XOM'], gen_plot=False<\/em><span class=\"sig-paren\">)<\/span><a class=\"headerlink\" href=\"#optimization.optimize_portfolio\" title=\"Permalink to this definition\">\u00b6<\/a><\/dt>\n<dd><p>This function should find the optimal allocations for a given set of stocks. You should optimize for maximum Sharpe\nRatio. The function should accept as input a list of symbols as well as start and end dates and return a list of\nfloats (as a one-dimensional numpy array) that represents the allocations to each of the equities. You can take\nadvantage of routines developed in the optional assess portfolio project to compute daily portfolio value and\nstatistics.<\/p>\n<dl class=\"field-list simple\">\n<dt class=\"field-odd\">Parameters<\/dt>\n<dd class=\"field-odd\"><ul class=\"simple\">\n<li><p><strong>sd<\/strong> (<em>datetime<\/em>) \u2013 A datetime object that represents the start date, defaults to 1\/1\/2008<\/p><\/li>\n<li><p><strong>ed<\/strong> (<em>datetime<\/em>) \u2013 A datetime object that represents the end date, defaults to 1\/1\/2009<\/p><\/li>\n<li><p><strong>syms<\/strong> (<em>list<\/em>) \u2013 A list of symbols that make up the portfolio (note that your code should support any\nsymbol in the data directory)<\/p><\/li>\n<li><p><strong>gen_plot<\/strong> (<em>bool<\/em>) \u2013 If True, optionally create a plot named plot.png. The autograder will always call your\ncode with gen_plot = False.<\/p><\/li>\n<\/ul>\n<\/dd>\n<dt class=\"field-even\">Returns<\/dt>\n<dd class=\"field-even\"><p>A tuple containing the portfolio allocations, cumulative return, average daily returns,\nstandard deviation of daily returns, and Sharpe ratio<\/p>\n<\/dd>\n<dt class=\"field-odd\">Return type<\/dt>\n<dd class=\"field-odd\"><p>tuple<\/p>\n<\/dd>\n<\/dl>\n<\/dd><\/dl>\n\n<dl class=\"function\">\n<dt id=\"optimization.test_code\">\n<code class=\"sig-prename descclassname\">optimization.<\/code><code class=\"sig-name descname\">test_code<\/code><span class=\"sig-paren\">(<\/span><span class=\"sig-paren\">)<\/span><a class=\"headerlink\" href=\"#optimization.test_code\" title=\"Permalink to this definition\">\u00b6<\/a><\/dt>\n<dd><p>This function WILL NOT be called by the auto grader.<\/p>\n<\/dd><\/dl>\n\n<\/div>\n\n\n          <\/div>\n          \n        <\/div>\n      <\/div>\n\n\n        <\/div>\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<div class=\"clearer\"><\/div>\n<!-- \/wp:html -->\n\n<!-- wp:html -->\n<div class=\"footer\">\n      \u00a92020, ML4T Staff.\n      \n      |\n      Powered by <a href=\"http:\/\/sphinx-doc.org\/\">Sphinx 2.2.0<\/a>\n      &amp; <a href=\"https:\/\/github.com\/bitprophet\/alabaster\">Alabaster 0.7.12<\/a>\n      \n\n    <\/div>\n<!-- \/wp:html -->","_et_gb_content_width":"","footnotes":""},"class_list":["post-1338","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1338","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=1338"}],"version-history":[{"count":1,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1338\/revisions"}],"predecessor-version":[{"id":1350,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1338\/revisions\/1350"}],"up":[{"embeddable":true,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1342"}],"wp:attachment":[{"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/media?parent=1338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}