{"id":4603,"date":"2015-04-20T09:33:14","date_gmt":"2015-04-20T13:33:14","guid":{"rendered":"http:\/\/pages.vassar.edu\/magnes\/?p=4603"},"modified":"2015-04-20T09:38:23","modified_gmt":"2015-04-20T13:38:23","slug":"trees-and-market-strategy-week-2-results-from-your-financial-advisors","status":"publish","type":"post","link":"https:\/\/pages.vassar.edu\/magnes\/2015\/04\/20\/trees-and-market-strategy-week-2-results-from-your-financial-advisors\/","title":{"rendered":"Trees and Market Strategy; Week 2 Results From Your Financial Advisors"},"content":{"rendered":"<p>After investigating the call and the put option last week, we decided to continue to investigate option or derivative trading. This time we looked at how to program binomial trees in MatLab. For a quick refresher a call option is when the owner of the asset, which can be a stock or portfolio, has the right to buy the asset at the pre-determined strike price. A put option is when the owner has the right to sell the asset at the pre-determined strike price. This means that if the asset price goes below the strike price, the put option is advantageous and makes the owner money. If the asset price goes above the strike price then the call option becomes the money making option.<\/p>\n<p>So what exactly does a binomial tree look like. Below is the an example of a binomial tree when n=3 which means that past n=0 there are three distinct division. In this case at n=0 the price of the asset is 100 dollars. Binomial trees are interesting because unlike the Black-Scholes method, which was previously discussed in last weeks post, the binomial tree provides the user with a flexible way to price the option. In this example at each node the price of the asset has two alternatives it can either go up in price or down in price. Unlike the Black-Scholes model the binomial tree provides a period to period transparency in the price of the option. It is important to note that this binomial tree does not follow the same definition that a typical discrete mathematics textbook would describe a tree. This is because the binomial option pricing tree contains cycles, where as in a strict mathematically definition trees cannot contain cycles.<\/p>\n<p><a href=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/Screen-Shot-2015-04-19-at-9.14.10-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-4615  aligncenter\" src=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/Screen-Shot-2015-04-19-at-9.14.10-PM-300x270.png\" alt=\"Screen Shot 2015-04-19 at 9.14.10 PM\" width=\"239\" height=\"215\" srcset=\"https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/Screen-Shot-2015-04-19-at-9.14.10-PM-300x270.png 300w, https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/Screen-Shot-2015-04-19-at-9.14.10-PM.png 364w\" sizes=\"auto, (max-width: 239px) 100vw, 239px\" \/><\/a><\/p>\n<p style=\"text-align: center\">\u00a0(Each number is the possible price of the asset).<\/p>\n<p>The binomial tree is more advantageous in pricing American options. This is because for an American option the owner at any point can exercise the option before the maturity date (when the option expires). The binomial tree works backwards to find the value of the option at T=0, when time is equal to zero. This helps determine how much one is willing to pay for the option. The binomial tree finds the difference in price between the original asset price, and the price at another discrete time interval, using the function max(K-P,0) , where K is the strike price, and P is the price of the asset at T=0. This function max(K-P,0) is used for a put option, and described more in our code.<\/p>\n<p>&nbsp;<\/p>\n<p>It is important to discuss the variables the binomial tree is dependent on. It is dependent on $\\sigma$ which is volatility, simply it is just the standard deviation in returns of an asset or portfolio, $r$ is risk neutral interest rate, $u$ and $d$ are percentages the asset either goes up or down at each stage of the tree. The formula for backwards induction to find the original value of the asset is\u2026<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 23px;\"><span class=\"ql-right-eqno\"> (1) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pages.vassar.edu\/magnes\/wp-content\/ql-cache\/quicklatex.com-fecae47917d06b8dfa31c8fd68a7ad20_l3.png\" height=\"23\" width=\"264\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#86;&#95;&#110;&#61;&#92;&#101;&#120;&#112;&#94;&#123;&#40;&#45;&#114;&#42;&#100;&#116;&#41;&#125;&#42;&#40;&#112;&#86;&#95;&#117;&#32;&#43;&#32;&#40;&#49;&#45;&#112;&#41;&#86;&#95;&#100;&#41; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>where $V_u$ is the upper price at a discrete stage, and $V_d$ is the lower price at a discrete stage. A discrete stage meaning n=1,2\u2026 We know need to look at what p is, well p simulates the geometric Brownian motion of the underlying stock or asset with parameters $r$ and $\\sigma$. p is given by the equation below:<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 42px;\"><span class=\"ql-right-eqno\"> (2) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pages.vassar.edu\/magnes\/wp-content\/ql-cache\/quicklatex.com-d9fd06d38078b6da0c41ff152cfad50f_l3.png\" height=\"42\" width=\"126\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#112;&#61;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#101;&#120;&#112;&#94;&#123;&#40;&#114;&#42;&#100;&#116;&#41;&#125;&#45;&#100;&#125;&#123;&#117;&#45;&#100;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>We have finished the pricing of an American put option for a binomial tree when n=3. And plan on continuing to work on the code for the option pricing method to work for an arbitrary number for n, and hope to have completed by our next post.<\/p>\n<p>The past week has been spent turning the basic ferromagnetic spin model (isingtest.m) created last week into a model of a basic financial system. In the ferromagnetic model, the spins of constituent atoms were represented by discrete spin values of 1 or -1. In this model, we will use the analogous atoms to represent agents in a market. This market will be based on any arbitrary good or stock, and like the ferromagnetic model, adjacent \u201cagents\u201d will be able to share information and influence each other. Here, the tendency for atoms to align with adjacent atoms represents a tendency of financial agents that work close to each other to use the same ideas.<\/p>\n<p>In this model, a spin value of 1 signifies that an agent is currently buying the good or stock, whereas the value of -1 signifies that the agent is currently selling it. The market is governed by two rules:<\/p>\n<ol>\n<li>The first rule is analogous to the ferromagnetic model: adjacent actors influence each other strongly.<\/li>\n<li>The second rule introduces an idea analogous to a heat bath. This rule states that the agents in the minority group have a special kind of knowledge, so all agents in the market will want to be part of that minority group.<\/li>\n<\/ol>\n<p>In order to initialize this market, we create a grid to store whether or not each agent is a buyer or seller. We initially assigned the majority of agents to be buyers, represented as white pixels. The sellers are interspersed as blocks throughout the market, represented by the black pixels. Below is an example of what an initial market might look like:<\/p>\n<p><a href=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/Strategic-Choices.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-4617 aligncenter\" src=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/Strategic-Choices-300x295.png\" alt=\"Strategic Choices\" width=\"300\" height=\"295\" srcset=\"https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/Strategic-Choices-300x295.png 300w, https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/Strategic-Choices.png 386w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>From here, our monte carlo method cycles through every agent in the market, using its position relative to its neighbors as well as an overall market trend to calculate the \u201cfield\u201d that pushes it toward one strategy or another. After every iteration, the display of the grid was altered accordingly. The equation for this field is below:<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 55px;\"><span class=\"ql-right-eqno\"> (3) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pages.vassar.edu\/magnes\/wp-content\/ql-cache\/quicklatex.com-ab5263dd8f35bc6977a2278ea67d4b31_l3.png\" height=\"55\" width=\"228\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#115;&#117;&#109;&#92;&#108;&#105;&#109;&#105;&#116;&#115;&#95;&#123;&#106;&#61;&#49;&#125;&#94;&#78;&#74;&#95;&#123;&#105;&#106;&#125;&#83;&#95;&#106;&#45;&#32;&#92;&#97;&#108;&#112;&#104;&#97;&#32;&#67;&#95;&#105;&#40;&#116;&#41;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#78;&#125;&#92;&#115;&#117;&#109;&#92;&#108;&#105;&#109;&#105;&#116;&#115;&#95;&#123;&#106;&#61;&#49;&#125;&#94;&#78;&#83;&#95;&#106;&#40;&#116;&#41; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>The first term in the expression is analogous to the spin alignments, whereas the second term is representative to the individual agent\u2019s view of the whole market. The value C corresponds to whether an agent will be a \u201cfundamentalist(C=1)\u201d or a \u201cchartist(C=-1).\u201d If the agent is a fundamentalist, it means that he or she will be likely to follow the rule that it is best to try to get into the minority, making the second term negative and pushing it against the first term. If the agent is a \u201cchartist,\u201d it means that he or she is content with being in the majority, and the sign of the second term is the same as the first. Whether or not the agent is a fundamentalist or a chartist is determined by whether or not choosing this strategy will increase the energy, or risk, of the system, which would improve the likelihood of making money. This probability of an agent changing his or her identity is determined with:<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 55px;\"><span class=\"ql-right-eqno\"> (4) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pages.vassar.edu\/magnes\/wp-content\/ql-cache\/quicklatex.com-5a33b7fd57cb6f5352fa1bd1cb022a7e_l3.png\" height=\"55\" width=\"358\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#67;&#95;&#105;&#40;&#116;&#43;&#49;&#41;&#61;&#45;&#67;&#95;&#105;&#40;&#116;&#41;&#32;&#92;&#58;&#32;&#105;&#102;&#32;&#92;&#58;&#32;&#92;&#97;&#108;&#112;&#104;&#97;&#32;&#83;&#95;&#105;&#40;&#116;&#41;&#32;&#67;&#95;&#105;&#40;&#116;&#41;&#32;&#92;&#115;&#117;&#109;&#92;&#108;&#105;&#109;&#105;&#116;&#115;&#95;&#123;&#106;&#61;&#49;&#125;&#94;&#78;&#83;&#95;&#106;&#40;&#116;&#41;&#60;&#48; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>Then, the probability of an agent remaining\/becoming a buyer is given by:<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 40px;\"><span class=\"ql-right-eqno\"> (5) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pages.vassar.edu\/magnes\/wp-content\/ql-cache\/quicklatex.com-cfa5780da16d04db556dcef4fbeb940e_l3.png\" height=\"40\" width=\"308\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#83;&#95;&#105;&#40;&#116;&#43;&#49;&#41;&#61;&#92;&#112;&#32;&#49;&#32;&#92;&#58;&#32;&#119;&#105;&#116;&#104;&#32;&#92;&#58;&#32;&#112;&#61;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#49;&#43;&#92;&#101;&#120;&#112;&#40;&#45;&#50;&#92;&#66;&#101;&#116;&#97;&#32;&#104;&#95;&#105;&#40;&#116;&#41;&#41;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 18px;\"><span class=\"ql-right-eqno\"> (6) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pages.vassar.edu\/magnes\/wp-content\/ql-cache\/quicklatex.com-349d17323c7accee53c0b07d6ebf2dd3_l3.png\" height=\"18\" width=\"196\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#83;&#95;&#105;&#40;&#116;&#43;&#49;&#41;&#61;&#32;&#45;&#49;&#32;&#92;&#58;&#32;&#119;&#105;&#116;&#104;&#32;&#92;&#58;&#32;&#49;&#45;&#112; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>The second term is the probability that the agent will remain\/become a seller. A random number is generated by the monte carlo method and compared to the probability, deciding which strategy the agent in question will use at the current time. Once the code has cycled through every agent in the market, it will update the grid displaying the identity of each agent\u2019s strategy at the given time. The average value of all of the strategies in the market is then taken, as it is representative of the price of the good or the stock. A positive average represents a positive trend in price, because there are more people that want to buy than sell. The opposite is true as well, as a negative average means that there is a surplus of sellers. Taking this average and subtracting from it the average of the last iteration gives use the change in price, or return, created by a shift in the market. An example is displayed below, plotting this average vs. time:<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig2.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-4618 aligncenter\" src=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig2-300x170.png\" alt=\"fig2\" width=\"300\" height=\"170\" srcset=\"https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig2-300x170.png 300w, https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig2-624x354.png 624w, https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig2.png 815w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The periods of extreme return in a negative or positive direction correspond to a market configuration where there are large groups of buyers grouped together and large groups of sellers grouped together as shown below:<\/p>\n<p><a href=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig3.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-4619 aligncenter\" src=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig3-286x300.png\" alt=\"fig3\" width=\"286\" height=\"300\" srcset=\"https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig3-286x300.png 286w, https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig3.png 378w\" sizes=\"auto, (max-width: 286px) 100vw, 286px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Conversely, when the returns stay near 0, it is because there is no real trend in the market and it is more turbulent, as such:<\/p>\n<p><a href=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig4.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-4620 aligncenter\" src=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig4-293x300.png\" alt=\"fig4\" width=\"293\" height=\"300\" srcset=\"https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig4-293x300.png 293w, https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig4.png 391w\" sizes=\"auto, (max-width: 293px) 100vw, 293px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Finally, another way to represent this trend is to show the difference between fundamentalists in the market compared with chartists in the market. This difference is displayed below, and it is possible to see that when there is a more extreme difference, there are more extreme changes in the return.<\/p>\n<p><a href=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig5.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-4622 aligncenter\" src=\"http:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig5-300x155.png\" alt=\"fig5\" width=\"300\" height=\"155\" srcset=\"https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig5-300x155.png 300w, https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig5-624x323.png 624w, https:\/\/pages.vassar.edu\/magnes\/files\/2015\/04\/fig5.png 892w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>For our final part of this project, we will try to use the autocorrelation function to characterize the volatility of the good over time. We will also try to add another strategy option, as well as possibly exploring a 3 dimensional system. The code for this part is \u201cTwoStrategyMarketModel.m\u201d<\/p>\n<p>Link to Code:<\/p>\n<p>https:\/\/drive.google.com\/folderview?id=0B01Mp3IqoCvhflF5azV4bHY2V0c3Vks0VXVyQkIxcnR4RmFaNDhVWEQtZGZSR2t6V2VWOHc&#038;usp=sharing<\/p>\n<p>The files are under the name: BinomialTreeNThree.m and TwoMarketStrategyModel.m<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After investigating the call and the put option last week, we decided to continue to investigate option or derivative trading. This time we looked at how to program binomial trees in MatLab. For a quick refresher a call option is when the owner of the asset, which can be a stock or portfolio, has the [&hellip;]<\/p>\n","protected":false},"author":4962,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4603","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/posts\/4603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/users\/4962"}],"replies":[{"embeddable":true,"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/comments?post=4603"}],"version-history":[{"count":17,"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/posts\/4603\/revisions"}],"predecessor-version":[{"id":4625,"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/posts\/4603\/revisions\/4625"}],"wp:attachment":[{"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/media?parent=4603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/categories?post=4603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pages.vassar.edu\/magnes\/wp-json\/wp\/v2\/tags?post=4603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}