{"id":205,"date":"2020-05-11T08:20:43","date_gmt":"2020-05-11T08:20:43","guid":{"rendered":"http:\/\/lucylabs.gatech.edu\/ml4t\/?page_id=205"},"modified":"2020-08-14T04:00:32","modified_gmt":"2020-08-14T04:00:32","slug":"classification-trader-hints","status":"publish","type":"page","link":"https:\/\/lucylabs.gatech.edu\/ml4t\/summer2020\/classification-trader-hints\/","title":{"rendered":"Classification Trader Hints"},"content":{"rendered":"\n[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.6&#8243; header_font=&#8221;|700||on|||||&#8221; hover_enabled=&#8221;0&#8243;]<h1 id=\"firstHeading\" class=\"firstHeading\" lang=\"en\" style=\"text-align: center;\"><span dir=\"auto\">Classification Trader Hints<\/span><\/h1>\n[\/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.6&#8243; header_2_font=&#8221;|||on|on||||&#8221; hover_enabled=&#8221;0&#8243;]<h2><span class=\"mw-headline\" id=\"Overview\">Overview<\/span><\/h2>\n<p><span>You will utilize your Random Tree learner to train and test a learning trading algorithm. Here are some ideas (gathered from a previous project) that you might find helpful if you are going to use a classification or regression learner for your trader.<\/span><\/p>\n[\/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.6&#8243; header_2_font=&#8221;|||on|on||||&#8221; hover_enabled=&#8221;0&#8243;]<h2><span class=\"mw-headline\" id=\"ML_Trader\">ML Trader<\/span><\/h2>\n<p>Convert your decision tree <strong>regression<\/strong> learner into a <strong>classification<\/strong> learner. The classifications should be:<\/p>\n<ul>\n<li>+1: LONG<\/li>\n<li>0: CASH<\/li>\n<li>-1: SHORT<\/li>\n<\/ul>\n<p>The X data for each sample (day) are simply the values of your indicators for the stock &#8212; you should have 3 to 5 of them. The Y data (or classifications) will be based on N day return (your choice for N). You should classify the example as a +1 or &#8220;LONG&#8221; if the N day return exceeds a certain value, let&#8217;s call it YBUY for the moment. You should classify the example as a -1 or &#8220;SHORT&#8221; if the N day return is below a certain value we&#8217;ll call YSELL. In all other cases the sample should be classified as a 0 or &#8220;CASH.&#8221; Note that it is very important that you train your learner with these classification values (not the N day returns).<\/p>\n<p>Note that your X values are calculated each day from the current day&#8217;s (and earlier) data, but the Y value (classification) is calculated using data from the future. You may tweak various parameters of your learner to maximize return (more on that below). Train and test your learning strategy over the in sample period.<\/p>\n<p><strong>Important note<\/strong>: You must set the leaf_size parameter of your decision tree learner to 5 or larger. This requirement is intended to avoid a degenerate overfit solution to this problem.<\/p>\n<p>You should tweak the parameters of your learner to maximize performance during the in sample period. Here is a partial list of things you can tweak:<\/p>\n<ul>\n<li>Adjust YSELL and YBUY.<\/li>\n<li>Adjust leaf_size.<\/li>\n<li>Utilize bagging and adjust the number of bags.<\/li>\n<\/ul>\n[\/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.6&#8243; header_2_font=&#8221;|||on|on||||&#8221; hover_enabled=&#8221;0&#8243;]<h2>Overview<\/h2>\n<ul>\n<li>Indicator design hints:\n<ul>\n<li>For your X values: Identify and implement at least 3 technical features that you believe may be predictive of future return.<\/li>\n<\/ul>\n<\/li>\n<li>Train a classification learner on in sample training data:\n<ul>\n<li>For your Y values: Use future N day return (not future price). Then classify that return as LONG, SHORT or CASH. You&#8217;re trying to predict a relative change that you can use to invest with.<\/li>\n<li>For debugging purposes, you may find it helpful to plot the value of the training classification data (-1, 0, 1) versus the stock price in one color.<\/li>\n<li>For debugging purposes, you may find it helpful to plot the value of the training classification output (-1, 0, 1) versus the stock price in another color. Ideally, these two lines should be very similar.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Your code should classify based on N day change in price. You need to build a new Y that reflects the N day change and aligns with the current date. Here&#8217;s pseudo code for the calculation of Y<\/p>\n[\/et_pb_text][et_pb_blurb title=&#8221;Code&#8221; use_icon=&#8221;on&#8221; font_icon=&#8221;%%71%%&#8221; icon_color=&#8221;#7cda24&#8243; icon_placement=&#8221;left&#8221; use_icon_font_size=&#8221;on&#8221; icon_font_size=&#8221;20px&#8221; _builder_version=&#8221;4.4.5&#8243; header_text_color=&#8221;#FFFFFF&#8221; header_font_size=&#8221;16px&#8221; header_line_height=&#8221;1.3em&#8221; background_color=&#8221;#1b2426&#8243; width=&#8221;100px&#8221; custom_margin=&#8221;||-44px|-50px|false|false&#8221; custom_padding=&#8221;10px|15px|2px|15px|false|false&#8221; saved_tabs=&#8221;all&#8221;][\/et_pb_blurb][et_pb_text _builder_version=&#8221;4.4.6&#8243; background_color=&#8221;#eff0f1&#8243; custom_margin=&#8221;|||60px|false|false&#8221; custom_padding=&#8221;3%|3%|3%|3%|false|false&#8221; hover_enabled=&#8221;0&#8243; border_width_top=&#8221;10px&#8221; border_color_top=&#8221;#7cda24&#8243; saved_tabs=&#8221;all&#8221;]<p>ret = (price[t+N]\/price[t]) &#8211; 1.0<br \/>if ret &gt; YBUY:<br \/>\u00a0 \u00a0 \u00a0 \u00a0 Y[t] = +1 # LONG<br \/>else if ret &lt; YSELL:<br \/>\u00a0 \u00a0 \u00a0 \u00a0 Y[t] = -1 # SHORT<br \/>else:<br \/>\u00a0 \u00a0 \u00a0 \u00a0 Y[t] = 0 # CASH<\/p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.4.6&#8243; hover_enabled=&#8221;0&#8243;]<p><span>If you select Y in this manner and use it for training, your learner will classify N day returns.<\/span><\/p>\n[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]\n","protected":false},"excerpt":{"rendered":"<p>Classification Trader Hints Overview You will utilize your Random Tree learner to train and test a learning trading algorithm. Here are some ideas (gathered from a previous project) that you might find helpful if you are going to use a classification or regression learner for your trader. ML Trader Convert your decision tree regression learner [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":272,"menu_order":14,"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-205","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/205","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=205"}],"version-history":[{"count":7,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/205\/revisions"}],"predecessor-version":[{"id":654,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/205\/revisions\/654"}],"up":[{"embeddable":true,"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/pages\/272"}],"wp:attachment":[{"href":"https:\/\/lucylabs.gatech.edu\/ml4t\/wp-json\/wp\/v2\/media?parent=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}