<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Tr8dr</title>
	<atom:link href="http://tr8dr.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tr8dr.wordpress.com</link>
	<description>Systematic Models &#38; Strategies</description>
	<lastBuildDate>Wed, 22 May 2013 21:20:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='tr8dr.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tr8dr</title>
		<link>http://tr8dr.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://tr8dr.wordpress.com/osd.xml" title="Tr8dr" />
	<atom:link rel='hub' href='http://tr8dr.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Money Management</title>
		<link>http://tr8dr.wordpress.com/2012/09/29/money-management/</link>
		<comments>http://tr8dr.wordpress.com/2012/09/29/money-management/#comments</comments>
		<pubDate>Sat, 29 Sep 2012 20:53:37 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=971</guid>
		<description><![CDATA[It has been almost a year since my last post.  I have been far too busy getting a new trading desk up and running.   I  thought to discuss money management, since am revisiting right now. Overview It is easy &#8230; <a href="http://tr8dr.wordpress.com/2012/09/29/money-management/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=971&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>It has been almost a year since my last post.  I have been far too busy getting a new trading desk up and running.   I  thought to discuss money management, since am revisiting right now.</p>
<h2>Overview</h2>
<p>It is easy to think that trading signal is the most important aspect of a trading strategy, but money management (and execution) can be even more important.   Loosely defined, money management is a mechanism for position-level risk management.  The mechanism attempts to regulate, accomplishing a number of things:</p>
<ol>
<li>ride out a profitable signal as long as there is continued profit potential
<ol>
<li>close out a profitable position when the p&amp;l is drifting sideways</li>
<li>close out a profitable position, alternatively when there is a drawdown</li>
<li>otherwise, allow the position to continue to profit, even through transient negative noise</li>
</ol>
</li>
<li>close out our losing positions as quickly as possible
<ol>
<li>close position once we have a view that it is unlikely to be profitable</li>
</ol>
</li>
<li>close out strategy if seems unstable
<ol>
<li>for example keeps hitting stop-loss</li>
<li>risk measures indicative of unstable market situation for strategy</li>
</ol>
</li>
</ol>
<p>A desirable feature of a money manager is that when pairing the money manager and signal together, we have a return distribution with positive skew and very limited negative tails.   We can even have a signal with &lt; 50% wins, but because of the generated bias in + returns / &#8211; returns, have an overall positive equity curve.   Of course I would advocate for much a much higher win ratio than 50% <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>Signal → Position</h2>
<p>I take the approach of having a trading signal that scales between [-1,1] or [0,1] on a continuous basis.   In my trading systems the money manager not only works as a risk manager, but also decides how to scale the signal into a desired position.</p>
<p>For example, if our maximum position is $5 million, we might scale our desired position from 0 to $5 million (if the signal reaches full power at 1).  The 0 or close to 0 level would indicate being out of market, 0.5 being at 1/2 strength or 2.5 million in.   Here is an example signal from 0 to 1:</p>
<div><a href="http://tr8dr.files.wordpress.com/2012/09/screen-shot-2012-09-29-at-4-29-00-pm.png"><img class="alignnone  wp-image-974" title="signal &amp; monotonicity" src="http://tr8dr.files.wordpress.com/2012/09/screen-shot-2012-09-29-at-4-29-00-pm.png?w=382&#038;h=246" alt="" width="382" height="246" /></a></div>
<p>Trading signals can be noisy, though we do our best to provide smooth signals.   Without regulation of how we map the signal to position size, the up and down dips in the signal would imply thrashing in and out of position, which would be costly.</p>
<p>Hence, we should try to enforce direction monotonicity, so as to avoid thrashing.</p>
<h2>Types of stop-loss</h2>
<p>There are a number of stop-loss types we should consider:</p>
<ol>
<li>stop-loss:
<ol>
<li>stop when (smoothed) equity curve has reached a negative return threshold</li>
</ol>
</li>
<li>stop-profit:
<ol>
<li>exit an up-to-current profitable trade, but one that has lost some % from the high</li>
</ol>
</li>
<li>stop-drift
<ol>
<li>a time and slope based stop that closes out a position whose equity curve is drifting more-or-less sideways for a significant period</li>
</ol>
</li>
</ol>
<h2>Risk Reentry Avoidance</h2>
<p>On a stop-loss not only want to close the position, but also have to &#8220;back away&#8221; from the signal, such that we do not immediately get back into an undesirable situation.   Depending on why we exited the position, we may want to:</p>
<ol>
<li>disable market entry until the signal has gone to zero</li>
<li>impose a time penalty</li>
<li>impose a market reentry restriction (wait for the market regime to reach a certain stage)</li>
</ol>
<h2>A FSM</h2>
<p>Here is a finite state machine that illustrates a possible state system guiding position scaling and money management:</p>
<p><a href="http://tr8dr.files.wordpress.com/2012/09/screen-shot-2012-09-29-at-4-49-18-pm.png"><img class="alignnone size-full wp-image-977" title="Money Management FSM" src="http://tr8dr.files.wordpress.com/2012/09/screen-shot-2012-09-29-at-4-49-18-pm.png?w=500&#038;h=316" alt="" width="500" height="316" /></a></p>
<p>The state system expresses some of the above money management features.   To make it effective, one needs to be clever about deciding on whether a negative movement is a sign to get out or a transient movement.   One can use a combination of signal, smoothed series, and aspects of order book and trade data to have a better read on this.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/971/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/971/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=971&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2012/09/29/money-management/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2012/09/screen-shot-2012-09-29-at-4-29-00-pm.png" medium="image">
			<media:title type="html">signal &#38; monotonicity</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2012/09/screen-shot-2012-09-29-at-4-49-18-pm.png" medium="image">
			<media:title type="html">Money Management FSM</media:title>
		</media:content>
	</item>
		<item>
		<title>Thought Experiment On Randomness</title>
		<link>http://tr8dr.wordpress.com/2011/10/05/thought-experiment-on-randomness/</link>
		<comments>http://tr8dr.wordpress.com/2011/10/05/thought-experiment-on-randomness/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 03:46:33 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=963</guid>
		<description><![CDATA[Was discussing pseudo-random number generators with a colleague, around desirable attributes of the distribution, periodicity, etc &#8212; all fun and important stuff. It reminded me of a chain of thought ranging from complexity theory to the philosophical.   Pardon the &#8230; <a href="http://tr8dr.wordpress.com/2011/10/05/thought-experiment-on-randomness/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=963&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Was discussing pseudo-random number generators with a colleague, around desirable attributes of the distribution, periodicity, etc &#8212; all fun and important stuff.</p>
<p>It reminded me of a chain of thought ranging from complexity theory to the philosophical.   Pardon the armchair physics and philosophy.</p>
<p>As we know from information theory, any sequence generated by an algorithm with no exogenous input, except perhaps an initial state, cannot be random.   There are multiple measures of randomness in theoretical computer science around measuring the degree of pattern in a given sequence (or string).    One that appeals to me, is the Kolmogorov complexity measure (I was reminded of this by recent posts on <a href="http://www.scottaaronson.com/blog/">Shtetl-Optimized</a>) which is approximately:</p>
<blockquote><p>for some string x (say a random sequence we are testing), what is the shortest possible program in some universal computer language K(x) that prints x and halts.</p></blockquote>
<p>Intuitively, if a sequence is truly random, there is no algorithm that can generate it short of the sequence literal itself.  Assuming we a looking at very long sequences of  X (our random sequence), the program to produce that must also be very large (as long as the literal) and hence have a very high K(x) measure.  A long pseudo random sequence may look to be quite complex at first glance, but can be described by a short program generating the sequence, and hence has a low K(x) measure.</p>
<p>Not being a complexity theorist, I&#8217;m playing pretty loose with the definition, but you get the idea.</p>
<p>Going further, one thing I&#8217;ve often thought about, is whether randomness truly exists in the universe.   This may be equivalent to asking, is the universe computable.  This question and theory around this has been proposed and discussed since the 1950s.   Are the random distributions we see in quantum states, for example, just manifestations of a complex computable function, probably one with many dimensions and long periodicity.</p>
<p>If the fabric of the universe is computable, then it stands to reason that what is contained within is also.  In this scenario, we being computable machines made of this macro-stuff called matter, are just very complex functions of our initial states;  Not just our initial state (our conception and program therein), but the state vector of all influences in the universe, our surroundings, and other automata.</p>
<p>Well you can see where this goes.   Free will is a function of our reason and environment, but our reasoning function is also predetermined by this astronomical state vector / ongoing computation.</p>
<p>Anyway, I was reluctant to post this for a while, but thought it would be fun for a change.  Starts with science and ends with philosophical possibility.</p>
<p><strong>Addendum<br />
</strong>I should add, the data we receive from &#8220;random&#8221; physical processes appears to be random.  If we assume a computable universe, the generating function for these random processes could be vast given the possibility of an &#8220;astronomical&#8221;, but finite, number of inputs (or dimension).   i.e.  Our approximation of the K(x) function appears to be large just because we do not know how to determine the generating function.   Hence in a short life-time of observation and computation, such a function would have the appearance of randomness (as in maximal complexity) and infinite period.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/963/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/963/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=963&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2011/10/05/thought-experiment-on-randomness/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>
	</item>
		<item>
		<title>Update</title>
		<link>http://tr8dr.wordpress.com/2011/09/15/update/</link>
		<comments>http://tr8dr.wordpress.com/2011/09/15/update/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 12:14:07 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=961</guid>
		<description><![CDATA[It has been a while since I&#8217;ve posted and apologize for leaving the prior subject mid-thread.   I&#8217;ve become extraordinarily busy with a new company, but will revert to research mode and follow-up once things settle down. In the mean &#8230; <a href="http://tr8dr.wordpress.com/2011/09/15/update/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=961&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>It has been a while since I&#8217;ve posted and apologize for leaving the prior subject mid-thread.   I&#8217;ve become extraordinarily busy with a new company, but will revert to research mode and follow-up once things settle down.</p>
<p>In the mean time, one of my long-term side interests has been biological systems.  These are interesting because are probably most complex systems we can study.   Our understanding of specific cells and interactions has grown enormously within a century, but we&#8217;re still only scratching the surface given crude measurement tools and the mind boggling complexity.   Computational biology provides a simulation based approach to studying these problems, and hence is of particular interest to me.</p>
<p>Some &#8220;holy grails&#8221; that have interested me:</p>
<ol>
<li>creation of artificial lifeforms to &#8220;prove&#8221; that life is nothing more than a system (done: Craig Venter&#8217;s team)</li>
<li>mapping of neural structures into simulation</li>
<li>creation of alternative chemistry&#8217;s / energy / replicating processes</li>
</ol>
<p>&nbsp;</p>
<p>Here is an article I just found of a researcher in the UK that is having some success with creating structures and processes based on metal salts as an alternative to carbon forms: <a href="http://www.newscientist.com/article/dn20906-lifelike-cells-are-made-of-metal.html"> Life cells made of metal</a>.   It seems like they have been able to create cell-like structures and may be close to a means of generating energy for the entity via photosynthesis.   Whether this is a fruitful or not, remains to be seen.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/961/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=961&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2011/09/15/update/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>
	</item>
		<item>
		<title>Smoothed UKF</title>
		<link>http://tr8dr.wordpress.com/2011/08/03/smoothed-utf/</link>
		<comments>http://tr8dr.wordpress.com/2011/08/03/smoothed-utf/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 18:21:33 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=925</guid>
		<description><![CDATA[The smoothed UKF performs smoothing on the state system a-posteriori.   The standard form of this filter is useful in getting an accurate view on prior states, but will not provide a smoothed online state estimate for the current or &#8230; <a href="http://tr8dr.wordpress.com/2011/08/03/smoothed-utf/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=925&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The smoothed UKF performs smoothing on the state system a-posteriori.   The standard form of this filter is useful in getting an accurate view on prior states, but will not provide a smoothed online state estimate for the current or next period (i.e. no better estimate than the non-smoothed UKF).</p>
<p>That said the smoothed UKF is still useful as:</p>
<ol>
<li>can be used to estimate the MLE for a stable parameter</li>
<li>a timeseries of smoothed prior states can be regressed to project a smoothed forward state (but is not part of the UKF framework)</li>
</ol>
<p>The form of UKF smoother that will briefly discuss is the forward-backward smoother.   As the name suggests, the first pass is to perform standard UKF filter, estimating the distribution <img src='http://s0.wp.com/latex.php?latex=p%28%7Bx_t%7D%7C%7Bx_%7Bt+-+1%7D%7D%2C%7By_%7B1%3At%7D%7D%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='p({x_t}|{x_{t - 1}},{y_{1:t}})' title='p({x_t}|{x_{t - 1}},{y_{1:t}})' class='latex' /> at each timestep.  Whereas the smoothing estimates a smoothed distribution in reverse, implying <img src='http://s0.wp.com/latex.php?latex=p%28x_%7Bt+-+1%7D%5ES%7Cx_t%5ES%2C%5CSigma+_t%5ES%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='p(x_{t - 1}^S|x_t^S,&#92;Sigma _t^S)' title='p(x_{t - 1}^S|x_t^S,&#92;Sigma _t^S)' class='latex' />.   The boundary <img src='http://s0.wp.com/latex.php?latex=x_T%5ES%2C%5CSigma+_T%5ES&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x_T^S,&#92;Sigma _T^S' title='x_T^S,&#92;Sigma _T^S' class='latex' /> is simply the last state and covariance estimated by the forward filter.</p>
<p>The smoothing approach is then for each <img src='http://s0.wp.com/latex.php?latex=x_%7Bt+%7D%5ES%2C+%5CSigma+_t%5ES&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x_{t }^S, &#92;Sigma _t^S' title='x_{t }^S, &#92;Sigma _t^S' class='latex' />, determine the predicted <img src='http://s0.wp.com/latex.php?latex=x_%7Bt%2B1+%7D%5E-%2C+%5CSigma+_%7Bt%2B1%7D%5E-%2C+%5CSigma+_%7Bt%2Ct%2B1%7D%5E-&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x_{t+1 }^-, &#92;Sigma _{t+1}^-, &#92;Sigma _{t,t+1}^-' title='x_{t+1 }^-, &#92;Sigma _{t+1}^-, &#92;Sigma _{t,t+1}^-' class='latex' />, and back out an appropriate adjustment given a computed kalman gain and the difference between the predicted t+1 and actual t+1 state:</p>
<p style="padding-left:30px;"><img src='http://s0.wp.com/latex.php?latex=%5Cleft%5B%5Cmu+_%7Bt%2B1%7D%5E+-+%2C%5Csum+_%7Bt%2B1%7D%5E+-+%2C%5Csum+_%7Bt%2Ct+%2B+1%7D%5E+-+%5Cright%5D+%3D+UT%5Cleft%28+%7B%7BX_t%7D%2C%5Csum+_%7Bt%2Ct%7D%5E%7B%7D%2Cf%28.%29%2C+%5Ccdots+%7D+%5Cright%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;left[&#92;mu _{t+1}^ - ,&#92;sum _{t+1}^ - ,&#92;sum _{t,t + 1}^ - &#92;right] = UT&#92;left( {{X_t},&#92;sum _{t,t}^{},f(.), &#92;cdots } &#92;right)' title='&#92;left[&#92;mu _{t+1}^ - ,&#92;sum _{t+1}^ - ,&#92;sum _{t,t + 1}^ - &#92;right] = UT&#92;left( {{X_t},&#92;sum _{t,t}^{},f(.), &#92;cdots } &#92;right)' class='latex' /></p>
<p style="padding-left:30px;"><img src='http://s0.wp.com/latex.php?latex=K+%3D+%5Csum+_%7Bt%2Ct+%2B+1%7D%5E+-+%7B%5Cleft%28+%7B%5Csum+_%7Bt+%2B+1%7D%5E+-+%7D+%5Cright%29%5E%7B+-+1%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='K = &#92;sum _{t,t + 1}^ - {&#92;left( {&#92;sum _{t + 1}^ - } &#92;right)^{ - 1}}' title='K = &#92;sum _{t,t + 1}^ - {&#92;left( {&#92;sum _{t + 1}^ - } &#92;right)^{ - 1}}' class='latex' /><br />
<img src='http://s0.wp.com/latex.php?latex=X_t%5ES+%3D+X_t%5E%7B%7D+%2B+K%5Cleft%28+%7BX_%7Bt+%2B+1%7D%5ES+-+%5Cmu+_%7Bt+%2B+1%7D%5E+-+%7D+%5Cright%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='X_t^S = X_t^{} + K&#92;left( {X_{t + 1}^S - &#92;mu _{t + 1}^ - } &#92;right)' title='X_t^S = X_t^{} + K&#92;left( {X_{t + 1}^S - &#92;mu _{t + 1}^ - } &#92;right)' class='latex' /><br />
<img src='http://s0.wp.com/latex.php?latex=%5Csum+_t%5ES+%3D+%5Csum+_t%5E%7B%7D+%2B+K%5Cleft%28+%7B%5Csum+_%7Bt+%2B+1%7D%5ES+-+%5Csum+_%7Bt+%2B+1%7D%5E+-+%7D+%5Cright%29%7BK%5ET%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;sum _t^S = &#92;sum _t^{} + K&#92;left( {&#92;sum _{t + 1}^S - &#92;sum _{t + 1}^ - } &#92;right){K^T}' title='&#92;sum _t^S = &#92;sum _t^{} + K&#92;left( {&#92;sum _{t + 1}^S - &#92;sum _{t + 1}^ - } &#92;right){K^T}' class='latex' /></p>
<p><strong>Results<br />
</strong>A simple example of a non-linear function is the Sine function.   Tracking the sine function using a linearization of the sine function with standard Kalman filter will perform poorly.  My test case for the UKF was the following function with noise:</p>
<p style="padding-left:30px;"><img src='http://s0.wp.com/latex.php?latex=y%28t%29+%3D+%7Ba_t%7D%5Csin+%5Cleft%28+%7B%7B%5Ctheta+_t%7D%7D+%5Cright%29+%2B+%7B%5Cvarepsilon+_t%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y(t) = {a_t}&#92;sin &#92;left( {{&#92;theta _t}} &#92;right) + {&#92;varepsilon _t}' title='y(t) = {a_t}&#92;sin &#92;left( {{&#92;theta _t}} &#92;right) + {&#92;varepsilon _t}' class='latex' /></p>
<p>where <img src='http://s0.wp.com/latex.php?latex=%7Ba_t%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='{a_t}' title='{a_t}' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=%5Ctheta+_t&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;theta _t' title='&#92;theta _t' class='latex' /> are linear functions of time.  The states in the system track: <img src='http://s0.wp.com/latex.php?latex=A%28t%29%2C%5Cfrac%7B%7BdA%7D%7D%7B%7Bdt%7D%7D%2C%5Ctheta+%28t%29%2C%5Cfrac%7B%7Bd%5Ctheta+%7D%7D%7B%7Bdt%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='A(t),&#92;frac{{dA}}{{dt}},&#92;theta (t),&#92;frac{{d&#92;theta }}{{dt}}' title='A(t),&#92;frac{{dA}}{{dt}},&#92;theta (t),&#92;frac{{d&#92;theta }}{{dt}}' class='latex' />.   Here is UKF tracking without smoothing:</p>
<p><a href="http://tr8dr.files.wordpress.com/2011/08/screen-shot-2011-08-03-at-11-48-18-am.png"><img class="alignnone size-full wp-image-940" title="Screen shot 2011-08-03 at 11.48.18 AM" src="http://tr8dr.files.wordpress.com/2011/08/screen-shot-2011-08-03-at-11-48-18-am.png?w=500&#038;h=466" alt="" width="500" height="466" /></a></p>
<p>And here is the same with smoothing:</p>
<p><a href="http://tr8dr.files.wordpress.com/2011/08/screen-shot-2011-08-03-at-11-49-35-am.png"><img class="alignnone size-full wp-image-941" title="Screen shot 2011-08-03 at 11.49.35 AM" src="http://tr8dr.files.wordpress.com/2011/08/screen-shot-2011-08-03-at-11-49-35-am.png?w=500&#038;h=462" alt="" width="500" height="462" /></a></p>
<p><strong>Code<br />
</strong>I&#8217;m enclosing R code for the augmented UKF and smoothed UKF.   For readability I have not optimized all of the R code (i.e. there are some for loops that could be vectorized).   Here is the common part (defining the Unscented Transform).</p>
<pre class="brush: r; title: ; notranslate">
## modified number of columns
ncols &lt;- function (x) ifselse(is.matrix(x), ncol(x), length(x))

## modified number of rows
nrows &lt;- function (x) ifelse(is.matrix(x), nrow(x), length(x))

#
#	Determine transformed distribution across non-linear function f(x)
#
#
unscented.transform.aug &lt;- function (
	MUx,				# mean of state
	P, 					# covariance of state
	Nyy,				# noise covariance matrix of f(x)
	f,					# non-linear function f(X, E)
	dt,					# time increment
	alpha = 1e-3,		# scaling of points from mean
	beta = 2,			# distribution parameter
	kappa = 1)
{
	Nyy &lt;- as.matrix(Nyy)

	## constants
	Lx &lt;- nrows(MUx)
	Ly &lt;- nrows(Nyy)
	n &lt;- Lx + Ly

	## create augmented mean and covariance
	MUx.aug &lt;- c (MUx, rep(0, Ly))
	P.aug &lt;- matrix(0, Lx+Ly, Lx+Ly)
	P.aug[1:Lx,1:Lx] &lt;- P
	P.aug[(Lx+1):(Lx+Ly),(Lx+1):(Ly+Ly)] &lt;- Nyy

	## generating sigma points
	lambda &lt;- alpha^2 * (n + kappa) - n
	A &lt;- t (chol (P.aug))
	X &lt;- MUx.aug + sqrt(n + lambda) * cbind (rep(0,n), A, -A)

	## generate weights
	Wc &lt;- c (
		lambda / (n + lambda) + (1 - alpha^2 + beta),
		rep (1 / (2 * (n + lambda)), 2*n))
	Wm &lt;- c (
		lambda / (n + lambda),
		rep (1 / (2 * (n + lambda)), 2*n))

	## propagate through function
	Y &lt;- apply(X, 2, function (v)
		{
			f (dt, v[1:Lx], v[(Lx+1):(Lx+Ly)])
		})

	if (is.vector(Y))
		Y &lt;- t(as.matrix(Y))

	## now calculate moments
	MUy &lt;- Y %*% Wm

	Pyy &lt;- matrix(0, nrows(Nyy), nrows(Nyy))
	Pxy &lt;- matrix(0, nrows(MUx), nrows(Nyy))

	for (i in 1:ncols(Y))
	{
		dy &lt;- (Y[,i] - MUy)
		dx &lt;- (X[1:Lx,i] - MUx)

		Pyy &lt;- Pyy + Wc[i] * dy %*% t(dy)
		Pxy &lt;- Pxy + Wc[i] * dx %*% t(dy)
	}

	list (mu = MUy, Pyy = Pyy, Pxy = Pxy)
}
</pre>
<p>The <strong>UKF without smoothing</strong>:</p>
<pre class="brush: r; title: ; notranslate">
#
#	Augmented UKF filtered series
#		- note that f and g are functions of state X and error vector N  f(dt, Xt, E)
#		- Nx and Ny state and observation innovation covariance
#		- Xo is the initial state
#		- dt is the time step
#
ukf.aug &lt;- function (
	series,
	f,
	g,
	Nx,
	Ny,
	Xo = rep(0, nrow(Nx)),
	dt = 1,
	alpha = 1e-3,
	kappa = 1,
	beta = 2)
{
	data &lt;- as.matrix(coredata(series))

	## description of initial distribution of X
	oMUx &lt;- Xo
	oPx &lt;- diag(rep(1e-4, nrows(Xo)))

	Yhat &lt;- NULL
	Xhat &lt;- NULL

	for (i in 1:nrow(data))
	{
		Yt &lt;- t(data[i,])

		## predict
		r &lt;- unscented.transform.aug (oMUx, oPx, Nx, f, dt, alpha=alpha, beta=beta, kappa=kappa)
		pMUx &lt;- r$mu
		pPx &lt;- r$Pyy

		## update
		r &lt;- unscented.transform.aug (pMUx, pPx, Ny, g, dt, alpha=alpha, beta=beta, kappa=kappa)
		MUy &lt;- r$mu
		Pyy &lt;- r$Pyy
		Pxy &lt;- r$Pxy

		K &lt;- Pxy %*% inv(Pyy)
		MUx = pMUx + K %*% (Yt - MUy)
		Px &lt;- pPx - K %*% Pyy %*% t(K)

		## set for next cycle
		oMUx &lt;- MUx
		oPx &lt;- Px

		## append results
		Yhat &lt;- rbind(Yhat, t(MUy))
		Xhat &lt;- rbind(Xhat, t(MUx))
	}

	list (Yhat = Yhat, Xhat = Xhat)
}
</pre>
<p>The <strong>UKF with smoothing</strong>:</p>
<pre class="brush: r; title: ; notranslate">
ukf.smooth &lt;- function (
	series, 					# series to be filtered
	f, 							# state mapping X[t] = f(X[t-1])
	g, 							# state to measure mapping Y[t] = g(X[t])
	Nx, 						# state innovation error covar
	Ny, 						# measure innovation covar
	Xo = rep(0, nrow(Nx)), 		# initial state vector
	dt = 1, 					# time increment
	alpha = 1e-3,
	kappa = 1,
	beta = 2)
{
	data &lt;- as.matrix(coredata(series))

	Lx &lt;- nrow(as.matrix(Nx))
	Ly &lt;- nrow(as.matrix(Ny))

	## description of initial distribution of X
	oMUx &lt;- Xo
	oPx &lt;- diag(rep(1e-4, nrows(Xo)))

	Ey &lt;- rep(0, nrows(Ny))
	Ex &lt;- rep(0, nrows(Nx))

	Ms &lt;- list()
	Ps &lt;- list()

	## forward filtering
	for (i in 1:nrow(data))
	{
		Yt &lt;- t(data[i,])

		## predict
		r &lt;- unscented.transform.aug (oMUx, oPx, Nx, f, dt, alpha=alpha, beta=beta, kappa=kappa)
		pMUx &lt;- r$mu
		pPx &lt;- r$Pyy

		## update
		r &lt;- unscented.transform.aug (pMUx, pPx, Ny, g, dt, alpha=alpha, beta=beta, kappa=kappa)
		MUy &lt;- r$mu
		Pyy &lt;- r$Pyy
		Pxy &lt;- r$Pxy

		K &lt;- Pxy %*% inv(Pyy)
		MUx = pMUx + K %*% (Yt - MUy)
		Px &lt;- pPx - K %*% Pyy %*% t(K)

		## set for next cycle
		oMUx &lt;- MUx
		oPx &lt;- Px

		## append results
		Ms[[i]] &lt;- MUx
		Ps[[i]] &lt;- Px
	}

	## backward filtering, recursively determine N(Ms[t-1],Ps[t-1]) from N(Ms[t],Ps[t])
	for (i in rev(1:(nrow(data)-1)))
	{
		## transform
		r &lt;- unscented.transform.aug (Ms[[i]], Ps[[i]], Nx, f, dt, alpha=alpha, beta=beta, kappa=kappa)
		MUx &lt;- r$mu
		Pxx &lt;- r$Pyy
		Pxy &lt;- r$Pxy[1:Lx,]

		K &lt;- Pxy %*% inv(Pxx)
		Ms[[i]] &lt;-  Ms[[i]] + K %*% (Ms[[i+1]] - MUx)
		Ps[[i]] &lt;- Ps[[i]] + K %*% (Ps[[i+1]] - Pxx) * t(K)
	}

	Yhat &lt;- NULL
	Xhat &lt;- NULL

	for (i in 1:nrow(data))
	{
		MUy &lt;- g(dt, Ms[[i]], Ey)
		MUx &lt;- Ms[[i]]

		## append results
		Yhat &lt;- rbind(Yhat, t(MUy))
		Xhat &lt;- rbind(Xhat, t(MUx))
	}

	list (Y = data, Yhat = Yhat, Xhat = Xhat)
}
</pre>
<p>Finally, here is the Sine test:</p>
<pre class="brush: r; title: ; notranslate">
#
#	Amplitude varying sine function state function:
#
#		Yt = Amp[t] Sin(theta[t]) + Ey
#
#		Theta[t] = Theta[t-1] + Omega[t-1] dt + Ex,1
#		Omega[t] = Omega[t-1] + Ex,2
#		Amp[t] = Amp[t-1] + Accel[t-1] dt + Ex,3
#		Accel[t] = Accel[t] + Ex,4
#
sine.f.xx &lt;- function (dt, Xt, Ex)
{
	nXt &lt;- c (
		Xt[1] + dt*Xt[2] + Ex[1],
		Xt[2] + Ex[2],
		Xt[3] + Ex[3],
		Xt[4] + Ex[4])

	nXt
}

#
#	Amplitude varying sine function observation function:
#
#		Yt = Amp[t] Sin(theta[t]) + Ey
#
#		Theta[t] = Theta[t-1] + Omega[t-1] dt + Ex,1
#		Omega[t] = Omega[t-1] + Ex,2
#		Amp[t] = Amp[t-1] + Accel[t-1] dt + Ex,3
#		Accel[t] = Accel[t] + Ex,4
#
sine.f.xy &lt;- function (dt, Xt, Ey)
{
	y &lt;- Xt[3] * sin(Xt[1] / pi) + Ey[1]
	as.matrix(y)
}

#debug(unscented.transform.aug)
#debug(ukf.aug)

series.r &lt;- sapply (1:500, function(x) (1+x/500) * sin(16 * x/500 * pi)) + rnorm(500, sd=0.25)

## unsmoothed test
u &lt;- ukf.aug (
	series.r, sine.f.xx, sine.f.xy,
	Nx = 1e-3 * diag(c(1/3, 1, 1/10, 1/10)),
	Ny = 1,
	Xo = c(0.10, 0.10, 1, 1e-3), alpha=1e-2)

data &lt;- rbind (
	data.frame(t = 1:500, y=series.r, type='raw', window='Price'),
	data.frame(t = 1:500, y=u$Yhat, type='filtered', window='Price'),
	data.frame(t = 1:500, y=u$Xhat[,3], type='amp', window='Params'))

ggplot() + geom_line(aes(x=t,y=y, colour=type), data) + facet_new(window ~ ., scales=&quot;free_y&quot;, heights=c(3,1))

## smoothed test
u &lt;- ukf.smooth (
	series.r, sine.f.xx, sine.f.xy,
	Nx = 1e-3 * diag(c(1/3, 1, 1/10, 1/10)),
	Ny = 1,
	Xo = c(0.10, 0.10, 1, 1e-3), alpha=1e-2)

data &lt;- rbind (
	data.frame(t = 1:500, y=series.r, type='raw', window='Price'),
	data.frame(t = 1:500, y=u$Yhat, type='filtered', window='Price'),
	data.frame(t = 1:500, y=u$Xhat[,3], type='amp', window='Params'))

ggplot() + geom_line(aes(x=t,y=y, colour=type), data) + facet_new(window ~ ., scales=&quot;free_y&quot;, heights=c(3,2))
</pre>
<p>If you find the above code useful or have improvements to suggest, kindly send me a note. Thanks.</p>
<p><strong>Next Steps<br />
</strong>Some next steps:</p>
<ol>
<li>Determine state-system appropriate for market making &amp; cycling regimes</li>
<li>Determine Multi-Model switching approach</li>
<li>Evaluation &amp; Analysis</li>
</ol>
<p>I will probably make a digression onto another topic in the next posting before revisiting this.  Stay tuned.</p>
<p>p.s. if you use wordpress, they have a latex equation rendering capability I just discovered (hence better inlining in this post).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/925/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/925/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=925&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2011/08/03/smoothed-utf/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/08/screen-shot-2011-08-03-at-11-48-18-am.png" medium="image">
			<media:title type="html">Screen shot 2011-08-03 at 11.48.18 AM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/08/screen-shot-2011-08-03-at-11-49-35-am.png" medium="image">
			<media:title type="html">Screen shot 2011-08-03 at 11.49.35 AM</media:title>
		</media:content>
	</item>
		<item>
		<title>Unscented Transform &amp; Filters</title>
		<link>http://tr8dr.wordpress.com/2011/07/28/unscented-transform-filters/</link>
		<comments>http://tr8dr.wordpress.com/2011/07/28/unscented-transform-filters/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 19:04:00 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=905</guid>
		<description><![CDATA[The unscented transform (and filter) was developed as a practical alternative to MC sampling in estimating the conditional distribution functions of hidden state systems.   We want to determine the hidden state (Xt)  given observations (Yt): The  Sequential MC approach &#8230; <a href="http://tr8dr.wordpress.com/2011/07/28/unscented-transform-filters/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=905&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The unscented transform (and filter) was developed as a practical alternative to MC sampling in estimating the conditional distribution functions of hidden state systems.   We want to determine the hidden state (Xt)  given observations (Yt):</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-7-01-57-pm.png"><img class="alignnone size-full wp-image-891" title="Screen shot 2011-07-27 at 7.01.57 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-7-01-57-pm.png?w=500" alt=""   /></a></p>
<p>The  Sequential MC approach to determining this distribution p(Xt | Y1:t) is calculated as folows:</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-9-43-31-am.png"><img class="alignnone size-full wp-image-906" title="Screen shot 2011-07-28 at 9.43.31 AM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-9-43-31-am.png?w=500" alt=""   /></a></p>
<p>This works for us, since we know the observations y[1:t] and we should have a view on the likelihood of state X given Y by projecting samples of X into Y via function g(.).   There are various approaches to determining the likelihood and reducing the number of particles (samples) required to arrive at a robust integration (such as SIR).</p>
<p>The basic MC particle sampling algorithm is as follows:</p>
<ol>
<li>generate N samples of X[t],i from f (X[t-1] + noise), transformed from X[t-1] to X[t] via that f(.) function</li>
<li>determine &#8220;particles&#8221; as p(Yt | X&#8217;[t],i) / normalizing constant, where p(Yt|Xt) can be determined by applying function g(x) and determining likelihood of computed Yt given Xt.</li>
<li>some resampling and kernel weighted selection may occur, depending on algorithm</li>
<li>Mean is then the probability weighted average of the Xt&#8217;s (as indicated in the above integral)</li>
</ol>
<p>I&#8217;ve implemented and used a number of variations of these in the past.   MC approaches are unavoidable for complex distributions (for instance ones that are multi-modal).   That said particle filters can be orders of magnitude slower than the Kalman family of filters.</p>
<p><strong>Unscented Transform<br />
</strong>Enter the unscented transform.   Much as with the SMC approach, the unscented transform uses sampling to determine the mean and higher-order moments of the distribution: p(x[t] | y[1:t]).   Instead of generating numerous random samples, the unscented approach is to take samples at specific points around the current mean.</p>
<p>The unscented approach also avoids approximating the non-linearity of  system functions, instead looks to determine the simpler problem of approximating the distribution.  2^d + 1 sample (or sigma) points are determined around the mean and transformed through the non-linear functions to arrive at a view of the distribution of the state vector.</p>
<p><a href="http://tr8dr.files.wordpress.com/2011/07/orthogonal-projections.png"><img class="alignnone size-full wp-image-909" title="orthogonal projections" src="http://tr8dr.files.wordpress.com/2011/07/orthogonal-projections.png?w=500&#038;h=214" alt="" width="500" height="214" /></a></p>
<p>As illustrated in Julier and Uhlmann&#8217;s 1997 seminal paper:</p>
<p><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-2-06-56-pm.png"><img class="alignnone size-full wp-image-910" title="Screen shot 2011-07-28 at 2.06.56 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-2-06-56-pm.png?w=500" alt=""   /></a></p>
<p>The sigma points determined around the mean (Si and with associated weights Wi), are transformed through the non-linear system function allowing us to determine the moments of the distribution p(μ, P), with mean μ and covariance P (higher order moments can be computed as well):</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-2-26-28-pm.png"><img class="alignnone size-full wp-image-911" title="Screen shot 2011-07-28 at 2.26.28 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-2-26-28-pm.png?w=500" alt=""   /></a></p>
<p>It then becomes a question of how to select these sigma points Si around the mean Xt.   We know that we want to choose Si = Xt + Ei, where each vector Ei provides an appropriate spread in a given dimension, along the orientation of the distribution.  If these points are well chosen, will provide enough information to reconstruct moments of the distribution.</p>
<p>Under the assumption that Xt (pre-transform) is elliptically distributed, it turns out that the column vectors of the Cholesky decomposition of the covariance matrix specify vectors co-linear with the axes of the distribution.   These are determined and scaled as follows:</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-3-40-45-pm.png"><img class="alignnone size-full wp-image-916" title="Screen shot 2011-07-28 at 3.40.45 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-3-40-45-pm.png?w=500" alt=""   /></a></p>
<p>For more detail read the following <a title="A Consisten, Debiased Method for Converting Bteween Polar and Cartesian Coordinates" href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;sqi=2&amp;ved=0CBUQFjAA&amp;url=http%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fdownload%3Fdoi%3D10.1.1.46.8107%26rep%3Drep1%26type%3Dpdf&amp;ei=Xq8xTo3UNcKcgQe6quH5DA&amp;usg=AFQjCNHo8y-X15XiCLoWuN3dkgrxCE55Tg&amp;sig2=IpOnVHReCpwtSWEEUmqI2g">paper</a>.</p>
<p><strong>Why the UKF</strong>?<br />
The typical implementation of the EKF uses a linear (and sometimes quadratic) approximation in the update of the distributions.  This can fail spectacularly (or just present significant error) unless your system is well behaved through 1st order dynamics.   The UKF approach also does not require calculation of Jacobian or Hessian matrices, which for some problems may be extremely difficult or impossible to provide.</p>
<p><strong>Next Step<br />
</strong>I am particularly interested in the forward-backward UTF with smoothing.   I have found that smoothing on the priors (not just the immediate t-1) provides a better forecast for the current and next periods.   Will write more about this next.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/905/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=905&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2011/07/28/unscented-transform-filters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-7-01-57-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-07-27 at 7.01.57 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-9-43-31-am.png" medium="image">
			<media:title type="html">Screen shot 2011-07-28 at 9.43.31 AM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/orthogonal-projections.png" medium="image">
			<media:title type="html">orthogonal projections</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-2-06-56-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-07-28 at 2.06.56 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-2-26-28-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-07-28 at 2.26.28 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-28-at-3-40-45-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-07-28 at 3.40.45 PM</media:title>
		</media:content>
	</item>
		<item>
		<title>Thinking About State Space Filters</title>
		<link>http://tr8dr.wordpress.com/2011/07/27/thinking-about-state-space-filters/</link>
		<comments>http://tr8dr.wordpress.com/2011/07/27/thinking-about-state-space-filters/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 01:09:06 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=889</guid>
		<description><![CDATA[I have not used stochastic state based systems for a couple of years, but have decided to revisit.   I had previously implemented a number of systems with both the EKF and 3 variants of particle filter, but encountered various &#8230; <a href="http://tr8dr.wordpress.com/2011/07/27/thinking-about-state-space-filters/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=889&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have not used stochastic state based systems for a couple of years, but have decided to revisit.   I had previously implemented a number of systems with both the EKF and 3 variants of particle filter, but encountered various issues.</p>
<p>In particular, found the parameterization of the evolution via the covariance matrices to be opaque and problematic for some systems.    Also both the EKF and particle filters were subject to numerical instability if the mean of the state distribution or observed samples shifted significantly with likelihoods approaching 0.</p>
<p>I&#8217;ve decided to revisit state space filters but with a different filtering approach, for the purposes of coming up with a different approach to multi-regime pricing.</p>
<p>I&#8217;ll start with an introduction.  The traditional state space model is a discrete (or discretized continuous) system represented by a measurement equation and state evolution equation:</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-7-01-57-pm.png"><img class="alignnone size-full wp-image-891" title="Screen shot 2011-07-27 at 7.01.57 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-7-01-57-pm.png?w=500" alt=""   /></a></p>
<p>Where:</p>
<ol>
<li>X is a n dimensional vector representing the state of the system on timestep t</li>
<li>Y is a m dimensional vector  representing the measurement on timestep t (for example a price in our price series)</li>
<li>f(.) is our state evolution function mapping the t-1 th state to the t th state</li>
<li>g(.) is our state to measurement mapping</li>
<li>ε_x our state noise / error ~ N (0, Σx)</li>
<li>ε_y our observation noise / error ~ N(0,Σy)</li>
</ol>
<p><strong>Kalman Family of Filters<br />
</strong>The kalman family of filters uses a bayesian logic to implement a linear error correction model, such that errors in the estimation of Yt propagate back to the evolving state Xt (or more precisely, an evolving distribution of Xt).</p>
<p>The traditional Kalman filter assumes a linear function f(.) and g(.), usually expressed as matrices:</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-7-30-55-pm.png"><img class="alignnone size-full wp-image-892" title="Screen shot 2011-07-27 at 7.30.55 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-7-30-55-pm.png?w=500" alt=""   /></a></p>
<p>We are interested in estimating the state Xt given the noisy observed data Yt, hence are interested in the pdf <strong>p(x[t] | y[1:t])</strong>.  Given that we will have a lagged (t-1) view on this pdf via the recursion inherent in filtering, we first need to be able to compute <strong>p(x[t] | y[1:t-1])</strong> and then using that <strong>p(x[t] | y[1:t])</strong>:</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-8-28-48-pm.png"><img class="alignnone size-full wp-image-896" title="Screen shot 2011-07-27 at 8.28.48 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-8-28-48-pm.png?w=500" alt=""   /></a></p>
<p>Hence as pointed out in (Hartikainen 2008) the above linear state equations map to distributions:</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-8-37-51-pm.png"><img class="alignnone size-full wp-image-897" title="Screen shot 2011-07-27 at 8.37.51 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-8-37-51-pm.png?w=500" alt=""   /></a></p>
<p>I won&#8217;t go into the math for the Kalman filter, as would like to discuss its issues and move on to more sophisticated approaches.  The 3 main issues I have with the Kalman Filter:</p>
<ol>
<li>can only express the evolution of linear state functions</li>
<li>hard to calibrate degree of fit via state and measurement noise covariance matrices</li>
<li>can become numerically unstable with unexpected noise (probabilities go to 0 or may oscillate wildly)</li>
</ol>
<p>The <strong>Extended Kalman Filter</strong> partially solves one of these issues (that of non-linear state functions) by adjusting the kalman distribution estimation to use 1 or 2 terms of the taylor series expansion of the state and observation functions.   This works well for functions completely described by 1st and 2nd derivatives, although has similar drawbacks in terms of calibration and stability.</p>
<p>Short of using a numerically expensive <strong>particle filter</strong>, it seems that a variant the <strong>Unscented Kalman Filter</strong> (UKF) presents the best choice for the potential state systems I will be using.    The UKF using a deterministic sampling approach mapped through the non-linear functions, provides multiple moments for the underlying distribution.   The distribution can then be described with greater accuracy than afforded through the EKF&#8217;s taylor expansion.</p>
<p><strong>Topics to be Discussed</strong>:</p>
<div>
<ol>
<li>Unscented Transform</li>
<li>Smoothing</li>
<li>Need for a Multiple Model approach with Markovian switching</li>
<li>Filter approach for multiple models</li>
<li>Possible Models</li>
</ol>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/889/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/889/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=889&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2011/07/27/thinking-about-state-space-filters/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-7-01-57-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-07-27 at 7.01.57 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-7-30-55-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-07-27 at 7.30.55 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-8-28-48-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-07-27 at 8.28.48 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-8-37-51-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-07-27 at 8.37.51 PM</media:title>
		</media:content>
	</item>
		<item>
		<title>Pricing &amp; Regime (part 1)</title>
		<link>http://tr8dr.wordpress.com/2011/07/27/pricing-regimes-part-1/</link>
		<comments>http://tr8dr.wordpress.com/2011/07/27/pricing-regimes-part-1/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 21:24:44 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=873</guid>
		<description><![CDATA[High frequency trading tends to fall into the following categories: some form of prop market making (probably largest %) gaming other players or microstructure short-period arbitrage execution algos One might also run medium frequency strategies that pursue: trend (if there &#8230; <a href="http://tr8dr.wordpress.com/2011/07/27/pricing-regimes-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=873&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>High frequency trading tends to fall into the following categories:</p>
<ol>
<li>some form of prop market making (probably largest %)</li>
<li>gaming other players or microstructure</li>
<li>short-period arbitrage</li>
<li>execution algos</li>
</ol>
<div>One might also run medium frequency strategies that pursue:</div>
<ol>
<li>trend (if there is sufficient momentum)</li>
<li>cycles (follow the pivots for high amplitude price cycles)</li>
<li>longer-period arbitrage</li>
</ol>
<div>Focusing on market making and trend/cycle following, understanding price regime (the gross characteristics of price movement) and pricing function (a view on expected forward price) is important.</div>
<p></b></p>
<div><strong>Regime</strong></div>
<div>We might like to have an indication of regime to determine whether we should be market making, following a trend, following cycles, etc.</div>
<p></p>
<div>In particular, with market making, there will be periods in the market where market making is &#8220;dangerous&#8221; (i.e. is almost guaranteed to lose money).   Aside from the obvious danger in gapping prices around news or other events, the main danger is in offering during periods of strong momentum.</div>
<p></p>
<div>There will be a strong order selection bias such that when the market is going up (down) you receive buying (selling) orderflow almost exclusively, and end up with short inventory against an appreciating (depreciating) price.</div>
<p></p>
<div>Hence, there will be periods during a trading day that are &#8220;good&#8221; for market making (i.e. when there is balanced order flow and very gradual price drift) and periods which are better suited for momentum or high-amplitude cycle following strategies.</div>
<div>
</p>
<div><strong>Pricing</strong></div>
<div>Pricing provides us with an expected mean and its derivatives over some forward period, as well as an estimate of noise and MR activity.   This information is invaluable in determining appropriate market making offering prices and in following high amplitude price activity.</div>
<p></p>
<div><strong>Goals</strong></div>
<div>We would like to have the following:</div>
</div>
<ol>
<li>A pricing function with (often) good accuracy over some forward period, tailored to the requirements of the regime</li>
<li>A notion of price regime</li>
<li>Other metrics such as upper and lower noise around the price function (mean), period and amplitudes of monotonic segments, etc.</li>
</ol>
<div>In the context of market making we are looking to have a monotonic and almost linear price function that represents a mean or a mode through price noise.   Calibrated in this fashion one has a convenient view on the forward price function and the upper and lower bounds on prices we are willing to offer on.   This combined with inventory can be used to dynamically bias the offerings.</div>
<p></p>
<div>In the context of momentum or cycling we are looking for a pricing function that follows the momentum or cycles with appropriate curvature and is reasonably predictive (or retrospective with low-lag) with respect to pivot points.</div>
<p></p>
<div><strong>Example</strong></div>
<div>Here is an example of a pricing function (the green line) during a momentum period (over the course of some hours), encountering a disturbance and change in regime to a cycling mode thereafter:</div>
<p></p>
<div> <a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-2-39-48-pm1.png"><img class="alignnone size-full wp-image-875" title="Screen shot 2011-07-27 at 2.39.48 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-2-39-48-pm1.png?w=500&#038;h=211" alt="" width="500" height="211" /></a></div>
<p></p>
<div>Here is the continuation within the series with the pricing function in a momentum / cycling mode:</div>
<div><a href="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-4-36-10-pm.png"><img class="alignnone size-full wp-image-876" title="Screen shot 2011-07-27 at 4.36.10 PM" src="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-4-36-10-pm.png?w=500&#038;h=209" alt="" width="500" height="209" /></a></div>
<p></p>
<div>Note that the above is smoothed a-posteri, so the trajectory of the filter has more noise as it progresses tick to tick.</div>
<p></p>
<div><strong>History Of Approaches</strong></div>
<div>I&#8217;ve used many approaches in the past in modeling the price function:</div>
<div>
<ol>
<li>variety of filters from the signal processing space</li>
<li>signal decompositions and partial reconstitutions</li>
<li>a number of different stochastic state systems with an EKF (extended kalman filter)</li>
<li>direct calibration of least squares splines with various heuristic rules</li>
</ol>
<div>My current approach is the #4, but would like to find a good solution using a SDE in a bayesian framework, as is more elegant and flexible.    My past experience with EKFs was that they are hard to parameterize (via the state and measurement covariances) and can easily become unstable in the presence of unexpected noise.</div>
</div>
<p></p>
<div>A few months ago Max Dama posted a link to a <a title="paper" href="http://arxiv.org/abs/0802.0220">paper</a> describing a TV-VAR model, but more of interest, an alternate approach to describing the kalman filter evolution rate with discount factors.   The discounting approach solves one of the problems in parameterizing Kalman filters.</div>
<p></p>
<div>That and in discussion with some other quants (hi Sasha) recently motivated me to reexamine the SDE approach.   I&#8217;ll be discussing an approach in some detail in the next posts.</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/873/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=873&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2011/07/27/pricing-regimes-part-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-2-39-48-pm1.png" medium="image">
			<media:title type="html">Screen shot 2011-07-27 at 2.39.48 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/07/screen-shot-2011-07-27-at-4-36-10-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-07-27 at 4.36.10 PM</media:title>
		</media:content>
	</item>
		<item>
		<title>Detecting Price Direction in Order Flow</title>
		<link>http://tr8dr.wordpress.com/2011/03/04/detecting-price-direction-in-order-flow/</link>
		<comments>http://tr8dr.wordpress.com/2011/03/04/detecting-price-direction-in-order-flow/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 23:58:50 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=862</guid>
		<description><![CDATA[As indicated in a previous post, high-freq market data is typically in the form of order updates, for example: This can be used to reconstruct the orderbook at any given instant, but can also be used to analyze movements within &#8230; <a href="http://tr8dr.wordpress.com/2011/03/04/detecting-price-direction-in-order-flow/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=862&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>As indicated in a previous post, high-freq market data is typically in the form of order updates, for example:</p>
<p><a href="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-05-at-11-40-51-am.png"><img class="alignnone size-full wp-image-825" title="Screen shot 2011-02-05 at 11.40.51 AM" src="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-05-at-11-40-51-am.png?w=500" alt=""   /></a></p>
<p>This can be used to reconstruct the orderbook at any given instant, but can also be used to analyze movements within the orderbook.   The most primitive approaches look at the incidence of size being removed or hitting a given price-level.    More sophisticated approaches try to determine order streams to see where an order is being moved to in the book.</p>
<p>Given that we can produce a variety of measures that can add information to our trading decisions.   Here is an example of a USD/JPY on a downward move of 10 pips with strong momentum.   The mid price is in the upper pane and the cumulative bid and ask movements (derived from order data) are in the lower pane:</p>
<p><a href="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-20-00-pm.png"><img class="alignnone size-full wp-image-863" title="Screen shot 2011-03-04 at 6.20.00 PM" src="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-20-00-pm.png?w=500&#038;h=438" alt="" width="500" height="438" /></a></p>
<p>One will note that the ask flows are more aggressive than the bid flows.   The above is not yet terribly useful, as the cumulative flows look to follow the price path more or less during a period of momentum.</p>
<p><strong>Momentum</strong><br />
More interesting is to look at what is happening in the book:</p>
<p><a href="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-23-40-pm.png"><img class="alignnone size-full wp-image-864" title="Screen shot 2011-03-04 at 6.23.40 PM" src="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-23-40-pm.png?w=500&#038;h=517" alt="" width="500" height="517" /></a></p>
<p>The reds represent areas of high cancellation and blues high insertion (I amplify this by scaling by the size of movement from one region to another).    You&#8217;ll notice the following:</p>
<ol>
<li><strong>Seller Book<br />
</strong>There is high movement into the inside (or more aggressive) areas of the book, in-line with the fact that the price has downward momentum.   There are vertically &#8220;trailing&#8221; deletions from the outside price levels as traders move their prices en-mass to the inside.</li>
<li><strong>Buyer Book<br />
</strong>Buyers / market makers are risk adverse and are moving their orders deeper into the book away from the inside.  Again we see a trail of deletions in the inside-most levels and strong movements in a couple of deeper bands.</li>
</ol>
<p><strong>Sideways Movement<br />
</strong>What does &#8220;sideways&#8221; or non-directional movement look like then?</p>
<p><a href="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-44-01-pm.png"><img class="alignnone size-full wp-image-865" title="Screen shot 2011-03-04 at 6.44.01 PM" src="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-44-01-pm.png?w=500&#038;h=524" alt="" width="500" height="524" /></a></p>
<p><a href="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-44-01-pm.png"></a>It looks a lot more random, with some upward and downward directional patterns in sequence.</p>
<p><strong>Cleaning It Up</strong><br />
The activity can be denoised to produce a signal that is much easier to read:</p>
<p><a href="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-52-58-pm.png"><img class="alignnone size-full wp-image-866" title="Screen shot 2011-03-04 at 6.52.58 PM" src="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-52-58-pm.png?w=500&#038;h=473" alt="" width="500" height="473" /></a></p>
<p>&nbsp;</p>
<p><strong>Summary</strong><br />
The approach is particularly useful for understanding movements over a short to medium timeframe.   However long-running price movements often have periods of &#8220;indecision&#8221; where the flow and price flounders for a period.   Ultimately this sort of approach needs to be evaluated on multiple windows to accomodate various timeframes.</p>
<p>(sorry this is mostly pretty pictures without much explanation.  Should provide some ideas though).</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/862/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/862/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=862&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2011/03/04/detecting-price-direction-in-order-flow/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-05-at-11-40-51-am.png" medium="image">
			<media:title type="html">Screen shot 2011-02-05 at 11.40.51 AM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-20-00-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-03-04 at 6.20.00 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-23-40-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-03-04 at 6.23.40 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-44-01-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-03-04 at 6.44.01 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/03/screen-shot-2011-03-04-at-6-52-58-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-03-04 at 6.52.58 PM</media:title>
		</media:content>
	</item>
		<item>
		<title>Ponzi-Like Bidding Scheme</title>
		<link>http://tr8dr.wordpress.com/2011/02/18/ponzi-like-bidding-scheme/</link>
		<comments>http://tr8dr.wordpress.com/2011/02/18/ponzi-like-bidding-scheme/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 13:26:32 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=854</guid>
		<description><![CDATA[Just for fun:  There is a retail bidding site QuiBids which has received a bit of press in the US recently.   The attraction is that they offer products (such as ipads) for, say, an average price of $30-50 (whatever &#8230; <a href="http://tr8dr.wordpress.com/2011/02/18/ponzi-like-bidding-scheme/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=854&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Just for fun:  There is a retail bidding site <a href="http://www.quibids.com/">QuiBids</a> which has received a bit of press in the US recently.   The attraction is that they offer products (such as ipads) for, say, an average price of $30-50 (whatever the highest bid is).    One may wonder how this works.</p>
<p>Most auctions are &#8220;penny auctions&#8221;, meaning that each bid placed on an item increments the price by $0.01.   Prospective buyers pay for each bid they put forward on an item.   In fact, the company charges $0.60 / bid.   So with an end-auction price of, say, $50, the ipad has brought in $3000, because there were 5000 bids to achieve that price.  Wow, these guys are making a lot of money in terms of % markup!</p>
<p>The bidding session gets prolonged by ~10 seconds each time a bid is made in the last seconds.   Basically, it seems to me that the winner is the person in the pool of bidders that has not exhausted his prepaid bids or otherwise given up.</p>
<p>Since one can see the bidder with the top bid in real-time as the end-game bidding occurs, perhaps one could game it, observing the timeseries of bids each participant has placed and come up with a view on likelihood of having reached their bidding limit.   At that point one would start testing by putting in a bid and determine who is left.</p>
<p>If the gaming commission understood what they are doing here, suspect they would have to get a gambling license.    Interesting &#8220;not-quite-a-scam&#8221; business concept.   I have to think that eventually most participants, not having won anything will discontinue with the site.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/854/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/854/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=854&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2011/02/18/ponzi-like-bidding-scheme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>
	</item>
		<item>
		<title>Bipartite Matching</title>
		<link>http://tr8dr.wordpress.com/2011/02/17/bipartite-matching/</link>
		<comments>http://tr8dr.wordpress.com/2011/02/17/bipartite-matching/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 23:02:46 +0000</pubDate>
		<dc:creator>tr8dr</dc:creator>
				<category><![CDATA[strategies]]></category>

		<guid isPermaLink="false">http://tr8dr.wordpress.com/?p=846</guid>
		<description><![CDATA[For very low-level order analysis we try to determine continuity from one order to the next as a stream of orders across a period.   This is applicable for orders generated by a given trader (algo) that are more-or-less continually &#8230; <a href="http://tr8dr.wordpress.com/2011/02/17/bipartite-matching/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=846&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>For very low-level order analysis we try to determine continuity from one order to the next as a stream of orders across a period.   This is applicable for orders generated by a given trader (algo) that are more-or-less continually in the market.</p>
<p>In most cases an order near the top of book has a short lifetime, but an algo will maintain continuity through resubmission into the order book at a different price level.   This stream of orders is often masked in various ways, but often has discernable patterns, depending on the sophistication or consideration towards masking this in the algo.</p>
<p>Going from order deletions to new order insertions we want to attempt to match up the old and new orders (where applicable), to determine the continuity of an order stream.   We therefore want to map from an old-set to a new-set:</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-10-30-pm.png"><img class="alignnone size-full wp-image-847" title="Screen shot 2011-02-17 at 5.10.30 PM" src="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-10-30-pm.png?w=500" alt=""   /></a></p>
<p>However, in order to determine, we have to explore all possible mappings with weights between these edges:</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-15-26-pm.png"><img class="alignnone size-full wp-image-848" title="Screen shot 2011-02-17 at 5.15.26 PM" src="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-15-26-pm.png?w=500" alt=""   /></a></p>
<p>The optimal mapping will be one that finds the set of one-to-one edges that has maximal weight.   This is a problem in graph theory and optimisation theory.   This can be expressed rather neatly as a linear constraints problem where we have:</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-42-30-pm.png"><img class="alignnone size-full wp-image-849" title="Screen shot 2011-02-17 at 5.42.30 PM" src="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-42-30-pm.png?w=500" alt=""   /></a></p>
<p>Where Xij is a matrix of 0 or 1, 1 indicating an edge and 0 no edge.  Wij is a corresponding matrix of weights for each edge.   Integer (or integral) linear programming solutions are classified as NP-hard and do not have an efficient algorithm.    We will be evaluating these on a relatively small # of orders each time, so the cost of a brute force solution is not bad.</p>
<p>The real trick is in determining the weights, representing the degree of similarity.  Going further, one may generate a tree of these (that spans out exponentially, but is trimmed regularly).   Some decisions on prior matches will be wrong and should be reevaluated holistically.</p>
<p style="padding-left:30px;"><a href="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-59-50-pm.png"><img class="alignnone size-full wp-image-852" title="Screen shot 2011-02-17 at 5.59.50 PM" src="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-59-50-pm.png?w=500" alt=""   /></a></p>
<p>Is it worth the effort?   Depends on what information you are interested in and what your game is.   We do a mixture range ultra-high frequency to medium frequency.   This is one sub-problem of a bigger picture.</p>
<h3>Addendum</h3>
<p>I should mention that the worst case brute-force approach involves examining combined weights for each permutation of edges.  This is a O(n!) algorithm that quickly becomes uncomputable.   For the specific bipartite matching problem, rather than the general Integral Linear Programming problem there are much more efficient solutions.   One of the simplest (though not the most efficient) is the &#8220;<a href="http://en.wikipedia.org/wiki/Hungarian_algorithm">Hungarian algorithm</a>&#8220;.   A reader pointed out a paper for an &#8220;<a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.64.1078&amp;rep=rep1&amp;type=pdf">online&#8221; approach</a> to matching as well.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tr8dr.wordpress.com/846/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tr8dr.wordpress.com/846/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tr8dr.wordpress.com&#038;blog=8581693&#038;post=846&#038;subd=tr8dr&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tr8dr.wordpress.com/2011/02/17/bipartite-matching/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f23b586c92cb305ab210b5f2cb805f1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tr8dr</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-10-30-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-02-17 at 5.10.30 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-15-26-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-02-17 at 5.15.26 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-42-30-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-02-17 at 5.42.30 PM</media:title>
		</media:content>

		<media:content url="http://tr8dr.files.wordpress.com/2011/02/screen-shot-2011-02-17-at-5-59-50-pm.png" medium="image">
			<media:title type="html">Screen shot 2011-02-17 at 5.59.50 PM</media:title>
		</media:content>
	</item>
	</channel>
</rss>
