<?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>Hack the market &#187; strategy development</title>
	<atom:link href="http://www.puppetmastertrading.com/blog/index.php/category/strategy-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.puppetmastertrading.com/blog</link>
	<description>Algorithmic trading experiences</description>
	<lastBuildDate>Wed, 21 Apr 2010 23:11:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>pairs portfolio</title>
		<link>http://www.puppetmastertrading.com/blog/2010/04/08/pairs-portfolio/</link>
		<comments>http://www.puppetmastertrading.com/blog/2010/04/08/pairs-portfolio/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 15:51:48 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[EMS Internals]]></category>
		<category><![CDATA[back-testing]]></category>
		<category><![CDATA[dereferenced]]></category>
		<category><![CDATA[portfolio management]]></category>
		<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=1175</guid>
		<description><![CDATA[People have asked me how I go about implementing a strategy in Stratbox.  While I&#8217;ve illustrated a good number of strategies running in Stratbox in these pages, I&#8217;ve never walked through a non-trivial example from conception, through design, implementation and iteration.  Today we&#8217;ll go through a reasonably complex example in total (I&#8217;ll provide source) detail.
The [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="/images/pairs.jpg" alt="" width="269" height="180" />People have asked me how I go about implementing a strategy in Stratbox.  While I&#8217;ve illustrated a good number of strategies running in Stratbox in these pages, I&#8217;ve never walked through a non-trivial example from conception, through design, implementation and iteration.  Today we&#8217;ll go through a reasonably complex example in total (I&#8217;ll provide source) detail.</p>
<p>The example I&#8217;ve chosen is, I think, very nice because it&#8217;s a portfolio-oriented strategy, which is pretty much the only kind I care to explore; it&#8217;s also based around the concept of pairs trading, which is something which most can easily relate to; and finally, it&#8217;s already public domain and yet almost certainly has some juice in it for those who care to understand it and extend it intelligently.</p>
<p>The example comes from the blog of a company, <a title="Palantir" href="http://www.palantirtech.com/" target="_blank">Palantir</a> which does (something like?) analytical / decision support software for both finance and intelligence-gathering services (quants and spooks &#8211; spooky quants?).  The specific example is <a title="Palantir: pairs trading strategy" href="http://www.palantirfinance.com/analysis-blog/?p=194" target="_blank">here</a> and is described thusly:</p>
<p><span id="more-1175"></span></p>
<blockquote><p>In this study we explore a trading strategy that isolates pairs of  instruments within a sector that are highly correlated. We enter a trade  if the price paths of these instruments diverge, going long one  instrument and short the other, with the assumption that their price  paths will converge.</p>
<p>We construct our strategy in four parts: (1) isolate the target set  of tradable instruments, (2) choose a rule for finding correlated pairs  within that set, (3) pick criteria for entering trades, and (4) test the  trading strategy.</p>
<p>&#8230;</p>
<p>For this study we want to isolate pairs of instruments whose  correlation is above a certain threshold.  At the beginning of each  quarter, we restrict our target stocks to the top 5 in the sector by  252-day correlation to the S&amp;P 500.  Then our <a href="http://www.palantirfinance.com/apps/strategy.html">Strategy</a> uses a metric that, for a given group of stocks, outputs a list of pairs  with a correlation above our target threshold of .60 over the same time  period.</p>
<p><strong>&#8230;<br />
</strong></p>
<p>Across every day and every pair in our trading list, we check the  21-day z-score (number of standard deviations from the mean) of the  difference between the two series. We classify the stocks as diverging  when the absolute value of the z-score is between 1.5 and 3.0. When this  condition is met we short the stock that is rising and long the stock  that is falling, sizing our position relative to the z-score and the  number of pairs currently trading.</p></blockquote>
<p><strong>~(sectors) ; reframing the strategy<br />
</strong></p>
<p>While I&#8217;ll implement a strategy broadly based on their description, I will use some poetic license to modify it in ways that seem to me sensible.  First, I have good experience writing equity strategies which deal with sectors and have pretty uniformly found that sectors, as defined by S&amp;P or whomever, are more trouble than they&#8217;re worth.  Instead, looking at correlation matrices and determining on that basis who should be paired, is much more fruitful in my experience.  Tr8der has some very nice posts illustrating (very prettily!) a similar point <a title="Tr8der: equity clusters 2" href="http://tr8dr.wordpress.com/2009/12/31/equity-clusters-2/" target="_blank">here</a> and <a title="Tr8der: equity clusters" href="http://tr8dr.wordpress.com/2009/12/30/equity-clusters/" target="_blank">here</a>.  (Actually, his point is a bit broader and represents an area of possibly promising development of this strategy which I won&#8217;t pursue here.)</p>
<p>So, we&#8217;re going to chunk the idea of explicitly using sectors.  Instead, we&#8217;ll simply construct, on a monthly basis (Palantir did this quarterly) a <em><strong>TrailDays</strong></em> correlation matrix from which we&#8217;ll extract the set of pairs which have a correlation greater than <em><strong>MinCorrelation</strong></em>.  On a daily basis, we will calculate the <em><strong>ZScoreDays</strong></em> z-scores of each of these pairs and sort them by absolute value, tossing those whose values are less than <em><strong>MinZScore </strong></em>or exceed <em><strong>MaxZScore</strong></em>.  Since I don&#8217;t like the idea of having an open-ended number of pairs/positions in my portfolio, I will constrain the portfolio to a maximum of <em><strong>N</strong></em> names and will <em><strong>Allocate</strong></em> $1M to the strategy.   Finally, we will look at the effect of trading an <em><strong>EvenlyWeight</strong></em>ed portfolio or a z-score weighted portfolio (as Palantir had done).</p>
<p>The initial &#8216;universe&#8217; of equities across which we will calculate our correlations will be filtered from my database of daily equity data going back to 2005 where the closing price is over $1, the average daily dollar-volume is over $50M and the data is relatively clean (few if any gaps).  This yields an initial universe of ~600 equities and ~180K pairs.</p>
<p>Assuming that we keep <em><strong>N</strong></em> above 20 or so and we keep our allocation constant at $1M, and assume execution at the close price, we should expect our results to be reasonably believable as it&#8217;s unlikely that the size we&#8217;re trading in would distort the market.  Scaling any strategy presents its own set of challenges which we&#8217;re not going to go into for this example, but an obvious direction for scaling the strategy would be to simply run it over intraday data and scale into and out of positions as conditions permit.</p>
<p>Ok, so that&#8217;s what our strategy is going to look like.  Now, how do we &#8220;make it so&#8221;?</p>
<p><strong>structure of a stratpart</strong></p>
<p>Within Stratbox, strategies are represented as composites made-up of &#8217;stratparts&#8217; each of which has its own metadata descriptor containing parameters.  Stratparts can be composed together within a strategy to enhance or modify the behavior of a strategy.  Thus, one can have a stratpart which implements the above logic paired with another stratpart which will e.g., modify the portfolio to impose beta neutrality, damp volatility or some other form of reporting or risk management.  Given that this example is already complexish, we&#8217;ll just stick to the one stratpart.</p>
<p>A stratpart has a few key elements.  One is the metadata descriptor which allows the strategy container (stratbox) to interact with it for back-testing, optimization or forward-walking purposes, or to allow a &#8216;trader&#8217; to interact with it dynamically during run-time (the so-called &#8216;gray box&#8217;).  Beyond that, it has an essentially event-driven design.  The method <strong>quote() </strong>is called when relevant (i.e., subscribed) market data arrives.  The method <strong>execution()</strong> is called when executions for orders that originated with this strategy are received.  And the method <strong>strategyEvent()</strong> is invoked on a variety of &#8216;interesting&#8217; events that the strategy implementer might care about.  None of these methods are required, so in its simplest form, a stratpart is a very simple piece of code to write.</p>
<p><strong>services in a stratpart</strong></p>
<p>Once one has complied with the minimal requirements for implementing a stratpart, one is rewarded with a variety of useful services: subscription-based market data feeds as well as a fast snapshot db and an in-memory historical db for quick correlation analyses cover market data needs.  Position management is handled at both the strategy level and at the exchange level (if you&#8217;re trading across multiple exchanges).  There is more, including performance analysis (e.g., sharpe, and its various analytic friends) and hierarchical cash allocation within and across strategies, but we won&#8217;t look at these in this example.</p>
<p><strong>implementing metadata</strong></p>
<p>So, the first thing we need to do is define our metadata.  This is done through the use of a conventionally-named static method <strong>Descriptor().<br />
</strong></p>
<pre class="brush: java;">
public static Descriptor Descriptor() {

 ArrayList&lt;Param&gt; params = new ArrayList&lt;Param&gt;();

 String cd = &quot;Unleveraged capital to apply&quot;;
 params.add(new Param(InitialBalance, cd, false, 1000000.0));

 String n = &quot;# of instruments to hold in portfolio&quot;;
 params.add(new Param(N, n, true, 20));

 String tc = &quot;Trailing days over which to calculate correlations&quot;;
 params.add(new Param(TrailDays, tc, true, 252));

 String mc = &quot;the minimum correlation of pairs to consider&quot;;
 params.add(new Param(MinCorrelation, mc, true, .75));

 String zd = &quot;trailing days over which to calc z-score&quot;;
 params.add(new Param(ZScoreDays, zd, true, 21));

 String mizs = &quot;minimum z-score&quot;;
 params.add(new Param(MinZScore, mizs, true, 1.5));

 String mazs = &quot;maximum z-score&quot;;
 params.add(new Param(MaxZScore, mazs, true, 3.0));

 String ew = &quot;evenly-weight portfolio? (or weight by z-score)&quot;;
 params.add(new Param(EvenlyWeight, ew, true, true));

 Descriptor _desc = new Descriptor
   (&quot;puppetmaster.strats.Pairs&quot;, _Desc, params);

 return _desc;
}

public Pairs(Strategy strat, Descriptor d) { super(strat, d); }
</pre>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p>Not the most interesting chunk of code, but pretty straightforward and its inclusion opens up a lot of functionality within the environment as each of these parameters can now be systematically or manually modified in-flight.  The third parameter to the Param constructor, a boolean, indicates if we want to allow the system to optimize this parameter.  Thus, the allocation/initialBalance parameter isn&#8217;t optimizable as it wouldn&#8217;t make any sense to do so.  Even so, we can (ourselves or through an allocation algorithm) modify this value to force the strategy to lighten or extend its financial footprint.  The others are fair game for optimization.</p>
<p>The constructor is also required &#8211; with that exact signature.  This is pretty much it for the &#8216;boilerplate&#8217; code required.</p>
<p><strong>&#8216;installing&#8217; the stratpart</strong></p>
<p>Now that we&#8217;ve met the minimum requirements for a stratpart, we can install it into stratbox.  This requires adding one line to your personal stratparts.xml config file.  Like so:</p>
<pre class="brush: xml; highlight: [5];">
&lt;?xml version='1.0'?&gt;
&lt;stratParts&gt;
 &lt;descriptor class='puppetmaster.model.strategy.FwdWalker'/&gt;
 &lt;descriptor class='puppetmaster.model.strategy.StrategyPortfolio'/&gt;
 &lt;descriptor class='puppetmaster.strats.Pairs'/&gt;
 &lt;descriptor class='puppetmaster.strats.AMBO'/&gt;
 &lt;descriptor class='puppetmaster.strats.meta.AdjMeanReverter'/&gt;
 &lt;descriptor class='puppetmaster.strats.meta.AdjTrendFollower'/&gt;
 &lt;descriptor class='puppetmaster.strats.meta.Binary'/&gt;
</pre>
<p>Once we&#8217;ve informed stratbox of the new stratpart we&#8217;ve written, we can view it within our library of stratparts within the strategy wizard in stratbox:</p>
<div class="wp-caption aligncenter" style="width: 454px"><img src="/images/plib.jpg" alt="" width="444" height="481" /><p class="wp-caption-text">Our Pairs strategy in the Strategy Wizard&#39;s stratparts library</p></div>
<p>And all of the parameters we defined within our descriptor show up on the next page where we can parameterize or optimize the strategy:</p>
<div class="wp-caption aligncenter" style="width: 453px"><img src="/images/pcfg.jpg" alt="" width="443" height="554" /><p class="wp-caption-text">Configuring the Pairs stratpart within the strategy wizard</p></div>
<p>This means that the stratpart can be combined with other stratparts to create new strategies as I&#8217;ve described  and that it can partake in the rich set of functionality within the stratbox gui.  Including actually trading.  But first, we must make the strategy actually do something&#8230;</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong>implementing event handling</strong></p>
<p>To that end, we must implement the event handling methods I&#8217;d described previously.  Since we&#8217;re not going to do any detailed execution handling in this strategy, we&#8217;ll only implement the <strong>quote()</strong> method and a subset of the events sent to the <strong>strategyEvent() </strong>method. In particular, we&#8217;ll listen to activation events (so we can initialize cleanly), changes to our descriptor and changes to our positions.</p>
<pre class="brush: java;">
/** listen for select strategyEvents */
public void strategyEvent(StrategyEvent event) {
  super.strategyEvent(event);
  switch (event.type) {
    case Activated:            _init();                 break;
    case DescriptorChanged:    _readDesc();             break;
    case PositionChanged:      _posnChange(event);      break;
  }
}
&lt;pre&gt;</pre>
<p>For quotes, we&#8217;ll just listen to the Beginning of Day (BOD) event.  If we wanted to trade intraday, we&#8217;d have to listen to tick events, but we&#8217;ll leave that for another day&#8230;</p>
<p>From a high-level, our code is pretty simple.  We determine the universe of pairs we might trade, we select from among them, we determine what our new portfolio should look like and then we trade to transition from our current state to our desired state.  That&#8217;s it.</p>
<pre class="brush: java;">
/** mkt data goes here, but we only listen for the BOD
 * (&quot;Beginning of day&quot;) event */
public void quote(Quote q) {
  if (q.type() != Quote.Type.BOD) return; // daily strat...

  try {
    List&lt;_Pair&gt; pairs = _getPairs();
    List&lt;_Pair&gt; sel = _selectPairs(pairs);
    List&lt;Position&gt; dp = (List&lt;Position&gt;)_desiredPfolio(pairs,sel);
    _Log.debug(&quot;PORTFOLIO: &quot;+dp);
    _trade(dp);
  } catch(Exception e) { _Log.error(e.getMessage(),e); }
}
</pre>
<p><strong>the messy details</strong></p>
<p>Digging into the details gets more complex, but not horrifically so, as stratbox already has basic analytics like correlation matrices, z-scores, volatility built into it.  Likewise with basic portfolio analytics and transformations. Thus, our code to trade a (pairs-based) long-short portfolio with an arbitrary number of elements is surprisingly simple:</p>
<pre class="brush: java;">
/** given a desired portfolio, trade to make it so */
void _trade(List&lt;? extends Position&gt; desiredFolio) {
  PositionRecord[] currFolio = posns();
  // Given our current portfolio (posns) and our desired state (dfolio),
  //  we generate the set of orders which will transform from the former
  //  to the latter
  //
  List&lt;Order&gt; orders = PortfolioComposer.TransformPortfolio
    (currFolio, desiredFolio, _orderF(), _strat, _strat.account());

  // place the orders for execution
  for (Order order : orders) {
    try {
      order.setType(Order.Type.MOC); // we trade at the close only
      _subscribe(order.contract());
      _execP().placeOrder(order);
    } catch (Exception e) { _Log.error(e.getMessage(), e); }
  }
}
</pre>
<p>As promised, I provide the full source listing below for those interested, but won&#8217;t over burden the discussion with a complete description of every little piece of it.</p>
<p><strong>a telling omission and some results</strong></p>
<p>Early in my career, working as a software engineer in a wall st front office technology department, I was befriended by a manager who told me he had once been a trader.  I asked him why he wasn&#8217;t a trader anymore.  He quipped:</p>
<blockquote><p>I was half of a talented trader.  I knew, in my bones, when to get into a trade.  Sadly, I was never really sure when to get out&#8230;</p></blockquote>
<p>It seems that the author of the Palantir example suffers a similar characteristic to my old friend (or is just being understandably cagey) &#8211; she specifies an entry condition, but not an exit!  Since she doesn&#8217;t impose any costs for trading, this has no big side effects, but in stratbox we do impose (pretty onerous -&gt; realistic!) costs for trading.</p>
<p>In any case, since this is just a simple example I&#8217;ve maintained the &#8216;no exit&#8217; policy and simply exit a trade once its pair goes out of the acceptable ranges for either correlation or z-score.  This has a bad effect on the strategy as you end up churning a lot of trades at the high end of the z-score range.  That is, if we set our upper boundary for z-score to be 3, then we might enter and exit a position multiple times as the z-score oscillates between, say, 2.9 and 3.1.  A more careful implementation could minimize this effect.</p>
<p>Another difference imposed by our more realistic simulation as opposed to the original example is that I&#8217;m restricting the portfolio size explicitly and explicitly limiting myself to trading a given contract within one pair as opposed to allowing a contract to trade across multiple pairs (invoking higher costs but allowing positions to offset and thus providing a neat little optimization &#8211; assuming trading costs nothing!).</p>
<p>All the same, the strategy clearly has some positive characteristics and when parameterized to take advantage of its naive exit strategy (by making the z-score low-end quite low, e.g., 0.5) takes on the character of a hedged trend-following strategy.  How so?  Well, while we are getting churned around the high-end (entry) z-scores, our profitable exits only happen once the z-scores have diminished (the prices have converged) considerably.  So we take more, smaller losses while our winners are held a bit longer.</p>
<div class="wp-caption aligncenter" style="width: 628px"><img src="/images/pairsOpt.jpg" alt="" width="618" height="260" /><p class="wp-caption-text">some Pairs results in &#39;10</p></div>
<p>Adding to my portfolio size improves things generally (and also increases the strategy&#8217;s scalability) while increasing the <em><strong>MinCorrelation </strong></em>parameter seems to hurt performance<em><strong> </strong></em>(not sure why, honestly &#8211; perhaps because if they&#8217;re very highly correlated and already diverging so strongly it may mean they&#8217;re actually diverging fundamentally).<strong> </strong>Returning to the topic of costs, each of these strategies incurred costs of over $5K for the period in question.<strong> </strong>And returning to the parameter which governs the weighting strategy employed, although I haven&#8217;t illustrated it here (as I haven&#8217;t looked at it very carefully), my initial finding is that it changed very little.  <em><strong><br />
</strong></em></p>
<p>There&#8217;s a great many areas where this strategy could be improved &#8211; that&#8217;s the fun, after all! &#8211; but hopefully even in its primitive form this example brings to light both an interesting baseline portfolio pairs strategy, while answering the question of how one goes about concretely implementing it within stratbox.</p>
<p>The entire strategy weighs-in at ~400 LOC including comments, boilerplate and individualized imports.  The source is here: <a href="/images/Pairs.java" target="_blank">Pairs.java</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2010/04/08/pairs-portfolio/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>transitions</title>
		<link>http://www.puppetmastertrading.com/blog/2010/02/08/transitions/</link>
		<comments>http://www.puppetmastertrading.com/blog/2010/02/08/transitions/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 21:21:12 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[EMS Internals]]></category>
		<category><![CDATA[portfolio management]]></category>
		<category><![CDATA[regime-switching]]></category>
		<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=1004</guid>
		<description><![CDATA[Today we return to our series on regime switching and the topic of managing portfolios of strategies.  In particular, we build on the examples illustrated in sensitivity testing and steppin&#8217; out, in which we showed historical and then real-time &#8216;forward-walking&#8217; of strategies.  The next step we&#8217;d described was to evolve the techniques illustrated to support [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="margin-left: 5px; margin-right: 5px;" src="/images/genetic.png" alt="" width="353" height="285" />Today we return to our series on regime switching and the topic of managing portfolios of strategies.  In particular, we build on the examples illustrated in <a title="sensitivity testing: historical forward walk" href="http://www.puppetmastertrading.com/blog/2009/11/14/sensitivity-testing/" target="_blank">sensitivity testing</a> and <a title="steppin' out" href="http://www.puppetmastertrading.com/blog/2009/11/25/steppin-out/" target="_blank">steppin&#8217; out</a>, in which we showed historical and then real-time &#8216;forward-walking&#8217; of strategies.  The next step we&#8217;d described was to evolve the techniques illustrated to support the real-time management of a portfolio of strategies.</p>
<p>In the example below, we look at another &#8216;meta&#8217; strategy named <em>StrategyPortfolio</em> which maintains a dynamic portfolio &#8211; P &#8211; of strategies which it will select from a set of strategies &#8211; S &#8211; running concurrently in simulation.  The constituents of P as well as their cash allocations and parameterizations will be rebalanced/adjusted regularly after an initial &#8216;out-of-sample&#8217; period during which only the S strategies are run.</p>
<p>Apart education, the intention of this strategy, as I&#8217;d originally suggested <a title="multi-strategy trading with regimes" href="http://www.puppetmastertrading.com/blog/2009/09/13/multi-strategy-trading-with-regimes/" target="_blank">here</a>, is to &#8216;back-into&#8217; a regime-switching strategy without attempting to directly quantify the regimes explicitly.</p>
<p>This has proved to be even more interesting than I&#8217;d expected, not so much because it performs particularly well (though it&#8217;s promising), but because of all of the things it has taught us.  In particular, the transitions are a killer and there are properties of strategies which (dis-)qualify them from being effective in such a scheme&#8230;</p>
<p><span id="more-1004"></span></p>
<p><strong><em>bad news </em><em>good news </em></strong><img class="alignleft" style="margin-left: 5px; margin-right: 5px;" src="/images/goodbad.jpg" alt="" width="270" height="212" /></p>
<p>As before, I&#8217;m not going to take the time to write-up my results in any formal manner but will again rely upon a quick screencast of the software running.  The good news is that I&#8217;m figuring out how to edit these things, so it&#8217;s mercifully shorter than earlier screencasts&#8230;</p>
<p><a title="Screencast: StrategyPortfolio in Stratbox" href="/images/flash/StrategyPortfolio/StrategyPortfolio.html" target="_blank">Please click here to see the screencast.</a></p>
<p>I hope you find it interesting and will look forward to any comments or suggestions you might make.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2010/02/08/transitions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>steppin&#8217; out</title>
		<link>http://www.puppetmastertrading.com/blog/2009/11/25/steppin-out/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/11/25/steppin-out/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 19:01:40 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[EMS Internals]]></category>
		<category><![CDATA[regime-switching]]></category>
		<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=822</guid>
		<description><![CDATA[We&#8217;ve been looking at what we&#8217;ve been calling &#8220;meta-strategies&#8221; &#8211; strategies that act upon other strategies &#8211; with the goal of implementing something like we&#8217;d described in the recent regime-switching post.  (Please note that since then I&#8217;ve added a category to capture this thread.)
Last time we saw an example of historical forward-walking of a portfolio-oriented [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 2px 5px;" src="/images/steppin-out.jpg" alt="" width="240" height="240" />We&#8217;ve been looking at what we&#8217;ve been calling &#8220;meta-strategies&#8221; &#8211; strategies that act upon other strategies &#8211; with the goal of implementing something like we&#8217;d described in the recent <a title="multi-strategy trading with regimes" href="http://www.puppetmastertrading.com/blog/2009/09/13/multi-strategy-trading-with-regimes/" target="_blank">regime-switching post</a>.  (Please note that since then I&#8217;ve added a category to capture this thread.)</p>
<p>Last time we saw an example of historical forward-walking of a portfolio-oriented day-trading strategy which utilized daily data.  This time we do something a bit more interesting and correspondingly complex.  Today we&#8217;ll look at a real-time forward-walk of a moderate-frequency strategy (trades perhaps a few hundred times in  a day) which looks at the top-of-the-book but doesn&#8217;t use market-depth.  The strategy is a simple mean-reverter that we&#8217;ve described before though we&#8217;ve had to make some small changes to get it to behave in the context we&#8217;re looking at now&#8230;</p>
<p><span id="more-822"></span></p>
<h3>meta-strategy protocol</h3>
<div class="wp-caption alignright" style="width: 179px"><img class=" " style="margin: 2px 3px;" src="/images/gigo.jpg" alt="" width="169" height="201" /><p class="wp-caption-text">careful ...</p></div>
<p>In particular, we need something of a protocol for sending <em>commands </em>from the meta-strategy to the &#8216;target&#8217; strategy.  Stratparts generally have a simple mechanism for this as they are notified of any changes to their descriptors.  What they do upon such notifications is their own business.  In order to achieve our goals, we might need to firm this up a bit, but it turns out this quickly becomes tricky terrain.</p>
<p>Consider a single contract strategy, say, a simple mean-reverter like one we&#8217;ve seen before (and which I&#8217;ll illustrate in the screencast below).  If we want to treat it as an element within a portfolio of strategies, then we need to be able to modify its allocation.  But changing the allocation to a dynamic strategy is very different from changing the allocation to a single name within a portfolio as the allocation effectively becomes a maximum and the strategy may spend the great majority of its time under-allocated.  But this is manageable if we don&#8217;t mind being under-allocated at times.</p>
<p>A harder case is if someone comes along and says, &#8220;stop trading gold&#8221;, and &#8220;start trading silver&#8221;.  What about my open positions &amp; orders?  If the answer is to go flat, then the <em>character </em>(of the returns) of the strategy is itself going to be effected by the fact that they are being mutated by a meta-strategy; if the answer isn&#8217;t to go flat then you&#8217;re really talking about a whole different, multi-contract strategy.  So you have to be careful to ensure that the kinds of mutations you are relying upon aren&#8217;t excessively disruptive to the strategy or you&#8217;re likely to see performance wildly different from normal for the strategy.  As always, if you put garbage in, you shouldn&#8217;t expect cotton candy to come out&#8230;</p>
<p>For this example, we can control allocation and two simple numeric params governing the strategy.  I&#8217;m just going to avoid the please-trade-a-different-contract-case and aim to address that issue by ultimately placing these strategies into a portfolio (some later day).  For now, we avoid the hard cases but I think the results remain interesting all the same&#8230;</p>
<p>In particular, just as we&#8217;d seen last time (on a totally different time-frame and with a totally different strategy), the forward-walked strategy appears to perform well relative to its peers&#8230;</p>
<p style="text-align: center;">If interested, <a title="Realtime Forward-walk example in stratbox" href="/images/flash/realtimeFwdWalk-Stratbox/realtimeFwdWalk-Stratbox.html" target="_blank">please click here</a> to see the screencast/example.</p>
<p style="text-align: left;">-</p>
<p style="text-align: left;">Happy Thanksgiving!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/11/25/steppin-out/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>sensitivity testing</title>
		<link>http://www.puppetmastertrading.com/blog/2009/11/14/sensitivity-testing/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/11/14/sensitivity-testing/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 16:44:34 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[EMS Internals]]></category>
		<category><![CDATA[back-testing]]></category>
		<category><![CDATA[performance analysis]]></category>
		<category><![CDATA[portfolio management]]></category>
		<category><![CDATA[regime-switching]]></category>
		<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=850</guid>
		<description><![CDATA[We&#8217;ve been looking at how a strategy container might view and implement a variety of modes for strategies it will launch and contain.  Last time I documented a uniform initialization process for many of them, including a posited walk-forward parameter optimization mode.  I&#8217;ve implemented an initial version of this that I&#8217;ll illustrate through a screencast [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 260px"><img src="/images/smarmySpock.gif" alt="" width="250" height="188" /><p class="wp-caption-text">&#39;optimization&#39; or &#39;search&#39;?</p></div>
<p>We&#8217;ve been looking at how a strategy container might view and implement a variety of modes for strategies it will launch and contain.  <a title="ready to launch" href="http://www.puppetmastertrading.com/blog/2009/11/08/ready-to-launch/" target="_blank">Last time</a> I documented a uniform initialization process for many of them, including a posited walk-forward parameter optimization mode.  I&#8217;ve implemented an initial version of this that I&#8217;ll illustrate through a screencast (first ever &#8211; be gentle) below, but before continuing want to raise a couple of cautionary notes about the slope we&#8217;re traversing here.</p>
<p>From the <a title="fools gold" href="http://puppetmastertrading.com/blog/2007/09/26/fools-gold/" target="_blank">very first post</a> on this blog I&#8217;ve tried to underline the danger that over &#8216;optimization&#8217; poses in view of the simple unalterable fact that if you look at enough random junk, you are bound to see things that look impossibly good.  Doesn&#8217;t mean they&#8217;re actually good.  In the context of trading strategy development, this is a particular danger as strategy parameter optimizers are easy to come by and can be very misleading if employed naively.  I think this is in part due to the term &#8216;optimization&#8217; which is really a stretch for what these tools do.  They&#8217;re better described as search tools as they are really searching through a tuple-space of possible parameter combinations that you&#8217;ve specified, and then ranking them by some criteria you specify.</p>
<p>They&#8217;re still useful, but less as &#8216;optimizers&#8217; and more as tools for judging the <em>sensitivity </em>of the strategy to different parameterizations.  If the strategy demonstrates good performance and stability over a variety of market conditions and parameterizations, you may just have found yourself a <a title="character of a winner" href="http://www.puppetmastertrading.com/blog/2008/04/04/the-character-of-a-winner/" target="_blank">winner</a>&#8230;</p>
<p>Anyway, I felt that had to be said&#8230;</p>
<p><span id="more-850"></span></p>
<p>Now, I&#8217;ll open the floor to a quick illustration of the initialization process described previously and an example of historical forward-walking.</p>
<p>At this point, I&#8217;m vested in the inquiry we&#8217;d started with the <a title="regime-switching" href="http://www.puppetmastertrading.com/blog/2009/09/13/multi-strategy-trading-with-regimes/" target="_blank">regime-switching post</a> and will apportion time each week towards implementing something like what we&#8217;d described there.  I expect the steps to be something like:</p>
<ol>
<li>historical fwd-walking which I&#8217;ll illustrate today</li>
<li>real-time fwd-walking, that is, dynamically adjusting a live strategy&#8217;s parameters based on a continuously repeated ranking of a concurrent &#8216;live optimization&#8217; of the same strategy</li>
<li>real-time allocation to a portfolio of strategies based on regime-switching where regimes are defined by the performance of a heterogeneous set of strategies we run concurrently (again &#8216;live optimization&#8217;)</li>
<li>peace on earth</li>
</ol>
<p>I may have some of the steps wrong, but am hopeful.  We&#8217;ll adjust as needed.</p>
<p>If interested, please click on the below image/link which will hopefully take you to a screencast.  This is my first-ever attempt to put a screencast in the blog, so please let me know if you have technical difficulties or suggestions on how to improve the experience.  Or if it&#8217;s just a big waste of time!</p>
<p>In the screencast I give a quick illustration of a simple backtest, a simple parameter optimization and finally a fwd-walk.  I&#8217;ll appreciate your feedback.</p>
<div class="wp-caption aligncenter" style="width: 410px"><a href="http://www.puppetmastertrading.com/images/flash/fwdWalk-Stratbox/fwdWalk-Stratbox.html"><img class=" " src="/images/forwardWalkScreencast.jpg" alt="click" width="400" height="311" /></a><p class="wp-caption-text">&gt;click&lt;</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/11/14/sensitivity-testing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>easy money</title>
		<link>http://www.puppetmastertrading.com/blog/2009/10/27/easy-money/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/10/27/easy-money/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 13:35:05 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[dereferenced]]></category>
		<category><![CDATA[strategy development]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=698</guid>
		<description><![CDATA[There seems to be a developing meme out there suggesting that algorithmic-, and in particular high-frequency, trading is some kind of gold-rush route to easy money which brings to mind&#8230;
&#8230;this revision of a paper I&#8217;d read previously: &#8220;Statistical Arbitrage in the US Equities Market&#8221; by Avellaneda and Lee.   It&#8217;s a detailed and thoroughly worked [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignleft" style="width: 252px"><img style="margin: 3px 5px;" src="/images/easyMoney.jpg" alt="" width="242" height="300" /><p class="wp-caption-text">you, hf-trading</p></div>
<p>There seems to be a developing meme out there suggesting that algorithmic-, and in particular high-frequency, trading is some kind of gold-rush route to easy money which brings to mind&#8230;</p>
<p>&#8230;this revision of a paper I&#8217;d read previously: <a title="Statistical Arbitrage in the US Equities Market by Avellaneda &amp; Lee" href="/images/AvellanedaLeeStatArb20090616.pdf" target="_blank">&#8220;Statistical Arbitrage in the US Equities Market&#8221;</a> by Avellaneda and Lee.   It&#8217;s a detailed and thoroughly worked (and now re-worked) paper illustrating the development and analysis of a US equity stat-arb strategy based on <a title="Principal Component Analysis" href="http://en.wikipedia.org/wiki/Principal_component_analysis" target="_blank">Principal Component Analysis</a> (PCA) and then revised to use ETFs.</p>
<p>I came across this paper as I have still never used PCA in any of my own strategy development work and read Carol Alexander&#8217;s excellent <a title="Market Models, Carol Alexander " href="http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471899755.html" target="_blank"><span style="text-decoration: underline;">Market Models</span></a> over my summer vacation with an eye towards giving a PCA hedging model a spin in the near-term. Thus, I wanted another look at this paper as a reference point.  Although it&#8217;s an excellent paper, I&#8217;m not going to urge you to go out and read it immediately unless you have a reasonably pressing practical interest.  Instead, I find it interesting largely because of one of its authors &#8211; Professor Avellaneda &#8211; and its conclusions in the form of its strategies&#8217; performance.</p>
<p>I&#8217;ve seen Prof Avellaneda speak a number of times at a variety of quant meetups organized by the relevant <a title="Columbia's Center for Financial Engineering" href="http://www.cfe.columbia.edu/">Columbia</a>/<a title="Courant" href="http://www.cims.nyu.edu/">NYU</a> financial engineering depts.  His paper reminds me that at least once during my noisome adolescent years, my father intoned darkly that:</p>
<blockquote><p><strong>the streets are littered with brilliant minds</strong></p></blockquote>
<p><span id="more-698"></span>Implying that any wits I may believe myself to possess wouldn&#8217;t by themselves be worth much in life and that I&#8217;d need to bring actual <em>tools</em> to the task of solving problems if I wanted to address interesting ones.  Having seen Mr Avellaneda speak, I&#8217;m confident that at my peak, my &#8220;processor&#8221; was never as fast as his.  Much worse, there is no comparison between the tools he can level at a problem compared to me &#8211; he&#8217;s on an entirely different playing field so far as concrete mathematical/analytical capabilities go.  That&#8217;s why I go see him speak and read his papers.</p>
<p>Thus, the <em>results</em> of Avellaneda and Lee&#8217;s work are particularly interesting to me as they&#8217;re really pretty dull: something like a Sharpe of .9 and degrading briskly.  Now, you don&#8217;t expect people to be providing detailed recipes to wildly profitable strategies, and this result isn&#8217;t <em>bad</em>, particularly given that they&#8217;re describing strategies which likely have significant capacity.  Still, it illustrates that very smart people working with sophisticated mathematical tools even over extended periods are still operating under noteworthy constraints.  Perhaps also: ideas are relatively easy &#8211; examining them in the requisite detail is difficult and time consuming, even for (particularly for?) people with the most finely honed toolsets&#8230;</p>
<p>I frequently have friends or colleagues who will observe that if you &#8220;just write a strategy that <em>foos</em> when <em>bar</em> but <em>yaddas</em> when <em>baz</em>&#8230; you should surely make money.&#8221;  Maybe.  But the reality is that just putting together the strategy and <em>working through it</em> takes significant time for anything but the simplest strategies.  Once you add genuine complexity to a strategy, you can spend enormous time tuning it.</p>
<p>This, in turn, poses a dilemma I encounter frequently and honestly don&#8217;t have a great answer for:</p>
<blockquote><p>how to find the balance between continuing development on a known good strategy and initiating the development and analysis of unrelated and novel strategies?</p></blockquote>
<h3>the back of the envelope as canvas</h3>
<p>This next (de-)reference isn&#8217;t directly pertinent to algo trading, but the lessons learned by building <strong>BIG</strong> distributed systems can surely be applied elsewhere.  And they&#8217;re just plain fascinating.</p>
<p>Google&#8217;s Jeff Dean gave a recent talk entitled &#8220;Designs, Lessons and Advice from Building Large Distributed Systems&#8221; at the <span style="font-family: Cambria;"><span style="text-decoration: underline;">La</span>rge Scale <span style="text-decoration: underline;">Di</span>stributed                         <span style="text-decoration: underline;">S</span>ystems and Middleware (somehow &#8220;LADIS&#8221;) <a title="LADIS" href="http://www.cs.cornell.edu/projects/ladis2009/" target="_blank">workshop</a> and the slides are <a title="Jeff Dean Keynote LADIS" href="http://www.cs.cornell.edu/projects/ladis2009/talks/dean-keynote-ladis2009.pdf" target="_blank">here</a>.   Go read them. </span></p>
<p><span style="font-family: Cambria;">If bald exhortation doesn&#8217;t convince you maybe slide 24 will:</span></p>
<p><span style="font-family: Cambria;"><img class="aligncenter" src="/images/ladis-slide24.png" alt="" width="497" height="377" /><br />
</span></p>
<p>or perhaps what he does with these baseline numbers in slide 27 will pique your interest:</p>
<div class="wp-caption aligncenter" style="width: 512px"><img src="/images/ladis-slide27.png" alt="back of the envelope as art form" width="502" height="375" /><p class="wp-caption-text">back of the envelope as art form</p></div>
<p><span style="font-family: Cambria;">One that made me (a serial prototype-builder) cringe:<br />
</span></p>
<blockquote style="text-align: left;"><p>Important skill: ability to estimate performance of a system design<br />
<span style="color: #ff0000;">– without actually having to build it!</span></p></blockquote>
<p>Ouch.</p>
<h3><span style="color: #ff0000;"><span style="color: #000000;">maybe it is easy after all</span></span></h3>
<p><span style="color: #ff0000;"><span style="color: #000000;">Of course, if you&#8217;ve studied Avellaneda &amp; Lee&#8217;s paper and it held no challenges or surprises and you&#8217;ve reviewed Mr Dean&#8217;s presentation and it&#8217;s old hat to you, too&#8230;<br />
</span></span></p>
<p><span style="color: #ff0000;"><span style="color: #000000;"> </span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/10/27/easy-money/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>inspirations from a material world</title>
		<link>http://www.puppetmastertrading.com/blog/2009/09/28/inspirations-from-a-material-world/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/09/28/inspirations-from-a-material-world/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 14:53:46 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=673</guid>
		<description><![CDATA[The real world, despite having lost some mind-share to reality tv, Tim Geithner and the internet, remains an interesting place and a potentially fruitful source of inspiration for our own efforts at strategy development.  In this pictorial post, I&#8217;ll take a look at some of the physical phenomena which inspire or reflect various trading strategies/domains.

]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignleft" style="width: 190px"><img style="margin: 3px 5px;" src="/images/Foucault_pendulum_animated.gif" alt="mean-reverting strategies" width="180" height="240" /><p class="wp-caption-text">mean-reverting strategies (Picture: wikimedia)</p></div>
<p>The real world, despite having lost some mind-share to reality tv, Tim Geithner and the internet, remains an interesting place and a potentially fruitful source of inspiration for our own efforts at strategy development.  In this pictorial post, I&#8217;ll take a look at some of the physical phenomena which inspire or reflect various trading strategies/domains.</p>
<p><span id="more-673"></span></p>
<div class="wp-caption aligncenter" style="width: 480px"><img src="/images/surfer.jpg" alt="trend-following strategies" width="470" height="310" /><p class="wp-caption-text">trend-following strategies (Picture: jamiescottimages.com)</p></div>
<div class="wp-caption aligncenter" style="width: 430px"><img class=" " src="/images/spiderWeb.jpg" alt="trading STIRs" width="420" height="315" /><p class="wp-caption-text">trading STIRs</p></div>
<div class="wp-caption aligncenter" style="width: 317px"><img class=" " src="/images/snakeOilByAnotherName.jpg" alt="technical analysis" width="307" height="461" /><p class="wp-caption-text">technical analysis</p></div>
<div class="wp-caption aligncenter" style="width: 406px"><img class=" " src="/images/waveFarm.jpg" alt="market-making" width="396" height="375" /><p class="wp-caption-text">making markets</p></div>
<div class="wp-caption aligncenter" style="width: 330px"><img src="/images/internalization.jpg" alt="internalization" width="320" height="213" /><p class="wp-caption-text">internalization</p></div>
<div class="wp-caption aligncenter" style="width: 510px"><img src="/images/steamrollerNickel.jpg" alt="writing options" width="500" height="377" /><p class="wp-caption-text">writing options</p></div>
<div class="wp-caption aligncenter" style="width: 471px"><img class="  " src="/images/americanFreedom.jpg" alt="exporting debt" width="461" height="346" /><p class="wp-caption-text">exporting debt</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/09/28/inspirations-from-a-material-world/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>multi-strategy trading with regimes</title>
		<link>http://www.puppetmastertrading.com/blog/2009/09/13/multi-strategy-trading-with-regimes/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/09/13/multi-strategy-trading-with-regimes/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 19:02:12 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[EMS Internals]]></category>
		<category><![CDATA[dereferenced]]></category>
		<category><![CDATA[portfolio management]]></category>
		<category><![CDATA[regime-switching]]></category>
		<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=594</guid>
		<description><![CDATA[One of the challenges of algorithmic trading is that although there&#8217;s plenty of interest in the space, practitioners aren&#8217;t generally forthcoming about their observations.  Academics, instead, focus on things that are frequently not very immediately practicable, or when they might be, always seem to set-up a little hedge-fund on the side while publishing colorful chum [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="margin: 2px;" src="/images/rswitch.jpg" alt="" width="225" height="300" />One of the challenges of algorithmic trading is that although there&#8217;s plenty of interest in the space, practitioners aren&#8217;t generally forthcoming about their observations.  Academics, instead, focus on things that are frequently not very immediately practicable, or when they might be, always seem to set-up a little hedge-fund on the side while publishing colorful chum about how markets are &#8216;behavioural&#8217; or somesuch.</p>
<p>Even if it&#8217;s hard to find good stuff, one must still look as there&#8217;s always more information that can help you than you can effectively process or retain.  A few weeks ago I was trying to formalize the expected profit function of an algorithm I&#8217;m developing and wanted to see what people had written about the topic.  I entered &#8216;define profit function for trading algo&#8217; into google and was pleasantly surprised to see a paper entitled <a title="Multi-strategy trading utilizing market regimes" href="/images/mstratRegimes.pdf" target="_blank">&#8216;Multi-strategy trading utilizing market regimes&#8217;</a> by Mlnarik, Ramamoorthy and Savani.  It doesn&#8217;t directly cover the topic I was looking for, but instead addresses a number of related topics I&#8217;ve been interested in for some time:</p>
<ul>
<li>the treatment of a strategy as an instrument in its own right</li>
<li>composing portfolios comprised of strategies</li>
<li>using regime switching techniques to manage portfolios of strategies</li>
</ul>
<p>In this post, I&#8217;ll briefly review their paper, illustrate how one can easily model strategies in relevant ways using the strategy &#8216;object model&#8217; I&#8217;ve described <a title="containing a strategy" href="http://www.puppetmastertrading.com/blog/2009/08/19/containing-a-strategy/" target="_blank">previously</a> through an example, and conclude with some thoughts on how these kinds of strategies might be implemented and further explored.</p>
<p><span id="more-594"></span></p>
<p><strong><a title="Multi-strategy trading utilizing market regimes" href="/images/mstratRegimes.pdf" target="_blank">&#8216;Multi-strategy trading utilizing market regimes&#8217;</a> by Mlnarik, Ramamoorthy and Savani</strong></p>
<p>Their paper begins:</p>
<blockquote><p>This paper considers the problem of dynamically allocating capital to a portfolio of trading strategies. The allocation should be robust, and the capital allocated to a trading strategy should reflect the confidence in the expected profit that the strategy will make in current market conditions.</p>
<p>Good trading strategies exploit recurring market dynamics that can be more prevalent in some time periods than in others. Indeed, the concept of regimes is fundamental to financial markets, and much research has focused on the detection of regime shifts. In this paper, we consider a regime as defined by a set of trading strategies that exhibit similar performance in a given time period.</p>
<p>We consider different parameterizations of the same strategy as distinct in our ground set of strategies. The trading problem is to pick a distribution over the ground set that will achieve good performance in the current time period.</p></blockquote>
<p>They start with some interesting definitions.  A trading strategy is defined as a function which takes a given market <em>State </em>and generates a convenient<strong> </strong><em>Answer </em>&#8220;denoting all possible trading decisions&#8221;.  <em>Strategy functions</em> can also be parameterized and different parameterizations of the same function/strategy are viewed as distinct <em>qualitative strategies</em>.  They assume the existence of  the set of all strategies.  A <strong>regime</strong> is defined as a set of trading strategies who behave similarly over a given period of time where <em>similarly</em> is measured by the variance of a fitness function.</p>
<p>So they start with a set of strategies, a fitness function and some historical market data or state, and their first task is to identify the regimes.  They do this by running the strategies against randomly selected partitions of historical data, quantifying their respective performances with the fitness function and identifying the clusters deemed statistically significant.  Those sufficiently significant and similar sets of strategies are themselves the <em>reasonable regimes</em> while the set of strategies within all the reasonable regimes are themselves dubbed the <em>reasonable strategies</em> &#8211; the candidates for execution.  This might sound strange, but as I&#8217;ll illustrate with a concrete example below, this is actually a pretty effective and even intuitive way of defining regimes.</p>
<p>They define function <em><strong>stFuncDist </strong></em>as, for any regime, generating a distribution or weighting of the strategies within the regime.<em><strong> </strong></em>While <em><strong>classifyMarket</strong></em> is a function that generates a distribution across all regimes for any given market state. Both models can be &#8220;trained&#8221; and they do so by again iterating randomly across chunks of historical data adjusting the weighting constants of these two functions.</p>
<p>Finally, it&#8217;s time to trade and they can effectively use <strong>classifyMarket </strong>to determine a predominant regime and allocate capital as indicated by <strong>stFuncDist</strong> to the appropriate set of &#8220;reasonable strategies.&#8221;</p>
<p>They claim to have utilized this technique to generate the results charted in Figure 1, but they give little detail on the initial universe of strategies.  I believe they had one strategy which was parameterized into a set of <em>qualitative strategies</em> and run across one market, the CME&#8217;s Nasdaq emini.  I have no reason to doubt that they had exactly this result, but without more details on what they actually did, it&#8217;s hard to view it as very meaningful, though it certainly is suggestive.  An interesting thing about how they present their result, which I&#8217;ve seen in other academic papers, is that because they&#8217;ve precisely defined the set of possible strategies they look at, they can also calculate max and min possible returns over the relevant period.</p>
<p><strong> </strong></p>
<div class="wp-caption aligncenter" style="width: 283px"><strong><strong><img src="/images/mstumr-returns.jpg" alt="Figure 1: Out-of-sample profit (middle line) versus possible min (bottom line) and max profit (top line) over all strategies for the period 2006-11-01 to 2008-08-28." width="273" height="142" /></strong></strong><p class="wp-caption-text">Figure 1: Out-of-sample profit (middle line) versus possible min (bottom line) and max profit (top line) over all strategies for the period 2006-11-01 to 2008-08-28.</p></div>
<p><strong> </strong></p>
<p>The paper continues with another section, but I&#8217;m going to stop my overview here as the last part is less interesting to me and the interested reader should of course read it themselves.</p>
<p><strong>complex strategies or simple strategies combined</strong></p>
<p>One of the broadest design questions I see for the development of effective trading algorithms is whether one should employ complex, customized algorithms or instead utilize simple algos which can be simply combined to produce <em>emergent</em> complexity.  Although the authors of this paper allude to &#8220;Good trading strategies&#8221;, I wonder if one can even forget the &#8220;good&#8221; part and instead worry about applying &#8211; even <em>bad</em>! &#8211; strategies at the right times.</p>
<p>There are a lot of things I like about this paper, but probably most of all it&#8217;s their definition and use of a regime.  One of my first <a title="redistribution" href="http://www.puppetmastertrading.com/blog/2007/10/07/redistribution/" target="_blank">posts</a> describes a pair of strategies &#8211; a simple mean reverter and a simple trend follower.  These two strategies are about as dumb as you please.  And yet, their behavior is pretty interesting apart the observations I&#8217;d published at the time regarding the distribution of their returns.  During the trading day, I&#8217;ve taken to running those two, old, dumb strategies across a variety of markets in simulation mode.  Why?  Because it&#8217;s easy, costs me nothing and actually is pretty interesting in that the strategies really do cluster in the way Mlnarik et al describe, effectively partitioning the market into visible regimes.</p>
<p><strong>a simple example: identifying regimes with strategies<br />
</strong></p>
<p>In order to illustrate this, I created a desktop within stratbox onto which I ran these two <em>qualitative strategies</em> parameterized differently and across six different markets.  In total, I have 48 strategies running with 24 of the mean reverting (MR) variety and 24 of the trend following (TF).  In figure 2 and figure 3, they are sorted by qualitative strategy – all of the MR strategies followed by all of the TF strats.   In figure 4, they’re instead sorted by instrument at the end of the day after all of the strats had been rendered quiescent for the night by their schedulers.  You can click to see a bigger version of these screenshots.  On each, the left side of the screen shows simple charts of the relevant markets while the right contains a table in which each line item is a running strategy.  The first is at the beginning of the day. the second is shortly before going silent at 4pm and the third is shortly after 4pm.</p>
<p style="text-align: center;">
<div class="wp-caption aligncenter" style="width: 510px"><a href="/images/regimes1.jpg" target="_blank"><img class="   " src="/images/regimes1.jpg" alt="variously parameterized mean-reverting &amp; trend-following strats run in sim " width="500" height="312" /></a><p class="wp-caption-text">Figure 2: variously parameterized MR &amp; TF strats run in realtime+simulation mode.  Sorted with the MR strats first. (click)</p></div>
<p style="text-align: center;">
<div class="wp-caption aligncenter" style="width: 510px"><a href="/images/regimes2.jpg" target="_blank"><img class=" " src="/images/regimes2.jpg" alt="later the same day" width="500" height="312" /></a><p class="wp-caption-text">Figure 3: later the same day</p></div>
<p style="text-align: center;"><strong> </strong></p>
<div class="wp-caption aligncenter" style="width: 510px"><strong><strong><a href="/images/regimes3.jpg" target="_blank"><img class=" " src="/images/regimes3.jpg" alt="at EOD, now sorted by instrument" width="500" height="312" /></a></strong></strong><p class="wp-caption-text">Figure 4: at EOD, now sorted by instrument</p></div>
<p>You’ll note that at all times throughout the day, the MR and TF strategies effectively mirrored each other regardless of market.  Although I’m not going to illustrate it, I’m going to just go right ahead and assert that this is almost always true  based on what I’ve seen.  And this is at the heart of the paper’s authors&#8217; insight regarding regimes – they can be effectively identified by examining the performance of even simple but well-defined strategies.</p>
<p>This suggests a simple means of implementing a similar design to that they described right on top of this example I’ve put together.</p>
<p><strong>modeling meta-strategies</strong></p>
<p>We need one more element to manage all of this – a meta-strategy – that is, a strategy for managing other strategies.  We support this idea in stratbox with what we call a controller strat.  The cannonical example of a controller strat is our implementation of the (Don’t) Panic button (the bright red button with an ! in the upper right hand corner) which will get all strategies out of the market with varying degrees of urgency and finality.  This is implemented as a controller strat which injects a stratpart into all running strategies.  The injected stratpart first deactivates its peers and then cancels outstanding orders and then gets out of the market with whatever urgency the user has required.</p>
<p><strong>allocating to portfolios of strategies</strong></p>
<p>In my example above, I have 48 strategies running in simulation across 6 futures markets.  Let’s imagine that at any moment in time, I will always have at least one strategy of each type (MR and TF) running for each market.<strong> </strong>Thus, I’ll always have 12 live strategies running against real money accounts and 36 candidates running against a simulator.  Effectively, we’ve just described a portfolio of 12 elements where each element is itself a strategy.</p>
<p>It’s not difficult to imagine implementing a controller strat which on a regular schedule will simply adjust the parametrization of the running strategies and their allocation of cash <em>based on the performance of the strategies running in simulation</em>.</p>
<p>It&#8217;s not difficult to imagine, but implementing it inevitably poses a variety of challenges not least of which is finding the time!  For now, we&#8217;re still finding new and interesting ways to express strategies which deal with portfolios of exchange-traded instruments.  But I think that this is just a point on our technology&#8217;s maturation curve which will ultimately lead to the regular development of strategies which operate on portfolios of strategies themselves&#8230;</p>
<p>Anyway, it&#8217;s nice to see a bit of academic work formalizing what I expect is a natural step in the evolution of trading algorithms.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/09/13/multi-strategy-trading-with-regimes/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>containing a strategy</title>
		<link>http://www.puppetmastertrading.com/blog/2009/08/19/containing-a-strategy/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/08/19/containing-a-strategy/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 19:46:33 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[EMS Internals]]></category>
		<category><![CDATA[FIX Protocol]]></category>
		<category><![CDATA[portfolio management]]></category>
		<category><![CDATA[strategy development]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=543</guid>
		<description><![CDATA[My son recently had his first birthday and amazes me daily with his new feats as he runs around increasingly stably exploring the world around him.  It occurs to me that the system I use to trade every day, Stratbox, is approaching its fourth &#8220;birthday&#8221; in the next few months.  I hadn&#8217;t originally intended to [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 3px 5px;" src="/images/theChase.jpg" alt="" width="240" height="194" />My son recently had his first birthday and amazes me daily with his new feats as he runs around increasingly stably exploring the world around him.  It occurs to me that the system I use to trade every day, Stratbox, is approaching its fourth &#8220;birthday&#8221; in the next few months.  I hadn&#8217;t originally intended to write a system &#8211; an algorithmic trading platform &#8211; but found that existing products were limited, expensive and didn&#8217;t fit my mental model of what they should do.</p>
<p>This isn&#8217;t surprising as I wanted the system to support all of the activities associated with our algorithmic trading.  It turns out that that&#8217;s a lot to ask of a system.  It also turns out that you learn as you go and so the system continues to evolve.  A few years ago I&#8217;d <a title="putting the pieces together" href="http://www.puppetmastertrading.com/blog/2007/10/12/putting-the-pieces-together/" target="_blank">posted</a> about the basics of a strategy container and in this post I&#8217;m going to come back to this topic and describe some of the layers of code and thought developed since then.</p>
<p>First, let&#8217;s consider the role of a strategy container.  Its job is to intermediate between trading strategies and the external environments with which they interact.  It must also provide services that strategies can use (e.g., position management) and that it wouldn&#8217;t make sense for each strategy to re-implement.  In the past I&#8217;ve focused on the former responsibility of adapting strategies to external environments.  Why is this necessary and interesting?  Because it allows us to take the same exact strategy and run it live, or in simulation or in backtest, etc.  Interesting and necessary, but not what I want to focus on this time.  Instead, I want to look at the services provided to strategies; the &#8216;ecosystem&#8217; a strategy container provides in the hope that strategies might flourish within it.</p>
<p><span id="more-543"></span></p>
<p>We&#8217;ll go from the bottom up.  At the bottom you have one or more pipes of market data coming in.  You might also have news feeds, weather feeds or other such things coming in and we&#8217;re just going to conflate them all and say &#8220;market data.&#8221;  Still at the bottom, you also have one or more  two-way pipes with your oms or broker or directly with exchanges or with an exchange simulator.  Within Stratbox we call this abstraction an &#8220;ExecutionPlatform&#8221; because it&#8217;s conceptually where trades get executed.  The lingua franca for execution platforms is FIX, so the baseline object model of a strategy container is likely going to look a lot like messages described by the FIX spec.  Here we have orders, executions and the like.  Within Stratbox we&#8217;ve implemented an exchange simulator, a <a title="QuickFIX: Open source FIX engine" href="http://www.quickfixengine.org/" target="_blank">QuickFIX</a>-based FIX interface and a couple broker-specific APIs and they are all of type ExecutionPlatform.  To a strategy, they all look the same.  Likewise with market data.  Within the strategy container, we provide a publish-subscribe model wherein any kind of market data can be subscribed to regardless of the ultimate source of the data.  The intention is always to intermediate between the strategy and its external environment.</p>
<p><strong>the baseline object model</strong></p>
<p>Great.  But now I want to write a trading strategy.  What&#8217;s that going to look like?   And this is where things get increasingly interesting as we get to decide what kind of facilities we&#8217;re going to provide.  We also need to manage concurrency in some fashion as trading is an intrinsically asynchronous activity.  For this lowest level of strategy, we&#8217;ll say that each market feed is handled by a thread which timestamps and enqueues a &#8220;Quote&#8221; for later consumption and redistribution to relevant subscribers by a MarketDataService within the container.  Likewise, each execution platform will be serviced by a thread who similarly enqueus &#8220;Execution&#8221; objects from exchanges real and simulated.  The threads handling executions should likely have a higher priority than the threads handling market data.  So, the strategy is naturally exposed to the markets&#8217; asynchronicity right off the bat.  What baseline facilities will our strategy have at its disposal?  Well, it needs to be able to manage orders and positions, so it needs some kind of a &#8220;blotter&#8221; facility.  With this in place, a strategy can safely assume that it doesn&#8217;t need to listen to each execution coming in just to have a correct picture of its book.  It needs access to a MarketDataSvc and it likely also needs access to historical data.  But, staying simple, that&#8217;s more or less all we have to provide and we&#8217;re going to provide all of these things to the strategy through a single handle: a strategy context.  By swapping out a strategy&#8217;s context, we can move the strategy among environments (eg, from simulation to live execution).</p>
<p>With these facilities in place, basic algorithms can be implemented within a strategy and you should be able to test and trade them.</p>
<p>But you&#8217;re dealing with very low-level stuff.  You&#8217;ll also find that you&#8217;re writing the same kind of code over and over.  This inspired the introduction of a layer on top of the baseline object model which I&#8217;ve described before: <a title="StratParts" href="http://www.puppetmastertrading.com/blog/2008/04/12/stratparts-a-strategy-component-model/" target="_blank">StratParts</a> &#8211; a strategy component model.</p>
<p><strong>StratParts &#8211; a component model for strategies</strong></p>
<p>With StratParts, we introduced metadata and composition (in the <a title="Composites" href="http://en.wikipedia.org/wiki/Composite_pattern" target="_blank">&#8220;composite pattern&#8221;</a> sense) to our Strategy object model.  A strategy is itself a stratpart which contains other stratparts.  Thus, stratparts introduce a hierarchical structure to a strategy.  Each stratpart publishes a metadata descriptor which is aggregated at the strategy level.  The descriptor contains all of the modifiable characteristics of the strategy and can be changed while a strategy is executing thus giving a sort of grey box capability wherein a trader (or another strategy etc) can modify the behavior of a strategy as it&#8217;s running.  Stratparts also create an effective means of providing scoping within your strategy environment.  Stratparts can &#8220;see&#8221; the activity of other stratparts within the same strategy &#8211; they&#8217;re all peers in this sense.  This scoping can also be used for allocation of resources across different elements of a strategy.  For example, one stratpart might be allocated 80% of the cash available to the strategy while another stratpart manages the remaining 20%.</p>
<p>Stratparts have proved to be very powerful and we&#8217;ve written many of them though we&#8217;ll sometimes write strategies as one monolithic stratpart where it makes sense.</p>
<p>Stratparts have a lot of uses but one thing they don&#8217;t do is help manage the low-level complexity inherent in trading activities.  This was best described by a trader with whom I&#8217;d collaborated.  He&#8217;s a reservist in the IDF and uses military metaphors like I use sports metaphors.  He bemoaned the low-level handling of orders required for a very close-to-the-market strategy we were working on and said that:</p>
<blockquote><p>we need an order like a &#8217;smart&#8217; missile: fire it and forget it</p></blockquote>
<p>He was right and that inspired the next level of abstraction/support that we built into the system.</p>
<p><strong>&#8217;smart&#8217; orders and the tradeflow stratpart</strong></p>
<p>The strategy we were developing was meant to look at a universe of futures spreads and generate all of the &#8216;cycles&#8217; that might result in an arbitrage opportunity.  Since these are rare at best, we were really looking for circumstances where it looked like we had an advantage based on depth-of-market and various heuristics we&#8217;d apply.  Among the functionality that he wanted was an &#8216;order&#8217; which would act as a limit unless some conditions obtained in which case it might pay the spread or otherwise stop being a fixed limit order.  He didn&#8217;t want to handle this inside the strategy but instead wanted to fire these things off and forget about them unless they required attention (eg, if they&#8217;re rejected by the exchange or his firm&#8217;s risk management checks).  Although we ended up calling these smart orders, they&#8217;re really a sort of very localized execution strategy themselves.</p>
<p>To support them, we utilized the same workflow (= state machine) framework we&#8217;d implemented for our ExchangeSimulator as we wanted to ensure that these smart orders had a very well-defined life-cycle with a clear set of states and guarantees about transitions among them.  We embedded this workflow engine into a stratpart which supported smart orders operating within this &#8220;tradeflow&#8221;.  Thus, the extra functionality (and weight/expense) of this functionality is only achieved/incurred when actually required or desired.  This has proven to be a powerful addition to the system and raises the level of services enjoyed by prospective strategies substantially, particularly given the variety of orders we&#8217;ve implemented which stand ready for use by any new strategy that might want to employ them.</p>
<p>At this point, it should be clear that we&#8217;re blurring the lines between the strategies themselves and the container.  Another way of thinking of it is that one container can have a set of pre-made building blocks that can be applied for families of strategies.  Each one provides a particular grammar with which a strategy&#8217;s aims can be expressed.  For very close-to-the-market strategies where very low-level handling of orders is required, the tradeflow stratpart provides a set of really useful facilities, but if I&#8217;m just trading with limits then it might not be so interesting.</p>
<p><strong>portfolio-oriented strategies and beyond<br />
</strong></p>
<p>I&#8217;ve mentioned <a title="portfolio strategy" href="http://www.puppetmastertrading.com/blog/2008/09/13/portfolio-atomic-element-of-a-trading-strategy/" target="_blank">before</a> that I only care to think of strategies that operate on a portfolio.  As such, we&#8217;ve written a good deal of facilities for creating, analyzing and manipulating portfolios within strategies.  By using these facilities within a tradeflow stratpart, I can express quite complex strategies relatively simply by using portfolio analytics to determine my current &#8216;model&#8217; portfolio and then using smart orders to most effectively transition me from my current state to my model state.  For the kind of trading I do, this provides a rich &#8216;vocabulary&#8217; for the development of strategies.  All the same, my brain is having a <em>tip-of-the-tongue moment</em> as I feel that there&#8217;s an entirely different model possible for portfolio-oriented strategies just at the periphery of my imagination&#8230;  oh well, there&#8217;s always something new to explore.</p>
<p>Different trading styles, perspectives or trading problems are undoubtedly better served by different sorts of facilities.  I&#8217;m finding that just as language constrains and shapes thought, the strategy container that you employ shapes and constrains the kinds of strategies that you can implement.</p>
<p>If you have any ideas about such facilities for any kind of trading you do, I&#8217;d love to hear them.</p>
<p>&#8211;</p>
<p><strong>a note about Stratbox</strong></p>
<p><img class="alignright" src="/images/sb.jpg" alt="" width="161" height="161" />Although I&#8217;m talking about our system in this blog, we&#8217;re not marketing the system and happily &#8220;just&#8221; use it for our own trading activities.  We had looked into marketing the system previously but ultimately feel the same about selling stratbox as <a title="pimp that strat" href="http://www.puppetmastertrading.com/blog/2009/03/18/pimp-that-strat/" target="_blank">selling strategies</a>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/08/19/containing-a-strategy/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>the trading frequency spectrum</title>
		<link>http://www.puppetmastertrading.com/blog/2009/07/28/the-trading-frequency-spectrum/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/07/28/the-trading-frequency-spectrum/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 13:42:45 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[hedge funds]]></category>
		<category><![CDATA[our managed markets]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[strategy development]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=145</guid>
		<description><![CDATA[
I&#8217;ve been saving the above image in a stubbed-out blog post I&#8217;ve wanted to write since a conversation I&#8217;d had in Jerusalem last fall.  The recent attention to high frequency trading and all of its attendant evils has reminded me that the topic is relevant and so I relate various thoughts at the risk of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="Frequency Spectrum" src="/images/frequencySpectum.gif" alt="" width="755" height="300" /></p>
<p>I&#8217;ve been saving the above image in a stubbed-out blog post I&#8217;ve wanted to write since a conversation I&#8217;d had in Jerusalem last fall.  The recent attention to high frequency trading and all of its attendant evils has reminded me that the topic is relevant and so I relate various thoughts at the risk of jumping on a cacophonous bandwagon of rumbling misinformation.</p>
<p>First of all, the conversation.  It was with a talented guy who acted as the CFO for a variety of companies including a small startup hedge fund which traded US equities at a high frequency.   Although he was a part-time cfo, he seemed pretty plugged-into their trading operations and noted that they use an agency-only brokerage service for automated traders I&#8217;m familiar with and that they were &#8220;looking at full data for many&#8221; hundred stocks concurrently. He remarked that their trading was going well but that their hit rate was something like 4% and dropping.  By hit rate, he meant that they were placing limits frequently and generally pulling the orders if they didn&#8217;t get hit immediately.  He didn&#8217;t specify, but I imagine that &#8220;immediately&#8221; might range from milliseconds out to a second or twenty.  If the market is composed of makers and takers, then these guys were definitely makers of liquidity in the strict sense that they were placing limits and making markets.</p>
<p>At the time I thought it was interesting because it seemed that so many people were focused on the very, very short term trade that the frequency was becoming saturated.  It looked like a reminder that trading frequencies populate a spectrum; in this case, this part of the spectrum was becoming so saturated that returns were becoming increasingly difficult to obtain as more players crowded into it.  I&#8217;m not sure how this hedge fund has fared, but at the time I remember thinking that they were going to have a tough time competing if they were only geared for high-frequency trading as the space becomes increasingly expensive to play in as the inevitable talent and technology arms race marches on.</p>
<p><a title="Lo &amp; Khandani" href="http://web.mit.edu/alo/www/Papers/august07_2.pdf" target="_blank">Lo and Khandani</a> provide the below image illustrating this phenomenon happening to a class of contrarian strategies Lo &amp; MacKinlay had described in 1990.  The strategies stop working as people squeeze out the alpha.</p>
<p><span id="more-145"></span></p>
<p><img class="aligncenter" title="contrarians crushed" src="/images/crushedContrarians.jpg" alt="" width="594" height="436" /></p>
<p>My conversation in Jerusalem mostly made me think that we were seeing a similar phenomenon amongst HF strategies.</p>
<p>What does it mean for a strategy to be high-frequency?  First of all, it&#8217;s a large class of strategies which probably shouldn&#8217;t be treated uniformly.  What they have in common is an intention to trade in and out of positions on a frequent basis where frequent will range from sub-seconds out to perhaps several seconds or even minutes in particularly felicitous cases.</p>
<p>Aside from the fact that one can trade at various frequencies, one can mix them and one might even be only peripherally aware of doing so.  A long-only, fundamentally-driven mutual fund (ie, not an algo or high-frequency trader) might call/fax/email/ftp/fix etc their trades into their brokers who might then execute the trades with their in-house or outsourced/white-labeled execution-quality algos.  Those algos might use some very clever close-to-the-market analytics to provide great execution for the client.  Or they might be traded profitably against.  Or both.</p>
<p>In any case, to me it seems clear that there is nothing intrinsically wrong about high-frequency trading itself.  People will always try to react to information as quickly as possible.  Why wouldn&#8217;t or shouldn&#8217;t they?  They also like to be clever.  Again, why wouldn&#8217;t this be expected and good?  I remember Lefevre recounting the use of personal teletypes by big speculators at the turn of the (prior) century.  Not your everyday household item at the time.  I also remember him recounting strategies for moving large positions which involved both buying and selling to hide one&#8217;s hand.  Why wouldn&#8217;t algos do the same and more?</p>
<p>That the loudest critics have been old-style execution traders &#8220;talking their book&#8221; to me tells the story here.</p>
<p>One other thing that my conversation evinces is the kinds of biz models being employed by brokers.  Like I said, this little hf hedge fund used an agency-only brokerage that caters to algo/hf traders.  Why is it important to note that it&#8217;s &#8220;agency only&#8221;?  Because, as the Goldman/Aleynikov story illustrates, strategies are organizationally porous in the sense that their value drips away as the human capital behind them moves from organization to organization and understanding of the strat&#8217;s internals become understood more broadly outside the organization.  This is likely the dynamic that drove Lo&#8217;s example above &#8211; more and more traders were employing similar strategies as the knowledge of the strategy leaked further and further from its original source(s).  Likewise, if I see all of your trading activity in sufficient detail, I might be able to reverse-engineer your strategy and work to steal your alpha.</p>
<p>Thus, traders are happy not to advertise their strategies&#8217; behaviors.  So an agency-only broker &#8211; a broker who doesn&#8217;t engage in prop trading themselves &#8211; should inspire trust in a potential client.</p>
<p>Great!  What an honest business model!  But there&#8217;s an irony here and it points to the real kinds of problems we should be bugging our regulators to be addressing.  The specific agency-only broker I mention wasn&#8217;t self-clearing.  That is, they were using another broker (Goldman in this case) to handle their backoffice duties.  And guess what?  Goldman is anything but agency only.  So, clients who feel warm and fuzzy that they are dealing with an agency-only shop are actually exposing all of their activities with a particularly sophisticated and arguably predatorial prop trader.  It&#8217;s like the Guiness ads.</p>
<p>It&#8217;s funny to me that while there sits a multi-trillion dollar hole in our fed&#8217;s balance sheet which such hippies as fox news and bloomberg (suing to find out) and our US congress (asking politely) can&#8217;t seem to tease an explanation for out of the relevant authorities, the blogosphere and regulators seem to focus their invective on short sellers, hedge funds and high-frequency traders.</p>
<div class="wp-caption aligncenter" style="width: 338px"><img title="Brilliant?" src="/images/Guiness-Brilliant.jpg" alt="partners at GS?" width="328" height="240" /><p class="wp-caption-text">secret meeting at 85 broad?</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/07/28/the-trading-frequency-spectrum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>the other interesting thing about the Serge Aleynikov story</title>
		<link>http://www.puppetmastertrading.com/blog/2009/07/08/the-other-interesting-thing-about-the-serge-aleynikov-story/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/07/08/the-other-interesting-thing-about-the-serge-aleynikov-story/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 15:31:28 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[our managed markets]]></category>
		<category><![CDATA[strategy development]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=466</guid>
		<description><![CDATA[There&#8217;s a whole bunch of interesting things about this story of how a programmer has allegedly stolen some of the code at the place he&#8217;d worked.  One is the remarkable reverb it&#8217;s created amongst bloggers.  The house pictured left is evidently the diabolical mastermind&#8217;s home according to the NJ Real Estate Report.  Another is the [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignleft" style="width: 266px"><img title="Serge's House" src="/images/sergesHouse.jpg" alt="his haunted house" width="256" height="192" /><p class="wp-caption-text">as suspected, the seat of evil can be found in NJ</p></div>
<p>There&#8217;s a whole bunch of interesting things about this story of how a programmer has allegedly stolen some of the code at the place he&#8217;d worked.  One is the remarkable reverb it&#8217;s created amongst bloggers.  The house pictured left is evidently the diabolical mastermind&#8217;s home according to the <a title="NJ Real Estate Report" href="http://njrereport.com/index.php/2009/07/06/did-serges-underwater-house-play-a-role/" target="_blank">NJ Real Estate Report</a>.  Another is the fact that a programmer stealing some code is news. Funny what becomes news (apparently a fêted pedophile died) and what doesn&#8217;t (we are creating <em>millions</em> of refugees in Pakistan).</p>
<p>One angle that I haven&#8217;t seen highlighted in all of the commentary is Mr Aleynikov&#8217;s choice of weapon.  Seems that he was an <a title="Erlang" href="http://en.wikipedia.org/wiki/Erlang_(programming_language)" target="_blank">erlang</a> guy with an interest in <a title="OCAML" href="http://en.wikipedia.org/wiki/Objective_Caml" target="_blank">ocaml</a>.  Choosing functional programming for algo trading systems is an interesting but not unique choice.</p>
<p><span id="more-466"></span></p>
<p>A few months back I&#8217;d seen <a title="Jane Street Capital" href="http://www.janestreet.com/" target="_blank">Jane St</a>&#8217;s Yaron Minsky give an <a title="Yaron Minsky: OCAML Trading at CMU" href="http://ocaml.janestreet.com/?q=node/61" target="_blank">interesting talk on OCAML</a> in which he describes the virtues of ocaml as applied to the algo trading domain.  You should watch it as he&#8217;s entertaining and clearly a &#8220;true believer.&#8221;   The key argument he makes is that algo trading requires correctness, agility and performance and that ocaml provides a great set of tools for addressing these needs.  Correctness and agility are supported by the rich type system while performance is just a happy feature of the language.</p>
<p><embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=-2336889538700185341&#038;hl=en&#038;fs=true" style="width:400px;height:326px" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash"> </embed></p>
<p>He describes Jane St&#8217;s need for correctness as obsessive &#8211; the company&#8217;s founders read/review all of the code that goes into production.  Thus, concision and the absence of OO languages&#8217; dynamic dispatching mechanisms are viewed as advantageous.</p>
<p>Mr Minsky admits that there are significant limitations involved in choosing ocaml, including a dearth of external libraries (they write their guis using <a title="curses" href="http://en.wikipedia.org/wiki/Curses_(programming_library)" target="_blank">curses</a>(!)) and a lack of native threading.  The language&#8217;s unpopularity turns out to be something of a double-edged sword as it results in the lack of usable libraries but also in a close-knit community of likely above-average developers.</p>
<p>Anyway, it&#8217;s an interesting decision for Jane St Capital to have made and it&#8217;s compounded by Mr Aleynikov&#8217;s use of Erlang/OTP at Goldman.  His linkedin profile describes his recent work as:</p>
<blockquote>
<p class="description">• Lead development of a distributed real-time co-located high-frequency trading (HFT) platform. The main objective was to engineer a very low latency (microseconds) event-driven market data processing, strategy, and order submission engine. The system was obtaining multicast market data from Nasdaq, Arca/NYSE, CME and running trading algorithms with low latency requirements responsive to changes in market conditions.<br />
• Implemented a real-time monitoring solution for the distributed trading system using a combination of technologies (SNMP, Erlang/OTP, boost, ACE, TibcoRV, real-time distributed replicated database, etc) to monitor load and health of trading processes in the mother-ship and co-located sites so that trading decisions can be prioritized based on congestion and queuing delays.<br />
• Responsible for development of real-time market feed handlers, order processing engines and trading tools at a Quantitative Equity Trading revenue-making HFT desk.</p></blockquote>
<p class="description">which makes it sound like they were using Erlang alongside a lot of C++.  I&#8217;d also speculate that their use of Erlang was more about concurrency than functional programming.</p>
<p class="description">One of the nice observations made by Mr Minsky is that there&#8217;s a magnificent freedom about prop trading: you don&#8217;t have clients to please and can thus make genuinely original technology decisions.  It looks to me like the curious case of Serge Aleynikov highlights some of that originality in play in serious algo trading prop shops.</p>
<p class="description">
<p class="description">
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/07/08/the-other-interesting-thing-about-the-serge-aleynikov-story/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
