{"id":1332,"date":"2021-01-14T00:24:06","date_gmt":"2021-01-14T00:24:06","guid":{"rendered":"http:\/\/lucylabs.gatech.edu\/ml4t\/?page_id=1332"},"modified":"2021-01-14T02:09:24","modified_gmt":"2021-01-14T02:09:24","slug":"project-8","status":"publish","type":"page","link":"https:\/\/lucylabs.gatech.edu\/ml4t\/spring2021\/code-documentation\/project-8\/","title":{"rendered":"Project 8"},"content":{"rendered":"\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-StrategyLearner\">\n<h1 style=\"text-align: center;\">Project 8: Strategy Evaluation<\/h1>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"text-decoration: underline;\">StrategyLearner.py<\/span><\/h2>\n<p>&nbsp;<\/p>\n<dl class=\"class\">\n<dt id=\"StrategyLearner.StrategyLearner\"><em class=\"property\">class <\/em><code class=\"sig-prename descclassname\">StrategyLearner.<\/code><code class=\"sig-name descname\">StrategyLearner<\/code><span class=\"sig-paren\">(<\/span><em class=\"sig-param\">verbose=False<\/em>, <em class=\"sig-param\">impact=0.0<\/em>, <em class=\"sig-param\">commission=0.0<\/em><span class=\"sig-paren\">)<\/span><\/dt>\n<dd>\n<p>A strategy learner that can learn a trading policy using the same indicators used in ManualStrategy.<\/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>verbose<\/strong> (<em>bool<\/em>) \u2013 If \u201cverbose\u201d is True, your code can print out information for debugging.<br \/> If verbose = False your code should not generate ANY output.<\/li>\n<li><strong>impact<\/strong> (<em>float<\/em>) \u2013 The market impact of each transaction, defaults to 0.0<\/li>\n<li><strong>commission<\/strong> (<em>float<\/em>) \u2013 The commission amount charged, defaults to 0.0<\/li>\n<\/ul>\n<\/dd>\n<\/dl>\n<dl class=\"method\">\n<dt id=\"StrategyLearner.StrategyLearner.add_evidence\"><code class=\"sig-name descname\">add_evidence<\/code><span class=\"sig-paren\">(<\/span><em class=\"sig-param\">symbol=&#8217;IBM&#8217;<\/em>, <em class=\"sig-param\">sd=datetime.datetime(2008<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">0<\/em>, <em class=\"sig-param\">0)<\/em>, <em class=\"sig-param\">ed=datetime.datetime(2009<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">0<\/em>, <em class=\"sig-param\">0)<\/em>, <em class=\"sig-param\">sv=10000<\/em><span class=\"sig-paren\">)<\/span><\/dt>\n<dd>\n<p>Trains your strategy learner over a given time frame.<\/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>symbol<\/strong> (<em>str<\/em>) \u2013 The stock symbol to train on<\/li>\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>sv<\/strong> (<em>int<\/em>) \u2013 The starting value of the portfolio<\/li>\n<\/ul>\n<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<dl class=\"method\">\n<dt id=\"StrategyLearner.StrategyLearner.testPolicy\"><code class=\"sig-name descname\">testPolicy<\/code><span class=\"sig-paren\">(<\/span><em class=\"sig-param\">symbol=&#8217;IBM&#8217;<\/em>, <em class=\"sig-param\">sd=datetime.datetime(2009<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">0<\/em>, <em class=\"sig-param\">0)<\/em>, <em class=\"sig-param\">ed=datetime.datetime(2010<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">0<\/em>, <em class=\"sig-param\">0)<\/em>, <em class=\"sig-param\">sv=10000<\/em><span class=\"sig-paren\">)<\/span><\/dt>\n<dd>\n<p>Tests your learner using data outside of the training data<\/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>symbol<\/strong> (<em>str<\/em>) \u2013 The stock symbol that you trained on on<\/li>\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>sv<\/strong> (<em>int<\/em>) \u2013 The starting value of the portfolio<\/li>\n<\/ul>\n<\/dd>\n<dt class=\"field-even\">Returns<\/dt>\n<dd class=\"field-even\">A DataFrame with values representing trades for each day. Legal values are +1000.0 indicating<br \/> a BUY of 1000 shares, -1000.0 indicating a SELL of 1000 shares, and 0.0 indicating NOTHING.<br \/> Values of +2000 and -2000 for trades are also legal when switching from long to short or short to<br \/> long so long as net holdings are constrained to -1000, 0, and 1000.<\/dd>\n<dt class=\"field-odd\">Return type<\/dt>\n<dd class=\"field-odd\">\n<p>pandas.DataFrame<\/p>\n<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><!-- \/divi:html --><\/p>\n<p><!-- divi:html --><\/p>\n<div class=\"clearer\"><\/div>\n<p><!-- \/divi:html --><\/p>\n<p><!-- 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","protected":false},"excerpt":{"rendered":"<p>Project 8: Strategy Evaluation &nbsp; &nbsp; StrategyLearner.py &nbsp; class StrategyLearner.StrategyLearner(verbose=False, impact=0.0, commission=0.0) A strategy learner that can learn a trading policy using the same indicators used in ManualStrategy. Parameters verbose (bool) \u2013 If \u201cverbose\u201d is True, your code can print out information for debugging. If verbose = False your code should not generate ANY output. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":1342,"menu_order":1,"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 8: Strategy Evaluation \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=\"prev\" title=\"Project 7: Q-Learning Robot\" href=\"qlearning_robot.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-StrategyLearner\">\n<span id=\"project-8-strategy-evaluation\"><\/span><h1>Project 8: Strategy Evaluation<a class=\"headerlink\" href=\"#module-StrategyLearner\" title=\"Permalink to this headline\">\u00b6<\/a><\/h1>\n<dl class=\"class\">\n<dt id=\"StrategyLearner.StrategyLearner\">\n<em class=\"property\">class <\/em><code class=\"sig-prename descclassname\">StrategyLearner.<\/code><code class=\"sig-name descname\">StrategyLearner<\/code><span class=\"sig-paren\">(<\/span><em class=\"sig-param\">verbose=False<\/em>, <em class=\"sig-param\">impact=0.0<\/em>, <em class=\"sig-param\">commission=0.0<\/em><span class=\"sig-paren\">)<\/span><a class=\"headerlink\" href=\"#StrategyLearner.StrategyLearner\" title=\"Permalink to this definition\">\u00b6<\/a><\/dt>\n<dd><p>A strategy learner that can learn a trading policy using the same indicators used in ManualStrategy.<\/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>verbose<\/strong> (<em>bool<\/em>) \u2013 If \u201cverbose\u201d is True, your code can print out information for debugging.\nIf verbose = False your code should not generate ANY output.<\/p><\/li>\n<li><p><strong>impact<\/strong> (<em>float<\/em>) \u2013 The market impact of each transaction, defaults to 0.0<\/p><\/li>\n<li><p><strong>commission<\/strong> (<em>float<\/em>) \u2013 The commission amount charged, defaults to 0.0<\/p><\/li>\n<\/ul>\n<\/dd>\n<\/dl>\n<dl class=\"method\">\n<dt id=\"StrategyLearner.StrategyLearner.add_evidence\">\n<code class=\"sig-name descname\">add_evidence<\/code><span class=\"sig-paren\">(<\/span><em class=\"sig-param\">symbol='IBM'<\/em>, <em class=\"sig-param\">sd=datetime.datetime(2008<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">0<\/em>, <em class=\"sig-param\">0)<\/em>, <em class=\"sig-param\">ed=datetime.datetime(2009<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">0<\/em>, <em class=\"sig-param\">0)<\/em>, <em class=\"sig-param\">sv=10000<\/em><span class=\"sig-paren\">)<\/span><a class=\"headerlink\" href=\"#StrategyLearner.StrategyLearner.add_evidence\" title=\"Permalink to this definition\">\u00b6<\/a><\/dt>\n<dd><p>Trains your strategy learner over a given time frame.<\/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>symbol<\/strong> (<em>str<\/em>) \u2013 The stock symbol to train on<\/p><\/li>\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>sv<\/strong> (<em>int<\/em>) \u2013 The starting value of the portfolio<\/p><\/li>\n<\/ul>\n<\/dd>\n<\/dl>\n<\/dd><\/dl>\n\n<dl class=\"method\">\n<dt id=\"StrategyLearner.StrategyLearner.testPolicy\">\n<code class=\"sig-name descname\">testPolicy<\/code><span class=\"sig-paren\">(<\/span><em class=\"sig-param\">symbol='IBM'<\/em>, <em class=\"sig-param\">sd=datetime.datetime(2009<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">0<\/em>, <em class=\"sig-param\">0)<\/em>, <em class=\"sig-param\">ed=datetime.datetime(2010<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">1<\/em>, <em class=\"sig-param\">0<\/em>, <em class=\"sig-param\">0)<\/em>, <em class=\"sig-param\">sv=10000<\/em><span class=\"sig-paren\">)<\/span><a class=\"headerlink\" href=\"#StrategyLearner.StrategyLearner.testPolicy\" title=\"Permalink to this definition\">\u00b6<\/a><\/dt>\n<dd><p>Tests your learner using data outside of the training data<\/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>symbol<\/strong> (<em>str<\/em>) \u2013 The stock symbol that you trained on on<\/p><\/li>\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>sv<\/strong> (<em>int<\/em>) \u2013 The starting value of the portfolio<\/p><\/li>\n<\/ul>\n<\/dd>\n<dt class=\"field-even\">Returns<\/dt>\n<dd class=\"field-even\"><p>A DataFrame with values representing trades for each day. Legal values are +1000.0 indicating\na BUY of 1000 shares, -1000.0 indicating a SELL of 1000 shares, and 0.0 indicating NOTHING.\nValues of +2000 and -2000 for trades are also legal when switching from long to short or short to\nlong so long as net holdings are constrained to -1000, 0, and 1000.<\/p>\n<\/dd>\n<dt class=\"field-odd\">Return type<\/dt>\n<dd class=\"field-odd\"><p>pandas.DataFrame<\/p>\n<\/dd>\n<\/dl>\n<\/dd><\/dl>\n\n<\/dd><\/dl>\n\n<\/div>\n\n\n          <\/div>\n          \n        <\/div>\n      <\/div>\n\n\n\n\n\n\n\n\n\n\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    <\/div>\n<!-- \/wp:html -->","_et_gb_content_width":"","footnotes":""},"class_list":["post-1332","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1332","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=1332"}],"version-history":[{"count":1,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1332\/revisions"}],"predecessor-version":[{"id":1366,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/1332\/revisions\/1366"}],"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=1332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}