<?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; back-testing</title>
	<atom:link href="http://www.puppetmastertrading.com/blog/index.php/category/back-testing/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>head in the clouds</title>
		<link>http://www.puppetmastertrading.com/blog/2010/04/21/head-in-the-clouds/</link>
		<comments>http://www.puppetmastertrading.com/blog/2010/04/21/head-in-the-clouds/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 23:10:29 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[back-testing]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=1219</guid>
		<description><![CDATA[or: scaling with elastic map-reduce
Between a rapidly evolving compute environment in which cores are multiplying like springtime rabbits, and a business domain in which the fecundity of market data is making those same rabbits look downright prudish, we are always looking for ways to scale our efforts.  There are three levels at which this can [...]]]></description>
			<content:encoded><![CDATA[<p><strong><img class="alignright" src="/images/headintheclouds.jpg" alt="" width="200" height="259" />or: scaling with elastic map-reduce</strong></p>
<p>Between a rapidly evolving compute environment in which cores are multiplying like springtime rabbits, and a business domain in which the fecundity of market data is making those same rabbits look downright prudish, we are always looking for ways to scale our efforts.  There are three levels at which this can be typically done:</p>
<ul>
<li>&#8220;below the processor&#8221; with things like CUDA or FPGAs,</li>
<li>&#8220;amongst the cores&#8221; with things like TBB, Cilk, &amp;tc, or</li>
<li>&#8220;in the cloud&#8221; (or grid) with things likes Amazon&#8217;s EC2 and its bewildering and fast-growing coterie of associated technologies and products</li>
</ul>
<p>Today we&#8217;ll look at a simple example which we implement on top of Hadoop and then deploy into Amazon&#8217;s cloud to get a back-of-the envelope feel for what kind of scaling we might expect to gain &#8211; and at what costs &#8211; from using this smorgasboard of technologies.</p>
<p><span id="more-1219"></span></p>
<p><strong>&#8217;smorgasboard&#8217; is being generous</strong></p>
<p>Probably the hardest thing whenever you look at some new set of technologies is just getting your bearings.  Amazon&#8217;s stack is complex and very much of a moving target, so I&#8217;ll start by providing a bit of a taxonomy of the beasties we&#8217;ll need to at least familiarize ourselves with in order to get anything done.</p>
<p>First, there&#8217;s the family of <a title="AWS" href="http://aws.amazon.com/" target="_blank">Amazon&#8217;s Web Services</a> (AWS).  This has been around for a good few years, so some parts of it are quite mature and well documented and understood where others are bleeding edge with an emphasis on bleeding.  All of them can be played with quite easily by simply signing up (this involves providing a credit card, so head&#8217;s up).  I can&#8217;t think of any more interesting family of technologies, so if you think there&#8217;s any possibility these technologies might help you scale, then I encourage you to sign up and give it a spin.  Very interesting stuff.</p>
<p>Anyway, within AWS we&#8217;ll play with Elastic Compute Cloud (EC2), Elastic MapReduce (EMR), Simple Storage Service (S3) and Elastic Block Storage (EBS).</p>
<p>EC2 provides you with direct access to Amazon&#8217;s racks of humming servers in the cloud.  Thanks to the miracles of modern virtualization technologies, an entire machine can be bundled up as an image file &#8211; an Amazon Machine Image (AMI &#8211; think of an OS&#8217;s DVD but with software that you specify, configured as you please). Once bundled into an AMI, your computer can be &#8216;installed&#8217; onto any number of machines within the cloud.  Nifty.</p>
<p>Such machines can be bought for long term use (at quite affordable rates), or they can be used on an as-needed basis for an hourly charge.  Hence the &#8216;Elastic&#8217; in EC2.  They can also be managed programmatically, and until recently, this was pretty much the only way to develop jobs in the cloud.</p>
<p>Each machine that you use in EC2 has some local storage associated with it, but this is not persistent across sessions.  Once your instance goes down, the data is all gone.  To get around this and to provide an all-around storage solution, AWS provides S3 which is, to me, an overly-simplified distributed file system which is something of a pain to use.  It is also limited to file sizes of 5G which I find to be a significant annoyance.  The good news is that S3 seems to be both highly durable and reasonably performant.</p>
<p>A more recent entry in the AWS world of storage is the EBS facility.  Here, you can create arbitrary sized &#8220;disks&#8221; in the cloud which can be attached directly to your computer nodes just as though they were local disks.  Very handy.  They don&#8217;t have the same level of durability as S3 as they&#8217;re not distributed, but I haven&#8217;t had any difficulties with them and they&#8217;re very useful for putting together AMIs within the cloud.</p>
<p>Finally, EMR brings the Hadoop implementation of Google&#8217;s marvelous distributed map-reduce model into the AWS cloud.  If you haven&#8217;t read about map-reduce, well perhaps you should &#8211; it&#8217;s really powerful.  <a title="Hadoop" href="http://hadoop.apache.org/" target="_blank">Hadoop</a> is an open-source implementation of it done in Java and seems quite nice though it&#8217;s under very active development, so the APIs are still very much a work in progress.  Be prepared to change your code.  Even though it&#8217;s written in Java, any language can be used to implement your own applications, and it seems as though both ruby and python are used pretty extensively along with java and c/c++.</p>
<p><strong>what map-reduce buys you</strong></p>
<p>The first thing map-reduce buys you is something of a headache as fitting your application design into the map-reduce model isn&#8217;t so obvious.  That said, it may well be worth a couple aspirin as it brings a great deal to the game.<strong> </strong></p>
<p>Consider an application we might find interesting which we&#8217;d like to place in the cloud &#8211; strategy back-testing.<strong> </strong>It seems to be a very natural fit for parallel processing as each strategy is independent of the others, so theoretically we should be able to run each one on it&#8217;s own virtual server without interdependencies.  While this is true, it&#8217;s rather easier than it sounds.  In order to implement our distributed backtesting platform, we first need to implement one that works on one node.  Fair enough.  We must then introduce a &#8220;chunker&#8221; which will break the overall set of simulations into bite-sized chunks.  We must then define an intermediate format for sending the strategies (or instructions) to each node.  And we must define an intermediate format for the results.  And then we need to implement an &#8220;assembler&#8221; which coalesces all of the results back into one result set which can be reported on or displayed etc.  And if one of the nodes fails, we have to notice it.  And if we notice that a node has failed, we need to figure out which job(s) it was responsible for and reallocate them to another node which presumably hasn&#8217;t failed&#8230;</p>
<p>And on and on.  The point is that this isn&#8217;t something that you&#8217;re going to get done in an afternoon.  Indeed, it&#8217;s unlikely that you could write a correct and complete specification of the system in an afternoon.</p>
<p>What map-reduce buys you is all of the distribution bits that I mention above.  The costs are that you will have to figure out how to model things such that they&#8217;re compliant with the map-reduce model and that the end result might not be as efficient as a hand-coded solution.  But when you can scale easily and cheaply, then raw efficiency may not be such an over-arching concern.</p>
<p><strong>scaling in the cloud with elastic map-reduce<br />
</strong></p>
<p>In order to get an idea how difficult it is to actually scale a solution, I implemented a simple program using real data and collecting some timings across a variety of  AWS/EMR configurations.<strong> </strong>To do this, I first had to code against Hadoop v18.3 which is what is supported in AWS.  (Initially I wrote it to v20.2 and was surprised at how much I had to change to back-port it to 18.3.)</p>
<p>The details of my test program aren&#8217;t important &#8211; basically counting various features from a set of heterogeneous files.  The files are approximately the same size ~1.8G and there were 10 of them, so the overall dataset is a bit over 18G.  I only do one map-reduce; I&#8217;m not chaining them together.  On a local machine &#8211; a pre-nehalem, dual-chip w/ quad-cores (8 total) xeon server with hardware raid &#8211; the process took 1068s or a touch under 18 minutes.</p>
<p>I was impressed to see that with absolutely no code changes, I was able to run the system on EMR without difficulties.  In fact, selecting the number of nodes to run against and the size of those nodes is just a matter of changing launch parameters.  Very nice.  AWS offers a variety of different specs on their servers.  I tested the classic &#8217;small&#8217; server which provides a 32-bit O/S, one core and 1.7G of memory as well as the &#8216;large&#8217; server which comes with a 64bit O/S and 2X2 cores and 7.5Gs of memory.  There are other configurations available, but I didn&#8217;t test them.  In all cases I was running centos5.4.</p>
<p>The results are tabulated and graphed below.</p>
<div class="wp-caption aligncenter" style="width: 441px"><img src="/images/emr-timings.jpg" alt="" width="431" height="181" /><p class="wp-caption-text">performance locally and in various cloud configurations </p></div>
<div class="wp-caption aligncenter" style="width: 420px"><img src="/images/emr-timings-chart.jpg" alt="" width="410" height="228" /><p class="wp-caption-text">time to complete vs. # nodes for large &amp; small nodes</p></div>
<p>Scaling isn&#8217;t exactly linear, but it is good and it is simple and it is cheap &amp; on-demand. Clearly for any given use-case, it will make sense to do tests like this to figure out what makes the most sense.  Another dimension to consider is cost.  Even partial hours count as a full hour, so putting big or many boxes against jobs that don&#8217;t take long to run isn&#8217;t cost effective.  That said, even though I fecklessly ran jobs which took as little as 10 minutes while paying for 60, the entire costs associated with developing and running the example I present here was less than $4US.</p>
<p>One thing I noticed is that the time to initialize instances seems to grow as you increase the number of nodes, though I didn&#8217;t quantify this.  In some cases, it was really quite long before real work started getting done &#8211; several minutes at least.  Getting this to work for interactive processes will take some thought and, probably, some dedicated nodes.  Another things to note is that although my local server did a fine job for itself, if we were to increase the dataset by a factor of, say 100, we&#8217;d reach a point where it simply couldn&#8217;t complete the operation whereas the cloud isn&#8217;t so strictly bounded.  It&#8217;s also pretty interesting that my local machine with 8-cores and 24G of RAM and pretty decent RAID subsystem got soundly spanked by eight of Amazon&#8217;s cheapie 1-core boxes.</p>
<p>Given that it is cheap, massively and simply scalable and not terribly difficult, one could say that if you don&#8217;t spend some time with your head in the clouds, then it&#8217;s possible you&#8217;ve got it stuck in the sand.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2010/04/21/head-in-the-clouds/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<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>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>ready to launch</title>
		<link>http://www.puppetmastertrading.com/blog/2009/11/08/ready-to-launch/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/11/08/ready-to-launch/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 13:08:50 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[EMS Internals]]></category>
		<category><![CDATA[back-testing]]></category>
		<category><![CDATA[regime-switching]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=784</guid>
		<description><![CDATA[In this post I&#8217;m going to revisit some of the topics discussed in the recent &#8216;containing a strategy&#8216; and &#8216;multi-strategy trading with regimes&#8216; posts, focusing on the process of assembling a strategy and its context in preparation for its launch into any of a variety of modes.
I recently realized that &#8211; from the perspective of [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignleft" style="width: 208px"><img src="/images/slightMiscalc.jpg" alt="he wasnt ready..." width="198" height="148" /><p class="wp-caption-text">poor Jorge wasn&#39;t ready...</p></div>
<p>In this post I&#8217;m going to revisit some of the topics discussed in the recent &#8216;<a title="containing a strategy" href="http://www.puppetmastertrading.com/blog/2009/08/19/containing-a-strategy/" target="_blank">containing a strategy</a>&#8216; and &#8216;<a title="multi strategy trading with regimes" href="http://www.puppetmastertrading.com/blog/2009/09/13/multi-strategy-trading-with-regimes/" target="_blank">multi-strategy trading with regimes</a>&#8216; posts, focusing on the process of assembling a strategy and its context in preparation for its launch into any of a variety of modes.</p>
<p>I recently realized that &#8211; from the perspective of a strategy container &#8211; the process of walk-forward testing is remarkably similar to the regime-switching model we&#8217;d discussed previously.  Up until now, I&#8217;ve employed walk-forward testing in an ad-hoc manner by taking an existing strategy and then writing a little driver very much like a unit-test scaffolding which would walk the strategy forward, permuting parameters based on previous performance.  Not a general solution, but straight-forward as I employ the strategy parameter optimizer from stratbox in this kind of a <em>toolkit</em> use-case.</p>
<p>I sat down to write one of these walk-forward scaffolds yesterday and started to think about how I could generalize the solution and roll it into stratbox&#8217;s GUI and it occurred to me that I could likely kill two birds with one stone&#8230;</p>
<h4><span id="more-784"></span><span style="color: #000000;">walk-forward testing</span></h4>
<p>&#8211;</p>
<p>I imagine there are different ideas/implementations of it, but for me walk-forward testing is the case where you are using repeated historical parameter &#8216;optimizations&#8217; to dynamically modify the parameters on a back-tested strategy.  For example, say we have strategy X with parameters p1 and p2.  Let&#8217;s say we want to walk-forward test it from the beginning of the year until now.  We&#8217;ll need a look-back period for optimizations &#8211; say 20 trading days &#8211; and a frequency with which to apply the results of our optimizations &#8211; say every 5 trading days.  So, on a weekly basis we&#8217;re going to look back at the prior (rolling) month performance and adjust our parameters to match the <em><strong>best</strong></em> performer.  How you define &#8216;best&#8217; is your business but I&#8217;ll use something simple like sharpe here.</p>
<p>Continuing with our example, we&#8217;ll say that p1 will be permuted 3 ways with values from { 1, 2, 3 } and p2 will be permuted across 4 values { &#8220;a&#8221;, &#8220;b&#8221;, &#8220;c&#8221;, &#8220;abcd&#8221; }.  So we have a basis of 12 strategies for optimization and we&#8217;ll call these O1&#8230;O12.</p>
<p>To perform a walk-forward test on X from 2009/01/01-now, we will begin a parallel back-test on O1..O12 starting 20 trading days <strong><em>before</em></strong> Jan1.  On Jan2 we will look at the prior ~month&#8217;s results and pick the strategy who had the highest sharpe ratio and clone him and start testing him &#8220;walking forward.&#8221;  Each week, we&#8217;ll repeat the process except that instead of cloning the winner as we did the first time, we&#8217;ll just make sure his params are the same as the new winner&#8217;s params.</p>
<p>Repeat this process until &#8216;now&#8217; and you&#8217;re done &#8211; you&#8217;ve performed walk-forward testing on X.</p>
<p>&#8211;</p>
<p>Let&#8217;s think about what&#8217;s happening here.  There are 12 strategies running from ~2008/12/1 and another strategy running from 2009/1/2; all strategies run until now.  There&#8217;s also the activity that &#8220;we&#8221; have done during this process.  What we are doing is the role of a meta-strategy just as we&#8217;d seen in the regime-switching case.  The walk-forward meta-strategy needs to watch a set of &#8216;optimization&#8217; strategies and permute another target (&#8220;X marks the spot&#8221;) strategy on a regular basis to match parameters with the prior period&#8217;s winner.</p>
<h4><span style="color: #000000;"><strong>differences vs. allocating to strategies with regimes</strong></span></h4>
<p>Let&#8217;s imagine that we&#8217;re going to take the 13 lovingly-named strategies O1&#8230;O12 and X, along with the newly revealed meta-strategy we&#8217;ll dub &#8220;M&#8221;, and put them onto a live environment instead of a historical back-test.  Suddenly we&#8217;re pretty close to what we&#8217;d described previously.  The biggest difference is just the <em>temporality</em> of the strategy context: historical or real-time.  Another difference is that O1&#8230;O<em><strong>n</strong></em> (let&#8217;s generalize just a bit) are no longer necessarily all the same strategy &#8211; they may be completely different. X is also no longer a strategy, but a portfolio of strategies:  a replicated subset of O1&#8230;On we&#8217;ll call X1..Xm.  &#8220;Best&#8221; is no longer a unary choice but must be rich enough to allow M to support some kind of an allocation algorithm across the X family.</p>
<p>OK, so there are some significant differences.  But from the perspective of the object model on which all of this can be implemented, the differences may be limited enough to warrant tackling together.</p>
<h4><span style="color: #000000;"><strong>ready to launch</strong></span></h4>
<p>Before looking at the workflow of a strategy launch, let&#8217;s consider all of the various modes we support with our design:</p>
<ul>
<li>Historical: back-test single strategy</li>
<li>Historical: parameter-based optimization of strategy (decomposes to many back-tests)</li>
<li>Historical: walk-forward testing of strategy</li>
<li>Real-time: SIM &#8211; run single strategy with real-time market data and an exchange simulator</li>
<li>Real-time: LIVE &#8211; run single strategy with real-time market data and a live connection to OMS/broker/exchange</li>
<li>Real-time: LIVE+SIM &#8211; run two cloned instances using the same market data, but with one routing orders to live venue(s) and the other to a simulator.  This is mostly useful for the development of a simulator or to evaluate the quality of simulation for a given strategy.</li>
<li>Real-time: optimization &#8211; run many strategies, permuted differently across live data but routing to a simulator.  I don&#8217;t know what this is useful for, but I find it entertaining&#8230; The screenshots from the <em>regimes</em> post were illustrating this mode.</li>
<li>Real-time: meta-strategy &#8211; our mythic regime-switching allocator will be a nice example of this mode.</li>
</ul>
<p>-</p>
<p>Consider the following sorta-flowchart illustrating the preparation for launch of a strategy.</p>
<div class="wp-caption aligncenter" style="width: 606px"><a href="/images/strategyLaunchFlow.jpg"><img src="/images/strategyLaunchFlow.jpg" alt="" width="596" height="466" /></a><p class="wp-caption-text">click for larger version...</p></div>
<p>The process has 4 or 5 stages depending on whether we&#8217;re being &#8220;meta&#8221; or not &#8211; that is, if we&#8217;re using optimization of any sort.  The highlighted parallelograms are the concrete end-result(s) for each of their respective steps.</p>
<ul>
<li><strong>Assemble Strategy Context</strong> &#8211; The basic channels of I/O for a trading strategy are its sources for market data and the exchanges where trades can be executed.  The MktDataSrc and ExecutionPlatform abstractions need to be specified.</li>
<li><strong>Assemble Strategy</strong> &#8211; Whatever mode we&#8217;re looking to employ will require a strategy either to itself go and trade for us or else to serve as the seed or prototype for our activities.  In this step we define that strategy.  For me, this can be a composite process as a strategy is made up of an arbitrary number of stratparts.  The assembly of a strategy can be done manually with a gui or by loading a strategy from a file or other store.  Once the parts are identified, they can be bound together to form a strategy instance.</li>
<li><strong>Configure Strategy</strong> &#8211; Once assembled, the strategy needs to be configured.  This may just mean we need to parameterize it appropriately for our use.  If we&#8217;re being meta and require optimization then we&#8217;ll also need to describe the parameters to modify and the ranges for each.  This gets boiled-down into an OptimizationDescriptor which is composed of a prototype strategy and the parameter/range data required to perform the requisite back-tests.</li>
<li><strong>Configure Optimization or Meta-strategy</strong> &#8211; If we&#8217;re not running an optimization or utilizing a meta-strategy, this step is skipped.  Otherwise, this is where the optimization and/or meta-strategy should be built and configured.</li>
<li><strong>Review &amp; Launch</strong> &#8211; Anytime you might loose a piece of software on an account with real money in it, it behooves you to pause and reflect for a moment.  Now is that moment.  If, after that moment of reflection, both you and whatever risk measures you employ agree that it&#8217;s OK, then it&#8217;s time to launch.  Happily, this is easy because we now have everything we need.  Again, the meta cases are a bit more involved as the strategies to be optimized or managed must be first generated based on the optimization descriptor we&#8217;ve inherited from earlier steps.  Then it&#8217;s a matter of assembling the pieces previously selected and configured and away we go.</li>
</ul>
<p>-</p>
<blockquote><p>Anytime you might loose a piece of software on an account with real money in it, it behooves you to pause and reflect for a moment.  Now is that moment.</p></blockquote>
<p>I was taught that writing software is easy <em>if</em> you can express the problem you&#8217;re looking to solve <em>and its solution</em> in clear and precise English.  I&#8217;m not sure about this being grammatical, clear or precise, but hopefully it&#8217;s enough to illustrate a means of uniformly modeling and implementing these beasties across a variety of use-cases.</p>
<p>For me, at least, writing this description is helpful as it forces me to walk through the various twists and turns in some detail before digging into the code.  When I get the integrated walk-forward testing working I&#8217;ll try to provide some illustration of its use and will look-ahead to developing a regime-switching example using the models/mechanisms we&#8217;ve been discussing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/11/08/ready-to-launch/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>goldman hacks</title>
		<link>http://www.puppetmastertrading.com/blog/2009/03/12/goldman-hacks/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/03/12/goldman-hacks/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 18:04:48 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[back-testing]]></category>
		<category><![CDATA[dereferenced]]></category>
		<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=409</guid>
		<description><![CDATA[A friend of mine pointed out an article he came across on his bloomberg terminal today which reminded him of a strategy I&#8217;d described to him sometime back and which we&#8217;ve been trading over the past year or so with good results.
To the great chagrin of some of my partners, I even wrote a few [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignleft" style="width: 210px"><img title="..." src="/images/goldmanHacks.gif" alt="rebranding?" width="200" height="200" /><p class="wp-caption-text">rebranding opportunity?</p></div>
<p>A friend of mine pointed out <a title="Goldman Hacks: Bull by Night, Bear by Day" href="http://www.bloomberg.com/apps/news?pid=newsarchive&amp;sid=aXhs9g9il2rk" target="_blank">an article</a> he came across on his bloomberg terminal today which reminded him of a strategy I&#8217;d described to him sometime back and which we&#8217;ve been trading over the past year or so with good results.</p>
<p>To the great chagrin of some of my partners, I even wrote a few posts about the phenomenon underlying our strategy and its evolution as we capitalized on it.  Eventually, they persuaded me to shut up already, but the outline was there for all &#8211; including Goldman! &#8211; to see.</p>
<p>My first post on the topic, <a title="unsung virtues of a dynamic hedge" href="http://www.puppetmastertrading.com/blog/2008/06/04/unsung-virtues-of-a-dynamic-hedge/">&#8220;unsung virtues of a dynamic hedge&#8221;</a> published June 4th of last year, was pretty coy and didn&#8217;t mention the source of alpha itself but talked about enhancing it with a dynamic hedge.</p>
<p>My next post on the topic, <a title="to dream" href="http://www.puppetmastertrading.com/blog/2008/07/14/to-dream/" target="_blank">&#8220;to dream&#8221;</a> was published July 14th of last year and laid out the exploitable discrepancy of the market&#8217;s behavior.  Interestingly, the data I provided in that posting went back the same amount of time as in Goldman&#8217;s piece.</p>
<p>I explicitly wrote one last time about the strategy in <a title="evolution of a strategy" href="http://www.puppetmastertrading.com/blog/2008/07/21/evolution-of-a-strategy/" target="_blank">&#8220;evolution of a strategy&#8221;</a> wherein I detailed the process by which we&#8217;d been evolving the strategy.</p>
<p>Now, one of the more entertaining things about having a blog is that you get to see who is viewing your content.  I&#8217;m happy to note that all of the major IBs are represented including a variety of distinct IPs within Goldman.</p>
<p><strong>Now, I&#8217;m not <em>accusing </em>them of stealing my ideas or anything untoward like that&#8230; but I&#8217;ll admit that I am <em>wondering </em>how long it&#8217;s going to take them to make similar observations across markets beyond US Equities&#8230;</strong></p>
<p>Read on for the Bloomberg article&#8230;</p>
<p><span id="more-409"></span></p>
<p>From the Bloomberg article:</p>
<blockquote><p>By Alexis Xydias</p>
<p>March 12 (Bloomberg) &#8212; Investors should take advantage of others’ “fear” of the night, according to a study by Goldman Sachs Group Inc. that shows holding U.S. stocks overnight since 1993 would have quadrupled an investment.</p>
<p>Buying futures on the <a onmouseover="return escape( popwQuoteShort( this, 'SPX:IND' ))" href="http://www.bloomberg.com/apps/quote?ticker=SPX%3AIND">Standard &amp; Poor’s 500 Index</a>, or a fund that replicates the benchmark for U.S. equities, just as the trading session ends and selling them when the market opens the next day has yielded 309 percent since 1993, New York-based analyst <a onmouseover="return escape( popwSearchNews( this ))" href="http://search.bloomberg.com/search?q=Peter+Berezin&amp;site=wnews&amp;client=wnews&amp;proxystylesheet=wnews&amp;output=xml_no_dtd&amp;ie=UTF-8&amp;oe=UTF-8&amp;filter=p&amp;getfields=wnnis&amp;sort=date:D:S:d1">Peter Berezin</a> wrote in a report sent to clients today. The inverse strategy lost 58 percent.</p>
<p>Investors and traders may have become more reluctant to hold securities overnight, when they’re unable to react to market declines abroad, Berezin wrote. The S&amp;P 500 has plummeted 54 percent since reaching a record in October 2007 as the crisis in credit markets and the collapse of banks including <a onmouseover="return escape( popwQuoteShort( this, 'LEH:US' ))" href="http://www.bloomberg.com/apps/quote?ticker=LEH%3AUS">Lehman Brothers Holdings Inc.</a> hammered equities, while the <a onmouseover="return escape( popwQuoteShort( this, 'VIX:IND' ))" href="http://www.bloomberg.com/apps/quote?ticker=VIX%3AIND">Chicago Board Options Exchange Volatility Index</a>, the so-called gauge of fear, has more than doubled.</p>
<p>“A large number of market participants are averse to holding overnight positions, which causes them to sell at the close (thereby depressing intraday returns) and buy at the open (thereby inflating overnight returns),” Berezin wrote. “Such aversion to overnight risk is likely to be higher during bear markets.”</p>
<p>Overnight Spread</p>
<p>The difference between market-close and market-open prices has widened to 9 basis points since October 2008, the study said, from a “long-term” average of 5 basis points. A basis point is 0.01 percentage point.</p>
<p>The best way to benefit is to hold the <a onmouseover="return escape( popwQuoteShort( this, 'SPX:IND' ))" href="http://www.bloomberg.com/apps/quote?ticker=SPX%3AIND">S&amp;P 500</a> at night, while short-selling it during the day, Berezin wrote. The strategy would have returned 507 percent in the period, the analyst said, while acknowledging the increased costs of such a trading-intensive strategy. Short-sellers sell borrowed securities on expectations they will be able to repurchase them at a cheaper price before their loan is due.</p>
<p>The S&amp;P 500 reached 666.79 on March 6, the lowest intraday level in more than 12 years. The benchmark index for American equities has fallen 20 percent this year.</p>
<p>“Even when one is pondering less trading intensive strategies, the analysis above suggests that there is a cost to be paid for avoiding overnight risk,” Berezin wrote.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/03/12/goldman-hacks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>trading the news</title>
		<link>http://www.puppetmastertrading.com/blog/2008/11/18/trading-the-news/</link>
		<comments>http://www.puppetmastertrading.com/blog/2008/11/18/trading-the-news/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 21:03:02 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[back-testing]]></category>
		<category><![CDATA[market data]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[strategy development]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=151</guid>
		<description><![CDATA[ Inevitably one of the first ideas people have when they start thinking about how to write a trading algorithm turns out to be among the hardest: trading the news.  The problems are many and in some cases not so obvious&#8230;but the natural appeal of the idea seems universally compelling.
Just after the dot.com craze, a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="news?" src="/images/news.jpg" alt="" width="282" height="320" /> Inevitably one of the first ideas people have when they start thinking about how to write a trading algorithm turns out to be among the hardest: trading the news.  The problems are many and in some cases not so obvious&#8230;but the natural appeal of the idea seems universally compelling.</p>
<p>Just after the dot.com craze, a brilliant friend of mine (who had just sold his web consulting startup) decided to write a book.  The premise was glorious.  A bunch of clever college-age kids formed a startup to predict the stock market.  The method they used was to constantly comb the web with ultra-sophisticated algorithms which would run across giant server farms overnight and ultimately <strong><em>generate tomorrow&#8217;s headlines</em></strong>.  Based on the headlines that their system generated, they would place trades that would take advantage of these predicted events.</p>
<p>Sadly, my friend never went on to complete his book, so I don&#8217;t know how it all turned out.  (Instead, he went on to start another successful company, this time in the field of robotics.)  While he was writing it, I loved getting new drafts as they were filled with clever ideas.  But the core idea of predicting headlines and then using those headlines to trade always struck me as especially cute.</p>
<p>For those of us without access to news-predicting algos, writing strategies based on the news is rather less straight forward, though there are a growing variety of products and services aiming to fill the gaps.  Today must have been trading-the-news-day as I found a few articles on the topic in my mailbox and even received a cold call from a vendor, <a title="Need to Know News" href="http://www.needtoknownews.com/" target="_blank">Need to Know News</a>, with just such an offering.  Below I&#8217;ll look at some of these offerings and consider some of the issues involved in writing trading strategies based on the news.<span id="more-151"></span></p>
<p>The idea of trading the news resonates with me as it was one of the first things I tried to automate.  In particular, I spent some time looking to trade crude and natural gas futures based on their respective weekly EIA reports.  This experience led me to a couple conclusions.</p>
<p><strong>The market knows before the news wires do. </strong>This is a big problem for two reasons.  The first is just plain-Jane latency, and I know that vendors are now effectively reducing latency to the sub-second level, but the market still knows first.  The second issue is deeper and is captured nicely by a quote I heard (sorry &#8211; I don&#8217;t remember where) which went something like:</p>
<blockquote><p>&#8220;capital markets are the original social networks&#8221;</p></blockquote>
<p>Which suggests that markets have their own internal languages and understandings.  Thus, <em>translating </em>a market-impacting event, like an EIA report, into a human-readable form to reason about it (even if there&#8217;s no human doing the reasoning) and then action it back into the market struck me as a necessarily lossy transformation.</p>
<p>Another way of seeing this is just to consider: what to do based on the news?  Sell a build of inventory?  Maybe with <em>your</em> money.  Compare the number against expectations?  Whose?  The semantic content that exists in the market seems to be intrinsically richer than that one might extract from a news wire.  But this problem of actioning a news item brings up the next issue.</p>
<p><strong>The problem of history</strong>.  One of the wonderful and horrible things about market data is that there is a lot of it going back a long ways.  This is an expensive pickle to <a title="Billions and billions" href="http://www.puppetmastertrading.com/blog/2008/08/22/billions-and-billions/" target="_blank">manage</a>, but it at least means that you have the ability to look back almost arbitrarily far into the past to see how markets responded to various conditions.  This isn&#8217;t so true with most news wires.</p>
<p>To some degree, these issues are being addressed by vendors.  And some of them will be addressed by how people utilize the news feeds.  If, instead of trying to write a strategy based wholly on the news, I try to improve an existing strategy by annotating its model with data gleaned from a feed, I might wind up with much better results.</p>
<p>Indeed, <a title="SIN Research Report: Algo-Trading on News " href="http://puppetmastertrading.com/images/News_n_Algorithmic_Trading_Research_Report_June08.pdf" target="_blank">one of the papers</a> I came across today is a research report from <a title="Securities Industry News" href="http://www.securitiesindustry.com/" target="_blank">Securities Industry News</a> (incidentally, my first tip-off that Citi was going down the toilet was when my management told me I could no longer keep my subscription to that fine periodical).  In it, market participants indicate that they expect to improve existing algos more than create brand-new ones.  But they also failed to complain about the lack of back-testable feed histories, so&#8230;</p>
<p>The <a title="AlphaSimplex assesses Reuters news feed" href="http://puppetmastertrading.com/images/Reuters_NewsScope_Event_Indices_Whitepaper.pdf" target="_blank">other paper</a> is a much more detailed quantitative exposition on how to build a news reading algo and some statistical analysis on how well it annotated the market.  This one is the work of <a title="Andrew Lo" href="http://web.mit.edu/alo/www/" target="_blank">Andrew Lo</a>&#8217;s <a title="AlphaSimplex Group" href="http://www.alphasimplex.com/" target="_blank">AlphaSimplex Group</a> and as such is required reading for anyone who really wants to implement such systems.</p>
<p>Ever since my first experiences with trying to trade energy commodities based on the EIA report via news feed, I&#8217;ve been pretty skeptical of the utility of trying to algorithmically trade the news.  That said, like everything else in this space, there&#8217;s an incredible amount of innovation going on and an incredible number of seriously smart and motivated folks working to ensure that this will be a productive path for those with the ability to tackle the formidable complexities presented.</p>
<p>&#8211;</p>
<p>Updated: added link to Need to Know News&#8217; site</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2008/11/18/trading-the-news/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>billions and billions</title>
		<link>http://www.puppetmastertrading.com/blog/2008/08/22/billions-and-billions/</link>
		<comments>http://www.puppetmastertrading.com/blog/2008/08/22/billions-and-billions/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 16:21:22 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[back-testing]]></category>
		<category><![CDATA[market data]]></category>
		<category><![CDATA[open-source software]]></category>
		<category><![CDATA[post-trade analysis]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog-test/?p=81</guid>
		<description><![CDATA[
While Carl Sagan&#8217;s famous formulation introduced a generation to the vastness of the cosmos, more recent history suggests that his memorable term might now be more aptly applied to financial extents: our deficits and debts, perhaps, to the economically or politically minded.  But for those of us with the markets on our mind, the [...]]]></description>
			<content:encoded><![CDATA[<p><img hspace="7" align="left" alt="billions and billions" title="billions and billions" src="http://puppetmastertrading.com/images/stars.jpg" /></p>
<p>While Carl Sagan&#8217;s famous formulation introduced a generation to the vastness of the cosmos, more recent history suggests that his memorable term might now be more aptly applied to financial extents: our deficits and <a target="_blank" title="US Public Debt" href="http://en.wikipedia.org/wiki/United_States_public_debt">debts</a>, perhaps, to the economically or politically minded.  But for those of us with the markets on our mind, the term has to evoke the enormity of the data we create and must manage every day.  We&#8217;ve recently been working with the <a target="_blank" title="NYSE TAQ Data" href="http://www.nyxdata.com/nysedata/default.aspx?tabid=730">NYSE&#8217;s TAQ data</a> in an effort to integrate it into <a target="_blank" title="Puppetmaster Trading: StratBox" href="http://puppetmastertrading.com">StratBox</a>&#8217;s back-testing and optimization capabilities.  And the enormity of the data is really just staggering.</p>
<p>Each day, the NYSE publishes all of the day&#8217;s quotes and trades as well as some reference data.  Compressed, the data will just about fit onto a DVD.  For one day.  A DVD.  Compressed.  It&#8217;s really mind-boggling.  A year of the stuff, uncompressed, will require over a <em>petabyte </em>of storage.  Over 1,125,899,906,842,624 bytes.  And that&#8217;s just the US Equities markets.  You want options data, too?  I hope your uncle is named <a title="EMC - " target="_blank" href="http://www.emc.com/index.htm">EMC</a>, because just managing the data is going to be <em>a challenge</em>&#8230;</p>
<p><span id="more-81"></span></p>
<blockquote><p>&#8220;Information about money has become almost as important as money itself.&#8221; &#8212; Walter Wriston, former Chairman of Citicorp</p></blockquote>
<p>The enormity and profile of market data far exceeds the capacity of traditional RDBMSes. While RDBMSes continue to expand their usable capacity &#8211; we have used partitioned tables with nearly a billion rows of market data which have performedÂ  astonishingly well &#8211; they simply can&#8217;t deal with the kinds of quote volumes modern markets are generating daily.  This has spawned a host of specialized timeseries database products, like the grandaddy: <a target="_blank" title="Sungard's Fame" href="http://www.sungard.com/Fame/">Sungard&#8217;s FAME</a> which I&#8217;d used back in the 90&#8217;s to write programs to calculate bond indices at JPM, to more recent offerings like <a target="_blank" title="Vhayu" href="http://www.vhayu.com/">Vhayu</a> and <a target="_blank" title="kdb+" href="http://kx.com/">Kdb+</a>.  These timeseries oriented data products undoubtedly have many distinguishing characteristics and features, but they share one immutable characteristic: they are unbelievably expensive &#8211; in some cases a single developer seat costs in the high 6-figures for an annual license.</p>
<p>Thus, while no doubt missing out on some of their high-end features and niceties, we&#8217;ve decided to seek solutions from some of the original purveyors of petabyte-scaled data: NASA and the NCSA through their <a title="HDF5: what is it?" target="_blank" href="http://hdf.ncsa.uiuc.edu/HDF5/whatishdf5.html">HDF5</a> system.  Designed to support vast scientific data stores and boasting sophisticated capabilities in support of parallel computing environments, it should be possible to get comparable performance to some of the high-end specialized finance products without the sticker shock.  Indeed, it&#8217;s potentially <a title="Quantlib" target="_blank" href="http://puppetmastertrading.com/blog/2008/06/14/using-quantlib-from-java/">another example of free software</a> providing a meaningful contribution to finance.</p>
<p>In researching cost-efficient and highly parallel hardware solutions to pair with our emergent data solution, I&#8217;ve come to realize that open-source is expanding its reach into the hardware sphere.</p>
<p><img title="Linux cluster in an IKEA Filing cabinet" alt="Linux cluster in an IKEA Filing cabinet" src="http://puppetmastertrading.com/images/helmer.png" /></p>
<p><a target="_blank" title="Helmer" href="http://helmer.sfe.se/">This guy</a> shares his experience and &#8220;recipe&#8221; for building a powerful and unique rendering cluster inside an IKEA filing cabinet.  It&#8217;s admittedly on the funky side for even a SOHO operation, but it&#8217;s no joke &#8211; it&#8217;s more powerful than a lot of production blade servers used on wall st and it cost him less than $4K.  He also includes a (very loosely described) spec for a more powerful next-generation version with some 50-Teraflops of capacity!  So, while the data we&#8217;re having to deal with is growing at an incredible rate, the tools we have to manage it are growing proportionately for those who know how to leverage the work so many smart people are producing and freely sharing.</p>
<p>As my dad told me years ago:</p>
<blockquote><p>&#8220;Good programmers write good programs.  Great programmers <em>steal </em>good programs.&#8221;</p></blockquote>
<p>At this point, we&#8217;re still in the &#8220;discovery&#8221; stage of our development of TAQ+HDF5 for StratBox, but as we progress I&#8217;ll periodically post some of our experiences.</p>
<p>&#8212;</p>
<p>UPDATE</p>
<p>Speaking of my dad, he saw this posting and pointed me to some <a target="_blank" title="Massive Information processing and Fault-Tolerance: The Google Approach" href="http://www.cis.temple.edu/~ingargio/cis307/readings/MapReduce.html">class notes</a> he&#8217;s been working on which describe the Google approach to massive information processing and fault-tolerance.Â  Interesting and full of great links to both academic and industrial papers/sites on the topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2008/08/22/billions-and-billions/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>execution quality at the open &amp; close</title>
		<link>http://www.puppetmastertrading.com/blog/2008/08/01/execution-quality-at-the-open-close/</link>
		<comments>http://www.puppetmastertrading.com/blog/2008/08/01/execution-quality-at-the-open-close/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 15:50:35 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[back-testing]]></category>
		<category><![CDATA[execution quality]]></category>
		<category><![CDATA[performance analysis]]></category>
		<category><![CDATA[post-trade analysis]]></category>
		<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog-test/?p=77</guid>
		<description><![CDATA[
I&#8217;ve been trading an increasing amount at the open and close of the equity markets using market-on-open (MOO) and market-on-close (MOC) order types and have found that the quality of executions varies enormously between the two types and have spent a bit of time analyzing the differences which I share below.
The quick scoop is that [...]]]></description>
			<content:encoded><![CDATA[<p><img align="middle" title="Execution Quality" alt="Execution Quality" src="http://puppetmastertrading.com/images/mouseExecution.jpg" /></p>
<p>I&#8217;ve been trading an increasing amount at the open and close of the equity markets using market-on-open (MOO) and market-on-close (MOC) order types and have found that the quality of executions varies enormously between the two types and have spent a bit of time analyzing the differences which I share below.</p>
<p>The quick scoop is that MOC orders almost invariably fill at the exchange&#8217;s published closing price, while MOOs vary very substantially from the published open price.  Below I quantify my findings in a bit greater depth.</p>
<p><span id="more-77"></span></p>
<p>I looked at 846 recent MOO and MOC equity trades made over the past two months.  Of all of these trades, only one MOC trade didn&#8217;t execute at the published close and the price I got was only off by one penny.  Across all of the trades, I received the open or close price 55% of the time.</p>
<p>The remaining 45% of the time I varied from the open by an average of +.04%  This means that I actually saw a slight price <em>improvement </em>in the average case.  That is, if I was shorting then I executed at a price above the listed open and vice-versa for longs.  I&#8217;ll take it!</p>
<p>In the below chart I plot the trades against their variance, positive or negative, from the listed open or close.</p>
<p><img align="middle" alt="Variance from listed open/close" title="Variance from listed open/close" src="http://puppetmastertrading.com/images/openCloseExecs.jpg" /></p>
<p>The biggest difference was a whopping 8.56% but at least it went in my favor.  The stdev across all of the trades was .87% so we&#8217;re not looking at too disperse a grouping.</p>
<p>This data is a bit skewed as the majority of the MOO orders are going short.  This is also a pretty limited universe of trades, so I&#8217;ll continue to look at the execution quality I&#8217;m getting on these order types and will revisit it if I see any interesting changes.</p>
<p>My interpretation is that my broker is making a best-effort to get a fair open price and they&#8217;re doing a creditable job of it.  The exchanges are doing a nearly perfect job with MOC orders.</p>
<p>What impact does this have on my strategies?  I&#8217;m not sure yet, but my first blush impression is that it might be worthwhile to try to get some price improvement over the posted open price as a means of both improving the results and extending the capacity of such strategies.  It&#8217;s a favorable result as it means that strategies which back-test well on open/close data have a pretty good chance of executing well in reality.</p>
<p>A related issue, which I&#8217;m still researching, concerns the capacity of such strategies and may be the topic of a future post&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2008/08/01/execution-quality-at-the-open-close/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>to dream</title>
		<link>http://www.puppetmastertrading.com/blog/2008/07/14/to-dream/</link>
		<comments>http://www.puppetmastertrading.com/blog/2008/07/14/to-dream/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 15:32:09 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[back-testing]]></category>
		<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog-test/?p=71</guid>
		<description><![CDATA[ People have long imagined ways to make money while they slept.Â  Happily, it&#8217;s not a pursuit I&#8217;m particularly bothered by, but as I develop trading strategies, I do make note of different market behaviors that correlate to the time of day. Or night.
In particular, I&#8217;ve been looking at various market-breadth ETFs recently as [...]]]></description>
			<content:encoded><![CDATA[<p><img hspace="7" align="left" title="..." alt="..." src="http://puppetmastertrading.com/images/makeMoneyWhileYouSleep.jpg" /> People have long imagined ways to make money while they slept.Â  Happily, it&#8217;s not a pursuit I&#8217;m particularly bothered by, but as I develop trading strategies, I do make note of different market behaviors that correlate to the time of day. Or night.</p>
<p>In particular, I&#8217;ve been looking at various market-breadth ETFs recently as possible fodder for the little dynamic hedger I&#8217;ve described <a title="unsung virtues of a dynamic hedge" target="_blank" href="http://puppetmastertrading.com/blog/2008/06/04/unsung-virtues-of-a-dynamic-hedge/">before</a>, and I&#8217;ve noticed an interesting behavior among several of them&#8230;</p>
<p><strong>Like the majority of traders, they do better when they&#8217;re not trading!</strong></p>
<p>That is, they actually display better performance at night than they do during the regular trading day; there&#8217;s more profit to be had in their gaps between sessions than there is during trading sessions. Below I quantify this observation more thoroughly&#8230;</p>
<p><span id="more-71"></span>I looked at the performance of a variety of ETFs across three super-simple &#8220;strategies&#8221;. The first of them trades overnight &#8211; buying the close and selling the following morning&#8217;s open.   The next buys at the open and sells at the close.   And the final one is, essentially, buy and hold though it&#8217;s implemented as a buy at close, sell and buy at following close. No costs or slippage are included.Â  The table below details the results for the SPY (S&#038;P 500), IWM (Russell 2000) and QQQQ (Nasdaq 100).</p>
<p>In all cases, the ETFs perform better overnight &#8211; they make more and have almost precisely half the risk, yielding very substantially better risk-adjusted performance measures (here sharpe is calculated with a constant 5% risk-free rate). These cases are highlighted in yellow in the table. Likewise, the worst performer in all cases was the &#8220;day-trader&#8221; who bought on the open and sold on the close. One thing to note about the below summary is that all data is taken from inception for each of the ETFs, so their duration varies! (For the SPY, since 1/29/1993; for the IWM, since 5/26/200 and for the QQQQ since 3/10/1999).<br />
<img align="middle" alt="I dream of ETFs..." title="I dream of ETFs..." src="http://puppetmastertrading.com/images/etfDreams.jpg" /></p>
<p>I tried the same analysis across a few other ETFs to see if the effect was a global one or a US-specific phenomenon. The results are mixed but likely negative for Europe (EWG), Japan (EWJ) and broad foreign markets (EFA). I&#8217;m not going to summarize that data here, but you can grab the excel workbook I used for this exercise <a title="Excel workbook with relevant data" target="_blank" href="http://puppetmastertrading.com/images/todream.xlsx">here</a>, though I warn you in advance that it&#8217;s about 2.3M. (If you find errors &#8211; please point them out!)</p>
<p>[UPDATE: .XLS 97-2003 version available <a target="_blank" title="Excel 1997-2003 version" href="/images/todream.xls">here</a> is ~3M]</p>
<p>For the US markets summarized in the table, the conclusion is pretty explicit &#8211; the great majority of the market&#8217;s profits are attained overnight. Even worse: in spite of the positive returns across all of these markets over the relevant periods, all of them show significantly negative intraday performance.</p>
<p>For long-only day-traders, this is the kind of result that should cause nightmares!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2008/07/14/to-dream/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>perils of parameterization</title>
		<link>http://www.puppetmastertrading.com/blog/2008/07/08/perils-of-parameterization/</link>
		<comments>http://www.puppetmastertrading.com/blog/2008/07/08/perils-of-parameterization/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 15:16:45 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[back-testing]]></category>
		<category><![CDATA[strategy development]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog-test/?p=65</guid>
		<description><![CDATA[
I came across and had to share this excellent vignette by Freeman Dyson on the perils of excess model parameterization&#8230;
In desperation I asked Fermi whether he was not impressed by the agreement between our calculated numbers and his measured numbers. He replied, â€œHow many arbitrary parameters did you use for your calculations?â€ I thought for [...]]]></description>
			<content:encoded><![CDATA[<p><img align="top" title="What he might do with 6 parameters?..." alt="What he might do with 6 parameters?..." src="/images/elephant_cartoon.jpg" /></p>
<p>I came across and had to share this excellent vignette by <a target="_blank" title="original PDF article " href="http://cmm.cit.nih.gov/~hassan//dyson.pdf">Freeman Dyson</a> on the perils of excess model parameterization&#8230;</p>
<blockquote><p>In desperation I asked Fermi whether he was not impressed by the agreement between our calculated numbers and his measured numbers. He replied, â€œHow many arbitrary parameters did you use for your calculations?â€ I thought for a moment about our cut-off procedures and said, â€œFour.â€ He said, â€œI remember my friend Johnny von Neumann used to say, with four parameters I can fit an elephant, and with five I can make him wiggle his trunk.â€</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2008/07/08/perils-of-parameterization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
