<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Win-Vector Blog &#187; Finance</title>
	<atom:link href="http://www.win-vector.com/blog/category/finance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.win-vector.com/blog</link>
	<description>The Applied Theorist&#039;s Point of View</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:09:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>&#8220;Easy&#8221; Portfolio Allocation</title>
		<link>http://www.win-vector.com/blog/2010/01/easy-portfolio-allocation/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=easy-portfolio-allocation</link>
		<comments>http://www.win-vector.com/blog/2010/01/easy-portfolio-allocation/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 20:09:13 +0000</pubDate>
		<dc:creator>John Mount</dc:creator>
				<category><![CDATA[Finance]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Lagrange Multipliers]]></category>
		<category><![CDATA[Mathematical Bedside Reading]]></category>
		<category><![CDATA[Portfolio Theory]]></category>
		<category><![CDATA[Sharpe Ratio]]></category>

		<guid isPermaLink="false">http://www.win-vector.com/blog/?p=1342</guid>
		<description><![CDATA[This is an elementary mathematical finance article. This means if you know some math (linear algebra, differential calculus) you can find a quick solution to a simple finance question. The topic was inspired by a recent article in The American Mathematical Monthly (Volume 117, Number 1 January 2010, pp. 3-26): &#8220;Find Good Bets in the [...]


Related posts:<ol><li><a href='http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/' rel='bookmark' title='Permanent Link: A Quick Appreciation of the Sharpe Ratio'>A Quick Appreciation of the Sharpe Ratio</a></li>
<li><a href='http://www.win-vector.com/blog/2009/09/a-discrete-model-gauging-market-efficiency/' rel='bookmark' title='Permanent Link: A Discrete Model Gauging Market Efficiency'>A Discrete Model Gauging Market Efficiency</a></li>
<li><a href='http://www.win-vector.com/blog/2009/10/what-is-the-gamblers-equivalent-of-amdahls-law/' rel='bookmark' title='Permanent Link: What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?'>What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This is an elementary mathematical finance article. This means if you know some math (linear algebra, differential calculus) you can find a quick solution to a simple finance question. The topic was inspired by a recent article in The American Mathematical Monthly (Volume 117, Number 1 January 2010, pp. 3-26): &#8220;Find Good Bets in the Lottery, and Why You Shouldn&#8217;t Take Them&#8221; by Aaron Abrams and Skip Garibaldi which said optimal asset allocation is now an undergraduate exercise. That may well be, but there are a lot of people with very deep mathematical backgrounds that have yet to have seen this. We will fill in the details here. The style is terse, but the content should be about what you would expect from one day of lecture in a mathematical finance course.</p>
<p><span id="more-1342"></span></p>
<p>Portfolio allocation is not the &#8220;magic predict the future&#8221; part of finance, it is the scheme for correctly applying magic predictions of the future. The idea is that if you had an prediction of future returns of a number of assets, the naive thing to do would be to invest everything into the asset with highest predicted return. Portfolio theory, while still taking the predictions at face value, picks an investment pattern that will (in risk-adjusted dollars) outperform the naive strategy even if the predictions are correct and is a bit safer when the predictions are wrong.</p>
<p>Suppose you had <img width="14" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg1.png" alt="$ n$"> different assets you could invest in. For the <img width="10" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg2.png" alt="$ i$"> -th asset there is an expected excess relative return of <img width="19" height="28" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg3.png" alt="$ \mu_i$"> and an estimated variance of <img width="17" height="28" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg4.png" alt="$ s_i$"> (for a definition of relative return see <a href="http://www.win-vector.com/blog/2010/01/relative-returns-a-banker-versus-trader-paradox/">Relative returns: a banker versus trader paradox</a> and for a definition of variance see <a href="http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/">A Quick Appreciation of the Sharpe Ratio</a>). Let the vector <img width="16" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg5.png" alt="$ w$"> be such that <img width="23" height="29" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg6.png" alt="$ X_i$"> represents the number of dollars we invest in the <img width="10" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg2.png" alt="$ i$"> -th asset. If <img width="23" height="29" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg6.png" alt="$ X_i$"> is positive then our plan is &#8220;to go long&#8221; or buy some of the <img width="10" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg2.png" alt="$ i$"> -th asset. If <img width="23" height="29" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg6.png" alt="$ X_i$"> is negative our plan is &#8220;to short&#8221; or sell some of the <img width="10" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg2.png" alt="$ i$"> -th asset to somebody else (It is called going short as we actually sell something we do not have. This is often allowed in finance; as long as we make the same pay-outs to the buyer that the buyer would receive if we really had the item to sell).</p>
<p>When we appeal to the idea of optimizing the portfolio Sharpe Ratio (again, see <a href="http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/">A Quick Appreciation of the Sharpe Ratio</a>) then we say a good portfolio is one that doesn&#8217;t just maximize expected relative returns (which is <img width="39" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg11.png" alt="$ X^{\top} \mu$"> ) but maximizes the ratio of expected relative return to standard deviation:</p>
</p>
<div align="center"><img width="73" height="56" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg8.png" alt="$\displaystyle \frac{X^{\top} \mu}{\sqrt{X^{\top} C X}} $"></div>
<p>where (for now) <img width="17" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg9.png" alt="$ C$"> is the matrix <img width="30" height="17" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg10.png" alt="$ s s^{\top}$"> . This ratio is called a &#8220;risk adjusted return&#8221; (versus the un-adjusted form <img width="39" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg11.png" alt="$ X^{\top} \mu$"> ). Also notice that the ratio is homogeneous in <img width="19" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg12.png" alt="$ X$"> (doubling <img width="19" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg12.png" alt="$ X$"> does not change the ratio as it simultaneously doubles the numerator and the denominator) so an optimal solution <img width="19" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg12.png" alt="$ X$"> describes not how much to invest, but what pattern to invest in. This allows us to introduce an important practical constraint: we are only going to allow ourselves to risk a total of <img width="16" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg13.png" alt="$ T$"> dollars (both long and short). That is: we insist <img width="105" height="33" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg14.png" alt="$ \sum_{i=1}^{n} \vert X_i\vert = T$"> . We will ignore this total investment constraint until the end when we can satisfy the constraint by simply re-scaling an partial solution.</p>
<p>To solve for <img width="19" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg12.png" alt="$ X$"> we introduce an old friend: <a href="http://en.wikipedia.org/wiki/Lagrange_multipliers">Lagrange Multipliers</a> (or equivalently the Karush-Kuhn-Tucker conditions of optimality). Since the fraction we are trying to optimize is homogeneous in <img width="19" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg12.png" alt="$ X$"> we can convert the denominator into a constraint and arbitrarily insist that <img width="99" height="38" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg15.png" alt="$ \sqrt{X^{\top} C X} = 1$"> without changing the nature of the problem. We are now trying to maximize <img width="39" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg11.png" alt="$ X^{\top} \mu$"> subject to <img width="99" height="38" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg15.png" alt="$ \sqrt{X^{\top} C X} = 1$"> . The Lagrangian conditions of optimality state at the optimum we must have the gradient of the objective is proportional to the gradient of the constraint or:</p>
</p>
<div align="center"><img width="225" height="40" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg16.png" alt="$\displaystyle \nabla_X X^{\top} \mu = \lambda \nabla_X ( \sqrt{X^{\top} C X} - 1 ) $"></div>
<p>for some (to be determined) constant <img width="13" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg17.png" alt="$ \lambda$"> . Pushing the gradient operator through we get:</p>
<div align="center"><img width="213" height="37" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg18.png" alt="$\displaystyle \mu = \lambda (1/2) ( X^{\top} C X )^{-1/2} 2 C X . $"></div>
<p>A similar equation could be gotten by appealing to a Rayleigh Quotient argument.</p>
<p>We do not yet know <img width="19" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg12.png" alt="$ X$"> (that is what we are trying to solve for), so we do not know what <img width="56" height="17" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg19.png" alt="$ X^{\top} C X$"> is. However, this is just a scalar and since we are just trying to solve up to a multiple we can throw it out and introduce a new multiple and see that it is enough to solve:</p>
</p>
<div align="center"><img width="76" height="33" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg20.png" alt="$\displaystyle \mu = \lambda' C X $"></div>
<p>where <img width="18" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg21.png" alt="$ \lambda'$"> is new (still unknown) scalar. This means we have:</p>
<div align="center"><img width="121" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg22.png" alt="$\displaystyle X = (1/\lambda') C^{-1} \mu $"></div>
<p>so our desired solution is some re-scaling of <img width="43" height="33" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg23.png" alt="$ C^{-1} \mu$"> .</p>
<p>As we stated earlier we have a total investment constraint of <img width="105" height="33" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg14.png" alt="$ \sum_{i=1}^{n} \vert X_i\vert = T$"> . We can achieve this with the following adjusted solution:</p>
</p>
<div align="center"><img width="189" height="51" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg24.png" alt="$\displaystyle X = \frac{T}{\sum_{i=1}^{n} \vert(C^{-1} \mu)_i\vert} C^{-1} \mu $"></div>
<p>as our desired optimal portfolio allocation. In the end we can solve for the optimal portfolio by merely solving a linear system (we don&#8217;t need anything as expensive as a general purpose optimizer in this case).</p>
<p>These are very old results (going back as long as there has been Sharpe Ratios and portfolio theory). A good example reference is: &#8220;The Valuation of Risk Assets and the Selection of Risky Investments in Stock Portfolios and Capital Budgets,&#8221; John Lintner, The Review of Economics and Statistics (1965) vol. 47 (1) pp. 13-37. These results are the basis for advice like: &#8220;diversify.&#8221; Without modeling risk you would tend to put all of your money in the predicted highest paying asset. When modeling risk you tend to put some of your money in each high paying asset and as long as they do not all fail at the same time you have some safety. Another (very different) route to diversification is the Kelly Criterion (discussed in <a href="http://www.win-vector.com/blog/2009/10/what-is-the-gamblers-equivalent-of-amdahls-law/">What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?</a>).</p>
<p>A very important risk we have not yet modeled is that our assets may have a tendency to fail at the same time (meaning we may not have really diversified usefully). The notion of assets may fail at the same time brings us to the ideas of correlation and covariance. When we took <img width="64" height="17" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg25.png" alt="$ C = s s^{\top}$"> we were implicitly assuming (or modeling), without justification, that each possible asset was independent of all the others (that there was no correlation between asset returns). This is, of course, not going to be anywhere near true in practice. Instead we should take <img width="17" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg9.png" alt="$ C$"> to be the <a href="http://en.wikipedia.org/wiki/Covariance_matrix">Covariance Matrix</a> that represent our estimate of the assent to asset correlations. In this case the solution methods above all work exactly as before. Companies such as MSCI Barra have made complete businesses out of producing and selling estimates of <img width="17" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg9.png" alt="$ C$"> .</p>
<p>Another issue is when we do not allow ourselves to &#8220;short&#8221; (or take a negative allocation of) assets. In this case we have the additional constraints <img width="48" height="29" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg26.png" alt="$ X \ge 0$"> which complicates our solution. For the special case where the asset variances are assumed to be independent (i.e. <img width="64" height="17" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg25.png" alt="$ C = s s^{\top}$"> ) it is enough to solve as above and merely replace any negative allocations with zero when inspecting and scaling the final step of the solution. When the covariances are non-trivial (<img width="17" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg9.png" alt="$ C$"> has non-zero off-diagonal entries) this solution may not be optimal. In this case the Karush-Kuhn-Tucker conditions are more complicated and at the point of optimal solution we have the following conditions:</p>
<p></p>
<div align="center">
<table cellpadding="0" align="center">
<tr valign="middle">
<td nowrap align="right"><img width="145" height="60" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg27.png" alt="$\displaystyle \mu + \lambda C X - \sum_{i=1}^{n} \tau_i E^i$"></td>
<td width="10" align="center" nowrap><img width="17" height="28" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg28.png" alt="$\displaystyle =$"></td>
<td align="left" nowrap>0</td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="19" height="29" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg29.png" alt="$\displaystyle X$"></td>
<td width="10" align="center" nowrap><img width="17" height="28" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg30.png" alt="$\displaystyle \ge$"></td>
<td align="left" nowrap>0</td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="48" height="60" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg31.png" alt="$\displaystyle \sum_{i=1}^{n} X_i$"></td>
<td width="10" align="center" nowrap><img width="17" height="28" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg28.png" alt="$\displaystyle =$"></td>
<td align="left" nowrap><img width="16" height="29" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg32.png" alt="$\displaystyle T$"></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="13" height="28" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg33.png" alt="$\displaystyle \tau$"></td>
<td width="10" align="center" nowrap><img width="17" height="28" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg30.png" alt="$\displaystyle \ge$"></td>
<td align="left" nowrap>0</td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="38" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg34.png" alt="$\displaystyle \tau^{\top} X$"></td>
<td width="10" align="center" nowrap><img width="17" height="28" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg28.png" alt="$\displaystyle =$"></td>
<td align="left" nowrap>0</td>
<td width="10" align="right">&nbsp;</td>
</tr>
</table>
</div>
<p><br clear="all"><br />
where <img width="19" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg12.png" alt="$ X$"> is the allocation vector we wish to solve for, <img width="13" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg17.png" alt="$ \lambda$"> is an unknown scalar, <img width="13" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg35.png" alt="$ \tau$"> is a new unknown vector and <img width="22" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg36.png" alt="$ E^i$"> is the vector with <img width="69" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg37.png" alt="$ (E^i)_i = 1$"> and zeroes elsewhere. Using the Karush-Kuhn-Tucker conditions has allowed us to again almost linearize the problem, but we know have sign constraints on <img width="19" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg12.png" alt="$ X$"> and <img width="13" height="14" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg35.png" alt="$ \tau$"> and what is called a complementarity constraint: <img width="67" height="17" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg38.png" alt="$ \tau^{\top} X = 0$"> . This sort of problem essentially called a &#8220;Linear Complementarity Problem&#8221; and is about as hard as solving a linear program (the typical solution method is a variation of the simplex method called &#8220;Lemke&#8217;s algorithm&#8221;). (Technically the <img width="13" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg17.png" alt="$ \lambda$"> prevents the problem from being in the right form, but <img width="13" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2010/01/EPAimg17.png" alt="$ \lambda$"> can be inspected out of the problem.) The problem can still be solved, you just need a bit more software. If we can not short assets (or at least simulate shorting assets) we not only eliminate many possible portfolios from consideration (so we likely end up with a less profitable portfolio than we would like) we also make the mathematics and computation a bit harder.</p>
<p>The goal of this writeup has been to show how to systematically convert investment advice like &#8220;this stock is going to really take off&#8221; into an allocation of assets (which in turn implies a pattern of trades). We take as unexamined premises where to get such advice and whether to use the Sharpe ratio or some other notion of risk and/or utility. The point is that even though it may be complicated, from this point it is just calculation and calculation is easy to automate.</p>


<p>Related posts:<ol><li><a href='http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/' rel='bookmark' title='Permanent Link: A Quick Appreciation of the Sharpe Ratio'>A Quick Appreciation of the Sharpe Ratio</a></li>
<li><a href='http://www.win-vector.com/blog/2009/09/a-discrete-model-gauging-market-efficiency/' rel='bookmark' title='Permanent Link: A Discrete Model Gauging Market Efficiency'>A Discrete Model Gauging Market Efficiency</a></li>
<li><a href='http://www.win-vector.com/blog/2009/10/what-is-the-gamblers-equivalent-of-amdahls-law/' rel='bookmark' title='Permanent Link: What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?'>What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.win-vector.com/blog/2010/01/easy-portfolio-allocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Discrete Model Gauging Market Efficiency</title>
		<link>http://www.win-vector.com/blog/2009/09/a-discrete-model-gauging-market-efficiency/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=a-discrete-model-gauging-market-efficiency</link>
		<comments>http://www.win-vector.com/blog/2009/09/a-discrete-model-gauging-market-efficiency/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 05:34:23 +0000</pubDate>
		<dc:creator>John Mount</dc:creator>
				<category><![CDATA[Finance]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Quantitative Finance]]></category>
		<category><![CDATA[Combinatorial Markets]]></category>
		<category><![CDATA[Discrete Markets]]></category>
		<category><![CDATA[Efficient Markets]]></category>
		<category><![CDATA[Information Taker]]></category>
		<category><![CDATA[Preditory Traders]]></category>

		<guid isPermaLink="false">http://www.win-vector.com/blog/?p=809</guid>
		<description><![CDATA[New paper: A Discrete Model Gauging Market Efficiency PDF We highly recommend reading the PDF version, but please find below a HTML translation of the paper. We follow up on some interesting work from the literature and explore some conditions that allow large predatory traders to dominate markets. A Discrete Model Gauging Market Efficiency John [...]


Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
<li><a href='http://www.win-vector.com/blog/2009/03/it-is-not-all-the-quants-fault/' rel='bookmark' title='Permanent Link: It is not all the quants&#8217; fault.'>It is not all the quants&#8217; fault.</a></li>
<li><a href='http://www.win-vector.com/blog/2007/10/paper-on-stock-trading/' rel='bookmark' title='Permanent Link: Paper on stock trading'>Paper on stock trading</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>New paper: A Discrete Model Gauging Market Efficiency <a href="http://www.win-vector.com/dfiles/DiscreteModel.pdf">PDF</a> </p>
<p>We <em>highly</em> recommend reading the PDF version, but please find below a HTML translation of the paper.</p>
<p>We follow up on some interesting work from the literature and explore some conditions that allow large predatory traders to dominate markets.</p>
<p><span id="more-809"></span></p>
<h1 align="center">A Discrete Model Gauging Market Efficiency</h1>
<p align="center"><strong>John Mount<a name="tex2html3" href="#foot12" id="tex2html3"><sup>1</sup></a></strong></p>
<p></p>
<p align="center"><b>Date:</b> September 8, 2009</p>
<hr />
<h3>Abstract:</h3>
<div>We describe a discrete market model appropriate for quantifying certain desirable and un-desirable features of financial markets. This model allows direct exploration of the impact of different market structures on efficiency and fairness. We conclude by demonstrating that a single trader with a large budget can generate profit while making the market not profitable for smaller traders.</div>
<h1><a name="SECTION00010000000000000000" id="SECTION00010000000000000000">Introduction</a></h1>
<p>Stochastic calculus techniques[<a href="#citeulike:2080469">KS01</a>] (such as Brownian Motion, Levy Processes[<a href="#Applebaum:2004p1042">App04</a>], Wiener Processes or the Ito Calculus[<a href="#citeulike:2635904">Ste03b</a>,<a href="#Steele:2003p2288">Ste03a</a>]) are not the only abstraction useful in thinking about financial markets. Real markets do not meet the typical assumptions of the above systems (infinitely divisible time, no trade costs, no long-term memory and no large actors) and routinely fail goodness of fit tests against such models[<a href="#Lo:2001p1619">LM01</a>,<a href="#Lo:2005p2193">Lo05</a>]. In fact there is a simple arbitrage argument that markets would have summary statistics identical to Ito processes even if they are not such processes.[<a href="#Shafer:2004p1497">Sha04</a>] When studying which features make a market fair or efficient we can not rely on mathematical tools that assume and depend on fair and efficient markets.</p>
<p>To build the tools for our study we follow up on some of the ideas of Hasanhodzic, Lo and Viola [<a href="#Hasanhodzic:2009p2605">HLV09</a>] and propose a specific discrete market model (as distinguished from more traditional continuous mathematics as in [<a href="#MertonCTF">Mer99</a>]) that allows us to effectively apply ideas from game theory[<a href="#AlgGT">NNV07</a>] and theoretical computer science. We show how to solve for optimal trading strategies in this market model and conclude with an illustration of how a single trader can dominate a market by merely exercising a larger budget.</p>
<h1><a name="SECTION00020000000000000000" id="SECTION00020000000000000000">Outline</a></h1>
<p>We will proceed as follows:</p>
<ul>
<li>Define our market model</li>
<li>Solve for optimal trading strategies in our market model</li>
<li>Perform the experiment of adding a single large trader to our model</li>
<li>Draw conclusions</li>
<li>Suggest further research.</li>
</ul>
<h1><a name="SECTION00030000000000000000" id="SECTION00030000000000000000">The Market Model</a></h1>
<p>Our goal is to investigate if even perfect traders are vulnerable to an additional trader that has a larger budget. To do this we must have a market model where at least:</p>
<ul>
<li>We can solve for the optimal trading strategy</li>
<li>There is a reason to trade (profits are available).</li>
</ul>
<p>We propose such a market model below.</p>
<h2><a name="SECTION00031000000000000000" id="SECTION00031000000000000000">The Market</a></h2>
<p>To simplify the description of traders (and to minimize the amount of state we have to carry) we propose a market model that abstracts out price and many other features.</p>
<p>Our market model is represented as an ordered sequence of the symbols &#8220;<img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg3.png" alt="$ +$"/> &#8221;, &#8220;0 &#8221; and &#8220;<img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg4.png" alt="$ -$"/> &#8221;. A &#8220;<img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg3.png" alt="$ +$"/> &#8221; represents a recent price increase, a &#8220;0 &#8221; represents no change and a &#8220;<img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg4.png" alt="$ -$"/> &#8221; represents a recent price decrease. We are deliberately avoiding direct representation of real market quantities such as absolute price, volume, inventory, bid/ask books, margin and elasticity. Time is represented by regular &#8220;ticks&#8221; or the simple advance to the next symbol in the market sequence. We will describe how the next symbol in the market sequence is determined after we have described trades.</p>
<h3><a name="SECTION00031100000000000000" id="SECTION00031100000000000000">Type 1 Trades</a></h3>
<p>The first type of trade we allow in this market is a &#8220;round trip.&#8221; A round trip is one of the two following trades:</p>
<ul>
<li>&#8220;a long round trip&#8221;
<p>An immediate buy in the current time tick followed by an automatic (forced) sell on the next time tick. This trade is considered profitable if the next market symbol is a <img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg3.png" alt="$ +$"/> as the sell then happens at a higher price than the initial buy, yielding a profit.</p>
</li>
<li>&#8220;a short round trip&#8221;
<p>An immediate sell in the current time tick followed by an automatic (forced) buy on the next time tick. This trade is considered profitable if the next market symbol is a <img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg4.png" alt="$ -$"/> as the buy then happens at a lower price than the initial sell, yielding a profit.</p>
</li>
</ul>
<p>The forced nature of these round trip trades allow us to avoid modeling inventory and margin. Round trip trades are meant to abstract some of the aspects of high-frequency trading strategies.</p>
<h3><a name="SECTION00031200000000000000" id="SECTION00031200000000000000">Type 2 Trades</a></h3>
<p>The second type of trade we allow is a &#8220;simple buy&#8221; or &#8220;simple sell&#8221; on the next time tick. This type of trade is meant to abstract some of the properties of a trader who is not so close to the market and has market-external interests (like inventory, customers, margin, fundamental knowledge <img width="28" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg5.png" alt="$ \cdots$"/> ).</p>
<h3><a name="SECTION00031300000000000000" id="SECTION00031300000000000000">Market Evolution</a></h3>
<p>The market model evolves forward as follows. The second half of each type 1 trade (the sell in the long round trip and buy in the short round trip) is entered as a net impact on the upcoming time tick. So: a long round trip actually generates a sell or downward price impact on the next market tick (and a short round trip generates a buy or upward price impact on the next market tick). This &#8220;reverse impact&#8221; is in our model because we are not allowing these traders to hold inventory and in a &#8220;buy followed by a sell&#8221; pattern the initial buy impact is further in the past then the sell (so should have a lesser future impact). This is also similar to how in real markets a large net short position represents an upward influence on price as the market participants know the short position must eventually be covered.</p>
<p>Also each type 2 (or simple) trade is also entered directly as market impact. So: as expected simple buy trades generate upward price impact and simple sell generate downward price impact.</p>
<p>To determine the next market-symbol we sum the net impact entered against the next tick, if the net impact is positive the symbol is a <img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg3.png" alt="$ +$"/> , if it is zero the symbol is 0 and if it is negative the symbol is a <img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg4.png" alt="$ -$"/> . This differs both from the market model in [<a href="#Hasanhodzic:2009p2605">HLV09</a>] (where price is additive) and from real markets (where elasticity of price with respect to trades is very complicated).</p>
<p>For example: if three traders choose &#8220;long round trip&#8221; (betting the market will go up in the short term) and one trader chooses &#8220;simple buy&#8221; (betting the market will go up long term) then the net impact on the next tick is <!-- MATH<br />
 $(-1) + (-1) + (-1) + (+1) = -2$<br />
 --><br />
<img width="257" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg6.png" alt="$ (-1) + (-1) + (-1) + (+1) = -2$"/> and the next symbol is <img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg4.png" alt="$ -$"/> . The long round trip traders lose money and the simple buy trader is has an unrealized loss.<a name="tex2html4" href="#foot37" id="tex2html4"><sup>2</sup></a>Just as we settled on a standard unit for trade size we will use a standard unit for profit and arbitrarily say all traders with realized loss lost one unit per share.</p>
<p>This market model is deliberately simple, but just as symbolic dynamics offers insights to continuous dynamical systems [<a href="#symbdyn">TBS91</a>] this market model serves as a platform for analyzing aspects of real markets.</p>
<h2><a name="SECTION00032000000000000000" id="SECTION00032000000000000000">Type 1 Traders</a></h2>
<p>We have described a very simple and very limited market. We will now describe some of the traders. Our first set of traders we call &#8220;Type 1 Traders&#8221; and they are meant to represent high-frequency quantitative or technical traders. Type 1 traders perform only type 1 trades (long round trip or short round trip) or abstain from trading. For now we are restricting each type 1 trader to trade a single unit either in a long round trip, a short round trip, or to not trade.</p>
<p>We will model these traders as having no internal state and a limited window of memory of the market. We allow the traders to use probabilistic strategies (so they do not get caught always performing the exact same trade in a repeating situation). Under these limits we can write each trader as a simple table representing a map from <!-- MATH<br />
 $\{+,0,-\}^{k}$<br />
 --><br />
<img width="82" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg7.png" alt="$ \{+,0,-\}^{k}$"/> (the sequences of symbols length <img width="14" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg8.png" alt="$ k$"/> , i.e. what the trader is modeled as remembering) to pairs <!-- MATH<br />
 $(p_{\text{long}},p_{\text{short}})$<br />
 --><br />
<img width="100" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg9.png" alt="$ (p_{\text{long}},p_{\text{short}})$"/> where <!-- MATH<br />
 $p_{\text{long}}$<br />
 --><br />
<img width="39" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg10.png" alt="$ p_{\text{long}}$"/> is the trader&#8217;s chosen probability of making a long round trip in this situation and <!-- MATH<br />
 $p_{\text{short}}$<br />
 --><br />
<img width="44" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg11.png" alt="$ p_{\text{short}}$"/> is the trader&#8217;s chosen probability of making a short round in this situation.<a name="tex2html5" href="#foot162" id="tex2html5"><sup>3</sup></a></p>
<p>We place no limit on how much effort the Type 1 Traders make in pre-computing their strategy tables. One important point is: since the traders are allowed to use probabilistic tables we can assume (in the limit) that the optimal trading strategy is the same for all type 1 traders. This is because if a type 1 trader is losing money to other type 1 traders who are themselves making a profit then the original type 1 trader can &#8220;cannibalize their own business&#8221; by copying a bit of the strategy they are vulnerable to into their own strategy. For example if a trader is losing money to profitable short round trippers they can fix this by trading short round trips a bit more often.<a name="tex2html6" href="#foot153" id="tex2html6"><sup>4</sup></a> When we can use the assumption that all the type 1 traders have identical strategy tables we can then solve for this table and immediately demonstrate the characteristic of the market formed by these optimal traders.</p>
<p>The market model evolves as follows: if there are <img width="20" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg15.png" alt="$ m$"/> type 1 traders with a common memory window size of <img width="14" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg8.png" alt="$ k$"/> then the market symbol at time-<img width="11" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg16.png" alt="$ t$"/> is:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
\text{market}(t) =<br />
\text{sign}\left(<br />
\sum_{i=1}^{m} \chi_i(\text{market}(t-1),\cdots,\text{market}(t-k))<br />
\right)<br />
\end{displaymath}<br />
 --></p>
<div align="center">&nbsp; &nbsp;market<img width="43" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg17.png" alt="$\displaystyle (t) =$"/>&nbsp; &nbsp;sign<img width="339" height="71" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg18.png" alt="$\displaystyle \left( \sum_{i=1}^{m} \chi_i(\text{market}(t-1),\cdots,\text{market}(t-k)) \right) $"/></div>
<p>where <img width="35" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg19.png" alt="$ \chi_i()$"/> is the random variable associated with the <img width="11" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg20.png" alt="$ i$"/> -th type 1 trader.</p>
<p>Already we can show: if the market is only populated by type 1 traders then the optimal trading strategy is to set <!-- MATH<br />
 $p_{\text{long}} =<br />
p_{\text{short}} = 0$<br />
 --><br />
<img width="134" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg21.png" alt="$ p_{\text{long}} = p_{\text{short}} = 0$"/> (to not trade) and there is in fact no market (no trades happen). This follows because for every time no more than half of the active type 1 traders can be on the profitable side, so at best the type 1 traders break even as a group and not trading is a dominant strategy.</p>
<p>To model another important aspect of markets (and to give the type 1 traders a reason to trade) we introduce type 2 traders.</p>
<h2><a name="SECTION00033000000000000000" id="SECTION00033000000000000000">Type 2 Traders</a></h2>
<p>Type 2 traders are completely oblivious to the market. Type 2 traders trade only type 2 trades (simple buy and simple sell). Type 2 traders trade, but do not look at or remember the market sequence. Oddly enough the type 2 traders abstract both the idea of completely informed traders (traders that know something about the future, so do not need to use the market past) and completely uniformed traders (traders trading due to some external to the market pressure like a need to recover liquid assets). For now we are restricting each type 2 trader to trade a single unit either in a simple buy or a simple sell.</p>
<p>We assume one family of type 2 traders that operate as follows: assume a simple sequence of &#8220;<img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg3.png" alt="$ +$"/> &#8221; and &#8220;<img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg4.png" alt="$ -$"/> &#8221; generated by the Markov Chain in Figure&nbsp;<a href="#fig:SimpleMarkovChain">1</a>. This Markov Chain emits a sequence of symbols where the same symbol follows the last with probability <img width="14" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg22.png" alt="$ p$"/> (and the symbol changes with probability <img width="44" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg23.png" alt="$ 1-p$"/> ).</p>
<div align="center"><a name="fig:SimpleMarkovChain" id="fig:SimpleMarkovChain"></a><a name="63"></a></p>
<table>
<caption align="bottom"><strong>Figure 1:</strong> Simple Markov Chain</caption>
<tr>
<td>
<div align="center"><img width="250" height="78" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/./SimpleChain.png" alt="Image SimpleChain"/></div>
</td>
</tr>
</table>
</div>
<p>We will call this sequence &#8220;the hidden symbol&#8221; as only our type 2 traders can see it (the type 1 traders can not). Each of our type 2 traders looks at the current hidden symbol and independently does the following: with probability <img width="13" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg24.png" alt="$ q$"/> they enter a simple buy or simple sell for the next time tick betting in the direction of the hidden symbol and with probability <img width="43" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg25.png" alt="$ 1-q$"/> they enter a simple buy or simple sell for the next time tick betting in the direction opposite to the hidden symbol. For now we will assume all type 2 traders share the same <img width="13" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg24.png" alt="$ q$"/> . The type 2 traders do not perform round trip trades, but instead hold inventory. Thus a type 2 trader&#8217;s long bet is modeled as adding a net upward impact to the next time period.</p>
<p>The market model now evolves as follows. If there are <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> type 2 traders then the market symbol at time-<img width="11" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg16.png" alt="$ t$"/> is:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
\text{market}(t) =<br />
\text{sign}\left(<br />
\sum_{i=1}^{m} \chi_i(\text{market}(t-1),\cdots,\text{market}(t-k))<br />
+ \sum_{i=1}^{n} \Upsilon_i(\text{hidden}(t-1))<br />
\right)<br />
\end{displaymath}<br />
 --></p>
<div align="center">&nbsp; &nbsp;market<img width="43" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg17.png" alt="$\displaystyle (t) =$"/>&nbsp; &nbsp;sign<img width="522" height="71" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg27.png" alt="$\displaystyle \left( \sum_{i=1}^{m} \chi_i(\text{market}(t-1),\cdots,\text{market}(t-k)) + \sum_{i=1}^{n} \Upsilon_i(\text{hidden}(t-1)) \right) $"/></div>
<p>where <!-- MATH<br />
 $\Upsilon_i()$<br />
 --><br />
<img width="37" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg28.png" alt="$ \Upsilon_i()$"/> is the random variable associated with the <img width="11" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg20.png" alt="$ i$"/> -th type 2 trader.</p>
<p>As is often the case in mathematics what the abstract model means can change if we add different interpretations. If the hidden sequence that all of the type 2 traders simultaneously observe is thought to represent some important hidden value like the true value of the company underlying the equity being traded, then we consider the type 2 traders to be informed and consider their knowledge to be an advantage. If we consider the shared sequence to be irrelevant noise then we see these traders as some loose coalition whose value comes only from the fact their trades correlate with each other. If <img width="59" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg29.png" alt="$ q=0.5$"/> then we have truly uninformed (and uncorrelated) traders who are indeed doing nothing. Many real market properties that are attributed as being consequences of non-arbitrage are in fact consequences of conventions no more meaningful than the one given here (for example: closed end funds).</p>
<p>The interesting point is if <img width="14" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg22.png" alt="$ p$"/> is not too near <img width="27" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg30.png" alt="$ 0.5$"/> and <img width="13" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg24.png" alt="$ q$"/> is not too near <img width="27" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg30.png" alt="$ 0.5$"/> then the type 2 traders have a serial correlation (a correlation over time) that the type 1 traders can learn and exploit for profit. Or, from another point of view, the type 1 traders can profit by supplying liquidity to the type 2 traders.</p>
<h1><a name="SECTION00040000000000000000" id="SECTION00040000000000000000">Solving for the Optimal Strategy</a></h1>
<p>Our market was designed to allow a very succinct description. With only type 1 traders and one uniform family of type 2 traders our market is completely specified if we know:</p>
<ul>
<li><img width="20" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg15.png" alt="$ m$"/> : The number of type 1 traders in the market</li>
<li><img width="14" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg8.png" alt="$ k$"/> : The memory length of type 1 traders</li>
<li><img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> : The number of type 2 traders in the market</li>
<li><img width="14" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg22.png" alt="$ p$"/> : The symbol stability odds on the hidden sequence watched by type 2 traders</li>
<li><img width="13" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg24.png" alt="$ q$"/> : the faithfulness of type 2 traders in trading the hidden symbol.</li>
</ul>
<p>Given these parameters there is a unique shared optimal strategy for the type 1 traders, and we can efficiently solve for this strategy (without resorting to approximate or simulation results).</p>
<p>The entire state of the market at a given time can be written as a tuple <img width="77" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg31.png" alt="$ s = (x,y)$"/> where <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg32.png" alt="$ x$"/> is the sequence of the <img width="14" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg8.png" alt="$ k$"/> most recent result symbols from the market sequence (<img width="56" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg33.png" alt="$ +,0,-$"/> ) and <img width="14" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg34.png" alt="$ y$"/> is the most recent symbol from the hidden sequence (<img width="40" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg35.png" alt="$ +,-$"/> ). So there are only <img width="47" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg36.png" alt="$ 2 * 3^k$"/> possible states for the market. Any posited type 1 strategy (along with the above parameters) completely determines the transition odds between each of these detailed market states. Figure&nbsp;<a href="#fig:DetailedMarketMarkovChain">2</a> illustrates the states that make up a <img width="46" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg1.png" alt="$ k=1$"/> market.</p>
<div align="center"><a name="fig:DetailedMarketMarkovChain" id="fig:DetailedMarketMarkovChain"></a><a name="83"></a></p>
<table>
<caption align="bottom"><strong>Figure 2:</strong> Detailed Market Markov Chain for <img width="46" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg1.png" alt="$ k=1$"/></caption>
<tr>
<td>
<div align="center"><img width="500" height="274" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/./Market1.png" alt="Image Market1"/></div>
</td>
</tr>
</table>
</div>
<p>Once the transition odds are known between all states it is a simple matter of linear algebra to solve exactly for the stationary distribution and expected value of the market (for type 1 traders).[<a href="#finiteMC">KS76</a>] Global optimization techniques can be used to identify the optimal strategies and we can then characterize how these market models behave when populated with optimal traders.<a name="tex2html9" href="#foot156" id="tex2html9"><sup>5</sup></a></p>
<p>For concreteness we show a piece of the computation for the <!-- MATH<br />
 $m=1, k=1,<br />
n=2, p=0.8, q=0.9$<br />
 --><br />
<img width="275" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg37.png" alt="$ m=1, k=1, n=2, p=0.8, q=0.9$"/> market model. If the market&#8217;s last symbol was <img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg3.png" alt="$ +$"/> and the last hidden state was <img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg3.png" alt="$ +$"/> then the odds of moving from this state to this same detailed state (both a new hidden symbol of <img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg3.png" alt="$ +$"/> and a new market symbol of <img width="18" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg3.png" alt="$ +$"/> ) for the next time is given by:</p>
<div align="center"><img width="25" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg38.png" alt="$\displaystyle P($"/>hidden<img width="412" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg39.png" alt="$\displaystyle _{\text{next}} = + \vert \text{hidden} = +) P( \chi_1(+) + \Upsilon_1(+) + \Upsilon_2(+) &gt; 0 ) $"/></div>
<p>(where <img width="37" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg40.png" alt="$ \chi_1()$"/> is random variable representing the trade of the type 1 trader and <!-- MATH<br />
 $\Upsilon_1()$<br />
 --><br />
<img width="39" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg41.png" alt="$ \Upsilon_1()$"/> , <!-- MATH<br />
 $\Upsilon_2()$<br />
 --><br />
<img width="39" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg42.png" alt="$ \Upsilon_2()$"/> are the random variables representing the trades of the type 2 traders).</p>
<p>Using nothing more complicated than knowledge of the binomial distribution we can compute the complete transition matrix for the detailed Market Markov Chain. For example: assume our type 1 traders trade the most recent market symbol (except 0) with <img width="27" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg43.png" alt="$ 0.7$"/> probability (and makes no trade otherwise). Now label our states as:</p>
<div align="center">
<table cellpadding="3" border="1">
<tr>
<td align="center">Last Market Symbol</td>
<td align="center">Hidden Symbol</td>
<td align="center">State ID Number</td>
</tr>
<tr>
<td align="center">+</td>
<td align="center">+</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">+</td>
<td align="center">-</td>
<td align="center">2</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">+</td>
<td align="center">3</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">-</td>
<td align="center">4</td>
</tr>
<tr>
<td align="center">-</td>
<td align="center">+</td>
<td align="center">5</td>
</tr>
<tr>
<td align="center">-</td>
<td align="center">-</td>
<td align="center">6</td>
</tr>
</table>
</div>
<p>then it is merely a matter of detailed arithmetic to derive the state to state transition probability matrix<a name="tex2html10" href="#foot97" id="tex2html10"><sup>6</sup></a>:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
P =<br />
\left(<br />
\begin{array}{llllll}<br />
0.648 &#038; 0.162 &#038; 0.648 &#038; 0.162 &#038; 0.7488 &#038; 0.1872 \\<br />
0.002 &#038; 0.008 &#038; 0.002 &#038; 0.008 &#038; 0.0272 &#038; 0.1088 \\<br />
0.0432 &#038; 0.0108 &#038; 0.144 &#038; 0.036 &#038; 0.0432 &#038; 0.0108 \\<br />
0.0108 &#038; 0.0432 &#038; 0.036 &#038; 0.144 &#038; 0.0108 &#038; 0.0432 \\<br />
0.1088 &#038; 0.0272 &#038; 0.008 &#038; 0.002 &#038; 0.008 &#038; 0.002 \\<br />
0.1872 &#038; 0.7488 &#038; 0.162 &#038; 0.648 &#038; 0.162 &#038; 0.648<br />
\end{array}<br />
\right)<br />
.<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="441" height="147" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg46.png" alt="\begin{displaymath} P = \left( \begin{array}{llllll} 0.648 &amp; 0.162 &amp; 0.648 &amp; 0.... ... &amp; 0.7488 &amp; 0.162 &amp; 0.648 &amp; 0.162 &amp; 0.648 \end{array}\right) . \end{displaymath}"/></div>
<p>Solving for the stationary distribution is, as promised, quite easy. We want to find a vector <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg32.png" alt="$ x$"/> such that <!-- MATH<br />
 $(P-I) x = 0$<br />
 --><br />
<img width="104" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg47.png" alt="$ (P-I) x = 0$"/> and <!-- MATH<br />
 $1\cdot x = 1$<br />
 --><br />
<img width="68" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg48.png" alt="$ 1\cdot x = 1$"/> (<img width="14" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg49.png" alt="$ I$"/> denoting the identity matrix). Under very general conditions this will be a set of <img width="43" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg50.png" alt="$ s+1$"/> equations over <img width="13" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg51.png" alt="$ s$"/> variables with rank <img width="13" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg51.png" alt="$ s$"/> (so will have a unique solution and we don&#8217;t need to add any sign constraints).</p>
<p>This solution gives us the stationary odds of the market (how likely we are to see the market in any state at a random observation time):</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
x =<br />
\left(<br />
\begin{array}{l}<br />
0.420497 \\<br />
0.048611 \\<br />
0.030892 \\<br />
0.030892 \\<br />
0.048611 \\<br />
0.420497<br />
\end{array}<br />
\right)<br />
.<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="151" height="147" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg52.png" alt="\begin{displaymath} x = \left( \begin{array}{l} 0.420497 \ 0.048611 \ 0.030892 \ 0.030892 \ 0.048611 \ 0.420497 \end{array}\right) . \end{displaymath}"/></div>
<p>Once we know this it is a matter of arithmetic to determine the expected value of the market for the type 1 trader.<a name="tex2html11" href="#foot104" id="tex2html11"><sup>7</sup></a> The trading strategy we imposed was not optimal but does have the positive value of <img width="36" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg53.png" alt="$ 0.13$"/> units expected profit per time tick. We can completely characterize these markets for moderate values of <img width="14" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg8.png" alt="$ k$"/> and arbitrary values of <img width="20" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg15.png" alt="$ m$"/> and <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> .</p>
<p>Already we can confirm some features we would expect to see in this model. For example the type 1 traders have a &#8220;tragedy of the commons&#8221; situation in that they are using up the correlations that the type 2 traders introduce. If there are too many technical traders trying to follow the type 2 traders then the market becomes anti-correlated and oscillates in a way that is not profitable for these traders (until they adjust their strategies). For example raising <img width="20" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg15.png" alt="$ m$"/> to <img width="14" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg54.png" alt="$ 2$"/> in our example makes the &#8220;follow the market 70%&#8221; of the time an unprofitable strategy that loses money at a rate of <img width="36" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg55.png" alt="$ 0.12$"/> units per time tick. However, with <img width="102" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg56.png" alt="$ m=2, n=3$"/> this same strategy is profitable at a rate of <img width="36" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg57.png" alt="$ 0.08$"/> units per time tick. The <img width="102" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg58.png" alt="$ m=2, n=2$"/> market can be made to be profitable if both of the technical traders act &#8220;superrationally&#8221;<a name="tex2html12" href="#foot158" id="tex2html12"><sup>8</sup></a> and lower their trade rate from following the market 70% of the time to something lower like 20% of the time. Figure&nbsp;<a href="#fig:stratValueK1N2M2">3</a> shows the expected value of the market <!-- MATH<br />
 $m=2, k=1, n=2, p=0.8, q=0.9$<br />
 --><br />
<img width="275" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg2.png" alt="$ m=2, k=1, n=2, p=0.8, q=0.9$"/> for the type 1 traders as the type 1 traders odds of &#8220;following the last symbol&#8221; are moved from 0 to <img width="14" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg59.png" alt="$ 1$"/> (and, as earlier, refrain from trading in all other cases).</p>
<div align="center"><a name="fig:stratValueK1N2M2" id="fig:stratValueK1N2M2"></a><a name="110"></a></p>
<table>
<caption align="bottom"><strong>Figure 3:</strong> Strategy values for <!-- MATH<br />
 $m=2, k=1, n=2, p=0.8, q=0.9$<br />
 --><br />
<img width="275" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg2.png" alt="$ m=2, k=1, n=2, p=0.8, q=0.9$"/></caption>
<tr>
<td>
<div align="center"><img width="400" height="400" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/./stratValueK1N2M2.png" alt="Image stratValueK1N2M2"/></div>
</td>
</tr>
</table>
</div>
<h1><a name="SECTION00050000000000000000" id="SECTION00050000000000000000">The Experiment</a></h1>
<p>Now that we have set up a market and described how to evaluate and solve for the optimal trading strategies we are ready to run an experiment. The experiment is the introduction of a large trader that trades at a much larger size than other type 1 traders. This large trader will act like a type 1 trader but it is allowed larger trade sizes and a small informational advantage over the other type 1 traders. This informational advantage is the ability to remember if their own last trade was one of three possible strategies (so it is not really extending the windows size, and this extension would not help the smaller type 1 traders against this strategy).</p>
<p>To illustrate we assume a market where <img width="52" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg60.png" alt="$ m=0$"/> , <img width="46" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg1.png" alt="$ k=1$"/> , <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> is large, <img width="63" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg61.png" alt="$ q&gt;1/2$"/> , <img width="63" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg62.png" alt="$ p &gt; 3/4$"/> and <!-- MATH<br />
 $n*(q-1/2)*(p-3/4)$<br />
 --><br />
<img width="187" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg63.png" alt="$ n*(q-1/2)*(p-3/4)$"/> is large (and all known to the large trader).</p>
<p>The large trader trades as follows: define three states to remember the large trader&#8217;s last state &#8220;odd time tick&#8221;, &#8220;even time tick following bluff&#8221; and &#8220;even time tick following non bluff.&#8221; We illustrate the large strategy in Figure&nbsp;<a href="#fig:Strat1">4</a>. On odd time ticks the large trader either bluffs (trades to flip the market symbol and takes a forced loss) or trades normally (allows the market to evolve under the influence of the type 2 traders and takes an expected profit). On even time ticks the large trader&#8217;s behavior depends if the last odd tick was a bluff (and the type 2 traders&#8217; influence on the market is masked) or the last odd tick was not a bluff (and the type 2 traders&#8217; influence on the market is visible). These two different states are marked in Figure&nbsp;<a href="#fig:Strat1">4</a> and the large trader abstains from trading after a bluff or trades for expected profit after a non-bluff.</p>
<div align="center"><a name="fig:Strat1" id="fig:Strat1"></a><a name="120"></a></p>
<table>
<caption align="bottom"><strong>Figure 4:</strong> Large Type 1 Trader States</caption>
<tr>
<td>
<div align="center"><img width="300" height="192" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/./Strat1.png" alt="Image Strat1"/></div>
</td>
</tr>
</table>
</div>
<p>The large trader&#8217;s strategy yields an augmented Markov chain that reflects the large trader&#8217;s state, the last symbol seen in the market and the last symbol of the hidden sequence. This Markov chain is shown in Figure&nbsp;<a href="#fig:BigStrat1">5</a> (with links from even time states to odd time states and links to and from unlikely states suppressed for clarity). We will describe the large trader&#8217;s strategy in detail below, but there are some simplifying points to keep in mind. Since <img width="85" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg64.png" alt="$ n (q-1/2)$"/> is large we are assuming that on odd time ticks and for even time ticks following non-bluffs the states where the market symbol and the hidden symbol disagree are very rare (and we will omit them from the analysis).</p>
<p>Stepping through the large trader strategy (see Figure&nbsp;<a href="#fig:BigStrat1">5</a>): on the odd time periods the large trader assumes that the market symbol equals the hidden symbol (i.e. the <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> type 2 traders successfully copied the hidden symbol to the market without interference). The large trader then flips a fair coin and with 50% chance &#8220;bluffs&#8221; (forcing the market to the symbol opposite the hidden symbol by trading a little more than <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> units in the appropriate direction) or on the other 50% of the time trades slightly less than <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> units to try and profit off the obvious tick to tick correlation in the market. On the even time ticks the large trader trades to profit if the previous trade was not a bluff or otherwise abstains from trading. The expected value of the sum of contributions of the type 2 traders is <!-- MATH<br />
 $\text{hidden\_symbol}*(q*n - (1-q)*n)$<br />
 --><br />
<img width="282" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg66.png" alt="$\text{hidden\_symbol}*(q*n - (1-q)*n)$"/> which has an absolute value of <!-- MATH<br />
 $(2 q - 1) n$<br />
 --><br />
<img width="76" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg67.png" alt="$ (2 q - 1) n$"/> . Let <!-- MATH<br />
 $Q = (2 q - 1) n$<br />
 --><br />
<img width="113" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg68.png" alt="$ Q = (2 q - 1) n$"/> . A bluff costs the large trader <img width="72" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg69.png" alt="$ Q + o(n)$"/> <a name="tex2html15" href="#foot159" id="tex2html15"><sup>9</sup></a> units as they enter a trade in large enough to overwhelm the type 2 traders with high probability. A trade for profit (either on a non-bluff odd time tick or a even time tick following a non-bluff) has a maximum expected value of <!-- MATH<br />
 $(Q -<br />
o(n)) * (p*(1) + (1-p)*(-1)) = Q ( 2 p - 1) - o(n)$<br />
 --><br />
<img width="441" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg72.png" alt="$ (Q - o(n)) * (p*(1) + (1-p)*(-1)) = Q ( 2 p - 1) - o(n)$"/> as the large trader must not overwhelm the expected effect of the type 2 traders. Every two time ticks the large trader either bluffs then abstains (with probability 1/2) or makes two profitable trade attempts in a row (with probability 1/2). So every 2 time ticks the expected return is:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
0.5 * (- Q - o(n) ) + 0.5 * 2 * (Q (2 p -1) - o(n))<br />
= (Q / 2) (p - 3/4) - o(n)<br />
.<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="559" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg73.png" alt="$\displaystyle 0.5 * (- Q - o(n) ) + 0.5 * 2 * (Q (2 p -1) - o(n)) = (Q / 2) (p - 3/4) - o(n) . $"/></div>
<p>Or (q &#8211; 1/2)(p-3/4)n/2 &#8211; o(n) expected units return per time tick.</p>
<div align="center"><a name="fig:BigStrat1" id="fig:BigStrat1"></a><a name="131"></a></p>
<table>
<caption align="bottom"><strong>Figure 5:</strong> Example Strategy for Large Type 1 Trader</caption>
<tr>
<td>
<div align="center"><img width="500" height="540" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/./BigStrat1.png" alt="Image BigStrat1"/> <font size="-1">
<p />(for clarity transitions between unlikely states and from even time ticks to odd time ticks are not shown)</font></div>
</td>
</tr>
</table>
</div>
<p>This large trader strategy is for illustration, and is in no sense optimal<a name="tex2html17" href="#foot136" id="tex2html17"><sup>10</sup></a>. The important result is that when looking at the sequence of market symbols with a window of length 2 (the length of window that would be useful in defining a trading strategy for a <img width="46" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg1.png" alt="$ k=1$"/> type 1 opposing trader) all the zero free market symbol sequences of length 2 come up with the same probability: <img width="31" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg75.png" alt="$ 1/4$"/> . To a limited memory type 1 opponent (or one who has to encode their strategy with limited memory) the market looks like a fair coin with no serial correlation. Thus, if we start with <img width="52" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg60.png" alt="$ m=0$"/> (i.e. no other type 1 traders) a single large trader can take over the market and when we later increase <img width="20" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg15.png" alt="$ m$"/> the new type 1 traders will compute an optimal strategy of not trading (i.e. they will see no method to profitably enter the market).</p>
<p>The large trader has rendered the market untradable for other type 1 traders in the strongest possible sense. Because this market model is symmetric, has no trading costs and no margin requirements, no strategy can exist that forces other adapting strategies to lose money. This is because a strategy that is forced to lose money can be adapted into a profitable strategy by reversing the long and short actions. The large trader is using slightly more memory but this is just an accounting gimmick so they know on which ticks the market has information from the type 2 traders and on which ticks are noise from their own &#8220;bluff&#8221; or &#8220;Pyrrhic&#8221; trades. The other type 1 traders have no advantage when given the equivalent gimmick.<a name="tex2html18" href="#foot137" id="tex2html18"><sup>11</sup></a> Also, the large trader strategy is self financing: the large trader can hold the market (make the market look purely random to outsiders) while extracting a profit.</p>
<h1><a name="SECTION00060000000000000000" id="SECTION00060000000000000000">Conclusion</a></h1>
<p>We have described a combinatorial market model that is designed for simplicity. As is well known from mathematics and theoretical computer science even very simple systems can exhibit arbitrarily complex behavior when feedback, recursion or iteration are involved.</p>
<p>We have shown how to explicitly derive optimal trading behavior for small traders in this market model. We then demonstrated how a large trader (allowed to move more volume than the small traders) can &#8220;hold the market&#8221; in the sense they can make the market appear to be uncorrelated to outsiders while extracting a profit on their own. The ability to completely characterize our market model allows us to show that a self financing large trader is a stable solution in this market model even in the presence of optimal opponents with similar computational power.</p>
<p>It is beyond the scope of current techniques to show under which conditions a self-financing large trader could exist in a &#8220;fully realistic&#8221; market model. But by demonstration we have shown that we can not assume there are no self financing large traders.</p>
<h1><a name="SECTION00070000000000000000" id="SECTION00070000000000000000">Further Research</a></h1>
<p>Interesting follow up studies, which are well within the scope of the methods demonstrated here, include:</p>
<ul>
<li>Larger <img width="14" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg8.png" alt="$ k$"/> and heterogeneous <img width="14" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg8.png" alt="$ k$"/></li>
<li>A cross-market arbitrage interpretation for the type 2 traders</li>
<li>More detailed price and hidden symbol trajectories</li>
<li>Non-finite strategies (strategies indexed by integers instead of a small set of symbols)</li>
<li>Inventory and margin</li>
<li>Trade volume controlling price change (i.e. a model of price&#8217;s elasticity with respect to trade volume).</li>
</ul>
<h2><a name="SECTION00080000000000000000" id="SECTION00080000000000000000">Bibliography</a></h2>
<dl compact>
<dt><a name="Applebaum:2004p1042" id="Applebaum:2004p1042">App04</a></dt>
<dd>David Applebaum, <i>Levy processes- from probability to finance and quantum groups</i>, Notices of the AMS <b>51</b> (2004), no.&nbsp;1336-1347, 12.</dd>
<dt><a name="probmeth" id="probmeth">AS92</a></dt>
<dd>Nogal Alon and Joel&nbsp;H. Spencer, <i>The probabilistic method</i>, Wiley, 1992.</dd>
<dt><a name="Hasanhodzic:2009p2605" id="Hasanhodzic:2009p2605">HLV09</a></dt>
<dd>Jasmina Hasanhodzic, Andrew&nbsp;W Lo, and Emanuele Viola, <i>A computational view of market efficiency</i>, 1-14.</dd>
<dt><a name="metamag" id="metamag">Hof85</a></dt>
<dd>Douglas&nbsp;R. Hofstadter, <i>Metamagical themas: Questiong for the essence of mind and pattern</i>, Basic Books Inc., 1985.</dd>
<dt><a name="finiteMC" id="finiteMC">KS76</a></dt>
<dd>John&nbsp;G. Kemeny and J.&nbsp;Lauri Snell, <i>Finite markov chains</i>, Springer, 1976.</dd>
<dt><a name="citeulike:2080469" id="citeulike:2080469">KS01</a></dt>
<dd>Ioannis Karatzas and Steven&nbsp;E. Shreve, <i>Methods of mathematical finance</i>, Springer, September 2001.</dd>
<dt><a name="Lo:2001p1619" id="Lo:2001p1619">LM01</a></dt>
<dd>Andrew&nbsp;W Lo and A&nbsp;Craig MacKinlay, <i>A non-random walk down wall street</i>, Princeton University Press, 2001.</dd>
<dt><a name="Lo:2005p2193" id="Lo:2005p2193">Lo05</a></dt>
<dd>Andrew&nbsp;W Lo, <i>Reconciling efficient markets with behavioral finance: The adaptive markets hypothesis</i>, 44.</dd>
<dt><a name="MertonCTF" id="MertonCTF">Mer99</a></dt>
<dd>Robert&nbsp;C. Merton, <i>Continuous-time finance</i>, Blackwell, 1999.</dd>
<dt><a name="AlgGT" id="AlgGT">NNV07</a></dt>
<dd>Eva&nbsp;Tardos Noam&nbsp;Nisan, Tim&nbsp;Roughgarden and Vijay&nbsp;V. Vazirani, <i>Algorithmic game theory</i>, Cambridge, 2007.</dd>
<dt><a name="Rall:1996p2473" id="Rall:1996p2473">RC96</a></dt>
<dd>Louis&nbsp;B Rall and George&nbsp;F Corliss, <i>An introduction to automatic differentiation</i>, SIAM: Computational Differentiation: Techniques, Applications and Tools (1996), 1-18.</dd>
<dt><a name="Shafer:2004p1497" id="Shafer:2004p1497">Sha04</a></dt>
<dd>Glenn Shafer, <i>Why do price series look like ito processes?</i>, Rutgers (2004), 43.</dd>
<dt><a name="Steele:2003p2288" id="Steele:2003p2288">Ste03a</a></dt>
<dd>J&nbsp;Michael Steele, <i>Ito calculus</i>, Encyclopedia of Actuarial Sciences (2003), 1-12.</dd>
<dt><a name="citeulike:2635904" id="citeulike:2635904">Ste03b</a></dt>
<dd>J.&nbsp;Michael Steele, <i>Stochastic calculus and financial applications</i>, Springer, June 2003.</dd>
<dt><a name="symbdyn" id="symbdyn">TBS91</a></dt>
<dd>Michael&nbsp;Keane Tim&nbsp;Bedford and Caroline Series, <i>Egrodic theory, symbolic dynamics and hyperbolic spaces</i>, Oxford University Press, 1991.</dd>
</dl>
<p></p>
<hr />
<h4>Footnotes</h4>
<dl>
<dt><a name="foot12" id="foot12">&#8230; Mount</a><a href="#tex2html3"><sup>1</sup></a></dt>
<dd>email: <tt><a name="tex2html1" href="mailto:jmount@win-vector.com" id="tex2html1">mailto:jmount@win-vector.com</a></tt> company: <tt><a name="tex2html2" href="http://www.win-vector.com/" id="tex2html2">http://www.win-vector.com/</a></tt></dd>
<dt><a name="foot37" id="foot37">&#8230; loss.</a><a href="#tex2html4"><sup>2</sup></a></dt>
<dd>We do not enforce any sort of &#8220;conservation of money&#8221; (that the amount of profit earned by the short trader should equal the amount of money lost by the long traders). In the real market there is an aspect of conservation of money in trades, but there is not a conservation of money in a single time period if the traders have net holdings.</dd>
<dt><a name="foot162" id="foot162">&#8230; situation.</a><a href="#tex2html5"><sup>3</sup></a></dt>
<dd>So <!-- MATH<br />
 $p_{\text{long}}<br />
\ge 0$<br />
 --><br />
<img width="71" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg12.png" alt="$ p_{\text{long}} \ge 0$"/> , <!-- MATH<br />
 $p_{\text{short}} \ge 0$<br />
 --><br />
<img width="76" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg13.png" alt="$ p_{\text{short}} \ge 0$"/> and <!-- MATH<br />
 $p_{\text{long}} +<br />
p_{\text{short}} \le 1$<br />
 --><br />
<img width="132" height="31" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg14.png" alt="$ p_{\text{long}} + p_{\text{short}} \le 1$"/> .</dd>
<dt><a name="foot153" id="foot153">&#8230; often.</a><a href="#tex2html6"><sup>4</sup></a></dt>
<dd>This &#8220;traders can imitate each other&#8221; is a &#8220;linearity of expectation argument&#8221;[<a href="#probmeth">AS92</a>] and is a common argument technique in game theory.</dd>
<dt><a name="foot156" id="foot156">&#8230; traders.</a><a href="#tex2html9"><sup>5</sup></a></dt>
<dd>The optimization problem has some easy aspects. At the optimum we can assume all the type 1 traders are identical (so we solve for one trader of magnitude <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> instead of solving for a population of <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> traders) and we can use automatic differentiation techniques[<a href="#Rall:1996p2473">RC96</a>] to get gradients as we work.</dd>
<dt><a name="foot97" id="foot97">&#8230; matrix</a><a href="#tex2html10"><sup>6</sup></a></dt>
<dd>We are being a little non-standard here in that we are writing <img width="18" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg44.png" alt="$ P$"/> as an operator on the left, so if <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg32.png" alt="$ x$"/> is the state-vector of probabilities at a given time tick then <img width="28" height="15" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg45.png" alt="$ P x$"/> is the state-vector of probabilities at the next time tick. This is not the convention in the Markov Chain literature, but more compatible with other topics in linear algebra.</dd>
<dt><a name="foot104" id="foot104">&#8230; trader.</a><a href="#tex2html11"><sup>7</sup></a></dt>
<dd>Some care has to be taken that in computing the value of a strategy as we need access to some several additional transition matrices (each conditioned on knowing the proposed trade of the type 1 trader we are studying).</dd>
<dt><a name="foot158" id="foot158">&#8230; &#8220;superrationally&#8221;</a><a href="#tex2html12"><sup>8</sup></a></dt>
<dd>That is each type 2 trader must dial down their trading activity to account for the number of other type 2 traders present. Douglas Hofstadter called such behavior &#8220;superrational&#8221;[<a href="#metamag">Hof85</a>]. Traders with small budgets who can not collaborate are actually likely to do this- because while they are trading at too high a rate they lose money. However, a trader that can work at higher volume or tolerate larger losses can outwait the others and have the market for theirselves.</dd>
<dt><a name="foot159" id="foot159">&#8230;</a><a href="#tex2html15"><sup>9</sup></a></dt>
<dd>The <img width="37" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg70.png" alt="$ o(n)$"/> is an &#8220;order-of&#8221; notation meant to denote a quantity that increases more slowly than <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> as <img width="15" height="18" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg26.png" alt="$ n$"/> gets large. An example <img width="37" height="36" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg70.png" alt="$ o(n)$"/> quantity would be <img width="30" height="38" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/09/dmmimg71.png" alt="$ \sqrt{n}$"/> . This notation (when used properly) greatly speeds up calculation by suppressing irrelevant details.</dd>
<dt><a name="foot136" id="foot136">&#8230; optimal</a><a href="#tex2html17"><sup>10</sup></a></dt>
<dd>At the very least we could tune the bluff frequency and also trade (albeit with less certainty) in the after-bluff periods</dd>
<dt><a name="foot137" id="foot137">&#8230; gimmick.</a><a href="#tex2html18"><sup>11</sup></a></dt>
<dd>Unless they use the gimmick to collude to overcome the organized size of the large trader, but then the other type 2 traders are essentially also one large trader</dd>
</dl>


<p>Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
<li><a href='http://www.win-vector.com/blog/2009/03/it-is-not-all-the-quants-fault/' rel='bookmark' title='Permanent Link: It is not all the quants&#8217; fault.'>It is not all the quants&#8217; fault.</a></li>
<li><a href='http://www.win-vector.com/blog/2007/10/paper-on-stock-trading/' rel='bookmark' title='Permanent Link: Paper on stock trading'>Paper on stock trading</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.win-vector.com/blog/2009/09/a-discrete-model-gauging-market-efficiency/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Thievery considered harmful</title>
		<link>http://www.win-vector.com/blog/2009/07/thievery-considered-harmful/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=thievery-considered-harmful</link>
		<comments>http://www.win-vector.com/blog/2009/07/thievery-considered-harmful/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 16:18:32 +0000</pubDate>
		<dc:creator>John Mount</dc:creator>
				<category><![CDATA[Finance]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Thieves]]></category>

		<guid isPermaLink="false">http://www.win-vector.com/blog/?p=178</guid>
		<description><![CDATA[A bit of a tempest in finance news involving accusations of sensitive code stolen from a major trading desk. For emerging details see: Special Agent Michael G. McSwain&#8217;s charges Mathew Goldstein&#8217;s Reuters article Zero Hedge blog entry For me this triggers some strong (and sad) personal memories. No matter what inappropriate &#8220;Robin Hood&#8221; intellectual property [...]


Related posts:<ol><li><a href='http://www.win-vector.com/blog/2008/04/sorting-in-anger/' rel='bookmark' title='Permanent Link: Sorting Used in Anger'>Sorting Used in Anger</a></li>
<li><a href='http://www.win-vector.com/blog/2010/01/relative-returns-a-banker-versus-trader-paradox/' rel='bookmark' title='Permanent Link: Relative returns: a banker versus trader paradox'>Relative returns: a banker versus trader paradox</a></li>
<li><a href='http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/' rel='bookmark' title='Permanent Link: A Quick Appreciation of the Sharpe Ratio'>A Quick Appreciation of the Sharpe Ratio</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A bit of a tempest in finance news involving accusations of sensitive code stolen from a major trading desk.  For emerging details see:</p>
<ul>
<li>
<a href="http://static.reuters.com/resources/media/editorial/20090706/Complaint%20--%20Aleynikov.pdf" target="other">Special Agent Michael G. McSwain&#8217;s charges</a>
</li>
<li>
<a href="http://blogs.reuters.com/commentaries/2009/07/05/a-goldman-trading-scandal/" target="other">Mathew Goldstein&#8217;s Reuters article</a>
</li>
<li>
<a href="http://zerohedge.blogspot.com/2009/07/is-case-of-quant-trading-industrial.html" target="other">Zero Hedge blog entry</a>
</li>
</ul>
<p><span id="more-178"></span></p>
<p>For me this triggers some strong (and sad) personal memories.</p>
<p>No matter what inappropriate &#8220;Robin Hood&#8221; intellectual property fantasies you have this (if true) is just wrong. I have never been a huge fan of the <a href="http://www.acm.org/about/code-of-ethics" target="other">ACM Code of Ethics</a> (which does cover this situation, but fails to seriously address much beyond having  responsibilities to your employer) but this sort of incident reminds me why computer science needs some approximation of a shared set of ethics that we can try to refer to.</p>
<p>A particularly sad part of the story that attracted my attention was the reliance on &#8220;bash history&#8221; to try and establish what happened.  Attempting to &#8220;prove&#8221; something using a &#8220;bash history&#8221; is something I have painful experience with.  The &#8220;bash history&#8221; system is incredibly inadequate even for what it was designed for (caching recent commands).  Simply having two shells open can cause non-deterministic overwriting, deletion, clobbering and time disorderings in the history file.  Furthermore bash history has no dates, times, directories or any other contextual hints written into it.  Finally bash history has no hashes, signatures, nonces, sequence numbers or any other device that helps establish authenticity.</p>
<p>Now for my story.  We (by chance) caught somebody walking off with our group&#8217;s entire source tree.  In the end all we had to go on was the bash history.  To hostile eyes bash history is nowhere near what you would call &#8220;forensic grade evidence.&#8221;  Unfortunately for us the theft was intramural, the thief was merely taking the code to another group in the same company to later mine and represent as their own work.  At this point even language worked against us- every time we accidentally said something like &#8220;our code&#8221; (as in the code we produced, not the code we own) we were perceived as being anti-company.  Evil prevailed (the thief was promoted) and I looked stupid for working so hard to try to interpret such low-quality evidence.  But we live in an objective world- just because you can&#8217;t prove something doesn&#8217;t mean there isn&#8217;t some buried ugly truth.</p>
<p>So what was stolen?  Not the code, that moved from one pocket of the corporation that owned it to another pocket of the same corporation.  What was stolen was reputation.  The thief presumably appeared to out-produce both his old colleagues and his new ones (who don&#8217;t have a few absconded person-years of development to draw from).  So an apology to anyone who was asked why they could not code as fast as our escaped &#8220;genius,&#8221; it was certainly not our intent to so equip him.  And a larger apology to the rest of the team, sorry we could not prove the misappropriation of your work.  </p>
<p>Of course Shakespeare said it much better (from Othello):</p>
<blockquote>
<pre>
Good name in man and woman, dear my lord,
Is the immediate jewel of their souls:
Who steals my purse steals trash; ’t is something, nothing;
’T was mine, ’t is his, and has been slave to thousands;
But he that filches from me my good name
Robs me of that which not enriches him
And makes me poor indeed.
</pre>
</blockquote>


<p>Related posts:<ol><li><a href='http://www.win-vector.com/blog/2008/04/sorting-in-anger/' rel='bookmark' title='Permanent Link: Sorting Used in Anger'>Sorting Used in Anger</a></li>
<li><a href='http://www.win-vector.com/blog/2010/01/relative-returns-a-banker-versus-trader-paradox/' rel='bookmark' title='Permanent Link: Relative returns: a banker versus trader paradox'>Relative returns: a banker versus trader paradox</a></li>
<li><a href='http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/' rel='bookmark' title='Permanent Link: A Quick Appreciation of the Sharpe Ratio'>A Quick Appreciation of the Sharpe Ratio</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.win-vector.com/blog/2009/07/thievery-considered-harmful/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What does the Market Think?</title>
		<link>http://www.win-vector.com/blog/2009/03/what-does-the-market-think/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=what-does-the-market-think</link>
		<comments>http://www.win-vector.com/blog/2009/03/what-does-the-market-think/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 18:23:43 +0000</pubDate>
		<dc:creator>John Mount</dc:creator>
				<category><![CDATA[Expository Writing]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[Information Markets]]></category>
		<category><![CDATA[Mergers]]></category>
		<category><![CDATA[Pricing]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.win-vector.com/blog/?p=71</guid>
		<description><![CDATA[What does the market think about IBM&#8217;s proposed acquisition of Sun? Given the differences in size between the two companies it is definitely a case of &#8220;IBM + Sun = IBM.&#8221; Also, one might think that IBM being down over 2% in price (1:30pm Eastern March 18 2009: mid day after the news got out) [...]


Related posts:<ol><li><a href='http://www.win-vector.com/blog/2008/05/is-search-advertising-a-market-for-lemons/' rel='bookmark' title='Permanent Link: Is Search Advertising a Market for Lemons?'>Is Search Advertising a Market for Lemons?</a></li>
<li><a href='http://www.win-vector.com/blog/2009/09/a-discrete-model-gauging-market-efficiency/' rel='bookmark' title='Permanent Link: A Discrete Model Gauging Market Efficiency'>A Discrete Model Gauging Market Efficiency</a></li>
<li><a href='http://www.win-vector.com/blog/2009/03/it-is-not-all-the-quants-fault/' rel='bookmark' title='Permanent Link: It is not all the quants&#8217; fault.'>It is not all the quants&#8217; fault.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>What does the market think about IBM&#8217;s proposed acquisition of Sun?<span id="more-71"></span><br />
Given the differences in size between the two companies it is definitely a case of &#8220;IBM + Sun = IBM.&#8221;   Also, one might think that IBM being down over 2% in price (1:30pm Eastern March 18 2009: mid day after the news got out) on a neutral day (Dow down 0.5%, NASDAQ and S&#038;P 500 up) is a strong vote against the merger.  A more careful analysis shows that the market has not really expressed a strong opinion yet.</p>
<p>A lot of ink is spilled about the &#8220;information markets&#8221; but a lot of writers ignore just how much of the pricing of markets is due to information-free arbitrage and represents how markets work (and not information).  For example the over 2% price decline in IBM actually tells us almost nothing- it is to be expected.</p>
<p>The quantity to look at is not price, but the total market value of IBM plus Sun.  </p>
<p>If the market is in equilibrium Sun&#8217;s price should increase by an amount equal to the premium IBM is thought to be willing to pay for the stock times the perceived probability of the deal going through.  Sun right now is $8.72 (up from $4.97) so it is safe to assume IBM is offering nearly a 100% premium on Sun stock and the market is fairly certain the deal will go through.  So Sun&#8217;s total market cap (price per share times total number of shares) rose from $3.7 billion to $6.5 billion (or a net increase of $2.8 billion).</p>
<p>IBM&#8217;s price slid from $92.91 to $90.83 this means that its market cap fell from $124.7 billion  to $121.9 billion or a loss of around $2.8 billion.  Almost identical to the increase that priced Sun up 75%.</p>
<p>So the market is pricing IBM + Sun today very very closely to what the sum of prices yesterday.  I would interpret this as yielding no information other than the fact that the market feels IBM will pay a substantial premium for Sun (and that the deal is likely to go through, yielding the 75% single day price in increase in Sun).  The fact that the sum of market caps is so well preserved indicates that no big player has yet started trading on a strong opinion if the deal is good or bad.</p>
<p>All of the above arguments are &#8220;arbitrage-like.&#8221;  The idea is if the market mis-priced the sum of IBM plus Sun then an informed trader could profit by taking an informed contrary position (it is not true arbitrage because the trader would have to take a risky position for a period of time) and waiting until some time after the merger finishes (or fails) to take a profit.  Of course, as is now painfully obvious, all such arguments are irrelevant if the market locks up.  Without a fluid market there is no reason for complicated combinations of investments to price lock step with each other.</p>


<p>Related posts:<ol><li><a href='http://www.win-vector.com/blog/2008/05/is-search-advertising-a-market-for-lemons/' rel='bookmark' title='Permanent Link: Is Search Advertising a Market for Lemons?'>Is Search Advertising a Market for Lemons?</a></li>
<li><a href='http://www.win-vector.com/blog/2009/09/a-discrete-model-gauging-market-efficiency/' rel='bookmark' title='Permanent Link: A Discrete Model Gauging Market Efficiency'>A Discrete Model Gauging Market Efficiency</a></li>
<li><a href='http://www.win-vector.com/blog/2009/03/it-is-not-all-the-quants-fault/' rel='bookmark' title='Permanent Link: It is not all the quants&#8217; fault.'>It is not all the quants&#8217; fault.</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.win-vector.com/blog/2009/03/what-does-the-market-think/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>It is not all the quants&#8217; fault.</title>
		<link>http://www.win-vector.com/blog/2009/03/it-is-not-all-the-quants-fault/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=it-is-not-all-the-quants-fault</link>
		<comments>http://www.win-vector.com/blog/2009/03/it-is-not-all-the-quants-fault/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 20:08:01 +0000</pubDate>
		<dc:creator>John Mount</dc:creator>
				<category><![CDATA[Expository Writing]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Bubble]]></category>
		<category><![CDATA[Copula]]></category>
		<category><![CDATA[Information Taker]]></category>
		<category><![CDATA[Price Taker]]></category>
		<category><![CDATA[Quants]]></category>

		<guid isPermaLink="false">http://www.win-vector.com/blog/?p=51</guid>
		<description><![CDATA[There is plenty of blame to go around from the current global financial crisis. But, I would like to point out that it is not &#8220;all the quants&#8217; fault.&#8221; We are all now, unfortunately, sitting in the middle of a high quality (and extremely expensive) lesson in financial mathematics. I would hate for some of [...]


Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
<li><a href='http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/' rel='bookmark' title='Permanent Link: A Quick Appreciation of the Sharpe Ratio'>A Quick Appreciation of the Sharpe Ratio</a></li>
<li><a href='http://www.win-vector.com/blog/2008/10/something-i-dont-get-about-business-and-bailouts/' rel='bookmark' title='Permanent Link: Something I don&#8217;t get about business and bailouts'>Something I don&#8217;t get about business and bailouts</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>
There is plenty of blame to go around from the current global financial crisis.  But, I would like to point out that it is not &#8220;all the quants&#8217; fault.&#8221;  We are all now, unfortunately, sitting in the middle of a high quality (and extremely expensive) lesson in financial mathematics.  I would hate for some of the truly important points to be lost to paying too much attention to some of the shiny details.
</p>
<p><span id="more-51"></span></p>
<p>
One fascinating article ( <a href="http://www.wired.com/techbiz/it/magazine/17-03/wp_quant?currentPage=all">Recipe for Disaster: The Formula That Killed Wall Street</a> by Felix Salmon, Wired, February 2009) has so popularized assigning blame to one formula (and one mathematician) that posting the image of a formerly obscure statistical formula (called a &#8220;copula&#8221;) is now considered good for a laugh.
</p>
<p><center><br />
<img src="http://www.win-vector.com/blog/wp-content/uploads/2009/03/copula.gif" alt="copula.gif" border="0" width="400"  /><br />
</p>
<caption>A copula formula.</caption>
<p></center></p>
<p>
However, the original mathematical paper being castigated (&#8220;On Default Correlation: A Copula Function Approach&#8221; by David X Li, Risk Metrics (2000)) is in fact good work.  What is wrong is not the formula but the over-reliance on the formula.  If we place all the blame on &#8220;copulas&#8221; we will be too ready to repeat the current disaster with some other &#8220;better&#8221; model.
</p>
<p>
We need to think more like Michael Lewis and use specific failures as miniature laboratories to learn larger lessons.  A great example is his write-up of the Iceland financial collapse ( <a href="http://www.vanityfair.com/politics/features/2009/04/iceland200904">Wall Street on the Tundra</a> by Michael Lewis, Vanity Fair, April 2009 ) which, if you read carefully, contains a general indictment of speculative greed and getting rich by pushing around bits of paper (instead pursing activities that create actual value).
</p>
<p>
So back to the copulas: what is to be learned (now at great expense) there?  I would like to work through some of the important points of Dr. Li&#8217;s paper and explain some of the painful points in our current lesson.  In my opinion none of the flaws are mathematical (or in the paper)- the flaws are all deep defects in logic and reason (and found in the later behavior of traders).
</p>
<p>
The main purpose of Dr. Li&#8217;s paper was to figure out how to price a newer and more complicated financial instrument (the credit default swap) in terms of older underlying instruments (mortgages).  In addition to developing the necessary mathematics the paper contains several clever ideas based on the logic of reasonable markets.  As the markets became very large and very unreasonable the logic no longer applied.  That is what went wrong.
</p>
<p>
Credit default swaps (in their simplest form) essentially started as insurance policies against mortgages defaulting.  Unfortunately, credit default swaps were unregulated financial instruments instead of regulated insurance policies.  Credit default swaps degenerated into &#8220;bets&#8221; (or derivative securities) when they were separated from the underlying mortgages.  You could, in essence, buy or sell insurance on your neighbor defaulting on their mortgage.
</p>
<p>
The legitimate use of credit default swaps would be to set up a market for insurance and re-insurance.  If you borrowed money to buy a house a bank might buy a credit default swap to partially insure against you defaulting on the loan.  However, the market went somewhat insane.  Since everything was measured in dollars and probabilities (instead of specific contracts and records) a bank that had a million dollars of exposure from lending you money (to buy your mansion) would end up buying insurance on your neighbor&#8217;s mansion (which they did not finance) from somebody with no really ability to pay-off in the event of default.  From a pure balance-sheet point of view the numbers &#8220;made sense&#8221; a bank with a million dollars of exposure brought the appropriate amount of insurance.  From a business point of view: they purchased insurance on the wrong property and purchased it from somebody they should not be doing business with.
</p>
<p>
So credit default swaps eventually made no sense as insurance policies.  How did they fare as financial instruments?  Even if credit default swaps made no sense for the institutions originating (creating) them there was a market trading them.  So, ignoring what they were: if you could buy them when they were cheap and sell them when they were expensive you could make money.  This is where Dr. Li&#8217;s paper comes in: he figured out how to estimate the underlying theoretical value of a credit default swap.  With this knowledge you would know when the market price for a credit default swap was cheap (the trading price would be below the theoretical price) or expensive (the trading price would be above the theoretical price).  Traders could make more money.
</p>
<p>
And this is where things went very very wrong.  With more profit there were more traders.  With more traders there was a larger market to accept credit default swaps.  Since there were no rules anybody could originate (create) them.  In particular there was no rule that said there could not be more credit default swaps than underlying mortgages.  And this is where the insanity of the market no longer matched the reasonable logic of Dr. Li&#8217;s original paper.
</p>
<p>
The idea of assigning a theoretical value to items using information from another market depends critically on two financial concepts.  The first one is well known and is called &#8220;price taker.&#8221;  The second one is more obscure and I will call it &#8220;information taker.&#8221;  Due to extreme scale both reasonable assumptions became false.
</p>
<p>
A &#8220;price taker&#8221; is a trader in the market that is small enough that the trader does not radically change prices.  This is the opposite of &#8220;price maker&#8221; who is a trader who&#8217;s activity is so great that they essentially drive prices.  The assumption was that the credit default market would be a &#8220;price taker&#8221; with respect to other markets.  The theory was that you could disassemble a credit default swap into some mortgages, some interest bearing annuities and some other pieces.  You could then get the prices for all of these components from other markets and know if the credit default swap was cheap or expensive relative to the current price of its constituent parts.  This works for a single credit default swap.  But what happens if you needed to take apart a larger number of them at once?  That might require acquiring more mortgages than actually exist.  Attempting to acquire or dump the components would have a huge price-making impact on all of the other markets.  The idea that the credit default swap should price at the current price of its components falls apart, the very attempt to dissemble them would re-price the other markets.  Even worse: the markets could &#8220;lock up&#8221; and stop trading (if for example you dumped so many mortgages into the markets that nobody wanted to buy any at any price).
</p>
<p>
What I call an &#8220;information taker&#8221; is a newer idea.  One of the clever steps in Dr. Li&#8217;s paper that the some of the unknown quantities needed by the theoretical model for credit default swaps could be estimated from the market pricing of mortgages.  For example: an estimate of future mortgage default rates is one component needed to correctly price credit default swaps.  One way to estimate future mortgage default rates is to learn a lot about actual mortgage holders, learn a lot about macro economics and try to predict future default rates in a number of plausible future scenarios.  This is expensive and it is by no means certain (since you really can not predict the future).  Another way to estimate future mortgage default rates is to examine the &#8220;credit spread&#8221; or difference in market pricing of mortgages as compared to less risky securities.  If these other markets are working correctly (or &#8220;in equilibrium&#8221;) you can infer the future default rates from the pricing.  This idea works, until too many people use it.  If everybody else in the market is performing expensive research on future default rates then: the pricing of mortgages (relative to other less risky assets) will necessarily give you the information needed to solve for your model&#8217;s unknowns.  However, once everybody is an &#8220;information taker&#8221; (using market pricing to try to estimate unmeasured fundamentals) the market is just one big &#8220;echo chamber&#8221; with no actual data being injected.  You can no longer correctly estimate parameters from the market because there are no informed players to steal from.  Even worse if those markets go out of equilibrium, lock up or stop trading you don&#8217;t even hear echoes- you become completely deaf.
</p>
<p>
These simple flaws in reasoning (in addition to bubble-driven greed) are behind the current global disaster.  We need to protect ourselves from all of these fundamental causes (which will occur again and again), not vilify some formerly obscure financial mathematics (which will never appear in the same skin twice).</p>


<p>Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
<li><a href='http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/' rel='bookmark' title='Permanent Link: A Quick Appreciation of the Sharpe Ratio'>A Quick Appreciation of the Sharpe Ratio</a></li>
<li><a href='http://www.win-vector.com/blog/2008/10/something-i-dont-get-about-business-and-bailouts/' rel='bookmark' title='Permanent Link: Something I don&#8217;t get about business and bailouts'>Something I don&#8217;t get about business and bailouts</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.win-vector.com/blog/2009/03/it-is-not-all-the-quants-fault/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Quick Appreciation of the Sharpe Ratio</title>
		<link>http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=a-quick-appreciation-of-the-sharpe-ratio</link>
		<comments>http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 03:15:07 +0000</pubDate>
		<dc:creator>John Mount</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Expository Writing]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Mathematical Bedside Reading]]></category>
		<category><![CDATA[Sharpe Ratio]]></category>

		<guid isPermaLink="false">http://www.win-vector.com/blog/?p=22</guid>
		<description><![CDATA[The current state of the global financial markets has gotten more people than usual worrying about the technical aspects of finance. One method for reasoning about investment returns and risk is a tool called the Sharpe Ratio. It is well worth reviewing this measure and seeing how, if used properly, it doesn&#8217;t favor any of [...]


Related posts:<ol><li><a href='http://www.win-vector.com/blog/2010/01/easy-portfolio-allocation/' rel='bookmark' title='Permanent Link: &#8220;Easy&#8221; Portfolio Allocation'>&#8220;Easy&#8221; Portfolio Allocation</a></li>
<li><a href='http://www.win-vector.com/blog/2009/10/what-is-the-gamblers-equivalent-of-amdahls-law/' rel='bookmark' title='Permanent Link: What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?'>What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?</a></li>
<li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The current state of the global financial markets has gotten more people than usual worrying about the technical aspects of finance.  One method for reasoning about investment returns and risk is a tool called the Sharpe Ratio.  It is well worth reviewing this measure and seeing how, if used properly, it doesn&#8217;t favor any of the mistakes that underly our current financial crisis.<span id="more-22"></span></p>
<p>The Sharpe ratio is a famous measure of &#8220;risk adjusted return&#8221; and is defined as &#8220;the ratio of the expected excess return from an investment divided by standard deviation of the excess return.&#8221;  It is most easily demonstrated by an example (which we work in pieces).</p>
<p>If an investment is expected to generate a profit of 15% in the next year and an insured bank account would generate 10% profit then the expected excess return invested is 15% &#8211; 10% = 5%.  A rational investor would never take a risky investment that did not have a positive excess return (else they would expect to make more money at a bank). &#8220;Expected&#8221; is a technical term which means the average return of the investment averaged over all possible outcomes (weighted by the odds of each outcome), we can explain this by working a couple of examples.</p>
<p>Consider investment &#8220;A&#8221; which is a generally good idea that returns a 20% profit in half the possible years and a 10% profit in the other half of the years.  Investment A has an expected return of 0.5*20% + 0.5*10% = 15%.  Investment &#8220;A&#8221; has 15% &#8211; 10% = 5% excess return.</p>
<p>Also consider another investment &#8220;B&#8221; which is a risky bet that returns 20% profit most years (around 95.8% of them) and goes bankrupt in the other years.  The expected return of investment &#8220;B&#8221; is 0.958*20% + 0.042*(-100%) = 14.96%, or essentially 15%.   Investment &#8220;B&#8221; has 15% &#8211; 10% = 5% excess return.</p>
<p>As we can see &#8220;expectation&#8221; alone can not really tell these two investments apart.  That is why the second component of the Sharpe ratio is something called the standard deviation.  The standard deviation is defined as the square-root of the squared deviations of the return from the target value of 15%.  What we do is measure for each possible outcome how far off the return is from the target of 15%, multiply this number by itself (called squaring it) and then take the square-root of the sum of all such values.  Again, this is best explained by an example.</p>
<p>Investment &#8220;A&#8221; has a standard deviation of:<br />
square-root(  0.5 * (20% &#8211; 15%)*(20% &#8211; 15%) +  0.5 * (10% &#8211; 15%)*(10% &#8211; 15%)  ) = 5%</p>
<p>And investment &#8220;B&#8221; has a standard deviation of:<br />
square-root( 0.958 *( 20% &#8211; 15%)*( 20% &#8211; 15%) + 0.042*(-100% &#8211; 15%)*(-100% &#8211; 15%) ) = 24%</p>
<p>Just like in the calculation of expectation we are taking every possible situation and summing (weighted by the likelihood) our value of interest (in this case the squared variation).</p>
<p>The standard deviation&#8217;s opinion is that investment &#8220;B&#8221; is about five times riskier than investment &#8220;A.&#8221;  And this is the grace of the Sharpe ratio: it says that investment &#8220;A&#8221;&#8216;s value is (15% &#8211; 10%)/5% =  1 and &#8220;B&#8221;&#8216;s value is (15% &#8211; 10%)/24% = 0.2.</p>
<p>An interesting feature of the Sharpe ratio is that, unlike Wall Street, it does not believe that leveraging increases profitability.  A common desperation move is to take an investment that has a moderate return and borrow money to simulate larger returns by having larger exposure.  For instance an investment that returns 15% can try to simulate a higher return by borrowing.   If for every $1,000 invested we borrow another $1,000 to invest (paying the risk rate of 10% for the money) one can show an apparent rate of return of ($2000*15% &#8211; $1000*10%)/$1000 or 20%.  However, this is not free money- the investor is taking on twice as much risk for only half as much more return.  In fact with sufficient leverage (three times, for times, thirty times) one can convert a safe investment into a risky investment that could even go bankrupt.  The Sharpe ratio (by design) is not fooled by this sort of manipulation.  Investing $1000 in investment A has the exact same Sharpe ratio as investing $1000 plus $1000 more borrowed at the risk-free rate (this is part of the cleverness of using excess returns instead of un-adjusted returns).</p>
<p>Unfortunately to use the Sharpe ratio you need good estimates of three things:</p>
<p>1) The expected return of the investment.</p>
<p>2) The risk-less available in the market (to compute excess).</p>
<p>3) The standard deviation of the investment.</p>
<p>All three of these facts are about the future, so we don&#8217;t really know any of them.  The historic returns of an investment are not the same thing as the expected returns in the future, interest rates can change and the standard deviation is especially hard to estimate.  However, if you have a model (or at least a theory) of what your investments are supposed to do then you can plug in estimates for these three quantities and use the Sharpe ratio to determine which investments really are best.</p>
<p>If you knew how investment &#8220;A&#8221; worked and could estimate that it returned 20% about half the time and 10% the other times you could estimate its Sharpe ratio as 1.  And if you knew investment &#8220;B&#8221; was a gamble that almost always paid off at 20% with a single rare event that causes bankruptcy you could estimate its Sharpe ratio as 0.2.  Even if your estimates were inaccurate (say you estimate investment &#8220;A&#8221;&#8216;s Sharpe ratio is 0.7 and investment &#8220;B&#8221;&#8216;s Sharpe ratio as 0.3) the indication is to stay away from investment &#8220;B.&#8221;</p>
<p>This is in stark contrast to the conclusion you would draw if you thought of these investments as a &#8220;black box&#8221; (like a fund of funds does) and looked only at their historic performance.  If you looked at around 5 years of historic performance of both investments you would (incorrectly) think the following:</p>
<p>Investment A looks kind of noisy, some years it returns 10% and some years it return 20%.  You would estimate (correctly) the return as averaging to 15% and you can even get a historic estimate of its standard deviation that is actually about right (5%)</p>
<p>Investment B looks like easy money.  With about 80% chance you would not have seen a bankruptcy, just 5 years of 20% returns.  You would mis-estimate the return as being 20% (all you have ever seen) and further mis-estimate the standard deviation as 0%.</p>
<p>Based on historic data alone you would fire the manager of investment &#8220;A&#8221;, give the manager of investment &#8220;B&#8221; a huge bonus and invest all of your money.  And a few years later you would go bankrupt.</p>
<p>What is going on is very well explained by Nassim Nicholas Taleb as &#8220;the turkey paradox.&#8221;  Domestic turkeys are all killed at about the exact same age (say 60 days).  For somebody that understands commercial poultry farming there is not any mystery or uncertainty about it.  60 days before you want to sell a turkey carcass you buy a turkey chick.  There is an inevitability and reverse causality- the desire for the turkey&#8217;s carcass funds and causes the turkey&#8217;s start of life 60 days earlier.  Now if the turkey is a statistical empiricist (perhaps with a PhD in machine learning) things look good.  The turkey sets up a model of each day having an unknown chance of being good or bad.  The turkey figures that each day&#8217;s outcome is an independent trial drawn from this single unknown probability.  The turkey collects evidence: every day it gets fed.  Each day is more evidence that all days will be good.  And then on day 60 the turkey gets a nasty surprise.  The turkey&#8217;s life was a bad investment from day one, all of the &#8220;evidence&#8221; the turkey collects along the way was irrelevant because the model was wrong.  And the model was wrong because the turkey guessed at the model instead of investigating the nature of poultry farming.</p>
<p>Much is the same in many investments.  There are investments that look like investment &#8220;B&#8221; when you open the hood.  Many of them involve writing &#8220;out of the money options&#8221; and &#8220;default swaps.&#8221;  These are essentially selling insurance on events that nobody thinks are likely.  Selling insurance that usually is not used is profitable, until the insurance gets used.   This is why insurance companies (if they are ethical) don&#8217;t treat the entirety of collected payments as profit- but as a stockpile that must be kept to pay the claims that will inevitably some day come true.</p>
<p>It is important to point out the Sharpe ratio will give you incorrect results if you plug bad estimates into it.  Overall the Sharpe ratio prefers good investments and diversification but it can be led astray.  In fact that is the whole point: no amount of smart math will undo the inevitable consequences of wrong models that are used because &#8220;you need something you can solve&#8221; (like the turkey) or &#8220;everybody else is getting rich using them&#8221; (like investment &#8220;B&#8221;).</p>


<p>Related posts:<ol><li><a href='http://www.win-vector.com/blog/2010/01/easy-portfolio-allocation/' rel='bookmark' title='Permanent Link: &#8220;Easy&#8221; Portfolio Allocation'>&#8220;Easy&#8221; Portfolio Allocation</a></li>
<li><a href='http://www.win-vector.com/blog/2009/10/what-is-the-gamblers-equivalent-of-amdahls-law/' rel='bookmark' title='Permanent Link: What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?'>What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?</a></li>
<li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.win-vector.com/blog/2008/09/a-quick-appreciation-of-the-sharpe-ratio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Betting Best-Of Series</title>
		<link>http://www.win-vector.com/blog/2008/05/betting-best-of-series/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=betting-best-of-series</link>
		<comments>http://www.win-vector.com/blog/2008/05/betting-best-of-series/#comments</comments>
		<pubDate>Wed, 28 May 2008 01:23:04 +0000</pubDate>
		<dc:creator>John Mount</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Expository Writing]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Quantitative Finance]]></category>
		<category><![CDATA[Dynamic Programming]]></category>
		<category><![CDATA[Technical Papers]]></category>

		<guid isPermaLink="false">http://www.win-vector.com/blog/?p=18</guid>
		<description><![CDATA[Betting Best of Series is a new expository paper describing the mathematics involved in betting on something like the United States&#8217; Major League Baseball World Series. It isn&#8217;t so much about baseball as about demonstrating some of the really great ideas from mathematical finance in a simplified setting. This sort analysis is the &#8220;secret sauce&#8221; [...]


Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/10/what-is-the-gamblers-equivalent-of-amdahls-law/' rel='bookmark' title='Permanent Link: What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?'>What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?</a></li>
<li><a href='http://www.win-vector.com/blog/2007/10/paper-on-stock-trading/' rel='bookmark' title='Permanent Link: Paper on stock trading'>Paper on stock trading</a></li>
<li><a href='http://www.win-vector.com/blog/2007/06/new-paper/' rel='bookmark' title='Permanent Link: New Paper'>New Paper</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.win-vector.com/dfiles/BestOf.pdf">Betting Best of Series</a> is a new expository paper describing the mathematics involved in betting on something like the United States&#8217; Major League Baseball World Series.  It isn&#8217;t so much about baseball as about demonstrating some of the really great ideas from mathematical finance in a simplified setting.  This sort analysis is the &#8220;secret sauce&#8221; in a lot of financial models and I trying to share the thrilling feeling of working with these techniques in an elementary essay (with diagrams).<span id="more-18"></span></p>
<p>Also in (less legible) HTML:</p>
<h1 align="center">Betting Best-Of Series</h1>
<p align="center"><strong>John Mount<a name="tex2html1" href="#foot16" id="tex2html1"><sup>1</sup></a></strong></p>
<p></p>
<p align="center"><b>Date:</b> May 27, 2008</p>
<hr />
<h1><a name="SECTION00010000000000000000" id="SECTION00010000000000000000">Introduction</a></h1>
<p>We use the United States&#8217; Major League Baseball World Series to demonstrate some of the &#8220;arbitrage arguments&#8221;<a name="tex2html2" href="#foot21" id="tex2html2"><sup>2</sup></a>used in mathematical finance. This problem is a classic finance puzzle question and is an interesting introduction to some exciting techniques.</p>
<p>&#8220;Arbitrage&#8221; is the simultaneous buying and selling of a commodity, usually in multiple markets, that returns a risk-free profit. An example would be finding a market where apples are selling for $1 and another where they are selling for $2, and then simultaneously executing a purchase order in the cheap market and a sales order in the expensive market (assuming no significant shipping risks or costs). Typically &#8220;arbitrage opportunities&#8221; are too much to hope for and to make a profit you must add value, loan money, hold inventory or take on risk. This is just the mathematical finance way of saying &#8220;there is no free lunch,&#8221; but a number of surprising facts about markets can be proven using this principle.</p>
<h1><a name="SECTION00020000000000000000" id="SECTION00020000000000000000">The Problem</a></h1>
<div align="center"><a name="fig:wsgames" id="fig:wsgames"></a><a name="27"></a></p>
<table>
<caption align="bottom"><strong>Figure 1:</strong> World Series Tree (Win over Loss)</caption>
<tr>
<td>
<div align="center"><img width="400" height="510" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./WorldSeries1.png" alt="Image WorldSeries1"/></div>
</td>
</tr>
</table>
</div>
<p>Consider a &#8220;first to win <img width="15" height="20" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg1.png" alt="$ k$"/> &#8221; contest like the United States&#8217; Major League Baseball World Series. The World Series is a &#8220;first to win four&#8221; contest (sometimes called &#8220;best of seven&#8221;) where a number of games are played between two teams and the first team to win four games is declared the series winner. Ignoring the possibility of ties this process can take from four to seven games. We can (as in Figure&nbsp;<a href="#fig:wsgames">1</a>) lay out all of the possibilities in to a picture that moves from left to right and then moves up when the first team wins and down when the second team wins.</p>
<p>Any sequence of games is represented by a path through this diagram (starting at the left) that reaches a node with no exit. At each node we have marked in the wins for each team (Team One on top, Team Two on the bottom). The nodes where one team has won four games are where the series ends.</p>
<p>The &#8220;arbitrage question&#8221; is:</p>
<blockquote><p>If you had access to a bookie who was willing to take an even-payoff bet (on either side) in each game of the World Series, can you design a schedule of bets on games that simulates an even-payoff one dollar bet on the outcome of the entire World Series?</p></blockquote>
<p>That is: you wish to make a bet that pays you $1 if your team wins the World Series and costs you $1 if your team is defeated. You can not find anybody to take such a bet- but you have found a bookie who makes the incredibly generous offer of taking bets (at even pay-off) on each and every game in the series. Can you, without any additional risk, simulate a World Series bet by making a series of per-game bets with this bookie?</p>
<h1><a name="SECTION00030000000000000000" id="SECTION00030000000000000000">The Answer</a></h1>
<p>The answer turns out to be that you can simulate a world-series bet. The reason for hope is that both types of bets (the even-payoff bets on games and an even-payoff bet on the whole series) are expressing the same underlying belief: that both teams have an exactly equal chance of winning. The teams may or may not have the equal chances of winning- but offering to take bets on both sides at equal pay-off is equivalent expressing just such a belief.</p>
<p>The principle that the probability you are willing to take bets at expresses your subjective probabilities is a principle goes back to Bruno de Finetti and is the most basic &#8220;arbitrage style&#8221; argument. The principle is simple but it is useful warm-up to think about. Under the assumption that you are &#8220;rational&#8221; (in the economic sense, which just means you are not giving money away without a reason) and if <img width="24" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg2.png" alt="$ p_S$"/> denotes your personal estimate of the probability of your team winning then if you are willing to bet $1 that your team wins at even payoff (meaning you collect $1 if your team wins pay $1 if your team loses) then for this bet to make economic sense you must have:</p>
<div align="center"><!-- MATH<br />
 \begin{equation*}<br />
p_S ( +\$1 ) + (1-p_S) (- \$1) \ge 0<br />
\end{equation*}<br />
 --></p>
<table cellpadding="0" width="100%" align="center">
<tr valign="middle">
<td nowrap align="center"><img width="244" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg3.png" alt="$\displaystyle p_S ( +\$1 ) + (1-p_S) (- \$1) \ge 0$"/></td>
<td nowrap width="10" align="right">&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
</div>
<p><br clear="all"/><br />
which means <!-- MATH<br />
 $p_S\ge \frac{1}{2}$<br />
 --><br />
<img width="60" height="40" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg4.png" alt="$ p_S\ge \frac{1}{2}$"/> .</p>
<p>Similarly if you are willing (for purely economic reasons) to take the other side of the bet at the same even-payoff bet on the other side (reversing the rolls of winning and losing) then it must be true that <!-- MATH<br />
 $p_S \le \frac{1}{2}$<br />
 --><br />
<img width="60" height="40" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg5.png" alt="$ p_S \le \frac{1}{2}$"/> . We then have our conclusion: from an economic point of view you should be willing to take either side of a fair-payoff bet only if your estimate of the probability of winning is <img width="32" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg6.png" alt="$ 1/2$"/> .</p>
<div align="center"><a name="fig:wspartial" id="fig:wspartial"></a><a name="44"></a></p>
<table>
<caption align="bottom"><strong>Figure 2:</strong> World Series With Some Values Filled In</caption>
<tr>
<td>
<div align="center"><img width="400" height="510" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./WorldSeries2.png" alt="Image WorldSeries2"/></div>
</td>
</tr>
</table>
</div>
<p>We now return to the World Series diagram. If we bet on individual games (instead of making one bet on the whole series) then at each node in the diagram we expect to have some sort of net winnings or net losses. For example at each node where our team has won four games we should be holding <img width="23" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg7.png" alt="$ \$1$"/> , so we will label these nodes with <img width="28" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg8.png" alt="$ +1$"/> . Similarly at each node where the opposing team has won for games we expect to have lost exactly <img width="23" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg7.png" alt="$ \$1$"/> so we label those nodes with <img width="29" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg9.png" alt="$ -1$"/> . Our task is to figure out the amount bet at each node and our net holdings at each node. If we can find a schedule of bet amounts that leads to the correct outcomes at the end of the world series and starts with an initial net holdings of $0 then we have solved the problem.</p>
<p>If we look at Figure&nbsp;<a href="#fig:wspartial">2</a> we see there the node corresponding to each team having won 3 games points to two nodes we know the values of (the World Series ending with either team the winner). We can use the fact that this node points only to nodes with known net holdings to figure out both the bet that must be made at this node and the net holdings this node should have at this point in World Series.</p>
<p>Let <img width="15" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg10.png" alt="$ x$"/> be the (unknown) net holdings we have at this node and <img width="14" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg11.png" alt="$ y$"/> be the (unknown) amount we bet then to complete the World Series bet we must have the following:</p>
<p></p>
<div align="center"><!-- MATH<br />
 \begin{eqnarray*}<br />
x + y &#038; = &#038; 1 \\<br />
 x - y &#038; = &#038; -1<br />
\end{eqnarray*}<br />
 --></p>
<table cellpadding="0" align="center" width="100%">
<tr valign="middle">
<td nowrap align="right"><img width="48" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg12.png" alt="$\displaystyle x + y$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg13.png" alt="$\displaystyle =$"/></td>
<td align="left" nowrap><img width="14" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg14.png" alt="$\displaystyle 1$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="48" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg15.png" alt="$\displaystyle x - y$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg13.png" alt="$\displaystyle =$"/></td>
<td align="left" nowrap><img width="29" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg16.png" alt="$\displaystyle -1$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
</table>
</div>
<p><br clear="all"/></p>
<p>This is enough to notice that <img width="15" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg10.png" alt="$ x$"/> (your holdings) must be the average of the two outcomes pointed to and <img width="14" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg11.png" alt="$ y$"/> (your bet) must be one half of the difference of the two outcomes. So the &#8220;each team has won three games&#8221; node (near the very right end of the diagram) should have a net holding of <img width="59" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg17.png" alt="$ x = \$0$"/> and we should bet <img width="58" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg18.png" alt="$ y = \$1$"/> . Filling in this node with the net holdings ($0) now means that there are other nodes that point only to nodes with filled-in net holdings. We can, in fact, repeat this process of filling in each node with unknown net holdings with the average of the two known nodes it points to until we complete the diagram as in Figure&nbsp;<a href="#fig:wsfull">3</a>.</p>
<div align="center"><a name="fig:wsfull" id="fig:wsfull"></a><a name="55"></a></p>
<table>
<caption align="bottom"><strong>Figure 3:</strong> World Series All Values Filled In</caption>
<tr>
<td>
<div align="center"><img width="400" height="510" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./WorldSeries3.png" alt="Image WorldSeries3"/></div>
</td>
</tr>
</table>
</div>
<p>In the completed figure each node is filled in with the net holdings required to implement our betting schedule. We can see that a diagram like this can always be filled out to completion by looking at the diagram as having layers like an onion and noticing that we start with the right most nodes filled in (they are the nodes where the world series ends). It is obvious that we can fill out every node in the layer of nodes just inside the outer layer if we start at the right most such node and work back. Every layer can be completed one after another until we get to the inner most layer which is just the starting node. To implement the betting strategy, we keep track of where we are in the diagram and always bet one half of the difference between the net holdings of the two nodes pointed to by the node we are at.</p>
<p>If the first node of the diagram was marked with a value other than zero it would mean that the world-series has a net bias for the first team or the second. Since the rules are symmetric this would be a nonsense conclusion, so we can be sure that all of the even-score nodes must be valued at zero.</p>
<p>The filling in of blanks using values ahead of them (from the future) is the heart of the Binomial Pricing Theory for options is based on a very deep idea called Dynamic Programming. The idea is that you may not know which future you will experience- but you may know the valuation of every possible future. It is an amazing fact that even without introducing probabilities or probability estimates of which future you will experience just knowing the value of every possible future is enough to compute the value of a bet in the present time. In our example: you may not know ahead of time the final scores of the world series, but you do know value of a world series bet for each possible ending score.</p>
<h1><a name="SECTION00040000000000000000" id="SECTION00040000000000000000">What is the analogy?</a></h1>
<p>From a finance or betting point of view the problem is solved- we have procedures for building the betting schedule and we have the schedule itself. From a mathematician&#8217;s point of view we have only just started- we have some procedures and relations but what are they an analogy of?</p>
<p>Naively one might think that they should bet around one fourth of their desired outcome in each game to simulate a best of four series. However to simulate a total World Series bet of <img width="23" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg7.png" alt="$ \$1$"/> we use an initial bet of <!-- MATH<br />
 $\$5/16 = \$0.3125$<br />
 --><br />
<img width="138" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg19.png" alt="$ \$5/16 = \$0.3125$"/> in our schedule. This is almost a third of our desired total bet. This gets us wondering: what is the general form of this first bet?</p>
<p>Let <!-- MATH<br />
 $\text{bet}(k)$<br />
 --><br />
bet<img width="29" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg20.png" alt="$ (k)$"/> denote the amount of the first bet in the simulation of a &#8220;best of <img width="15" height="20" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg1.png" alt="$ k$"/> &#8221; bet. If we compute <!-- MATH<br />
 $\text{bet}(k)$<br />
 --><br />
bet<img width="29" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg20.png" alt="$ (k)$"/> (by constructing betting schedules as above) for many values of <img width="15" height="20" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg1.png" alt="$ k$"/> we see that <!-- MATH<br />
 $\text{bet}(k)$<br />
 --><br />
bet<img width="29" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg20.png" alt="$ (k)$"/> seems to shrink slower than <img width="39" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg21.png" alt="$ 1/k.$"/> In fact it seems to shrink at a rate of around <!-- MATH<br />
 $1/\sqrt{k}$<br />
 --><br />
<img width="49" height="44" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg22.png" alt="$ 1/\sqrt{k}$"/> . Even more intriguing if you plot <!-- MATH<br />
 $k/(\text{bet}(k)*\text{bet}(k))$<br />
 --><br />
<img width="31" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg23.png" alt="$ k/($"/>bet<img width="39" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg24.png" alt="$ (k)*$"/>bet<img width="37" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg25.png" alt="$ (k))$"/> it converges (very slowly) to <!-- MATH<br />
 $3.14 \cdots$<br />
 --><br />
<img width="66" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg26.png" alt="$ 3.14 \cdots$"/> . We can conjecture that for very large <img width="15" height="20" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg1.png" alt="$ k$"/> the initial bet is: <!-- MATH<br />
 $1/\sqrt{\pi k}$<br />
 --><br />
<img width="61" height="44" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg27.png" alt="$ 1/\sqrt{\pi k}$"/> where <img width="16" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg28.png" alt="$ \pi$"/> is the famous ratio of the ratio of the length of the circumference of a circle to the the length of the diameter of the same circle.</p>
<p>Now <!-- MATH<br />
 $1/\sqrt{\pi k}$<br />
 --><br />
<img width="61" height="44" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg27.png" alt="$ 1/\sqrt{\pi k}$"/> is much larger that <img width="33" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg29.png" alt="$ 1/k$"/> (as <img width="15" height="20" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg1.png" alt="$ k$"/> gets large). So the scheme says to bet a fairly large amount of your budget on the first game, and that winning the first bet is worth a bit more than you would expect (it takes you more than one <img width="15" height="20" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg1.png" alt="$ k$"/> th of the way to victory).</p>
<div align="center"><a name="fig:wsWeightedPaths" id="fig:wsWeightedPaths"></a><a name="71"></a></p>
<table>
<caption align="bottom"><strong>Figure 4:</strong> Weighted Paths</caption>
<tr>
<td>
<div align="center"><img width="400" height="510" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./WorldSeries4.png" alt="Image WorldSeries4"/></div>
</td>
</tr>
</table>
</div>
<p>What is going on? We can again apply an arbitrage or de Finetti style argument and say since the whole game was &#8220;fair&#8221; with expected pay-off zero then we can relate probabilities and payoffs. The net holdings at each node encode how much of an advantage you have at the node (or how much you should pay to take over from another gambler at this point). If we let <img width="21" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg30.png" alt="$ p_1$"/> denote the probability of going on to win the World Series bet after winning the first bet then we must have:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
p_1 (\$1) + (1-p_1) (-\$1) = \text{bet}(k) .<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="210" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg31.png" alt="$\displaystyle p_1 (\$1) + (1-p_1) (-\$1) =$"/>&nbsp; &nbsp;bet<img width="34" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg32.png" alt="$\displaystyle (k) . $"/></div>
<p>Or <!-- MATH<br />
 $p_1 = (\text{bet}(k) + 1)/2$<br />
 --><br />
<img width="54" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg33.png" alt="$ p_1 = ($"/>bet<img width="88" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg34.png" alt="$ (k) + 1)/2$"/> . For the real World Series we had <!-- MATH<br />
 $\text{bet}(4)=5/16$<br />
 --><br />
bet<img width="91" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg35.png" alt="$ (4)=5/16$"/> so <!-- MATH<br />
 $p_1 = 21/32$<br />
 --><br />
<img width="93" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg36.png" alt="$ p_1 = 21/32$"/> . This means we can read-off from the valuation tree that the probability of winning the World Series (for perfectly equally matched teams) rise from <img width="32" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg6.png" alt="$ 1/2$"/> to <img width="51" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg37.png" alt="$ 21/32$"/> after you win the first game.<a name="tex2html7" href="#foot77" id="tex2html7"><sup>3</sup></a> This can be confirmed from Figure&nbsp;<a href="#fig:wsfull">3</a>. It is easy to confirm that a <img width="51" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg37.png" alt="$ 21/32$"/> portion of all paths the node where Team One has one the first game end with Team One winning the whole World Series (each path must be weighted by its probability which are <!-- MATH<br />
 $2^{-path<br />
length}$<br />
 --><br />
<img width="90" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg38.png" alt="$ 2^{-path length}$"/> ). Instead of computing the bets we could have computed the probability of going on to win the World Series at each node<a name="tex2html8" href="#foot80" id="tex2html8"><sup>4</sup></a> (and then used the above equivalence principle to read off the required bets).</p>
<p>We can create a new diagram where we start at the node where our team has won the first game and we label all the non-ending nodes with the number of paths that reach the node. For example the two nodes immediately after start can be reach one way each and the next three nodes (&#8220;3 games to 0&#8221;, &#8220;2 games to 1&#8221; and &#8220;1 games to 2&#8221;) can be reached 1,2 and 1 ways respectively. It is a clever trick to notice that the easiest way to count the number of paths to a node is to just add the number of ways found on the previous nodes that point to the our target node. This clever way of counting paths is to use weighted paths (inspired by something called Pascal&#8217;s Triangle). Figure&nbsp;<a href="#fig:wsWeightedPaths">4</a> shows a few columns of a weighted path diagram (thought he ending nodes are re-written as the sum of the paths reaching them where every path is divided by <!-- MATH<br />
 $2^{-\text{path length}}$<br />
 --><br />
<img width="93" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg39.png" alt="$ 2^{-\text{path length}}$"/> which is the probability of following such a path).</p>
<p>The entries of weighted path diagram are identified by how many columns out from the start node they are and how many steps from one side of the row they are. Both identifiers start at zero so the starting node is denoted as <!-- MATH<br />
 ${0 \choose 0}$<br />
 --><br />
<img width="29" height="42" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg40.png" alt="$ {0 \choose 0}$"/> the two nodes just after them are denoted <!-- MATH<br />
 ${1 \choose 0}$<br />
 --><br />
<img width="29" height="42" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg41.png" alt="$ {1 \choose 0}$"/> and <!-- MATH<br />
 ${1 \choose 1}$<br />
 --><br />
<img width="29" height="42" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg42.png" alt="$ {1 \choose 1}$"/> . The three nodes just after these are denoted <!-- MATH<br />
 ${2 \choose 0}$<br />
 --><br />
<img width="29" height="42" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg43.png" alt="$ {2 \choose 0}$"/> , <!-- MATH<br />
 ${2 \choose 1}$<br />
 --><br />
<img width="29" height="42" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg44.png" alt="$ {2 \choose 1}$"/> , <!-- MATH<br />
 ${2 \choose 2}$<br />
 --><br />
<img width="29" height="42" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg45.png" alt="$ {2 \choose 2}$"/> and are (as we said before) equal to 1,2 and 1 respectively. These entries are called &#8220;binomial coefficients&#8221; and the rules for computing them (for integers <img width="31" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg46.png" alt="$ a,b$"/> ) are as follows:</p>
<div align="center"><!-- MATH<br />
 \begin{eqnarray*}<br />
{a \choose b} &#038; = &#038; 0 \;\text{if $a&lt;0$\  or $b&lt;0$\  or $b>a$} \\<br />
{a \choose 0} &#038; = &#038; 1 \;\text{if $a>=0$} \\<br />
{a \choose a} &#038; = &#038; 1 \;\text{if $a>=0$} \\<br />
{a \choose b} &#038; = &#038; {a-1 \choose b-1} + {a-1 \choose b} \;\text{otherwise.}<br />
\end{eqnarray*}<br />
 &#8211;></p>
<table cellpadding="0" align="center" width="100%">
<tr valign="middle">
<td nowrap align="right"><img width="42" height="64" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg47.png" alt="$\displaystyle {a \choose b}$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg13.png" alt="$\displaystyle =$"/></td>
<td align="left" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg48.png" alt="$\displaystyle 0 \;$"/>if <img width="49" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg49.png" alt="$ a&lt;0$"/> or <img width="47" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg50.png" alt="$ b&lt;0$"/> or <img width="47" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg51.png" alt="$ b&gt;a$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="42" height="64" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg52.png" alt="$\displaystyle {a \choose 0}$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg13.png" alt="$\displaystyle =$"/></td>
<td align="left" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg53.png" alt="$\displaystyle 1 \;$"/>if <img width="63" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg54.png" alt="$ a&gt;=0$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="42" height="64" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg55.png" alt="$\displaystyle {a \choose a}$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg13.png" alt="$\displaystyle =$"/></td>
<td align="left" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg53.png" alt="$\displaystyle 1 \;$"/>if <img width="63" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg54.png" alt="$ a&gt;=0$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="42" height="64" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg47.png" alt="$\displaystyle {a \choose b}$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg13.png" alt="$\displaystyle =$"/></td>
<td align="left" nowrap><img width="174" height="64" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg56.png" alt="$\displaystyle {a-1 \choose b-1} + {a-1 \choose b} \;$"/>otherwise.</td>
<td width="10" align="right">&nbsp;</td>
</tr>
</table>
</div>
<p><br clear="all"/></p>
<p>From our diagram we see that the probability of winning the World Series bet is a diagonal sum across Pascal&#8217;s Triangle (weighted by powers of 2). To somebody trained in combinatorics it is obvious<a name="tex2html9" href="#foot101" id="tex2html9"><sup>5</sup></a> that a sum like this must itself be a single binomial coefficient. A quick trip to &#8220;The On-Line Encyclopedia of Integer Sequences&#8221; is enough to identify the solution (Encyclopedia sequence &#8220;A001700&#8221;) and we can get an exact form for initial bet:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
\text{bet}(k) =  { 2 k - 3 \choose k - 1} 2^{-(2 n - 3)} .<br />
\end{displaymath}<br />
 --></p>
<div align="center">&nbsp; &nbsp;bet<img width="204" height="64" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg57.png" alt="$\displaystyle (k) = { 2 k - 3 \choose k - 1} 2^{-(2 n - 3)} . $"/></div>
<p>A lot is known about Binomial coefficients. In fact by a formal called &#8220;Stirling&#8217;s approximation&#8221; we know</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
{ 2 k - 3 \choose k - 1} 2^{-(2 n - 3)} \approx \frac{1}{\sqrt{\pi k}}<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="215" height="64" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg58.png" alt="$\displaystyle { 2 k - 3 \choose k - 1} 2^{-(2 n - 3)} \approx \frac{1}{\sqrt{\pi k}} $"/></div>
<p>as observed.</p>
<h1><a name="SECTION00050000000000000000" id="SECTION00050000000000000000">Relations</a></h1>
<p>de Finetti used this style of reasoning to provide a foundation for the basic theory of probability. Probability theory has always been somewhat problematic for mathematicians in that it has &#8220;content&#8221; or &#8220;an interpretation&#8221; whereas the power of modern mathematics comes from a more axiomatic or content-free way of thinking. The issue is if you are defining the meaning or interpretation of something like probability how do you check or demonstrate that you have the correct meaning without referring to some other pre-existing interpretation? A foundational or first interpretation has trouble looking for prior definitions to show equivalence to.[<a href="#Shafer:2002p1513">6</a>]</p>
<p>The arbitrage-free arguments and the binomial arguments in particular are the basis of much of mathematical finance and are the basis for a number of Nobel Prizes in Economics including the Black-Scholes-Merton Option Pricing Model[<a href="#Black:1973p1502">2</a>] and the Binomial Option Pricing Model.[<a href="#Cox:1979p1505">5</a>]</p>
<p><img width="16" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/betimg28.png" alt="$ \pi$"/> (the ratio of the circumference of a circle to its diameter) is one of the most famous constants in mathematics. Pascal&#8217;s Triangle is one of the oldest and most studied diagrams in mathematics with roots all the way back into ancient China.[<a href="#OstermanCoulter:2003p1034">4</a>] It is actually remarkable how much Zhu Shijie 1303 diagram: <img width="200" height="312" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./Yanghui_triangle.png" alt="Image Yanghui_triangle"/> looks like our modern version of Pascal&#8217;s Triangle (though they are separated by about 350 years, source Wikipedia): <img width="200" height="102" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./Triangle.png" alt="Image Triangle"/>. The two diagram differ only in the notation used to write numbers and both start by filling in two diagonals of ones and all other numbers are the sums of the two numbers nearest and above them.</p>
<p>The arguments that replace paths with counts are a particular example of a technique called &#8220;Dynamic Programming&#8221; invented by Richard Bellman for mathematical optimization and now one of the core concepts of algorithm design.[<a href="#dynamicProgramming">1</a>]</p>
<p>The idea of using a set of unknown futures that each have a known value is the key idea in solving a number of hard problems in probability and in optimization in the face of uncertainty. One of the the most famous of these problems is the &#8220;two armed bandit&#8221; where one must decide how to split ones bets between two slot machines that are thought to pay-off at different rates.[<a href="#Chernoff:1959p1444">3</a>]</p>
<p>For the two armed bandit problem the concern is how long to experiment with both machines when one machine seems to be paying more. The correct solution depends on seeing that how certain you need to be on the difference in machine vales (which in turn drives how long you experiment on both machines). This is a function of how long you intend to use the information. If you intend to play for a long time you want a long initial research phase to produce a very high confidence ranking of the machines; if you do not intend to play for long you want to switch to the machine you suspect is better sooner and on less evidence. Of course &#8220;slot machines&#8221; is just a toy-problem standing in for uncertain investments, research spending or even spending on different only advertising phrases.</p>
<h1><a name="SECTION00060000000000000000" id="SECTION00060000000000000000">Conclusions</a></h1>
<p>The finance &#8220;no arbitrage&#8221; principle is actually a very powerful mathematical tool. It is equivalent to but somewhat more graceful than introducing probabilities when solving some combinatorial problems. In this setting it is equivalent to de Finetti&#8217;s principle and converting between probabilities and net holdings is very easy.</p>
<h2><a name="SECTION00070000000000000000" id="SECTION00070000000000000000">Bibliography</a></h2>
<dl compact>
<dt><a name="dynamicProgramming" id="dynamicProgramming">1</a></dt>
<dd>B<small>ELLMAN,</small> R.<br />
<em>Dynamic Programming</em>.<br />
Dover Publications, 2003.</dd>
<dt><a name="Black:1973p1502" id="Black:1973p1502">2</a></dt>
<dd>B<small>LACK,</small> F., <small>AND</small> S<small>CHOLES,</small> M.<br />
The pricing of options and corporate liabilities.<br />
<em>The Journal of Political Economy 81</em>, 3 (Jun 1973), 637-654.</dd>
<dt><a name="Chernoff:1959p1444" id="Chernoff:1959p1444">3</a></dt>
<dd>C<small>HERNOFF,</small> H.<br />
Sequential design of experiments.<br />
<em>Ann. Math. Statist. 30</em>, 3 (Feb 1959), 755-770.</dd>
<dt><a name="OstermanCoulter:2003p1034" id="OstermanCoulter:2003p1034">4</a></dt>
<dd>C<small>OULTER,</small> L.&nbsp;O.<br />
What is mathematics? toward a global view.<br />
17.</dd>
<dt><a name="Cox:1979p1505" id="Cox:1979p1505">5</a></dt>
<dd>C<small>OX,</small> J.&nbsp;C., R<small>OSS,</small> S.&nbsp;A., <small>AND</small> R<small>UBINSTEIN,</small> M.<br />
Option pricing: A simplified approach.<br />
<em>Journal of Financial Economics</em> (Sep 1979), 39.</dd>
<dt><a name="Shafer:2002p1513" id="Shafer:2002p1513">6</a></dt>
<dd>S<small>HAFER,</small> G., G<small>ILLETT,</small> P.&nbsp;R., <small>AND</small> S<small>CHERL,</small> R.&nbsp;B.<br />
A new understanding of subjective probability and its generalization to lower and upper prevision.<br />
<em>Game-Theoretic Probability Project</em> (Oct 2002), 62.</dd>
</dl>
<p></p>
<hr />
<h4>Footnotes</h4>
<dl>
<dt><a name="foot16" id="foot16">&#8230; Mount</a><a href="#tex2html1"><sup>1</sup></a></dt>
<dd>http://www.win-vector.com/</dd>
<dt><a name="foot21" id="foot21">&#8230; arguments&#8221;</a><a href="#tex2html2"><sup>2</sup></a></dt>
<dd>More pedantically we are using the principle of &#8220;no arbitrage&#8221; or &#8220;arbitrage free&#8221; argument, but the name is traditional.</dd>
<dt><a name="foot77" id="foot77">&#8230; game.</a><a href="#tex2html7"><sup>3</sup></a></dt>
<dd>Again, this if for the unrealistic situation of perfectly matched teams. For teams that have uneven probability the series strongly amplifies the better team&#8217;s chance of winning (which is one of the series intents). Also a better could update his subjective probability based on the first outcome which also changes things.</dd>
<dt><a name="foot80" id="foot80">&#8230; node</a><a href="#tex2html8"><sup>4</sup></a></dt>
<dd>This calculation is in essence summing end outcomes across all possible paths weighted by how likely each path is. There are many possible paths, but the calculation can be performed quite efficiently.</dd>
<dt><a name="foot101" id="foot101">&#8230; obvious</a><a href="#tex2html9"><sup>5</sup></a></dt>
<dd>&#8220;Obvious&#8221; is actually a special term in mathematics. To illustrate what it means we repeat a story. A mathematician was giving a lecture and stated that the point just shown was obvious. A student asked if it was really obvious. The mathematician stopped the lecture and paused to think. The mathematician thought some more, and eventually walked out of the room. Forty minutes later the mathematician returned to the lecture hall and informed the student that the last point was indeed obvious.</dd>
</dl>


<p>Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/10/what-is-the-gamblers-equivalent-of-amdahls-law/' rel='bookmark' title='Permanent Link: What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?'>What is the gambler&#8217;s equivalent of Amdahl&#8217;s Law?</a></li>
<li><a href='http://www.win-vector.com/blog/2007/10/paper-on-stock-trading/' rel='bookmark' title='Permanent Link: Paper on stock trading'>Paper on stock trading</a></li>
<li><a href='http://www.win-vector.com/blog/2007/06/new-paper/' rel='bookmark' title='Permanent Link: New Paper'>New Paper</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.win-vector.com/blog/2008/05/betting-best-of-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Search Advertising a Market for Lemons?</title>
		<link>http://www.win-vector.com/blog/2008/05/is-search-advertising-a-market-for-lemons/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=is-search-advertising-a-market-for-lemons</link>
		<comments>http://www.win-vector.com/blog/2008/05/is-search-advertising-a-market-for-lemons/#comments</comments>
		<pubDate>Tue, 13 May 2008 16:29:59 +0000</pubDate>
		<dc:creator>John Mount</dc:creator>
				<category><![CDATA[Finance]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Market for Lemons]]></category>
		<category><![CDATA[Online Advertising]]></category>

		<guid isPermaLink="false">http://www.win-vector.com/blog/?p=17</guid>
		<description><![CDATA[author: John Mount, 5-13-2008 Anand Rajaraman recently wrote a very thought-provoking entry on his Datawocky blog. He asks “Is Search Advertising a Giffen Good?” As he explains a Giffen Good is a sort of economic doomsday machine that some segment of consumers are forced to buy more of an inferior good as the price of [...]


Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/07/should-your-mom-use-google-search/' rel='bookmark' title='Permanent Link: Should your mom use Google search?'>Should your mom use Google search?</a></li>
<li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
<li><a href='http://www.win-vector.com/blog/2008/06/how-market-designs-set-prices/' rel='bookmark' title='Permanent Link: How Market Designs Set Prices'>How Market Designs Set Prices</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>author: John Mount, 5-13-2008</p>
<p>Anand Rajaraman recently wrote <a href="http://anand.typepad.com/datawocky/2008/04/is-search-adver.html">a very thought-provoking entry</a> on his Datawocky blog.  He asks “Is Search Advertising a Giffen Good?”   As he explains a Giffen Good is a sort of economic doomsday machine that some segment of consumers are forced to buy more of an inferior good as the price of the inferior good goes up.  His article is well written are really invites one to think about the issue.  Anand’s question made me thing about a number of issues (which I will outline here) and I will leave off with a question of my own.</p>
<p><span id="more-17"></span></p>
<p>The classic example of a Giffen situation is when rice or noodles are sold to the poor.  If the price of rice goes up this segment of consumers has no choice but to curtail their spending on more expensive legumes, vegetables and meat to put what remains of their spending power into the cheapest source of calories (which could remain rice, even though the price of rice increased).  This isn&#8217;t really free choice, or stockpiling in anticipation of further price increases but a simple grim economic trap.  Giffen behaviors have long been suspected but not really documented with much quality until recently (see “Giffen Behavior: Theory And Evidence” Robert T Jensen, John F Kennedy, NBER Working Paper (2007) vol. 13243).</p>
<p>It is hard to determine if advertisers are Giffen consumers.  For one marketing and advertising are “Positional Goods,” that is goods that derive some of their value from ranking (like market share).  Marketing and advertising also have large negative externalities.  That is every advertising dollar spent by Company A not only takes business away from Company B (the more famous zero-sum part of advertising) but also drives up unit costs of advertising for all advertisers (part of the negative externality).  These sort of goods can drive a lot of very strange (and counter-intuitive) market behaviors.</p>
<p>The first strange market behavior is an unlimited ratchet effect.  It is hard to pinpoint what portion of advertising really grows the market and what portion merely moves consumers from brand to brand (television advertising of cigarettes in the United States cigarette is an interesting example &#8220;The Effect of the 1971 Advertising Ban on Behavior in the Cigarette Industry&#8221; Craig A. Gallet, Managerial and Decision Economics, Vol. 20, No. 6 (Sep., 1999), pp. 299-303. ).  To the extent that advertising is not growing the market you just have dollars chasing each other.  Society can experience a ratcheting effect where you move from a reasonable amount of advertising spend to a place, as described in Cory Doctorow’s “The Rebranding of Billy Bailey,” where so much is spent on advertising that people have to lease out advertising space on their own skin.  That is people can not afford to buy goods at inflated prices unless they earn additional income by subjugating their selves to marketing campaigns and prices are in turn high because so much is spent on marketing campaigns.</p>
<p>This ratcheting effect is so strong that we see hints of game-theoretic situations every bit as strange as those described in Herman Kahn’s “On Thermonuclear War.”</p>
<p>Returning to the United States cigarette example we can speculate if the 1970’s ban on TV advertising was really an “arms control treaty” among cigarette manufactures to decrease television spend (remember under United States law it would be illegal collusion for competing companies to negotiate a spending cap among themselves).  We also saw use of “credible threats” in the form of advertising deliberately spent in very inefficient channels (such as expensive golf sponsorships).  Such spending is dollars deliberately wasted to demonstrate that one company could instantly move dollars into more effective channels (magazine ads, billboards, NASCAR) if any completing company “defected” and moved more of its dollars into effective channels.  The companies themselves do not need to be incredibly clever or  Machiavellian to come up with these strategies- the competition in the market can lead them into these behaviors.</p>
<p>In on-line advertising “targeted ads” (that is ads shown to people who have just typed in a search related to a product) are by far the most valuable.  This is, of course, because these are often the people that are closest to making a purchase.  But these are also the “zero sum” people- you are not growing the overall market when you advertise to them.  So if you could get your competitors to agree not to advertise to them you would also be happy not to advertise to them (somebody would still make the sale and you would all save a lot of money).</p>
<p>Now I will get to my question: is search advertising a market for lemons?  A “market for lemons” is a market where goods are hard to examine so it is marginally profitable to try to get away with selling defective goods in the market.  Usually such markets collapse as buyers can not afford to pay fair value (as they know they will often get defective goods) and sellers stop placing any non-defective goods (as buyers are no longer able to offer fair prices).  The name comes from the American slang for a defective car and the ideas (including an analysis of used car markets leading to the invention of “dealer certified” guarantees) eventually led to a Nobel Prize in Economics.</p>
<p>We must realize that high spend in advertising is not always proof that there is high value in advertising.  The dynamics of the market can cause high spend independent of true value.  Right now we are seeing very high and increasing spend in search advertising.  I argue that spending alone is not enough to determine the value of search advertising.  We have seen an on-line advertising boom/bust cycle once before; back when everybody was trading traffic through affiliate networks (the “eyeballs and money” era of the Internet).  Affiliate networks were definitely a market for lemons: full of aggregators that mixed premium traffic with low quality traffic and sold the aggregate for more than sum of the parts.  To avoid this we now market advertising impressions (often banners, priced as CPM) and advertising clicks (often driven by target text ads, priced as CPC).  However both of impressions and clicks are just traffic seen from the other side.  Once you get clever with targeting, modeling and manipulating “click through rates” you see that each advertising click is in fact equivalent to some large (but predictable) amount of traffic.</p>
<p>Given so many clever players the question becomes: does search advertising really remain a fundamentally different market than affiliate traffic?</p>


<p>Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/07/should-your-mom-use-google-search/' rel='bookmark' title='Permanent Link: Should your mom use Google search?'>Should your mom use Google search?</a></li>
<li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
<li><a href='http://www.win-vector.com/blog/2008/06/how-market-designs-set-prices/' rel='bookmark' title='Permanent Link: How Market Designs Set Prices'>How Market Designs Set Prices</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.win-vector.com/blog/2008/05/is-search-advertising-a-market-for-lemons/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Paper on stock trading</title>
		<link>http://www.win-vector.com/blog/2007/10/paper-on-stock-trading/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=paper-on-stock-trading</link>
		<comments>http://www.win-vector.com/blog/2007/10/paper-on-stock-trading/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 02:03:33 +0000</pubDate>
		<dc:creator>John Mount</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Quantitative Finance]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[Dynamic Programming]]></category>
		<category><![CDATA[Stock Trading]]></category>
		<category><![CDATA[Technical Papers]]></category>

		<guid isPermaLink="false">http://www.win-vector.com/blog/2007/10/03/paper-on-stock-trading/</guid>
		<description><![CDATA[author: John Mount I have finally written up and released a paper in PDF: Automatic Generation and Testing of Trades describing a lot of the statistics and optimization methods used when I was technical trading on a Banc of America Securities proprietary program trading desk.  It was a very exciting time. I have also included [...]


Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
<li><a href='http://www.win-vector.com/blog/2007/06/new-paper/' rel='bookmark' title='Permanent Link: New Paper'>New Paper</a></li>
<li><a href='http://www.win-vector.com/blog/2009/09/a-discrete-model-gauging-market-efficiency/' rel='bookmark' title='Permanent Link: A Discrete Model Gauging Market Efficiency'>A Discrete Model Gauging Market Efficiency</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>author: John Mount</p>
<p>I have finally written up and released a paper in  PDF: <a href="http://www.win-vector.com/SelectedPapers/files/AutomaticGenerationAndTestingOfTrades.pdf">Automatic Generation and Testing of Trades</a> describing a lot of the statistics and optimization methods used when I was technical trading on a Banc of America Securities proprietary program trading desk.  It was a very exciting time. </p>
<p><span id="more-5"></span><br />
I have also included a less legible HTML version:</p>
<h1 align="center">Automatic Generation and Testing of <em>Un-Rolls</em> for Profitable Technical Trades</h1>
<p align="center"><strong>John Mount<a name="tex2html1" href="#foot10" id="tex2html1"><sup>1</sup></a></strong></p>
<p></p>
<p align="center"><b>Date:</b> September 9, 2007</p>
<hr />
<h1><a name="SECTION00010000000000000000" id="SECTION00010000000000000000">Introduction</a></h1>
<p>In this paper we discuss some of the basic steps in developing successful technical trading strategies. The method involves identifying an inefficiency or irregularity in the market and then using rigorous statistical methods to track and exploit this single feature of the market. We show how to automatically generate and test optimal <em>un-rolls</em> or trades that undo (at a profit) automatically triggered technical trades. That is to say, if the first half of technical trade is specified we show how to find the other half.</p>
<p>Our technique is to use standard tools, such as kernel methods[<a href="#nonparametricStatistics">8</a>] and Markov chains[<a href="#markovChains">4</a>], to model both the efficient and the inefficient portions of the US stock markets.[<a href="#investments">6</a>]</p>
<p>The author traded profitably using some of these techniques while part of a program trading desk at Banc of America Securities.</p>
<h1><a name="SECTION00020000000000000000" id="SECTION00020000000000000000">Technical Trading</a></h1>
<p>Technical trading is a popular universe of security-trading strategies that trade using only the so-called <em>technical data</em> which are price graphs, volumes, bid/ask books and other data commonly available in market feeds.<a name="tex2html2" href="#foot21" id="tex2html2"><sup>2</sup></a>Input sources can also include external triggers based on news, RSS feeds, on-line information and corporate announcements.<a name="tex2html3" href="#foot22" id="tex2html3"><sup>3</sup></a>These strategies are very attractive in that that are quantifiable, easy to implement and easy to back-test on historic data. A major weakness of technical trading strategies is that they ignore deeper knowledge or analysis of the companies that are behind the securities being traded. Systems of technical trading are used both by large sophisticated hedge funds and by a varying population of day-traders.</p>
<p>Typical technical variables include price, time, volume and moving averages. It is important to know that many of these variables are really just analogies and not essential features of the market. For example: none of the variables current price, time, velocity, acceleration or inertia are real market quantities. What is traditionally called <em>current price</em> is actually the price of the last trade, which is in the past and may or may not ever be seen again. The fundamental variables of state of US stock markets are bid (best purchase price and quantity currently offered), ask (best sale price and quantity currently offered), and last trade (price and quantity). Each change of these variables is called a <em>tick</em> and can happen at any time. More detailed views include detailed bid and ask books from multiple market participants and estimates of inventory imbalance of various market makers and specialists.</p>
<p>In addition to working with the proper variables a sound strategy must also have at least two important components that we call foundation and empirical correctness. Without these components there is a large danger self-delusion and an unreliable strategy.</p>
<p>By <em>foundation</em> we mean that there are <em>a priori</em> reasons to believe that some variation of the strategy should be profitable. By ignoring the nature of the companies underling the securities being traded technical trading starts on shaky ground. In fact it is tempting to appeal to an <em>efficient market</em> hypothesis and claim that no technical trading strategy should be profitable. In some sense this is true- trades made in true ignorance expose a trader to significant risk, trading costs and pointless payment of the so-called bid-ask gap. Founded technical trading strategies are based on violations of the efficient market hypothesis- identifying situations where the market is in fact not efficient and trading into these situations. If there is no reason to suspect a market inefficiency there really is no reason to perform a technical trade. Testing numerous un-founded trading strategies is more likely to discover irrelevant anomalies in past data or discover flaws in one&#8217;s statistical procedures than it is likely to discover new valuable trading rules.[<a href="#Ioannids:2005aa">3</a>]</p>
<p>Possible market irregularities include (but are not limited to):</p>
<ul>
<li>Market Open</li>
<li>External News</li>
<li>Earnings Reports</li>
<li>M&amp;A news</li>
<li>Unusual Volume</li>
<li>Inferred state of Market Maker / Specialist state</li>
<li>Detailed Bid/Ask book.</li>
</ul>
<p>By <em>empirical correctness</em> we mean that strategy can be validated and proven on historic market data. A technical strategy can have as much mathematical pedigree as you like, but it does not make sense if it can not be mechanically implemented and proven on historic data. Many technical features are popular due to their familiarity or the quality of graphs they produce- but the true measure is how well strategies generate specific executable actions and the quantified outcomes of those actions.</p>
<p>Given an irregularity it remains to develop the trading strategy. Typically this involves an initial trade (a buy or a sell) triggered by evidence of the irregularity/inefficiency followed somewhat later by a reversal or un-rolling of the trade (selling back against an initial buy or buying back against an initial sell). If markets were perfectly efficient and instantaneous in incorporating external events this should not work- so it is important to test that there really is a repeatable market inefficacy.</p>
<p>Possible initial trading strategies could include:</p>
<ul>
<li>Selling stock into an unusual price spike (a <em>contrarian</em> strategy).</li>
<li>Buying stock immediately on news (a <em>superior connection</em> strategy).</li>
<li>Selling stock into a perceived specialist imbalance (a <em>superior knowledge</em> strategy).</li>
</ul>
<p>It would be naive to expect that a strategy that starts on a trigger and then reverses its trade blindly (say some fixed time after the trigger) is fully efficient. We must assume that other players in the market have seen effects of the trigger we traded and that their actions introduce biases and uncertainty into the market. Modeling these effects will allow us to produce a systematic <em>unrolling</em> strategy that can complete any <em>entry strategy</em> into a complete round-trip system. This systematic unrolling strategy is the subject of this writeup.</p>
<h1><a name="SECTION00030000000000000000" id="SECTION00030000000000000000">First Model</a></h1>
<h2><a name="SECTION00031000000000000000" id="SECTION00031000000000000000">The Efficient Market Hypothesis</a></h2>
<p>The efficient market hypothesis is a useful tool, even when you are attempting to find inefficient market situations. It represents the baseline you feel you have found a useful deviation from. The efficient market hypothesis has many variants but the essential content is that the market is full of <em>informed players</em> so any information is <em>already factored in to the price</em>. For example if there is publicly available information that gives a reasonable expectation that a stock should rise in the future then informed investors would purchase the stock early to be in a position to benefit from this increase. These purchases actually cause their own price-increase (by the simple laws of supply and demand) and have the effect of reducing the value of the information- as they move the price increase back in time (from the expected future change in value to the time of the anticipatory buying). This is what is meant by the phrase &#8220;already factored in.&#8221;</p>
<div align="center"><a name="fig:actual" id="fig:actual"></a><a name="47"></a></p>
<table>
<caption align="bottom"><strong>Figure 1:</strong> Dell 10-13-2006 Tick Data.</caption>
<tr>
<td>
<div align="center"><img width="500" height="402" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./morning.png" alt="Image morning"/></div>
</td>
</tr>
</table>
</div>
<p>There is a mathematical concept that captures the idea of <em>already factored in</em>: Martingales. The Martingale condition is a concept that says the expected future value is the current value. For example betting a dollar on the flip of a fair coin is a Martingale of value <img width="23" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg1.png" alt="$ \$0$"/> (the odds of winning and losing a dollar balance out). The future value may be higher or lower- but when the Martingale condition is met the average of all these value weighted by their likelihood of occurrence is equal to the current value. The <em>already factored in</em> example mentioned above shows how the many players in the market tend to establish a near-Martingale by trading in such a way to move the current price to be the expected value of the future price.</p>
<div align="center"><a name="fig:random" id="fig:random"></a><a name="198"></a></p>
<table>
<caption align="bottom"><strong>Figure 2:</strong> Graph of a <em>market-like</em> random walk.</caption>
<tr>
<td>
<div align="center"><img width="500" height="500" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./random.png" alt="Image random"/></div>
</td>
</tr>
</table>
</div>
<p>If market prices were the sum of many individual traders each with bounded-budgets who traded independently then we could apply the <em>central limit theorem</em> or <em>law of large numbers</em> and say that the market is indeed a random walk like the famous Brownian motion from physics. In fact on first inspection the market price histories (as in Figure&nbsp;<a href="#fig:actual">1</a>) indeed look very similar to graphs generated by such a random process (as in Figure&nbsp;<a href="#fig:random">2</a>).</p>
<p>As we have said: it is no coincidence that the market looks nearly like a Brownian motion. Informed trading effects tend to impart Martingale like tendencies (once the overall increase factor of the value of holding wealth is factored out). Also, if the variance of the market were much larger than that of a similar Brownian motion this would itself attract <em>channel traders</em> who would benefit by trading in and out of the excess wiggling. The point is that an efficient market is usually pretty well described by random processes that have the Martingale property (like Brownian motions or Markov chains), so these are appropriate modeling tools.</p>
<p>If the market process really were such a random walk than there would be little point in technical trading. The whole theory of Martingales was developed to precisely describe situations where bets based on collecting historic information can not work. This is often called the <em>no gambling system</em> principle and it can be actually proven for systems like Martingales, unbiased Markov chains, drift-free Brownian motion and was even used as an foundational concept to define randomness by von Mises.[<a href="#vonMises">7</a>] However, traders have a large number of pervasive dependencies. Dependencies can be shared information, <em>herd mentality</em> or shared trading practices. There are also some traders with very large budgets, so the conditions commonly needed to apply the law of large numbers do not apply and it is not inevitable that the market is indeed a Brownian motion. In fact one can show that even though the market overall looks very much like a Brownian motion it has too many events that would be considered very rare in this model (crashes, run-ups, events correlated in time) to have plausibly been generated by such a model.</p>
<h2><a name="SECTION00032000000000000000" id="SECTION00032000000000000000">Exploiting Inefficiency</a></h2>
<p>A basic rule of thumb is: without a good reason to believe contrary you are not too far off assuming the market is efficient. So we decided to model the morning market as being nearly memoryless. That is we modeled it as if future prices depend only on the most recent price and not on the detailed history of prices. We will, however, condition the model on the bias introduced by the presence initial trade trigger.</p>
<p>The most basic memoryless model is the Markov Chain. In this model the world has finite number of situations called <em>states</em>. For example we could say the stock price being near each a number of price differences from the previous day&#8217;s close is a state. We could take our states to be: <img width="68" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg2.png" alt="$ +0.50\%$"/> , <img width="68" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg2.png" alt="$ +0.50\%$"/> , <img width="68" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg3.png" alt="$ +0.25\%$"/> , <img width="53" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg4.png" alt="$ 0.00\%$"/> , <img width="53" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg5.png" alt="$ 0.25\%$"/> , <img width="68" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg6.png" alt="$ -0.50\%$"/> . If our strategy involved an end of day sale followed by a next-day buy-back then knowing which state we are in allows us to assign a value to buying back the stock while in that state. This would be the negative of the relative change in stock price (price decreases work for us) times the value of the stock sold the day before (minus trading costs). If we modeled round-trip trading costs as <img width="56" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg7.png" alt="$ \$20.00$"/> and assume our triggered trade purchased a total value of <img width="69" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg8.png" alt="$ \$46,000$"/> of Dell then we could map buying back in each possible state to a net dollar value of the round trip. For instance buying back in the state <img width="68" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg2.png" alt="$ +0.50\%$"/> would represent a net-loss of <img width="42" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg9.png" alt="$ \$250$"/> . We actually want to make the states a bit more detailed by adding a notion of time. If we modeled time in 5-minute intervals and (for the sake of diagram clarity) assumed that we only move up or down one state-level the Markov that modeled the first 15 minutes of the market could be represented in a diagram as in Figure&nbsp;<a href="#fig:chain1">3</a>.</p>
<div align="center"><a name="fig:chain1" id="fig:chain1"></a><a name="74"></a></p>
<table>
<caption align="bottom"><strong>Figure 3:</strong> Markov Chain Model</caption>
<tr>
<td>
<div align="center"><img width="505" height="400" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./Chain1.png" alt="Image Chain1"/></div>
</td>
</tr>
</table>
</div>
<p>Each circle represents a state and each arrow represents a transition from state to state. We would use historic market data to find for every stock in this situation the relative frequency each transition is taken. For instance we would measure in our historic data what fraction of the time a stock that is 5 minutes and in the <img width="68" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg3.png" alt="$ +0.25\%$"/> state moves to the <img width="68" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg2.png" alt="$ +0.50\%$"/> state at the 10 minute mark. These learned state transition probabilities can be made to depend on factors from the previous day close (% increase, volume, market-capitalization) . In the diagram we are going to assume all transitions are equally likely except for the arrows with square bases which we each take to be twice as likely as each regular arrow leaving the same state. The success of our strategy depends on finding situations where our model predicts these sort of advantageous asymmetric conditions. Without these asymmetries (greater net propensity for price decrease than for price increase) we would be in a gambling situation where no strategy could possibly have net-positive value.</p>
<p>The diagram also encodes another assumption of the problem- we have a deadline for buying back the stock. In this case the diagram indicates a forced buy-back at time +15 minutes if a buy-back has not been made before that time. In reality many more levels and many more time intervals are modeled. Also note we have made the top row (representing maximal loss) absorbing. This is introducing a deliberate pessimistic flaw into the model (or equivalently adds a stop-loss condition to the strategy). We do not want the maximal loss states to have a reflected barrier (like the maximal profit states do) as this would make the model overly optimistic. Instead we force the model to be pessimistic and chose enough levels so that the maximum loss bound is not often achieved and therefor does not have large effect on the model.</p>
<div align="center"><a name="fig:chain2" id="fig:chain2"></a><a name="81"></a></p>
<table>
<caption align="bottom"><strong>Figure 4:</strong> Valuing Interior States</caption>
<tr>
<td>
<div align="center"><img width="505" height="400" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./Chain2.png" alt="Image Chain2"/></div>
</td>
</tr>
</table>
</div>
<p>What we want to know is the net-value of being short (having sold) the stock the evening before. This is represented by the left-most circle which does not yet have a known value. The value of this state depends both on the transition odds of the states and on the trading strategy used to buy back the stock. There is, for example, no value in reaching the price-drop states if our strategy doesn&#8217;t take advantage and buy back while in these states. So the value of the states depends both on the uncertain future behavior of the market and of the currently unspecified buy-back strategy. The neat thing about this sort of diagram and treatment is that the forced-liquidation states at the end make it possible to simultaneously find the optimal trading strategy and assign values to all of the states. For example in the next diagram we see that the value of allowing the middle state at +10 minutes <em>to ride</em> (i.e. waiting instead of buying the stock back at this time) is equal to the properly weighted average of the ending states it connects to, in this case: <!-- MATH<br />
 $\frac{1}{4}(-\$135) + \frac{1}{4}(-\$20) + \frac{1}{2} \$95 = \$8.75$<br />
 --><br />
<img width="302" height="40" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg10.png" alt="$ \frac{1}{4}(-\$135) + \frac{1}{4}(-\$20) + \frac{1}{2} \$95 = \$8.75$"/> . The value of buying-back in this states is <img width="47" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg11.png" alt="$ -\$20$"/> so the optimal strategy is to take our chances in the next time interval (see Figure&nbsp;<a href="#fig:chain2">4</a>).</p>
<p>We can repeat this sort of argument for each state in the second to last column and determine the net-value of each state under the optimal trading strategy. States whose optimal strategy is to <em>stop</em> (perform the buy-back immediately) are indicated by not having any outgoing arrows (see Figure&nbsp;<a href="#fig:chain2b">5</a>).</p>
<div align="center"><a name="fig:chain2b" id="fig:chain2b"></a><a name="98"></a></p>
<table>
<caption align="bottom"><strong>Figure 5:</strong> Propagating the Valuation</caption>
<tr>
<td>
<div align="center"><img width="505" height="400" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./Chain2b.png" alt="Image Chain2b"/></div>
</td>
</tr>
</table>
</div>
<p>The procedure moves from right to left using known states to fill in decisions and values for unknown states. In fact the calculation is so simple and orderly we can encode the entire filling-in procedure in a spreadsheet table:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
\begin{array}{|l|lllr|}<br />
\hline<br />
 &#038; \text{column A} &#038; \text{column B} &#038; \text{column C} &#038; \text{column D} \\<br />
\hline<br />
\text{row 1} &#038; =D1 &#038; =D1 &#038; =D1 &#038; -\$250 \\<br />
\text{row 2} &#038; =\max(D2,(B1+B2+B3)/3) &#038; =\max(D2,(C1+C2+C3)/3) &#038; =\max(D2,(D1+D2+D3)/3) &#038; -\$135 \\<br />
\text{row 3} &#038; =\max(D3,(B2+B3+2*B4)/4) &#038; =\max(D3,(C2+C3+2*C4)/4) &#038; =\max(D3,(D2+D3+2*D4)/4) &#038; -\$20 \\<br />
\text{row 4} &#038; =\max(D4,(B3+B4+2*B5)/4) &#038; =\max(D4,(C3+C4+2*C5)/4) &#038; =\max(D4,(D3+D4+2*D5)/4) &#038; \$95 \\<br />
\text{row 5} &#038; =\max(D5,(B4+B5)/2) &#038; =\max(D5,(C4+C5)/2) &#038; =\max(D5,(D4+D5)/2) &#038; \$210 \\<br />
\hline<br />
\end{array}<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="1057" height="147" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg12.png" alt="\begin{displaymath} \begin{array}{\vert l\vert lllr\vert} \hline &amp; \text{column... ...(C4+C5)/2) &amp; =\max(D5,(D4+D5)/2) &amp; \$210 \ \hline \end{array}\end{displaymath}"/></div>
<p><font size="-2">.</font></p>
<p>This is in fact the same type dynamic programming[<a href="#dynamicProgramming">1</a>] method used to value options under the <em>binomial model</em>.</p>
<p>The completed diagram is shown in Figure&nbsp;<a href="#fig:chain3">6</a>.</p>
<div align="center"><a name="fig:chain3" id="fig:chain3"></a><a name="120"></a></p>
<table>
<caption align="bottom"><strong>Figure 6:</strong> Complete Valuation</caption>
<tr>
<td>
<div align="center"><img width="505" height="400" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./Chain3.png" alt="Image Chain3"/></div>
</td>
</tr>
</table>
</div>
<p>For our (made up) example the net-value of round trip trade is an expected value <img width="47" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg13.png" alt="$ \$7.47$"/> profit.</p>
<p>What remains is to choose a set of conditions to base a model estimates on. We then only trade situations that have an acceptable predicted risk and reward profile.</p>
<p>To build the state transition models we collect all the historic trade data and then segregate it into groups of data that match each possible trigger condition we wish to use to help bias our system. There is a trade-off: the more detailed the list of trigger conditions the more powerful biases we can detect (things are less smeared together) but we have less data available for each possible combination of conditions and lower reliability in modeling. To address this we advocate using non-parametric or kernel methods here to average data that nearly fits the conditions to get estimates that are both detailed and reliable.</p>
<p>For example our estimate is of the form:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
P(s_1 \rightarrow s_2) \approx<br />
\frac{<br />
\sum_{training-example} wt(training-example,s_1) P(s_1 \rightarrow s_2|training-example,s_1)<br />
}{<br />
\sum_{training-example} wt(training-example,s_1) P(s_1|training-example)<br />
}<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="766" height="68" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg14.png" alt="$\displaystyle P(s_1 \rightarrow s_2) \approx \frac{ \sum_{training-example} wt(... ...sum_{training-example} wt(training-example,s_1) P(s_1\vert training-example) } $"/></div>
<p>A usable <!-- MATH<br />
 $wt(training-example,s_1)$<br />
 --><br />
<img width="227" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg15.png" alt="$ wt(training-example,s_1)$"/> can be gotten from the law of conditional probability (<!-- MATH<br />
 $P(A, B) = P(A)P(B|A)$<br />
 --><br />
<img width="203" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg16.png" alt="$ P(A, B) = P(A)P(B\vert A)$"/> ), so we use <!-- MATH<br />
 $P(training-example,s_1) = P(s_1 | training-example)<br />
P(training-example)$<br />
 --><br />
<img width="649" height="37" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg17.png" alt="$ P(training-example,s_1) = P(s_1 \vert training-example) P(training-example)$"/> . Under empirical re-sampling each training example is treated as equally likely (more common situations are accounted by the fact they yield more examples in the training set) so we can use <!-- MATH<br />
 $wt(training-example,s_1) = P(s_1 | training-example)$<br />
 --><br />
<img width="466" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg18.png" alt="$ wt(training-example,s_1) = P(s_1 \vert training-example)$"/> .</p>
<p>For <!-- MATH<br />
 $P(s_1 \rightarrow s_2 | training-example)$<br />
 --><br />
<img width="264" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg19.png" alt="$ P(s_1 \rightarrow s_2 \vert training-example)$"/> we can just estimate the frequency of when we are in a <img width="56" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg20.png" alt="$ state_A$"/> near <img width="21" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg21.png" alt="$ s_1$"/> how often do we see a next-state <img width="57" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg22.png" alt="$ state_B$"/> such that <!-- MATH<br />
 $state_B/state_A$<br />
 --><br />
<img width="118" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg23.png" alt="$ state_B/state_A$"/> is approximately <img width="97" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg24.png" alt="$ s-2/s-1$"/> .</p>
<p>For both of these estimates is pays to blur things a bit during the estimation procedure replacing sums of the form:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
E_{condition(x)=true}[f(x)] = \frac{<br />
\sum_{condition(x)=true} f(x)<br />
}{<br />
\sum_{condition(x)=true} 1<br />
}<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="376" height="70" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg25.png" alt="$\displaystyle E_{condition(x)=true}[f(x)] = \frac{ \sum_{condition(x)=true} f(x) }{ \sum_{condition(x)=true} 1 } $"/></div>
<p>with softer forms like:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
E_{condition(x)=true}[f(x)] \approx \frac{<br />
\sum_{x} e^{-\lambda violation(x)}f(x)<br />
}{<br />
\sum_{x} e^{-\lambda violation(x)}<br />
}<br />
.<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="379" height="69" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg26.png" alt="$\displaystyle E_{condition(x)=true}[f(x)] \approx \frac{ \sum_{x} e^{-\lambda violation(x)}f(x) }{ \sum_{x} e^{-\lambda violation(x)} } . $"/></div>
<h1><a name="SECTION00040000000000000000" id="SECTION00040000000000000000">A Second Model</a></h1>
<p>One thing we one might want is to use a much more detailed model of time. One way to do this is just to add more time-states to the model. This can cause problems as we now have many more transition probabilities to estimate.<a name="tex2html10" href="#foot134" id="tex2html10"><sup>4</sup></a>Suppose we wanted to switch our model from being indexed by time to being indexed by tick. Bid, Ask and Trade ticks can happen at any time and any rate so even with a trading deadline, so there is uncertainty in how many more ticks there are before the trade deadline. We can work at the tick level (without introducing too many states) by introducing a new model that has cycles in the arrow diagram (see Figure&nbsp;<a href="#fig:chain4">7</a>).</p>
<div align="center"><a name="fig:chain4" id="fig:chain4"></a><a name="140"></a></p>
<table>
<caption align="bottom"><strong>Figure 7:</strong> Recurrent Model (With Cycles)</caption>
<tr>
<td>
<div align="center"><img width="505" height="400" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/./Chain4.png" alt="Image Chain4"/></div>
</td>
</tr>
</table>
</div>
<p>The short vertical arrows represent the odds of moving from price-state to price-state in the same time column. The left to right dotted arrows represent the odds of being the tick that moves to the next time column. We can now estimate the transition odds from a great quantity of per-tick data giving us very reliable transition odds. We would like to fill in the values of all the states of this model (like we did in the earlier diagrams)- but the fill-in procedure will not work in the presence of cycles. States we need to fill in our given state do not yet have known values because they themselves depend on the state we are trying to value.</p>
<h2><a name="SECTION00041000000000000000" id="SECTION00041000000000000000">Linear Program Treatment</a></h2>
<p>The standard way to deal with unknown quantities that simultaneously depend on each other is to introduce variables and write down a set of simultaneous inequalities.</p>
<p>If we introduce the variables <img width="14" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg27.png" alt="$ v$"/> , <!-- MATH<br />
 $a_1 \cdots a_5$<br />
 --><br />
<img width="68" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg28.png" alt="$ a_1 \cdots a_5$"/> , <!-- MATH<br />
 $b_1 \cdots b_5$<br />
 --><br />
<img width="64" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg29.png" alt="$ b_1 \cdots b_5$"/> and <!-- MATH<br />
 $c_1 \cdots c_5$<br />
 --><br />
<img width="64" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg30.png" alt="$ c_1 \cdots c_5$"/> to represent all of the unknown values in our last diagram we can quickly write down many relations we know to be true for them.</p>
<p>For example for the set of variables <img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg31.png" alt="$ c_1$"/> through <img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg32.png" alt="$ c_5$"/> we know that each state is worth at lest as much as the value of stopping in that state. This can be written as:</p>
<p></p>
<div align="center"><!-- MATH<br />
 \begin{eqnarray*}<br />
c_1  &#038; \ge &#038;  -\$250  \\<br />
c_2  &#038; \ge &#038;  -\$135  \\<br />
c_3  &#038; \ge &#038;  -\$20 \\<br />
c_4  &#038; \ge &#038;  \$95 \\<br />
c_5  &#038; \ge &#038;  \$210 \\<br />
.<br />
\end{eqnarray*}<br />
 --></p>
<table cellpadding="0" align="center" width="100%">
<tr valign="middle">
<td nowrap align="right"><img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg33.png" alt="$\displaystyle c_1$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="57" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg35.png" alt="$\displaystyle -\$250$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg36.png" alt="$\displaystyle c_2$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="57" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg37.png" alt="$\displaystyle -\$135$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg38.png" alt="$\displaystyle c_3$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="47" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg39.png" alt="$\displaystyle -\$20$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg40.png" alt="$\displaystyle c_4$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="32" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg41.png" alt="$\displaystyle \$95$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg42.png" alt="$\displaystyle c_5$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="42" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg43.png" alt="$\displaystyle \$210$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="10" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg44.png" alt="$\displaystyle .$"/></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="10" align="right">&nbsp;</td>
</tr>
</table>
</div>
<p><br clear="all"/></p>
<p>Each state (except deadline and stop-loss states) is also worth at least the expected value of continuing one more step, which can be written as:</p>
<p></p>
<div align="center"><!-- MATH<br />
 \begin{eqnarray*}<br />
c_2  &#038; \ge &#038;  p(c_2  \rightarrow  c_2) c_2 + p(c_2  \rightarrow  c_1) c_1 + p(c_2  \rightarrow  c_3) c_3 + p(c_2 \;\text{escape}) (-\$135) \\<br />
c_3  &#038; \ge &#038;  p(c_3  \rightarrow  c_3) c_3 + p(c_3  \rightarrow  c_2) c_2 + p(c_3  \rightarrow  c_4) c_4 + p(c_3 \;\text{escape}) (-\$20) \\<br />
c_4  &#038; \ge &#038;  p(c_4  \rightarrow  c_4) c_4 + p(c_4  \rightarrow  c_3) c_3 + p(c_4  \rightarrow  c_5) c_5 + p(c_4 \;\text{escape}) \$95 \\<br />
c_5  &#038; \ge &#038;  p(c_5  \rightarrow  c_5) c_5 + p(c_5  \rightarrow  c_4) c_4 + p(c_5 \;\text{escape}) \$210 \\<br />
.<br />
\end{eqnarray*}<br />
 --></p>
<table cellpadding="0" align="center" width="100%">
<tr valign="middle">
<td nowrap align="right"><img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg36.png" alt="$\displaystyle c_2$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="412" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg45.png" alt="$\displaystyle p(c_2 \rightarrow c_2) c_2 + p(c_2 \rightarrow c_1) c_1 + p(c_2 \rightarrow c_3) c_3 + p(c_2 \;$"/>escape<img width="78" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg46.png" alt="$\displaystyle ) (-\$135)$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg38.png" alt="$\displaystyle c_3$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="412" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg47.png" alt="$\displaystyle p(c_3 \rightarrow c_3) c_3 + p(c_3 \rightarrow c_2) c_2 + p(c_3 \rightarrow c_4) c_4 + p(c_3 \;$"/>escape<img width="69" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg48.png" alt="$\displaystyle ) (-\$20)$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg40.png" alt="$\displaystyle c_4$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="412" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg49.png" alt="$\displaystyle p(c_4 \rightarrow c_4) c_4 + p(c_4 \rightarrow c_3) c_3 + p(c_4 \rightarrow c_5) c_5 + p(c_4 \;$"/>escape<img width="40" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg50.png" alt="$\displaystyle ) \$95$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="20" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg42.png" alt="$\displaystyle c_5$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="289" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg51.png" alt="$\displaystyle p(c_5 \rightarrow c_5) c_5 + p(c_5 \rightarrow c_4) c_4 + p(c_5 \;$"/>escape<img width="49" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg52.png" alt="$\displaystyle ) \$210$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="10" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg44.png" alt="$\displaystyle .$"/></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="10" align="right">&nbsp;</td>
</tr>
</table>
</div>
<p><br clear="all"/></p>
<p>This can be re-written into matrix form where we have</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
A =<br />
\begin{bmatrix}<br />
 1 &#038;   &#038;   &#038;   &#038;   \\<br />
   &#038; 1 &#038;   &#038;   &#038;   \\<br />
   &#038;   &#038; 1 &#038;   &#038;   \\<br />
   &#038;   &#038;   &#038; 1 &#038;   \\<br />
   &#038;   &#038;   &#038;   &#038; 1 \\<br />
-P(c_2 \rightarrow c_1) &#038;  1-P(c_2 \rightarrow c_2) &#038; -P(c_2 \rightarrow c_3) &#038; &#038; \\<br />
   &#038; -P(c_3 \rightarrow c_2) &#038; 1-P(c_3 \rightarrow c_3) &#038; -P(c_3 \rightarrow c_4) &#038; \\<br />
   &#038;   &#038; -P(c_4 \rightarrow c_3) &#038; 1-P(c_4 \rightarrow c_4) &#038; -P(c_4 \rightarrow c_5) \\<br />
   &#038;   &#038;   &#038;  -P(c_5 \rightarrow c_4)  &#038; 1-P(c_5 \rightarrow c_5)<br />
\end{bmatrix},<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="734" height="226" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg53.png" alt="$\displaystyle A = \begin{bmatrix} 1 &amp; &amp; &amp; &amp; \ &amp; 1 &amp; &amp; &amp; \ &amp; &amp; 1 &amp; &amp; \ &amp; &amp;... ...5) \ &amp; &amp; &amp; -P(c_5 \rightarrow c_4) &amp; 1-P(c_5 \rightarrow c_5) \end{bmatrix}, $"/></div>
<p><!-- MATH<br />
 \begin{displaymath}<br />
b =<br />
\begin{bmatrix}<br />
-\$250 \\<br />
-\$135 \\<br />
-\$20 \\<br />
\$95 \\<br />
\$210 \\<br />
P(c_2 \;\text{escape}) (-\$135) \\<br />
P(c_3 \;\text{escape}) (-\$20) \\<br />
P(c_4 \;\text{escape}) \$95 \\<br />
P(c_5 \;\text{escape}) \$210<br />
\end{bmatrix}<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="232" height="226" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg54.png" alt="$\displaystyle b = \begin{bmatrix} -\$250 \ -\$135 \ -\$20 \ \$95 \ \$21... ... \ P(c_4 \;\text{escape}) \$95 \ P(c_5 \;\text{escape}) \$210 \end{bmatrix}$"/></div>
<p>and our vector of unknowns is</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
x =<br />
\begin{bmatrix}<br />
c_1 \\<br />
c_2 \\<br />
c_3 \\<br />
c_4 \\<br />
c_5<br />
\end{bmatrix}.<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="90" height="135" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg55.png" alt="$\displaystyle x = \begin{bmatrix} c_1 \ c_2 \ c_3 \ c_4 \ c_5 \end{bmatrix}. $"/></div>
<p>In matrix form we say <img width="62" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg56.png" alt="$ A x \ge b$"/> . We are assuming we have estimates for all of the entries of <img width="18" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg57.png" alt="$ A$"/> and <img width="12" height="20" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg58.png" alt="$ b$"/> &#8211; so the only unknowns are the entries of <img width="15" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg59.png" alt="$ x$"/> . If these were equalities (instead of inequalities) we would call this a set of simultaneous equations and we could use linear algebra to solve for the unknown values. Because they are inequalities we will have to instead solve what is known as a linear program.[<a href="#linProg">5</a>] It turns out the optimal values for <!-- MATH<br />
 $c_1, \cdots c_5$<br />
 --><br />
<img width="69" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg60.png" alt="$ c_1, \cdots c_5$"/> are given by solving:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
\min 1\cdot x \;\text{s.t.}\;\\A x \ge b .<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="78" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg61.png" alt="$\displaystyle \min 1\cdot x \;$"/>s.t.<img width="68" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg62.png" alt="$\displaystyle \;\\ A x \ge b . $"/></div>
<p>This has an admittedly strange form (the objective condition <!-- MATH<br />
 $\min 1\cdot x$<br />
 --><br />
<img width="72" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg63.png" alt="$ \min 1\cdot x$"/> seems very arbitrary and one would at first think the likely form is <!-- MATH<br />
 $\max p \cdot x$<br />
 --><br />
<img width="76" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg64.png" alt="$ \max p \cdot x$"/> where <img width="14" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg65.png" alt="$ p$"/> is the vector probabilities of getting into each <img width="12" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg66.png" alt="$ c$"/> -state). There is also the issue that we merely wrote down inequalities that we knew would be true for the optimal solution to the stopping problem, but we have not guaranteed that there are not more conditions we have not thought of (i.e. these conditions are necessary, but we have not yet established that they are sufficient).</p>
<p>We show (in the appendix) that this is in fact the right procedure for solving for all of the <img width="12" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg66.png" alt="$ c$"/> -values. Each of these linear programs can be quickly solved using standard software. We can also see that the same type of procedure can then be applied to the <img width="12" height="20" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg58.png" alt="$ b$"/> -values (which depend only on <img width="12" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg66.png" alt="$ c$"/> -values, which are by this point known). In fact we can substitute back (using linear programs instead of filling-in) until we know <img width="14" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg27.png" alt="$ v$"/> the expected value (under the model) of the entire round-trip trade.</p>
<h2><a name="SECTION00042000000000000000" id="SECTION00042000000000000000">More on the Transition Probability Estimate</a></h2>
<p>We can augment our state to carry more information that just the current ask-price relative to our previous night&acirc;&euro;&trade;s sale</p>
<p>If we are in <img width="79" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg67.png" alt="$ stage-b$"/> of our Markov model we can modify <!-- MATH<br />
 $wt(training-example,s_1)$<br />
 --><br />
<img width="227" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg15.png" alt="$ wt(training-example,s_1)$"/> to be: <!-- MATH<br />
 $P(s_1 | training-example)<br />
P(training-example | todayâ¬"s \; stage-a \; move \; summary)$<br />
 --><br />
<img width="683" height="37" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg68.png" alt="$ P(s_1 \vert training-example) P(training-example \vert today&acirc;&euro;&trade;s \; stage-a \; move \; summary)$"/> (to do this we build an estimated transition matrix for <img width="81" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg69.png" alt="$ stage-a$"/> from only the trajectory of today&acirc;&euro;&trade;s stock and then evaluate how likely the trajectory the training example from the past is under this model, much smoothing/blurring is required to make this calculation usable). Even better: we can group training data and use Bayes&acirc;&euro;&trade; law: <!-- MATH<br />
 $P(training-group | todayâ¬"s \; stage-a \; move \; summary) = P(todayâ¬"s \; stage-a \; move \; summary | training-group) P(training-group) /<br />
P(todayâ¬"s \; stage-a \; move \; summary)$<br />
 --><br />
<img width="1399" height="37" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg70.png" alt="$ P(training-group \vert today&acirc;&euro;&trade;s \; stage-a \; move \; summary) = P(today&acirc;&euro;&trade;s ... ... training-group) P(training-group) / P(today&acirc;&euro;&trade;s \; stage-a \; move \; summary)$"/></p>
<p>This allows us to group the training examples (on a few criteria, like less than a month old or not, trading volume, volatility &#8230;) and use a group of examples to build a model to evaluate today&acirc;&euro;&trade;s moves against (aggregated data to form model to check today&acirc;&euro;&trade;s single trajectory). As is traditional in Bayes estimates we ignore the denominator as it does not vary as a function of training group.</p>
<h1><a name="SECTION00050000000000000000" id="SECTION00050000000000000000">Conclusion</a></h1>
<p>We have demonstrated some of the methods of using standard statistical and optimization techniques to automatically generate and back-test <em>un-roll</em> trades that turn properly conditioned technical trades into profitable round-trip trades. What we have presented is the technical machinery for building the <em>second half</em> of a profitable trade pair where the first half is some technical signal such as price or a market external trigger.</p>
<h2><a name="SECTION00060000000000000000" id="SECTION00060000000000000000">Bibliography</a></h2>
<dl compact>
<dt><a name="dynamicProgramming" id="dynamicProgramming">1</a></dt>
<dd>B<small>ELLMAN,</small> R.<br />
<em>Dynamic Programming</em>.<br />
Dover Publications, 2003.</dd>
<dt><a name="stopping" id="stopping">2</a></dt>
<dd>B<small>REIMAN,</small> L.<br />
<em>Stopping Rule Problems</em>.<br />
John Wiley &amp; sons, 1964, ch.&nbsp;Applied Combinatorial Mathematics.</dd>
<dt><a name="Ioannids:2005aa" id="Ioannids:2005aa">3</a></dt>
<dd>I<small>OANNIDS,</small> J. P.&nbsp;A.<br />
Why most published research findings are false.<br />
<em>PLOS Medicine 2</em>, 8 (Aug 2005), 0697-0701.</dd>
<dt><a name="markovChains" id="markovChains">4</a></dt>
<dd>K<small>EMENY,</small> J.&nbsp;G., <small>AND</small> S<small>NELL,</small> J.&nbsp;L.<br />
<em>Finite Markov Chains</em>.<br />
Springer, 1960.</dd>
<dt><a name="linProg" id="linProg">5</a></dt>
<dd>S<small>CHRIJVER,</small> A.<br />
<em>Theory of Linear and Integer Programming</em>.<br />
John Wiley &amp; sons, 1986.</dd>
<dt><a name="investments" id="investments">6</a></dt>
<dd>S<small>HARPE,</small> W., A<small>LEXANDER,</small> G.&nbsp;J., <small>AND</small> B<small>AILLY,</small> J.&nbsp;W.<br />
<em>Investments</em>, 6&nbsp;ed.<br />
Prentice Hall, 1998.</dd>
<dt><a name="vonMises" id="vonMises">7</a></dt>
<dd><small>VON</small> M<small>ISES,</small> R.<br />
<em>Probability, Statistics and Truth</em>.<br />
Dover Publications, 1981.</dd>
<dt><a name="nonparametricStatistics" id="nonparametricStatistics">8</a></dt>
<dd>W<small>ASSERMAN,</small> L.<br />
<em>All of Nonparametric Statistics</em>.<br />
Springer, 2006.</dd>
</dl>
<div align="center"><b>APPENDIX</b></div>
<h1><a name="SECTION00070000000000000000" id="SECTION00070000000000000000">Why the Linear Program Solution is Correct</a></h1>
<p>How do we know the linear program solves the original problem?</p>
<ul>
<li>Because there are a lot of formulas?</li>
<li>Linear program looks kind-of right?</li>
<li>Works on a few examples?</li>
</ul>
<p>To actually prove correctness we need to derive and compare to some representations of the optimal solution. All of the inequalities we wrote must be true for the optimal solution- but we have no prior guarantee that these are the only conditions. Their could be additional conditions that we forgot to model.</p>
<p>Breiman[<a href="#stopping">2</a>] presented a clever argument technique that exploits the particularly nice structure of solutions of this problem. He noticed that solutions have both a lattice like structure (you can combine solutions by taking minimums) and an operator structure (applying the probability transition matrix and stopping rules to a solution yields a solution). It turns out this is too much well behaved structure for any non-trivial solution set to have and it lets us show that optimal solutions are essentially unique which in turn lets us show the linear program solution solves the actual trading problem.</p>
<div><a name="thm:stopping" id="thm:stopping"><b>Theorem 1</b></a> &nbsp; <i>Assume that every state in the Markov chain has a path to a forced stopping state. Let <img width="18" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg71.png" alt="$ T$"/> be a maximal optimal set of stopping nodes and define the vector <img width="11" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg72.png" alt="$ t$"/> such that <!-- MATH<br />
 $t_i = E[stopping\; value\; under\; T\; rules \;|\; started \; at \; i]$<br />
 --><br />
<img width="418" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg73.png" alt="$ t_i = E[stopping\; value\; under\; T\; rules \;\vert\; started \; at \; i]$"/> . Let <img width="15" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg59.png" alt="$ x$"/> be an optimal feasible solution to the linear program:</i></p>
<div align="center"><!-- MATH<br />
 \begin{eqnarray*}<br />
\min 1 \cdot x &#038; &#038; \\<br />
x &#038; \ge &#038; stop\\<br />
(I-P)x &#038; \ge &#038; 0<br />
\end{eqnarray*}<br />
 --></p>
<table cellpadding="0" align="center" width="100%">
<tr valign="middle">
<td nowrap align="right"><img width="72" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg74.png" alt="$\displaystyle \min 1 \cdot x$"/></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="15" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg75.png" alt="$\displaystyle x$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap><img width="38" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg76.png" alt="$\displaystyle stop$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="77" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg77.png" alt="$\displaystyle (I-P)x$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap>0</td>
<td width="10" align="right">&nbsp;</td>
</tr>
</table>
</div>
<p><br clear="all"/><br />
<i>where <img width="14" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg78.png" alt="$ I$"/> is the identity matrix, <img width="19" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg79.png" alt="$ P$"/> is the matrix of transition odds of the Markov chain and <img width="38" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg80.png" alt="$ stop$"/> is the vector of stopping values.</i></p>
<p><i>Then <img width="47" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg81.png" alt="$ x = t$"/> .</i></p>
</div>
<p>The theorem says if <img width="11" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg72.png" alt="$ t$"/> is an optimal solution for the original valuation problem (that we may or may not know how to calculate) and <img width="15" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg59.png" alt="$ x$"/> is an optimal feasible solution to the linear program (which is now written in a slightly different but equivalent form) then <img width="47" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg81.png" alt="$ x = t$"/> . So, as hoped, solving the linear program is equivalent to solving the original stopping problem. The extra condition of every state being able to eventual reach a forced stopping state is true in our formulation due to the trading deadline.</p>
<p>The proof gets a little involved but the essential ideas are as follows:</p>
<ul>
<li>Check an optimal stopping solution would obey the linear program inequalities (so they are necessary, still need to show they are sufficient).</li>
<li>Show that the linear program solution even if it did differ from the optimal stopping solution can not be less than the optimal stopping solution in any coordinate (this is the lattice minimum step).</li>
<li>Use the fact that every state has a path to a forced stopping state to show that the linear programing solution can not hide any excess value above best possible stopping value away from the rest of the system (this is the operator step).</li>
</ul>
<div><i>Proof</i>. [Proof of Theorem&nbsp;<a href="#thm:stopping">1</a>] The theory of linear programming duality says that there is a <em>dual problem</em> to our linear program and this dual is: <!-- MATH<br />
 $\max u \cdot stop$<br />
 --><br />
<img width="101" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg83.png" alt="$ \max u \cdot stop$"/> where</p>
<div align="center"><!-- MATH<br />
 \begin{eqnarray*}<br />
u, v  &#038; \ge &#038;  0 \\<br />
(u v) A &#038; = &#038; c<br />
.<br />
\end{eqnarray*}<br />
 --></p>
<table cellpadding="0" align="center" width="100%">
<tr valign="middle">
<td nowrap align="right"><img width="33" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg84.png" alt="$\displaystyle u, v$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg34.png" alt="$\displaystyle \ge$"/></td>
<td align="left" nowrap>0</td>
<td width="10" align="right">&nbsp;</td>
</tr>
<tr valign="middle">
<td nowrap align="right"><img width="53" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg85.png" alt="$\displaystyle (u v) A$"/></td>
<td width="10" align="center" nowrap><img width="19" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg86.png" alt="$\displaystyle =$"/></td>
<td align="left" nowrap><img width="18" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg87.png" alt="$\displaystyle c .$"/></td>
<td width="10" align="right">&nbsp;</td>
</tr>
</table>
</div>
<p><br clear="all"/><br />
The point of the dual is it is known that for all <img width="52" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg88.png" alt="$ x, u, v$"/> feasible we have <!-- MATH<br />
 $u \cdot stop \le c \cdot x$<br />
 --><br />
<img width="121" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg89.png" alt="$ u \cdot stop \le c \cdot x$"/> . And for optimal <img width="52" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg88.png" alt="$ x, u, v$"/> we have <!-- MATH<br />
 $u \cdot stop = c \cdot x$<br />
 --><br />
<img width="120" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg90.png" alt="$ u \cdot stop = c \cdot x$"/> .</p>
<p>Take <img width="52" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg88.png" alt="$ x, u, v$"/> as an optimal solution to the linear program and the dual.</p>
<p>One can check <img width="11" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg72.png" alt="$ t$"/> itself must obey all of the conditions of the linear program so duality theory tells us <!-- MATH<br />
 $u \cdot stop \le c \cdot t$<br />
 --><br />
<img width="117" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg91.png" alt="$ u \cdot stop \le c \cdot t$"/> .</p>
<p>Define a vector <img width="14" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg92.png" alt="$ z$"/> such that <!-- MATH<br />
 $z_i = \min(x_i, t_i)$<br />
 --><br />
<img width="126" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg93.png" alt="$ z_i = \min(x_i, t_i)$"/> . <img width="14" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg92.png" alt="$ z$"/> also obeys the primal linear program inequalities, so we know <!-- MATH<br />
 $u \cdot stop \le c \cdot z$<br />
 --><br />
<img width="120" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg94.png" alt="$ u \cdot stop \le c \cdot z$"/> . Now <!-- MATH<br />
 $u \cdot stop = c \cdot t$<br />
 --><br />
<img width="116" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg95.png" alt="$ u \cdot stop = c \cdot t$"/> so we have <!-- MATH<br />
 $c \cdot t \le c \cdot z$<br />
 --><br />
<img width="90" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg96.png" alt="$ c \cdot t \le c \cdot z$"/> . Each entry of <img width="12" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg66.png" alt="$ c$"/> is <img width="14" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg97.png" alt="$ 1$"/> and <!-- MATH<br />
 $z_i \le t_i$<br />
 --><br />
<img width="56" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg98.png" alt="$ z_i \le t_i$"/> for all <img width="11" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg99.png" alt="$ i$"/> which can only mean that <img width="46" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg100.png" alt="$ z = t$"/> . This means entry by entry we have <!-- MATH<br />
 $x_i \ge t_i$<br />
 --><br />
<img width="58" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg101.png" alt="$ x_i \ge t_i$"/> .</p>
<p>Now define the vector function <img width="34" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg102.png" alt="$ F()$"/> such that <!-- MATH<br />
 $F(w)_i = \max(stop_i, \sum_j P(i \rightarrow j) w_j)$<br />
 --><br />
<img width="300" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg103.png" alt="$ F(w)_i = \max(stop_i, \sum_j P(i \rightarrow j) w_j)$"/> . For the true solution <img width="11" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg72.png" alt="$ t$"/> we have <img width="72" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg104.png" alt="$ F(t) = t$"/> . The linear program solution <img width="15" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg59.png" alt="$ x$"/> also has <img width="80" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg105.png" alt="$ F(x) = x$"/> . Now if we suppose <img width="47" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg106.png" alt="$ x \neq t$"/> then there exists an <img width="11" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg99.png" alt="$ i$"/> such that <img width="56" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg107.png" alt="$ x_i - t_i$"/> is maximal and state <img width="11" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg99.png" alt="$ i$"/> points to at least one state <img width="13" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg108.png" alt="$ j$"/> such that <!-- MATH<br />
 $x_i - t_i > x_j &#8211; t_j$<br />
 &#8211;><br />
<img width="136" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg109.png" alt="$ x_i - t_i &gt; x_j - t_j$"/> . This must be true because none of these maximal difference states can be forced stopping states. So some maximal difference state must have a transition to a non maximal difference, otherwise this would violate the fact that all states have eventual paths to forced stopping states (where <!-- MATH<br />
 $x_k - t_k = 0$<br />
 --><br />
<img width="96" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg110.png" alt="$ x_k - t_k = 0$"/> ). For this particular <img width="11" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg99.png" alt="$ i$"/> we claimed <!-- MATH<br />
 $x_i > t_i \ge stop_i$<br />
 &#8211;><br />
<img width="123" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg111.png" alt="$ x_i &gt; t_i \ge stop_i$"/> so we have:</p>
<p><!-- MATH<br />
 \begin{displaymath}<br />
(F(x) - F(t))_i =<br />
\left\{<br />
\begin{array}{l l}<br />
   \sum_j P(i \rightarrow j) x_j - stop_i &#038; \quad \text{if $\sum_j P(i \rightarrow j) t_j < stop_i$} \\<br />
   \sum_j P(i \rightarrow j) (x_j - t_j) &#038; \quad \text{otherwise}<br />
\\\end{array} \right.<br />
.<br />
\end{displaymath}<br />
 --></p>
<div align="center"><img width="592" height="55" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg112.png" alt="\begin{displaymath} (F(x) - F(t))_i = \left\{ \begin{array}{l l} \sum_j P(i \ri... ... (x_j - t_j) &amp; \quad \text{otherwise} \\ \end{array} \right. . \end{displaymath}"/></div>
<p>So either way we have for this particular <img width="11" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg99.png" alt="$ i$"/> : <!-- MATH<br />
 $(F(x) - F(t))_i \le \sum_j P(i \rightarrow j) (x_j - t_j)$<br />
 --><br />
<img width="323" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg113.png" alt="$ (F(x) - F(t))_i \le \sum_j P(i \rightarrow j) (x_j - t_j)$"/> . But we must have <!-- MATH<br />
 $\sum_j P(i \rightarrow j) (x_j - t_j) < x_i - t_i$<br />
 --><br />
<img width="255" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg114.png" alt="$ \sum_j P(i \rightarrow j) (x_j - t_j) &lt; x_i - t_i$"/> because <!-- MATH<br />
 $\sum_j P(i \rightarrow j) = 1$<br />
 --><br />
<img width="143" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg115.png" alt="$ \sum_j P(i \rightarrow j) = 1$"/> , <!-- MATH<br />
 $x_j - t_j \le x_i - t_i$<br />
 --><br />
<img width="136" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg116.png" alt="$ x_j - t_j \le x_i - t_i$"/> for all <img width="13" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg108.png" alt="$ j$"/> and <!-- MATH<br />
 $x_j - t_j < x_i - t_i$<br />
 --><br />
<img width="136" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg117.png" alt="$ x_j - t_j &lt; x_i - t_i$"/> for at least one <img width="13" height="34" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg108.png" alt="$ j$"/> . So <!-- MATH<br />
 $(F(x) - F(t))_i < x_i - t_i$<br />
 --><br />
<img width="200" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg118.png" alt="$ (F(x) - F(t))_i &lt; x_i - t_i$"/> and we see <img width="34" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg102.png" alt="$ F()$"/> is essentially a contraction on the segment between <img width="11" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg72.png" alt="$ t$"/> and <img width="15" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg59.png" alt="$ x$"/> . Since a contraction on a bounded interval can not have two distinct fixed points our supposition that <img width="47" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg106.png" alt="$ x \neq t$"/> is untenable and we know <img width="47" height="19" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg81.png" alt="$ x = t$"/> . <img width="19" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg82.png" alt="$ \qedsymbol$"/></div>
<p>We are done- we have shown there is essentially only one optimal solution to the stopping problem (the only possible variation is rules that differ in what they do for states-<img width="11" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg99.png" alt="$ i$"/> such that <!-- MATH<br />
 $\sum_j P(i \rightarrow j) t_j = stop_i$<br />
 --><br />
<img width="187" height="39" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg119.png" alt="$ \sum_j P(i \rightarrow j) t_j = stop_i$"/> ). We also should by now have some insight as to why we used a linear program like <!-- MATH<br />
 $\min 1\cdot x \;\text{s.t.}\; A x \ge b$<br />
 --><br />
<img width="78" height="16" align="bottom" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg120.png" alt="$ \min 1\cdot x \;$"/>s.t.<img width="68" height="35" align="middle" border="0" src="http://www.win-vector.com/blog/wp-content/uploads/2009/08/stoimg121.png" alt="$ \; A x \ge b$"/> : the linear program is solving for the minimum value at each state that does not dip below the expected value of neighboring states.</p>
<p></p>
<hr />
<h4>Footnotes</h4>
<dl>
<dt><a name="foot10" id="foot10">&#8230; Mount</a><a href="#tex2html1"><sup>1</sup></a></dt>
<dd>http://www.mzlabs.com/</dd>
<dt><a name="foot21" id="foot21">&#8230; feeds.</a><a href="#tex2html2"><sup>2</sup></a></dt>
<dd>To emphasize; by technical trades we mean trades based on market data (as opposed to fundamental analysis) we do not include popular culture uses of the term such as candlesticks, Eliot waves and so on.</dd>
<dt><a name="foot22" id="foot22">&#8230; announcements.</a><a href="#tex2html3"><sup>3</sup></a></dt>
<dd>We are assuming that these triggers can be made automatic by using a labeled information service or natural language processing techniques.</dd>
<dt><a name="foot134" id="foot134">&#8230; estimate.</a><a href="#tex2html10"><sup>4</sup></a></dt>
<dd>The explosion of states can be managed by adding some regularity conditions on how transition probability estimates are allowed to change over time. This serves to reduce the complexity or rank of the estimation problem and improves the generalization ability of the model.</dd>
</dl>


<p>Related posts:<ol><li><a href='http://www.win-vector.com/blog/2009/03/what-does-the-market-think/' rel='bookmark' title='Permanent Link: What does the Market Think?'>What does the Market Think?</a></li>
<li><a href='http://www.win-vector.com/blog/2007/06/new-paper/' rel='bookmark' title='Permanent Link: New Paper'>New Paper</a></li>
<li><a href='http://www.win-vector.com/blog/2009/09/a-discrete-model-gauging-market-efficiency/' rel='bookmark' title='Permanent Link: A Discrete Model Gauging Market Efficiency'>A Discrete Model Gauging Market Efficiency</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.win-vector.com/blog/2007/10/paper-on-stock-trading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
