<?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>Numerical Method Inc.</title>
	<atom:link href="http://numericalmethod.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://numericalmethod.com/blog</link>
	<description>Mathematics @ Your Fingertips</description>
	<lastBuildDate>Fri, 24 May 2013 14:27:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Change of Measure/Girsanov&#8217;s Theorem Explained</title>
		<link>http://numericalmethod.com/blog/2013/05/16/change-of-measuregirsanovs-theorem-explained/</link>
		<comments>http://numericalmethod.com/blog/2013/05/16/change-of-measuregirsanovs-theorem-explained/#comments</comments>
		<pubDate>Wed, 15 May 2013 19:45:21 +0000</pubDate>
		<dc:creator>Haksun Li</dc:creator>
				<category><![CDATA[Seminars]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=1535</guid>
		<description><![CDATA[Change of Measure or Girsanov&#8217;s Theorem is such a [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: justify;">Change of Measure or Girsanov&#8217;s Theorem is such an important theorem in Real Analysis or Quantitative Finance. Unfortunately, I never really understood it until much later after having left school. I blamed it to the professors and the textbook authors, of course. <img title="Laughing" alt="Laughing" src="http://numericalmethod.com/blog/wp-content/plugins/ultimate-tinymce/addons/emotions/img/smiley-laughing.gif" border="0" /> The textbook version usually goes like this.</p>
<p>Given a probability space <img src='http://s.wordpress.com/latex.php?latex=%5C%7B%5COmega%2C%5Cmathcal%7BF%7D%2CP%5C%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\{\Omega,\mathcal{F},P\}' title='\{\Omega,\mathcal{F},P\}' class='latex' />, and a non-negative random variable Z satisfying <img src='http://s.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D%28Z%29%20%3D%201&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mathbb{E}(Z) = 1' title='\mathbb{E}(Z) = 1' class='latex' /> (why 1?). We then defined a new probability measure Q by the formula, for all <img src='http://s.wordpress.com/latex.php?latex=A%20%5Cin%20%5Cmathcal%7BF%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='A \in \mathcal{F}' title='A \in \mathcal{F}' class='latex' />.</p>
<p style="text-align: center;"><img src='http://s.wordpress.com/latex.php?latex=Q%28A%29%20%3D%20%5Cint%20_AZ%28%5Comega%29dP%28w%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Q(A) = \int _AZ(\omega)dP(w)' title='Q(A) = \int _AZ(\omega)dP(w)' class='latex' /></p>
<p style="text-align: justify;">Any random variable X, a measurable process adapted to the natural filtration of the <img src='http://s.wordpress.com/latex.php?latex=%5Cmathcal%7BF%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mathcal{F}' title='\mathcal{F}' class='latex' />, now has two expectations, one under the original probability measure P, which denoted as <img src='http://s.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D_P%28X%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mathbb{E}_P(X)' title='\mathbb{E}_P(X)' class='latex' />, and the other under the new probability measure Q, denoted as <img src='http://s.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D_Q%28X%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mathbb{E}_Q(X)' title='\mathbb{E}_Q(X)' class='latex' />. They are related to each other by the formula</p>
<p style="text-align: center;"><img src='http://s.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D_Q%28X%29%20%3D%20%5Cmathbb%7BE%7D_P%28XZ%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mathbb{E}_Q(X) = \mathbb{E}_P(XZ)' title='\mathbb{E}_Q(X) = \mathbb{E}_P(XZ)' class='latex' /></p>
<p style="text-align: justify;">If <img src='http://s.wordpress.com/latex.php?latex=P%28Z%20%3E%200%29%20%3D%201&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='P(Z &gt; 0) = 1' title='P(Z &gt; 0) = 1' class='latex' />, then P and Q agree on the null sets. We say Z is the Radon-Nikodym derivatives of Q with respect to P, and we write <img src='http://s.wordpress.com/latex.php?latex=Z%20%3D%20%5Cfrac%7BdQ%7D%7BdP%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Z = \frac{dQ}{dP}' title='Z = \frac{dQ}{dP}' class='latex' />. To remove the mean, μ, of a Brownian motion, we define</p>
<p style="text-align: center;"><img src='http://s.wordpress.com/latex.php?latex=Z%3D%5Cexp%20%5Cleft%20%28%20-%5Cmu%20X%20-%20%5Cfrac%7B1%7D%7B2%7D%20%5Cmu%5E2%20%5Cright%20%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Z=\exp \left ( -\mu X - \frac{1}{2} \mu^2 \right )' title='Z=\exp \left ( -\mu X - \frac{1}{2} \mu^2 \right )' class='latex' /></p>
<p style="text-align: justify;">Then under the probability measure Q, the random variable Y = X + μ is standard normal. In particular, <img src='http://s.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D_Q%28X%29%20%3D%200&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mathbb{E}_Q(X) = 0' title='\mathbb{E}_Q(X) = 0' class='latex' /> (so what?).</p>
<p style="text-align: justify;">This text made no sense to me when I first read it in school. It was very frustrated that the text was filled with unfamiliar terms like probability space and adaptation, and scary symbols like integration and <img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7BdQ%7D%7BdP%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{dQ}{dP}' title='\frac{dQ}{dP}' class='latex' />. (I knew what <img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7Bdy%7D%7Bdx%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{dy}{dx}' title='\frac{dy}{dx}' class='latex' /> meant when y was a function and x a variable. But what on earth were dQ over dP?)</p>
<p style="text-align: justify;">Now after I have become a professor to teach students in finance or financial math, I would get rid of all the jargon and rigorousness. I would focus on the intuition rather than the math details (traders are not mathematicians). Here is my laymen version.</p>
<p style="text-align: justify;">Given a probability measure P. A probability measure is just a function that assigns numbers to a random variable, e.g., 0.5 to head and 0.5 to tail for a fair coin. There could be another measure Q that assigns different numbers to the head and tail, say, 0.6 and 0.4 (an unfair coin)! Assume P and Q are equivalent, meaning that they agree on what events are possible (positive probabilities) and what events have 0 probability. Is there a relation between P and Q? It turns out to be a resounding yes!</p>
<p style="text-align: justify;">Let’s define <img src='http://s.wordpress.com/latex.php?latex=Z%3D%5Cfrac%7BQ%7D%7BP%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Z=\frac{Q}{P}' title='Z=\frac{Q}{P}' class='latex' />. Z here is a function as P and Q are just functions. Z is evaluated to be 0.6/0.5 and 0.4/0.5. Then we have</p>
<p style="text-align: center;"><img src='http://s.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D_Q%28X%29%20%3D%20%5Cmathbb%7BE%7D_P%28XZ%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mathbb{E}_Q(X) = \mathbb{E}_P(XZ)' title='\mathbb{E}_Q(X) = \mathbb{E}_P(XZ)' class='latex' /></p>
<p style="text-align: justify;">This is intuitively true when doing some symbol cancellation. Forget about the proof even though it is quite easy like 2 lines. We traders don’t care about proof. Therefore, the distribution of X under Q is (by plugging in the indicator function in the last equation):</p>
<p style="text-align: center;"><img src='http://s.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D_Q%28X%20%5Cin%20A%29%20%3D%20%5Cmathbb%7BE%7D_P%28I%28X%20%5Cin%20A%29Z%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mathbb{E}_Q(X \in A) = \mathbb{E}_P(I(X \in A)Z)' title='\mathbb{E}_Q(X \in A) = \mathbb{E}_P(I(X \in A)Z)' class='latex' /></p>
<p style="text-align: justify;">Moreover, setting X = 1, we have (Z here is a random variable):</p>
<p style="text-align: center;"><img src='http://s.wordpress.com/latex.php?latex=%5Cmathbb%7BE%7D_Q%28X%29%20%3D%201%20%3D%20%5Cmathbb%7BE%7D_P%28Z%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mathbb{E}_Q(X) = 1 = \mathbb{E}_P(Z)' title='\mathbb{E}_Q(X) = 1 = \mathbb{E}_P(Z)' class='latex' /></p>
<p style="text-align: justify;">These results hold in general, especially for the Gaussian random variable and hence Brownian motion. Suppose we have a random (i.e., stochastic) process generated by (adapted to) a Brownian motion and it has a drift μ under a probability measure P. We can find an equivalent measure Q so that under Q, this random process has a 0 drift. Wiki has a <a href="http://en.wikipedia.org/wiki/File:Girsanov.png">picture</a> that shows the same random process under the two different measures: each of the 30 paths in the picture has a different probability under P and Q.</p>
<p style="text-align: justify;">The change of measure, Z, is a function of the original drift (as would be guessed) and is given by:</p>
<p style="text-align: center;"><img src='http://s.wordpress.com/latex.php?latex=Z%3D%5Cexp%20%5Cleft%20%28%20-%5Cmu%20X%20-%20%5Cfrac%7B1%7D%7B2%7D%20%5Cmu%5E2%20%5Cright%20%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Z=\exp \left ( -\mu X - \frac{1}{2} \mu^2 \right )' title='Z=\exp \left ( -\mu X - \frac{1}{2} \mu^2 \right )' class='latex' /></p>
<p style="text-align: justify;">For a 0 drift process, hence no increment, the expectation of the future value of the process is the same as the current value (a laymen way of saying that the process is a martingale.) Therefore, with the ability to remove the drift of any random process (by finding a suitable Q using the Z formula), we are ready to do options pricing.</p>
<p style="text-align: justify;">Now, if you understand my presentation and go back to the textbook version, you should have a much better understanding and easier read, I hope.</p>
<p>References:</p>
<ul>
<li><span style="line-height: 13px;"><a href="http://www.amazon.com/Stochastic-Calculus-Finance-II-Continuous-Time/dp/0387401016/ref=sr_1_3?ie=UTF8&amp;qid=1368646418&amp;sr=8-3&amp;keywords=shreve+e+stochastic+calculus">Stochastic Calculus for Finance II: Continuous-Time Models, Steven Shreve</a><br />
</span></li>
<li><a href="http://www.amazon.com/Introduction-Stochastic-Calculus-Applications-3rd/dp/1848168314/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1368646460&amp;sr=1-1&amp;keywords=introduction+to+stochastic+calculus+with+applications">Introduction To Stochastic Calculus With Applications (3rd Edition), Fima C. Klebaner</a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2013/05/16/change-of-measuregirsanovs-theorem-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mean-Variance Portfolio Optimization When Means And Covariances Are Unknown</title>
		<link>http://numericalmethod.com/blog/2013/02/16/mean-variance-portfolio-optimization-when-means-and-covariances-are-unknown/</link>
		<comments>http://numericalmethod.com/blog/2013/02/16/mean-variance-portfolio-optimization-when-means-and-covariances-are-unknown/#comments</comments>
		<pubDate>Sat, 16 Feb 2013 05:50:56 +0000</pubDate>
		<dc:creator>Ken Yiu</dc:creator>
				<category><![CDATA[AlgoQuant]]></category>
		<category><![CDATA[Algorithmic Trading]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=1291</guid>
		<description><![CDATA[[Lai, Xing and Chen, 2010], in the paper &#8220;Mean-Va [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: justify">[Lai, Xing and Chen, 2010], in the paper &#8220;Mean-Variance Portfolio Optimization When Means And Covariances Are Unknown&#8221;, proposed a ground breaking method to do portfolio optimization. In what follows we summarize their idea and use it to implement a periodic rebalancing strategy based on the <a title="AlgoQuant" href="http://numericalmethod.com/blog/algoquant/" target="_blank">AlgoQuant</a> framework.</p>
<div class="wp-caption alignright" style="width: 192px"><a href="http://upload.wikimedia.org/wikipedia/commons/e/e1/Markowitz_frontier.jpg" target="_blank"><img class="  " alt="efficient frontier" src="http://upload.wikimedia.org/wikipedia/commons/e/e1/Markowitz_frontier.jpg" width="182" height="100" /></a><p class="wp-caption-text">efficient frontier</p></div>
<p style="text-align: justify">Harry Markowitz won the Nobel prize for his work in mean-variance (MV) portfolio optimization in 1950s. The theory is widely regarded as fundamental in financial economics. It says, given a target return of a portfolio of m assets, the optimal (in terms of information ratio) weighting <img src='http://s.wordpress.com/latex.php?latex=w_%7Beff%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='w_{eff}' title='w_{eff}' class='latex' /> is given by</p>
<p style="text-align: center"><img src='http://s.wordpress.com/latex.php?latex=w_%7Beff%7D%3D%5Carg%20%5Cmin_w%20w%5ET%20%5CSigma%20w%20%5Ctext%7B%20subject%20to%20%7D%20w%5ET%5Cmu%20%3D%20%5Cmu_%2A%2C%20w%5ET1%20%3D%201&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='w_{eff}=\arg \min_w w^T \Sigma w \text{ subject to } w^T\mu = \mu_*, w^T1 = 1' title='w_{eff}=\arg \min_w w^T \Sigma w \text{ subject to } w^T\mu = \mu_*, w^T1 = 1' class='latex' /></p>
<p style="text-align: justify">where <img src='http://s.wordpress.com/latex.php?latex=%5Cmu&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mu' title='\mu' class='latex' /> is the <em>expected future</em> returns, and <img src='http://s.wordpress.com/latex.php?latex=%5CSigma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\Sigma' title='\Sigma' class='latex' /> is the <em>expected</em> covariance matrix of <em>future</em> returns. This problem is readily solved by <em>quadratic programming</em>.</p>
<p style="text-align: justify">Nonetheless, the assumption that <img src='http://s.wordpress.com/latex.php?latex=%5Cmu&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mu' title='\mu' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=%5CSigma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\Sigma' title='\Sigma' class='latex' /> are known in advance is very dubious. This has been referred to as the &#8220;Markowitz optimization engima&#8221;. The attempts made so far are to better forecast these estimators, namely <img src='http://s.wordpress.com/latex.php?latex=%5Chat%7B%5Cmu%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\hat{\mu}' title='\hat{\mu}' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=%5Chat%7B%5CSigma%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\hat{\Sigma}' title='\hat{\Sigma}' class='latex' />, as accurately as possible. The maximum likelihood estimate (MLE) from the training sample is an example. It turns out, however, that MLE performs poorly because the estimators are quite different from the realized values [Michaud, 1989]. Since then, three approaches have been proposed to address the difficulty. The first approach uses a multi-factor model to reduce the dimensionality in estimating <img src='http://s.wordpress.com/latex.php?latex=%5CSigma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\Sigma' title='\Sigma' class='latex' /> [Fan, Fan and Lv, 2008]. The second approach uses Bayes or other shrinkage estimates of <img src='http://s.wordpress.com/latex.php?latex=%5CSigma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\Sigma' title='\Sigma' class='latex' /> [Ledoit and Wolf, 2004]. Both approaches attempt to use improved estimates of  <img src='http://s.wordpress.com/latex.php?latex=%5CSigma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\Sigma' title='\Sigma' class='latex' /> for the plug-in efficient frontier. They have also been modified to provide better estimates of <img src='http://s.wordpress.com/latex.php?latex=%5Cmu&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mu' title='\mu' class='latex' />, for example, in the quasi-Bayesian approach of [Black and Litterman, 1990]. The third approach uses bootstrapping to correct for the bias of <img src='http://s.wordpress.com/latex.php?latex=%5Chat%7Bw%7D_%7Beff%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\hat{w}_{eff}' title='\hat{w}_{eff}' class='latex' /> as an estimate of <img src='http://s.wordpress.com/latex.php?latex=w_%7Beff%7D.&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='w_{eff}.' title='w_{eff}.' class='latex' /></p>
<p style="text-align: justify">The innovation in [Lai, Xing and Chen, 2010] is to move away from the traditional approach of finding better estimators. They instead assume inherent uncertainty, hence risk, in these estimators. In other words, because the mean and covariance matrix of <em>future returns</em> are estimated from past returns, the <strong>uncertainties of these estimators</strong> should be incorporated into the portfolio <strong>risk</strong>. The authors formulate a <strong>stochastic optimization framework</strong> which solves a more fundamental problem. Given the past returns <img src='http://s.wordpress.com/latex.php?latex=r_1%2C%20%5Cldots%2C%20r_n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='r_1, \ldots, r_n' title='r_1, \ldots, r_n' class='latex' />,</p>
<p style="text-align: center">maximize <img src='http://s.wordpress.com/latex.php?latex=%5Cleft%20%5C%7BE%28w%5ETr_%7Bn%2B1%7D%29%20-%20%5Clambda%20Var%28w%5ETr_%7Bn%2B1%7D%29%5Cright%20%5C%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\left \{E(w^Tr_{n+1}) - \lambda Var(w^Tr_{n+1})\right \}' title='\left \{E(w^Tr_{n+1}) - \lambda Var(w^Tr_{n+1})\right \}' class='latex' /></p>
<p style="text-align: justify">where <img src='http://s.wordpress.com/latex.php?latex=w%5ETr_%7Bn%2B1%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='w^Tr_{n+1}' title='w^Tr_{n+1}' class='latex' /> is now regarded as a random variable conditional on the past returns, and <img src='http://s.wordpress.com/latex.php?latex=%5Clambda&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\lambda' title='\lambda' class='latex' /> is a <em>risk-aversion index</em> (investor&#8217;s preference).</p>
<p>This stochastic optimization problem is not standard due to the <img src='http://s.wordpress.com/latex.php?latex=E%28.%29%5E2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='E(.)^2' title='E(.)^2' class='latex' /> term in <img src='http://s.wordpress.com/latex.php?latex=Var%28.%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Var(.)' title='Var(.)' class='latex' /> (<img src='http://s.wordpress.com/latex.php?latex=Var%28X%29%20%3D%20E%5BX%5E2%5D%20-%20%28E%5BX%5D%29%5E2&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='Var(X) = E[X^2] - (E[X])^2' title='Var(X) = E[X^2] - (E[X])^2' class='latex' />). To tackle this problem, the authors solve instead an equivalent stochastic optimization problem:</p>
<p style="text-align: center"><img src='http://s.wordpress.com/latex.php?latex=%5Cmax_%7B%5Ceta%7D%20%5C%7BE%5Bw%5ET%28%5Ceta%29r_%7Bn%2B1%7D%5D%20-%20%5Clambda%20Var%5Bw%5ET%28%5Ceta%29r_%7Bn%2B1%7D%5D%5C%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\max_{\eta} \{E[w^T(\eta)r_{n+1}] - \lambda Var[w^T(\eta)r_{n+1}]\}' title='\max_{\eta} \{E[w^T(\eta)r_{n+1}] - \lambda Var[w^T(\eta)r_{n+1}]\}' class='latex' /></p>
<p style="text-align: justify">where</p>
<p style="text-align: center"><img src='http://s.wordpress.com/latex.php?latex=w%28%5Ceta%29%20%3D%20%5Carg%20%5Cmin_w%20%5C%7B%5Clambda%20E%5B%28w%5ETr_%7Bn%2B1%7D%29%5E2%5D%20-%20%5Ceta%20E%28w%5ETr_%7Bn%2B1%7D%29%20%5C%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='w(\eta) = \arg \min_w \{\lambda E[(w^Tr_{n+1})^2] - \eta E(w^Tr_{n+1}) \}' title='w(\eta) = \arg \min_w \{\lambda E[(w^Tr_{n+1})^2] - \eta E(w^Tr_{n+1}) \}' class='latex' /></p>
<p style="text-align: justify">and</p>
<p style="text-align: center"><img src='http://s.wordpress.com/latex.php?latex=%5Ceta%20%3D%201%20%2B%202%5Clambda%20E%28W_B%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\eta = 1 + 2\lambda E(W_B)' title='\eta = 1 + 2\lambda E(W_B)' class='latex' /></p>
<p style="text-align: justify">Next, define the function</p>
<p style="text-align: center"><img src='http://s.wordpress.com/latex.php?latex=C_%7B%5Clambda%2C%5Cmu_n%2CV_n%7D%28%5Ceta%29%20%3D%20E%5Bw%5ET%28%5Ceta%29%5Cmu_n%5D%20%2B%20%5Clambda%20%28E%5Bw%5ET%28%5Ceta%29%5Cmu_n%5D%29%5E2%20-%20%5Clambda%20E%5Bw%5ET%28%5Ceta%29%20V_n%20w%28%5Ceta%29%5D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='C_{\lambda,\mu_n,V_n}(\eta) = E[w^T(\eta)\mu_n] + \lambda (E[w^T(\eta)\mu_n])^2 - \lambda E[w^T(\eta) V_n w(\eta)]' title='C_{\lambda,\mu_n,V_n}(\eta) = E[w^T(\eta)\mu_n] + \lambda (E[w^T(\eta)\mu_n])^2 - \lambda E[w^T(\eta) V_n w(\eta)]' class='latex' /></p>
<p style="text-align: justify">where <img src='http://s.wordpress.com/latex.php?latex=%5Cmu_n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mu_n' title='\mu_n' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=V_n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='V_n' title='V_n' class='latex' /> are the first and second moments of returns. The problem now becomes maximizing <img src='http://s.wordpress.com/latex.php?latex=C_%7B%5Clambda%2C%5Cmu_n%2CV_n%7D%28%5Ceta%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='C_{\lambda,\mu_n,V_n}(\eta)' title='C_{\lambda,\mu_n,V_n}(\eta)' class='latex' /> which can be achieved by any univariate maximization algorithm such as <a href="http://en.wikipedia.org/wiki/Brent's_method" target="_blank">Brent&#8217;s method</a> (<a href="http://www.numericalmethod.com/javadoc/suanshu/com/numericalmethod/suanshu/optimization/univariate/bracketsearch/BrentMinimizer.html" target="_blank">BrentMinimizer</a> in <a title="SuanShu" href="http://numericalmethod.com/blog/suanshu/" target="_blank">SuanShu</a> can be used to minimize the negative of this function).</p>
<p style="text-align: justify">The remaining task is to estimate <img src='http://s.wordpress.com/latex.php?latex=%5Cmu_n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mu_n' title='\mu_n' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=V_n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='V_n' title='V_n' class='latex' /> to plug into <img src='http://s.wordpress.com/latex.php?latex=C_%7B%5Clambda%2C%5Cmu_n%2CV_n%7D%28%5Ceta%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='C_{\lambda,\mu_n,V_n}(\eta)' title='C_{\lambda,\mu_n,V_n}(\eta)' class='latex' />. <img src='http://s.wordpress.com/latex.php?latex=%5Cmu_n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mu_n' title='\mu_n' class='latex' /> can be estimated by, for example, bootstrapping, a multi-factor model, a GARCH model, etc. Similarly, <img src='http://s.wordpress.com/latex.php?latex=V_n%20%3D%20%5CSigma%20%2B%20%5Cmu_n%20%5Cmu_n%5ET&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='V_n = \Sigma + \mu_n \mu_n^T' title='V_n = \Sigma + \mu_n \mu_n^T' class='latex' /> can be estimated by first estimating the sample covariance matrix <img src='http://s.wordpress.com/latex.php?latex=%5CSigma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\Sigma' title='\Sigma' class='latex' />. As <img src='http://s.wordpress.com/latex.php?latex=%5CSigma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\Sigma' title='\Sigma' class='latex' /> may be unstable when the sample size is small, our implementation uses a covariance-shrinkage method described in [Ledoit and Wolf 2004].</p>
<p style="text-align: justify">Putting all these steps together, the algorithm to compute the optimal weighting looks like this:<br />
<code></code></p>
<ol style="text-align: justify">
<li>Estimate <img src='http://s.wordpress.com/latex.php?latex=%5Cmu_n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\mu_n' title='\mu_n' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=V_n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='V_n' title='V_n' class='latex' /> from past returns</li>
<li>Estimate <img src='http://s.wordpress.com/latex.php?latex=a%20%3D%20E%5Bw%5ET%28%5Ceta%29%5Cmu_n%5D%2C%20b%20%3D%20E%5Bw%5ET%28%5Ceta%29V_nw%28%5Ceta%29%5D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='a = E[w^T(\eta)\mu_n], b = E[w^T(\eta)V_nw(\eta)]' title='a = E[w^T(\eta)\mu_n], b = E[w^T(\eta)V_nw(\eta)]' class='latex' /></li>
<li>Construct the univariate real function <img src='http://s.wordpress.com/latex.php?latex=C_%7B%5Clambda%2C%5Cmu_n%2CV_n%7D%28%5Ceta%29%20%3D%20a%20%2B%20%5Clambda%20a%5E2%20-%20%5Clambda%20b&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='C_{\lambda,\mu_n,V_n}(\eta) = a + \lambda a^2 - \lambda b' title='C_{\lambda,\mu_n,V_n}(\eta) = a + \lambda a^2 - \lambda b' class='latex' /></li>
<li>Maximize <img src='http://s.wordpress.com/latex.php?latex=C_%7B%5Clambda%2C%5Cmu_n%2CV_n%7D%28%5Ceta%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='C_{\lambda,\mu_n,V_n}(\eta)' title='C_{\lambda,\mu_n,V_n}(\eta)' class='latex' /> over <img src='http://s.wordpress.com/latex.php?latex=%5Ceta&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\eta' title='\eta' class='latex' /></li>
<li>Compute the optimal weighting <img src='http://s.wordpress.com/latex.php?latex=w%5E%2A%20%3D%20w%28%5Ceta%5E%2A%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='w^* = w(\eta^*)' title='w^* = w(\eta^*)' class='latex' /> using the optimal <img src='http://s.wordpress.com/latex.php?latex=%5Ceta%5E%2A&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\eta^*' title='\eta^*' class='latex' /></li>
</ol>
<p style="text-align: justify"><code></code>We have implemented this algorithm in AlgoQuant as a component/module/<a href="http://www.numericalmethod.com/trac/numericalmethod/browser/algoquant/core/src/main/java/com/numericalmethod/algoquant/model/signal/Signal.java" target="_blank">signal</a>. Using our component based programming paradigm, it is easy to modify the steps in the implementation without a lot of changes to the code. For instance, we can pass in the constructor of <code>Lai2010NPEBModel</code> a <code>GridSearchCetaMaximizer</code> object instead of a <code>BrentCetaMaximizer</code> object to change the algorithm to maximize <img src='http://s.wordpress.com/latex.php?latex=C%28%5Ceta%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='C(\eta)' title='C(\eta)' class='latex' />.</p>
<p>In addition, we have coded up a <a href="http://www.numericalmethod.com/trac/numericalmethod/browser/algoquant/core/src/main/java/com/numericalmethod/algoquant/execution/strategy/Strategy.java" target="_blank">trading strategy</a> using Lai&#8217;s portfolio optimization algorithm as a signal. This strategy re-balances periodically a basket of assets according to the optimal weighting computed by the model. Specifically, <code><a href="http://www.numericalmethod.com/trac/numericalmethod/browser/algoquant/core/src/main/java/com/numericalmethod/algoquant/execution/strategy/handler/DepthHandler.java" target="_blank">onDepthUpdate()</a></code>, collects the returns series using the component <code><a href="http://www.numericalmethod.com/trac/numericalmethod/browser/algoquant/core/src/main/java/com/numericalmethod/algoquant/model/returns/ReturnSeries.java" target="_blank">ReturnSeries</a></code> with its <code>update()</code> method. Then, <code><a href="http://www.numericalmethod.com/trac/numericalmethod/browser/algoquant/core/src/main/java/com/numericalmethod/algoquant/execution/strategy/handler/TimerHandler.java" target="_blank">onTimerUpdate()</a></code> is triggered periodically (say, every 3 months) to call the model (passing in the returns matrix) and to send orders to re-balance the assets accordingly. We backtest this trading strategy using the <code><a href="http://www.numericalmethod.com/trac/numericalmethod/browser/algoquant/core/src/main/java/com/numericalmethod/algoquant/execution/simulator/Simulator.java" target="_blank">Simulator</a></code> object together with the historical data from Yahoo! Finance (or other data sources).</p>
<p>An online demonstration can be found <a href="http://www.numericalmethod.com:8080/nmj2ee-war/faces/webdemo/lai2010.xhtml" target="_blank">here</a>.</p>
<h3 style="text-align: justify">References</h3>
<ul style="text-align: justify">
<li>Black, F. and Litterman, R. (1990). Asset Allocation: Combining Investor Views with Market Equilibrium. Goldman, Sachs &amp; Co., New York.</li>
<li>Fan, J, Fan, Y and Lv, J. (2008). High dimensional covariance matrix estimation using a factor model. J. Econometrics 147 186-197.</li>
<li>Lai, T. L., Xing, H. and Chen Z. (2010). Mean-variance portfolio optimization when means and covariances are unknown. Annals of Applied Statistics 2011, Vol. 5, No. 2A, p. 798-823.</li>
<li>Ledoit, P. and Wolf, M. (2004). Honey, I shrunk the sample covariance matrix. J. Portfolio Management 30 110–119.</li>
<li>Michaud, R. O. (1989). Efficient Asset Management. Harvard Business School Press, Boston.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2013/02/16/mean-variance-portfolio-optimization-when-means-and-covariances-are-unknown/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FREE .NET/C# Numerical/Math library</title>
		<link>http://numericalmethod.com/blog/2012/12/25/dotnet-csharp-numerical-math-library/</link>
		<comments>http://numericalmethod.com/blog/2012/12/25/dotnet-csharp-numerical-math-library/#comments</comments>
		<pubDate>Tue, 25 Dec 2012 13:52:40 +0000</pubDate>
		<dc:creator>Haksun Li</dc:creator>
				<category><![CDATA[SuanShu]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=1259</guid>
		<description><![CDATA[On this Christmas Day, we are happy to announce that Su [...]]]></description>
				<content:encoded><![CDATA[<p>On this Christmas Day, we are happy to announce that SuanShu.net is <strong>FREE</strong> for all! SuanShu.net has all the <a title="SuanShu features" href="http://www.numericalmethod.com/trac/numericalmethod/wiki/SuanShuFeatures" target="_blank">features</a> as its Java sibling as well as has undergone the same many thousands of test cases daily.</p>
<p>There are a <a title="SuanShu.net tutorial" href="http://www.numericalmethod.com/trac/numericalmethod/wiki/SuanShuDotNet" target="_blank">tutorial</a> and <a title="SuanShu.net examples" href="http://www.numericalmethod.com/trac/numericalmethod/browser/public/SuanShu.NET" target="_blank">examples</a> that show you how to build a SuanShu application in Visual Studio. One major advantage of using SuanShu.net over the Java version is that it integrates seamlessly with Microsoft Excel. By <a title="Integrating SuanShu with Microsoft Excel" href="http://www.numericalmethod.com/trac/numericalmethod/wiki/SuanShuExcel" target="_blank">incorporating SuanShu library in your spreadsheet</a>, you literally have access to hundreds of numerical algorithms when manipulating and analyzing your data, significantly enhancing Excel&#8217;s productivity.</p>
<p>We hope that you enjoy using SuanShu.net in your work. If you have any interesting story, comments or feedback, we&#8217;d love to hear from you.</p>
<p>Starting <a title="SuanShu download" href="http://numericalmethod.com/blog/suanshu/" target="_blank">downloading SuanShu.net</a> now!</p>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2012/12/25/dotnet-csharp-numerical-math-library/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bloomberg Tick-By-Tick Data Download</title>
		<link>http://numericalmethod.com/blog/2012/12/21/bloomberg-tick-by-tick-data-download/</link>
		<comments>http://numericalmethod.com/blog/2012/12/21/bloomberg-tick-by-tick-data-download/#comments</comments>
		<pubDate>Fri, 21 Dec 2012 06:15:06 +0000</pubDate>
		<dc:creator>Ken Yiu</dc:creator>
				<category><![CDATA[AlgoQuant]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=1248</guid>
		<description><![CDATA[Bloomberg maintains tick-by-tick historical data for on [...]]]></description>
				<content:encoded><![CDATA[<p>Bloomberg maintains tick-by-tick historical data for only 140 days. However, you may want to backtest your strategies with a longer history. In this case, you can archive these tickdata by yourself and do backtesting with the archived data. Since version 0.2, AlgoQuant supports downloading tick-by-tick data from Bloomberg and saving them as CSV files via the <strong>Bloomberg Java API</strong> v3 (assuming that you have access to a Bloomberg terminal).</p>
<p>After you download the <a title="AlgoQuant" href="http://numericalmethod.com/blog/algoquant/" target="_blank">AlgoQuant package</a>, you will find that there is a folder <code>lib/blpapi-dummy</code> which contains the Bloomberg API jar file (<code><strong>blpapi3.jar</strong></code>). This file is a dummy for AlgoQuant to compile. To use the Bloomberg Java API, you need to replace the file with the real API jar file. If your machine has been deployed the Bloomberg API, you can find the real jar file in your hard drive, for example,</p>
<blockquote><p><code>C:\blp\API\APIv3\JavaAPI\v3.4.3.2\lib\blpapi3.jar</code></p></blockquote>
<p>Note that the version number of the API may be automatically upgraded by Bloomberg.</p>
<p>The code for connecting, downloading and saving the tickdata is located in the package <strong><code>com.numericalmethod.algoquant.data.historicaldata.bloomberg</code></strong>.  You can find in the package a simple demo application &#8220;<code>TickDataDownloadApp</code>&#8220;, which accepts command-line arguments and downloads tickdata of a given period for a given security:</p>
<blockquote><p><code>Usage: TickDataDownloadApp &lt;security&gt; &lt;startDate (yyyy-MM-dd)&gt; &lt;endDate (yyyy-MM-dd)&gt; &lt;output dir&gt;</code></p></blockquote>
<p>Note that the start date should be within 140 days as it is the oldest history you can download from Bloomberg.</p>
<p>Here is how it works. The Bloomberg system provides a core service named &#8220;<code>//blp/refdata</code>&#8221; which allows downloading a wide range of market data. The code opens a session to connect to the <code>localhost</code> at port <code>8194</code> (change the settings in <code>SimpleSessionFactory</code> if you are using a different port). Then, it sends the <code>IntradayTickRequest</code> with the security symbol, start and end dates. Upon receiving the response, the <code>BloombergTickDataFileWriter</code> saves the data as zipped CSV files in the specified output folder (one file per trading day). For example,</p>
<blockquote><p><code>TickDataDownloadApp "5 HK Equity" 2012-12-01 2012-12-21 data</code></p></blockquote>
<p>will save the data as <code>.csv.zip</code> files in the folder &#8220;<code>data/5 HK Equity</code>&#8220;.</p>
<p>Since AlgoQuant is source-available, you are free to change the code to download different data, or save the data into your database instead of files.</p>
<p>&nbsp;</p>
<p>Happy downloading data! <img src='http://numericalmethod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<p><strong>Reference</strong>: <em>Bloomberg API Version 3.x Developer&#8217;s Guide</em></p>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2012/12/21/bloomberg-tick-by-tick-data-download/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SuanShu 2.0</title>
		<link>http://numericalmethod.com/blog/2012/12/13/suanshu-2-0/</link>
		<comments>http://numericalmethod.com/blog/2012/12/13/suanshu-2-0/#comments</comments>
		<pubDate>Thu, 13 Dec 2012 15:43:31 +0000</pubDate>
		<dc:creator>Haksun Li</dc:creator>
				<category><![CDATA[SuanShu]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=1168</guid>
		<description><![CDATA[We are proud to announce the release of SuanShu 2.0! Th [...]]]></description>
				<content:encoded><![CDATA[<p>We are proud to announce the release of SuanShu 2.0! This release is the accumulation of customer feedbacks and our experience learnt in the last three years coding numerical computation algorithms. SuanShu 2.0 is a redesign of the software architecture, a rewrite of many modules, additions of new modules and functionalities driven by user demands and applications, numerous bug fixes as well as performance tuning. We believe that SuanShu 2.0 is the best numerical and statistical library ever available in Java, if not all, platform.</p>
<p>Here are highlights of the new features available since 2.0.</p>
<p>-          ordinary and partial differential equation solvers</p>
<p>-          Optimization: Quadratic Programming,  Sequential Quadratic Programming, (Mixed) Integer Linear Programming, Semi-Definite Programming</p>
<p>-          ARIMA fit</p>
<p>-          LASSO and LARS</p>
<p>-          Gaussian quadrature/integration</p>
<p>-          Interpolation methods</p>
<p>-          Trigonometric functions and physical constants</p>
<p>-          Extreme Value Theory</p>
<p>Continuing our tradition, we will still provide trial license and academic license for eligible schools and research institutes. Moreover, we now provide another way to get a FREE SuanShu license – the contribution license. If you are able to contribute code to the SuanShu library, you can get a permanent license. For more information, see: <a title="SuanShu 2.0 Contributor License" href="http://numericalmethod.com/blog/suanshu/" target="_blank">http://numericalmethod.com/blog/suanshu/</a></p>
<p>We hope that you will find the new release of SuanShu more helpful than ever in your work. If you have any comments to help us improve, <a href="mailto:info@numericalmethod.com?Subject=SuanShu feedback">please do let us know.</a></p>
<p>Happy birthday to TianTians and Merry Christmas to all!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2012/12/13/suanshu-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trading and Investment as a Science</title>
		<link>http://numericalmethod.com/blog/2012/09/03/trading-and-investment-as-a-science/</link>
		<comments>http://numericalmethod.com/blog/2012/09/03/trading-and-investment-as-a-science/#comments</comments>
		<pubDate>Sun, 02 Sep 2012 23:38:13 +0000</pubDate>
		<dc:creator>Haksun Li</dc:creator>
				<category><![CDATA[Algorithmic Trading]]></category>
		<category><![CDATA[Investment]]></category>
		<category><![CDATA[Seminars]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=1092</guid>
		<description><![CDATA[Here is the synopsis of my presentation at HKSFA, Septe [...]]]></description>
				<content:encoded><![CDATA[<p>Here is the synopsis of my presentation at <a title="HKSFA presentation" href="http://www.hksfa.org/form.asp?id=273" target="_blank">HKSFA, September 2012</a>. The presentation can be downloaded from <a title="Trading and Investment As a Science" href="http://numericalmethod.com/papers/Trading%20and%20Investment%20As%20A%20Science.pdf" target="_blank">here</a>.</p>
<p>1.</p>
<p>Many people lose money playing the stock market. The strategies they use are nothing but superstitions. There is no scientific reason why, for example, buying on a breakout of the 250-day-moving average, would make money. Trading profits do not come from wishful thinking, ad-hoc decision, gambling, and hearsay, but diligent systematic study.<br />
• Moving average as a superstitious trading strategy.</p>
<p>2.</p>
<p>Many professionals make money playing the stock market. One approach to investment decision or trading strategy is to treat it as a science. Before we make the first trade, we want to know how much money we expect to make. We want to know in what situations the strategy will make (or lose) money and how much.<br />
• Moving average as a scientific trading strategy</p>
<p>3.</p>
<p>There are many mathematical tools and theories that we can use to quantify, analyse, and verify a trading strategy. We will show case some popular ones.<br />
• Markov chain (a trend-following strategy)<br />
• Cointegration (a mean-revision strategy)<br />
• Stochastic differential equations (the best trading strategy, ever!)<br />
• Extreme value theory (risk management, stop-loss)<br />
• Monte Carlo simulation (what are the success factors in a trading strategy?)</p>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2012/09/03/trading-and-investment-as-a-science/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SuanShu on Amazon EC2</title>
		<link>http://numericalmethod.com/blog/2012/05/21/using-suanshu-on-amazon-ec2/</link>
		<comments>http://numericalmethod.com/blog/2012/05/21/using-suanshu-on-amazon-ec2/#comments</comments>
		<pubDate>Mon, 21 May 2012 11:51:02 +0000</pubDate>
		<dc:creator>Ken Yiu</dc:creator>
				<category><![CDATA[SuanShu]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=371</guid>
		<description><![CDATA[Cloud computing is very popular nowadays. Delegating yo [...]]]></description>
				<content:encoded><![CDATA[<p>Cloud computing is very popular nowadays. Delegating your CPU-intensive computation (or simulation) to the cloud seems to be a smart choice. Many of our users asked if <a href="http://www.numericalmethod.com/wiki/numericalmethod/wiki/SuanShu">SuanShu</a> can be run on Amazon&#8217;s Elastic Compute Cloud (EC2), because SuanShu license requires a <a href="http://en.wikipedia.org/wiki/MAC_address">MAC address</a> and they have no control on which machine being used when they launch an EC2 instance. Here comes a good news! Amazon Web Service (AWS) now supports Elastic Network Interface (ENI), by which you can bind your EC2 instance to a specified network interface. Therefore, you can license your SuanShu against the MAC address of the ENI, and launch an instance with the same ENI and MAC address. For details, please visit the blog <a href="http://aws.typepad.com/aws/2011/12/new-elastic-network-interfaces-in-the-virtual-private-cloud.html">here</a>. User guide for ENI can also be found <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using-eni.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2012/05/21/using-suanshu-on-amazon-ec2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data Mining</title>
		<link>http://numericalmethod.com/blog/2012/02/12/data-mining/</link>
		<comments>http://numericalmethod.com/blog/2012/02/12/data-mining/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 20:37:12 +0000</pubDate>
		<dc:creator>Haksun Li</dc:creator>
				<category><![CDATA[Algorithmic Trading]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=334</guid>
		<description><![CDATA[The good quant trading models reveal the nature of the  [...]]]></description>
				<content:encoded><![CDATA[<p>The good quant trading models reveal the nature of the market; the bad ones are merely statistical artifacts.</p>
<p>One most popular way to create spurious trading model is data snooping or data mining. Suppose we want to create a model to trade AAPL daily. We download some data of, e.g., 100 days of <a title="AAPL" href="http://www.numericalmethod.com/wiki/numericalmethod/browser/algoquant/algoquant/src/com/numericalmethod/algoquant/execution/product/equity/usa/nasdaq/AAPL.java" target="_blank">AAPL</a>, from Yahoo. If we work hard enough with the data, we will find a curve (model) that explains the data very well. For example, the following curve perfectly fits the data.</p>
<p>Suppose the prices are <img src='http://s.wordpress.com/latex.php?latex=%5C%7B%20x_1%2C%20x_2%2C%20%5Cdots%20x_n%20%5C%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\{ x_1, x_2, \dots x_n \}' title='\{ x_1, x_2, \dots x_n \}' class='latex' /></p>
<img src='http://s.wordpress.com/latex.php?latex=%5Cfrac%7B%28t-2%29%5Cdots%28t-n%29%7D%7B%281-2%29%5Cdots%281-n%29%7D%28x_1%29%20%2B%20%5Cfrac%7B%28t-1%29%5Cdots%28t-n%29%7D%7B%282-1%29%5Cdots%282-n%29%7D%28x_2%29%20%2B%20%5Cdots%20%2B%20%5Cfrac%7B%28t-1%29%5Cdots%28t-n%2B1%29%7D%7B%28n-1%29%5Cdots%28n-n%2B1%29%7D%28x_n%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\frac{(t-2)\dots(t-n)}{(1-2)\dots(1-n)}(x_1) + \frac{(t-1)\dots(t-n)}{(2-1)\dots(2-n)}(x_2) + \dots + \frac{(t-1)\dots(t-n+1)}{(n-1)\dots(n-n+1)}(x_n)' title='\frac{(t-2)\dots(t-n)}{(1-2)\dots(1-n)}(x_1) + \frac{(t-1)\dots(t-n)}{(2-1)\dots(2-n)}(x_2) + \dots + \frac{(t-1)\dots(t-n+1)}{(n-1)\dots(n-n+1)}(x_n)' class='latex' />
<p>Of course, most of us are judicious enough to avoid this obvious over-fitting formula. Unfortunately, some may fall into the trap of it in disguise. Let’s say we want to understand what factors contribute to the AAPL price movements or returns. (We now have 99 returns.) We come up with a list of 99 possible factors, such as PE, capitalization, dividends, etc. One very popular method to find significant factors is linear regression. So, we have</p>
<img src='http://s.wordpress.com/latex.php?latex=r_t%20%3D%20%5Calpha%20%2B%20%5Cbeta_1f_%7B1t%7D%20%2B%20%5Cdots%20%2B%20%5Cbeta_99f_%7B99t%7D%20%2B%20%5Cepsilon_t&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='r_t = \alpha + \beta_1f_{1t} + \dots + \beta_99f_{99t} + \epsilon_t' title='r_t = \alpha + \beta_1f_{1t} + \dots + \beta_99f_{99t} + \epsilon_t' class='latex' />
<p>Guess how well this fits? The goodness-of-fit (R-squared) turns out be 100% &#8211; a perfect fit! It can be proved that this regression is a complete nonsense. Even if we throw in random values for those 99 factors, we will also end up with a perfect fit regression. Consequently, the coefficients and t-stats mean nothing.<br />
Could we do a “smaller” regression on a small subset of factors, e.g., one factor at a time, and hope to identify the most significant factor? This step-wise regression turns out to be spurious as well. For a pool of large enough factors, there is big probability of finding (the most) significant factors even when the factors values are randomly generated.</p>
<p>Suppose we happen to regress returns on only capitalization and finds that this factor is significant. Even so, we may in fact be doing some form of data snooping. This is because there are thousands other people testing the same or different factors using the same data set, i.e., AAPL prices from Yahoo. This community, taken as a whole, is doing exactly the same step-wise regression described in the last paragraph. <em>In summary, empirical evidence alone is not sufficient to justify a trading model.</em></p>
<p>To avoid data snooping in designing a trading strategy, Numerical Method Inc. recommends our clients a four-step procedure.</p>
<ol>
<li>Hypothesis: we start with an insight, a theory, or a common sense about how the market works.</li>
<li>Modeling: translate the insight in English into mathematics (in Greek).</li>
<li>Application: in-sample calibration and out-sample backtesting.</li>
<li>Analysis: understand and explain the winning vs. losing trades.</li>
</ol>
<p>In steps 1 and 2, we explicitly write down the model assumptions, deduce the model properties, and compute the p&amp;l distribution. We prove that under those assumptions, the strategy will always make money (on average). Whether these assumptions are true can be verified against data using techniques such as hypothesis testing. Given the model parameters, we know exactly how much money we expect to make. This is all done before we even look at a particular data set. In other words, we avoid data snooping by using the data set only until the calibration step and <em>after</em> we have created a trading model.</p>
<p>An example of creating a trend following strategy using this procedure can be found in lecture 1 of the course “<a title="Introduction to Algorithmic Trading Strategies" href="http://numericalmethod.com/papers/course1/index.html" target="_blank">Introduction to Algorithmic Trading Strategies</a>”.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2012/02/12/data-mining/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Role of Technology in Quantitative Trading Research</title>
		<link>http://numericalmethod.com/blog/2011/10/27/the-role-of-technology-in-quantitative-trading-research/</link>
		<comments>http://numericalmethod.com/blog/2011/10/27/the-role-of-technology-in-quantitative-trading-research/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 18:14:43 +0000</pubDate>
		<dc:creator>Haksun Li</dc:creator>
				<category><![CDATA[AlgoQuant]]></category>
		<category><![CDATA[Algorithmic Trading]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=275</guid>
		<description><![CDATA[I posted my presentation titled &#8220;The Role of Tech [...]]]></description>
				<content:encoded><![CDATA[<p>I posted my presentation titled &#8220;The Role of Technology in Quantitative Trading Research&#8221; presented in</p>
<ul>
<li><a title="HKU-HKUST-Stanford Conference in Quantitative Finance" href="http://hkumath.hku.hk/~imr/records1112/HHSCqf-final.pdf">HKU-HKUST-Stanford Conference in Quantitative Finance</a>. Dec 9, 2011.</li>
<li><a title="Workshop On Recent Developments Of Financial Mathematics (REDFIN2011)" href="http://research.utar.edu.my/CMS/redfin2011/speakers.html">Workshop On Recent Developments Of Financial Mathematics (REDFIN2011)</a>. Dec 13, 2011.</li>
</ul>
<p>You can find the powerpoint <a href="http://numericalmethod.com/papers/The Role Of Technology In Quantitative Trading Research.pptx">here</a>.</p>
<p><strong>Abstract</strong>:</p>
<p>There needs a technology to streamline the quantitative trading research process. Typically, quants/traders, from idea generation to strategy deployment, may take weeks if not months. This means not only loss of trading opportunity, but also a lengthy, tedious, erroneous process marred with ad-hoc decisions and primitive tools. From the organization’s perspective, comparing the paper performances of different traders is like comparing apples to oranges. <a title="The Right (and Wrong) Way to Run an Algorithmic Trading Group" href="http://numericalmethod.com/blog/2011/05/20/the-right-and-wrong-way-to-run-an-algorithmic-trading-group/">The success of the firm relies on hiring the right geniuses.</a> Our solution is a technological process that standardizes and automates most of the mechanical steps in quantitative trading research. Creating a new trading strategy should be as easy and fun as playing Legos by assembling together simpler ideas. Consequently, traders can focus their attention on what they are supposed to be best at – imagining new trading ideas/strategies.</p>
<p><strong>Excerpts</strong>:</p>
<ul>
<li>In reality, the research process for a quantitative trading strategy, from conceptual design to actual execution, is very time consuming, e.g., months. The backtesting step, in the broadest sense, takes the longest time. There are too many details that we can include in the backtesting code. To just name a few, data cleaning and preparation, mathematics algorithms, mock market simulation, execution and slippage assumptions, parameter calibration, sensitivity analysis, and worst of all, debugging. In practice, most people will ignore many details and make unfortunate “approximation”. This is one major reason why real and paper p&amp;l’s are different.</li>
<li>Before AlgoQuant, there is no publicly available quantitative trading research platform that alleviates quants/traders from coding up those “infrastructural” components. Most of the existing tools are either lacking extensive built-in math libraries, or lacking modern programming language support, or lacking plug-and-play “trading toolboxes”.</li>
<li>Technology can change the game by enhancing productivity. Imagine there is a system that automates and runs in a parallel grid of 100s of CPUs for you all those tedious and mundane tasks, data cleaning, mock market, calibration, and mathematics. You can save 80% of coding time and can focus your attention to trading ideas and analysis. Jim, using Matlab, may find a successful trading strategy in 3 months. You, equipped with the proper technology, may find 3 strategies in a month! The success of a hedge fund shall no longer rely on hiring genius.</li>
<li>After we code up a strategy and choose a parameter set, there is a whole suite of analysis that we can go through and many measures that we can compute to evaluate the strategy. For instance, we can see how the strategy performs for historical data, simulated data generated from Monte Carlo simulation (parametric) or bootstrapping (non-parametric), as well as scenario data (hand crafted). We can construct the p&amp;l distribution (it is unfortunate that historical p&amp;l seems to be the popular performance measure; we traders do not really care about what we could make in the past but care only about our bonuses in the future; so what we really want to see is the future p&amp;l distribution for uncertainty not historical p&amp;l); we can do sensitivity analysis of parameters; we can compute the many performance statistics. All these are very CPU-intensive tasks. Using AlgoQuant, you simply feed your strategy into the system. AlgoQuant runs all these tasks on a parallel grid and generates a nice report for you.</li>
<li>The academic community publishes very good papers on quantitative trading strategies. Unfortunately they are by-and-large unexplored. First, they are very difficult to understand because they are written for peer reviewers not laymen. Second, they are very difficult to reproduce because most authors do not publish source code. Third, they are very difficult to apply in real trading because the source code is not meant for public use, even if available.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2011/10/27/the-role-of-technology-in-quantitative-trading-research/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NUMERICAL METHOD INC Selected as a Red Herring Top 100 Asia Tech Startup</title>
		<link>http://numericalmethod.com/blog/2011/10/27/numerical-method-inc-selected-as-a-red-herring-top-100-asia-tech-startup/</link>
		<comments>http://numericalmethod.com/blog/2011/10/27/numerical-method-inc-selected-as-a-red-herring-top-100-asia-tech-startup/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 17:26:47 +0000</pubDate>
		<dc:creator>Haksun Li</dc:creator>
				<category><![CDATA[AlgoQuant]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[SuanShu]]></category>

		<guid isPermaLink="false">http://numericalmethod.com/blog/?p=268</guid>
		<description><![CDATA[Hong Kong, China - Numerical Method Incorporation Limit [...]]]></description>
				<content:encoded><![CDATA[<p>Hong Kong, China - <strong>Numerical Method Incorporation Limited</strong> has won the Top 100 Asia award. <strong>Numerical Method Inc.</strong> publishes <a title="SuanShu" href="http://www.numericalmethod.com/wiki/numericalmethod/wiki/SuanShu">SuanShu</a>, a Java math library, and <a title="AlgoQuant" href="http://www.numericalmethod.com/wiki/numericalmethod/wiki/AlgoQuant">AlgoQuant</a>, an algorithmic/quantitative trading strategy research platform.</p>
<p>Red Herring announced its <a title="Top 100 Asia award" href="http://www.redherring.com/red-herring-asia/2011-red-herring-top-100-asia/">Top 100 Asia award</a> in recognition of the leading private companies from Asia, celebrating these startups’ innovations and technologies across their respective industries.</p>
<p>Red Herring’s Top 100 list has become a mark of distinction for identifying promising new companies and entrepreneurs. Red Herring editors were among the first to recognize that companies such as Facebook, Twitter, Google, Yahoo, Skype, Salesforce.com, YouTube, and eBay would change the way we live and work.</p>
<p>“Choosing the companies with the strongest potential was by no means a small feat,” said Alex Vieux, publisher and CEO of Red Herring. “After rigorous contemplation and discussion, we narrowed our list down from hundreds of candidates from across Asia to the Top 100 Winners. We believe <strong>Numerical Method Inc.</strong> embodies the vision, drive and innovation that define a successful entrepreneurial venture. <strong>Numerical Method Inc.</strong> should be proud of its accomplishment, as the competition was very strong.”</p>
<p>Red Herring’s editorial staff evaluated the companies on both quantitative and qualitative criteria, such as financial performance, technology innovation, management quality, strategy, and market penetration. This assessment of potential is complemented by a review of the track record and standing of startups relative to their sector peers, allowing Red Herring to see past the “buzz” and make the list a valuable instrument of discovery and advocacy for the most promising new business models in Asia.</p>
<p>&nbsp;</p>
<div id="attachment_270" class="wp-caption alignnone" style="width: 600px"><a href="http://numericalmethod.com/blog/wp-content/uploads/2011/10/award-ceremony.jpg"><img class="size-full wp-image-270   " title="Red Herring Top 100 Asia Award Ceremony" src="http://numericalmethod.com/blog/wp-content/uploads/2011/10/award-ceremony.jpg" alt="Red Herring Top 100 Asia Award Ceremony" width="590" height="442" /></a><p class="wp-caption-text">Red Herring Top 100 Asia Award Ceremony</p></div>
]]></content:encoded>
			<wfw:commentRss>http://numericalmethod.com/blog/2011/10/27/numerical-method-inc-selected-as-a-red-herring-top-100-asia-tech-startup/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
