<?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</title>
	<atom:link href="http://www.puppetmastertrading.com/blog/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.puppetmastertrading.com/blog</link>
	<description>Algorithmic trading experiences</description>
	<lastBuildDate>Tue, 02 Mar 2010 15:47:21 +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>basic economics of an algorithmic trading startup</title>
		<link>http://www.puppetmastertrading.com/blog/2010/03/02/basic-economics-of-an-algorithmic-trading-startup/</link>
		<comments>http://www.puppetmastertrading.com/blog/2010/03/02/basic-economics-of-an-algorithmic-trading-startup/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 15:45:32 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[startup]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=1104</guid>
		<description><![CDATA[or: how to quit your job to riches!
Recently I had a thought-provoking email exchange with a reader of this blog.  It was with a fellow who wanted to startup an algorithmic trading business and was seeking my advice.  Its arrival was timely for me and I hope the advice I provided the aspiring entrepreneur was [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.puppetmastertrading.com/blog/wp-content/uploads/2010/02/accounting.jpg"><img class="alignright size-full wp-image-1105" title="accounting" src="http://www.puppetmastertrading.com/blog/wp-content/uploads/2010/02/accounting.jpg" alt="" width="120" height="150" /></a><strong>or: how to quit your job to riches!</strong></p>
<p>Recently I had a thought-provoking email exchange with a reader of this blog.  It was with a fellow who wanted to startup an algorithmic trading business and was seeking my advice.  Its arrival was timely for me and I hope the advice I provided the aspiring entrepreneur was helpful.</p>
<p>The conversation forced me to reconsider familiar terrain from a different perspective, so I share it along with some further thoughts in the hope that it might act as something of a counter-weight to articles and blogs entreating you to &#8220;learn algo-trading!&#8221; (as though it were a fun! weekend hobby) or &#8220;make a million % trading the xyz&#8221; and more nefarious advertisements selling the trading equivalents of male-enhancement pills &amp; potions (&#8220;I turned a used bus ticket and some pocket change into $7M in 2 months trading the e-mini!&#8221;).</p>
<p>I&#8217;ve changed the writer&#8217;s name and all identifying characteristics for obvious reasons.  He wrote:<span id="more-1104"></span></p>
<blockquote><p>Hi Tito,</p>
<p>First of all I want to say I really enjoy your blog.  I particularly like your latest portfolio of strategies that updates itself intraday while running a host of strategies in simulation.</p>
<p>I saw that you left Wall Street back in 2005; I am currently at <em>[a 'money-center' bank in]</em> London and am contemplating a similiar move.  Was wondering if you have any advice or words of thought, particularly in this market/economic environment?  My dream has always been to work at a small hf or high freq shop or to start one of my own.  After several years, I finally think I have enough strategies and angles to go forward.</p>
<p>Btw, you are not at Tower Research, are you?  They have t-shirts which read &#8220;Hack Wall Street&#8221;</p>
<p>Regards,</p>
<p><em>[Sean]</em></p></blockquote>
<p>Not knowing <em>&#8216;Sean&#8217;</em> from Adam, I replied aiming to be helpful but with a characteristic dose of snark:</p>
<blockquote><p>Hi <em>[Sean]</em>,</p>
<p>Thanks for your kind words &#8211; they&#8217;re appreciated.</p>
<p>I always have advice.  Quality is the issue.  That said, even my ordinarily low standards can&#8217;t be met w/o more info about you.  (e.g., what kind of work have you been doing?, what kind of money do you have salted away (that you are willing to lose!)? etc etc).</p>
<p>But I can still make a few observations.  My first is general:</p>
<div>If you haven&#8217;t been working, directly, in a hedge fund or a hft shop, I wouldn&#8217;t recommend trying to start one on your own.  Join one, understand all aspects of the business, build a track record and contacts and only then (if at all) attempt your own gig.</div>
<p>Regarding: &#8220;particularly in this market/economic environment&#8221;  and &#8220;HFT&#8221;:</p>
<div>
<p>HFT is (wrongly, imo) currently under serious attack.  Off-market derivatives and bought politicians were used to wreck economies, but HFT has become the scapegoat.  I believe that <em>[the bank you work at]</em> has shut down their prop HFT biz and I know that <em>[another bank]</em> has.  Many others go under every day.  Whatever else this might mean, it certainly means that there will be fewer jobs and more qualified people on the street competing for them.</p>
<p>It also means there is a possibility (probably a small one) that some kind of regulatory action literally kills the field.  A tobin tax or the like would mean the end of HFT.  Which would make HFT an unfortunate business to be in&#8230;</p>
<p>Also, HFT is a *very* specialized field.  You need to have very specialized skills to really add value.  Only you can answer if you do or not.</p>
<p>Finally, a wise wall st old-timer once told me: &#8220;there are years to make a killing on your bonus and there are years to keep your job&#8230;&#8221;</p>
</div>
<p>Regarding: &#8220;a small hf&#8221;</p>
<div>
<p>Hedge funds are (mostly) a very different business from HFT shops.  The successful hf mgrs I know all aver that the game is all about raising money &#8211; managing it is very secondary (unless you&#8217;re seriously foolish or a fraud).   It also raises the question:</p>
</div>
<p>Most of all: What do you really want to do with your life?</p>
<p>Good luck to you.  Best,</p>
<p>Tito.</p>
<p>ps &#8211; I&#8217;m not sure that I&#8217;ve ever even heard of tower research&#8230;</p></blockquote>
<p>This probably wasn&#8217;t what he wanted to hear and he came back a bit piqued at my necessarily ill-targeted advice:</p>
<blockquote><p>Same clarifications if I may:1)  When I said my dream was to start my own small hf or high freq shop, I should have stated that is my long-term goal.  In the short term, I see myself working for a hedge fund first while also trading my own PA in respectable size (quant strategies, fully systematic).</p>
<p>2) I should state that I have run a $50M systematic book successfully at <em>[London bank]</em> albeit only on low frequency strategies.  I have also worked at a very large prominent electronic market making desk at <em>[London Bank]</em>.  So while this is not the same as have direct experience at a hedge fund, I dont consider myself a novice either.  However, I agree that I am not ready to start my own hf or hf shop.  My issue at the moment is I would like to focus more on the medium-to-high frequency end at the spectrum, but it appears this is not going to be possible at <em>[London Bank]</em>.</p>
<p>3)  I agree with many of the the things you stated about HF.  Just curious, do you consider yourself a HF trader?   I honestly consider myself more of a medium frequency/intraday with no overnight risk trader.  I am definitely not ultra high frequency or doing any latency arb and I think &#8220;medium frequency&#8221; is a good place to be.</p>
<p>4) Question for you:  do you consider a 6 figure PA account large enough to establish a track record in terms of hashing out if something indeed has an _actual_ out-of-sample edge?  Granted this is not alot of money, but my assertion is that this is enough to &#8220;go live&#8221; with several systems _in very small size_ with strict money management. [ie no more than 2% risk per trade, absolute max 10:1 leverage, etc]  And I am not starting from scratch; I have been in quant strategy for over 2 1/2 years and have several systems ready to go.</p>
<p>Where I am at now is that I am ready to do #4 full-time while continuing to interview with hedge funds and high freq shops.  I have the right background Electrical and Computer Engineering from <em>[top-tier American University]</em>, graduate work in time series analysis and econometrics from <em>[top-tier UK biz school]</em>, <em>[more impressive sounding experience]</em> but it is taking longer than I had hoped to make the jump to the buy side.</p>
<p>I realize you are probably thinking &#8220;hold on to your job on the sell side at all costs etc..&#8221; as it is really bad at there and may likely get worse, and while I dont disagree, at some point a person has to move towards what they want instead of living in fear forever.  Let&#8217;s just say the past couple of years in banking have not been enjoyable.</p>
<p>Sorry for ranting but hope you can understand where I am coming from&#8230;would appreciate any advice you may still have&#8230;</p>
<p>Regards,</p></blockquote>
<p><em>Sean</em> had provided some useful information with which we could do some simple math. He had a good background and some hundreds of thousands of dollars he was willing to risk on the venture. Not bad, right?&#8230; I responded:</p>
<blockquote><p>It all sounds reasonable and none of it sounds like a rant.</p>
<p>1,2  Sound good to me.</p>
<p>3 Definitely not ultra high.  Many hundreds of trades per day at most for any given strategy.</p>
<p>4  Yes, but for what?   Your (excellent) background is certainly no handicap (though many or most places require a phd for a quant position with p&amp;l), so the question as to whether you can land the job you desire is an empirical one.  Go for it!  Certainly I wouldn&#8217;t recommend that you quit your job and start trading as that immediately puts you at a very substantial disadvantage from the perspective of employers.  I empathize with the &#8220;past couple of years in banking have not been enjoyable,&#8221; but 6 figures of savings aren&#8217;t a ton if you&#8217;re used to living a banker&#8217;s lifestyle in an expensive financial center like nyc or the city.  Going to the buy-side sounds like a great idea; quitting your job? &#8211; not so much.</p>
<p>Your decision will also depend on your position in life.  If you have a family (or want to), a partner who enjoys spending money, a desire to travel, etc etc.  Quitting your job to trade your own account is certainly ballsy and if you are successful then shazam!  If not, then you may have irrevocably pushed yourself off the (successful if not enjoyable) path you&#8217;ve worked so hard to obtain; if economies really go down the tubes or bigger wars become fashionable, you could find yourself in a really funky spot.  Or you could be wildly successful and build a giant sailboat that kick&#8217;s larry ellison&#8217;s butt&#8230;</p>
<div class="wp-caption alignright" style="width: 331px"><img class=" " src="/images/larrysTri.jpg" alt="" width="321" height="214" /><p class="wp-caption-text">New Holder of the America&#39;s Cup!</p></div>
<p>Let me ask you a few questions.  What platform(s) do you intend to use?  Where will you get your data?  How will you store it?  Manage it?  For me, back in 2005 I thought I&#8217;d just head on out there, buy some spiffy product and be off and trading.  I was profoundly wrong about that.  Retail level platforms are crap.  Seriously unusable.  (My info on this may be dated, I admit &#8211; hence my questions to you <img src='http://www.puppetmastertrading.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> )  I don&#8217;t think you can afford an institutional platform with 6figures in the bank unless you are *immediately* profitable and burning through half your wad in a few months will impose stress that&#8217;s altogether more serious than whatever ridiculous nonsense I imagine you have to put up with at <em>[London bank]</em> these days.  Building your own platform isn&#8217;t so easy and is quite time-consuming.  Worse than that, it causes you to have to focus on a lot of things that are *not* central to your primary aim.</p>
<p><strong>Let&#8217;s look at numbers.  Say you have ~$500K in hand and a requirement of ~$100K to live.  20% seems plausible.  But you will actually need to do rather better than 20%.  Insurance costs are a mother (maybe not in the uk), but they&#8217;re a good deal less than usable office space, bandwidth and lots of other oddments you&#8217;ll find yourself paying (eg, accountants aren&#8217;t free, lawyers aren&#8217;t cheap, and programmers mostly suck).  So, your real expenses aren&#8217;t 100K/year, but more like say 150K or worse.  Oh yeah, there&#8217;s taxes, too.  So, in reality starting from a 6figure base, you need to make ~30% or rather better to *break*even*.  If you have a year in which you make less than your break-even point, then the numbers get really grim.  On the other hand, you need to have a serious blowout year to make a significant difference in these basic numbers.  There&#8217;s no margin for error or, worse, misfortune.  Don&#8217;t get sick, don&#8217;t break an arm, don&#8217;t have a loved-one need anything from you and don&#8217;t lose any money!  In spite of all of your experience, intelligence and hard work, a bit of bad luck can put you into an untenable position.  There&#8217;s a good reason the Greeks believed that the only thing more powerful and less controllable than their rich pantheon of powerful Gods were <a rel="nofollow" href="http://en.wikipedia.org/wiki/Moirae" target="_blank">The Fates</a>.</strong></p>
<p>All of this said, who the heck am I?  Sounds like you have a great background and some passionate ideas about what you want to do.  I don&#8217;t want to be negative or dissuade you from pursuing a dream.  But I assume you&#8217;ve got all the up-side worked out and have thus focused on the (potential) down-side!  ;^&gt;</p>
<p>Best,</p></blockquote>
<p>I haven&#8217;t heard back from <em>Sean</em> and at this point don&#8217;t expect to though I gave him as direct and honest advice as I was capable of providing.</p>
<p><strong>a cautionary tale</strong></p>
<p>This exchange resonated with me because, almost exactly five years ago I had a &#8217;serious&#8217; conversation with my then-fiancée (and now wife and mother of our beautiful son).  I had been working hard for years and had lived very frugally (would you believe a $900/month 1-bedroom apartment in manhattan two blocks east of union sq?), saving my money to one day pursue a long-held dream.  I said to her, &#8220;I can buy you a house with cash today or I can start a business and, most likely, lose everything and have to start all over again.&#8221;</p>
<p>(This was my own version of David Einhorn&#8217;s memorable &#8216;Greenlight moment&#8217; as recounted in his &#8220;Fooling Some of the People All of the Time.&#8221;)</p>
<p>She assented and not too many weeks later I walked away from my steadily ascending career and Puppetmaster Trading was formed.  I was then in a similar circumstance to what my erstwhile pen-pal <em>Sean</em> is in today.</p>
<p>Around the time that I had this email exchange, I was being forced to face the fact that Puppetmaster Trading was in just such an untenable position as I&#8217;d described.</p>
<p>Someday I might write a post-mortem along the lines of the <a title="Roger Ehrenberg: Monitor110: a post-mortem" href="http://www.informationarbitrage.com/2008/07/monitor110-a-po.html" target="_blank">courageous and revealing post</a> Roger Ehrenberg wrote describing the errors he&#8217;d made in one of his startups.  But today isn&#8217;t that day; I need some distance and perspective to adequately compose my thoughts and identify the key errors I&#8217;ve made along the way.</p>
<p>So, to <em>Sean</em> and others like him, view this as a cautionary tale.  Don&#8217;t view it as &#8216;proof&#8217; that starting your company is a bad idea.  Even given constraints like <em>Sean</em>&#8217;s, I&#8217;m 100% certain that success was possible but for a few costly errors of judgment I personally made.  After the first year and a half, our trading returns were always positive.  In 2008 we had a real blowout year which could have been a game-changer had I not elected to pursue an ill-fated partnership (which hinted beguilingly at an outright sale) rather than sticking to what was working.  There were other mistakes, too &#8211; some of them possibly worse.  Interestingly, all of them were about running a business and not about algorithmic trading<em> per se</em>.</p>
<p>Selecting a business model and <span style="text-decoration: underline;">focus</span>, funding issues, partnership dynamics, effective team-building and the like are where the game is won or lost.</p>
<p><strong>the funny business (models) of algorithmic trading</strong></p>
<p>As far as business models go, algorithmic trading can be taken in quite a few directions, the simplest of which is proprietary trading which is where we ultimately settled.  If you&#8217;re building a platform you can try to be a product company, but then I don&#8217;t think you&#8217;d really qualify as an algo-trading concern.  One can also form one of many varieties of funds or advisories to bring in external funding and all of these have their strengths and drawbacks.  And all require the track record, marketing savvy and connections to bring in the commitments.  We&#8217;ve looked at almost all of these options and pursued a few.</p>
<p>If you&#8217;re building your own platform with the intent of trading it, it&#8217;s a bit of a funny situation, because no-one wants to bear the cost of building a system you won&#8217;t sell.  Buying systems and then integrating them such that they&#8217;re practically usable is such an expensive proposition that one is essentially forced to bring in external money unless they happen to have a few spare millions of dollars lying about that they don&#8217;t mind spending. Actually, in retrospect, this is nearly as true if you&#8217;re building instead of buying.</p>
<p>Perhaps the most interesting models that we explored were those in which algorithms backed structured products or ETF-like vehicles.  I think there will be many such products in the future with good reason.  But to do this, you need to partner with a bigger financial firm.  Here, again, you need connections (and probably will be better served by a firm name a bit more sober than our own!) and at least some heft of your own as established investment houses aren&#8217;t in the business of working with the proverbial two guys in a garage.</p>
<p>All of these are viable models, and all present unique challenges and opportunities.  The bottom-line is that to startup successfully you need to select one and then either obtain funding early on or you need to be lucky *and* commit no errors.</p>
<p><strong>to build or buy&#8230;<br />
</strong></p>
<p>As for the platform we built, Stratbox, I can only view it as a success &#8211; many tens of thousands of trades have passed through it and only once, very early on in (I think) december&#8217;05 (before it had even a rudimentary GUI), did we lose any money from it on account of a coding error.  Although I haven&#8217;t looked carefully at algo platforms in years, I&#8217;m told it has features that even well-established companies haven&#8217;t put into their commercial products and there&#8217;s no doubt that having full source code enables degrees of freedom that are impossible with off-the-shelf products.</p>
<p>The fact that Stratbox isn&#8217;t a commercial product has real drawbacks, especially in terms of the &#8216;fit and finish&#8217; one expects from established software.   But it also brings considerable  benefits in that you can really drive development based on immediate needs.  In very short time frames, you can build the 90% of functionality that you need *now*.   It&#8217;s just not possible for an established vendor to implement, test, and roll-out new features with the requisite solidity and 100% finish anywhere near as fast as can an &#8216;agile&#8217; team with skin (and maybe an organ or two) in the game.  Thus, if I were to start all over again, while I would look at the various vendor offerings (and might well change my mind based on that review), I&#8217;m still inclined to think that I&#8217;d continue to &#8220;roll my own&#8221;.</p>
<p><strong>the evolution will be blogged</strong></p>
<p>I started this blog as a means of composing my thoughts and sharing my &#8216;algorithmic trading experiences&#8217;  and in that light it&#8217;s been a quiet success.  Although it has been a minor time- and cash-sink, I enjoy it and have benefited from the people I&#8217;ve met through its pages.   I also always view writing as its own reward.  I send a sincere &#8220;thank you&#8221; to all who have read and all who have shared their own insights and experiences.  At some point &#8211; not too soon &#8211; I may try my hand at a constructive post-mortem.  In the meanwhile, I&#8217;ll continue as I have and write when I have something to say.  The longer-term fate of the blog remains to be seen and will likely depend on what I end up doing next.</p>
<p style="text-align: center;"><a href="http://www.puppetmastertrading.com"><img class="aligncenter" src="/images/logo-txt.gif" alt="" width="407" height="263" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2010/03/02/basic-economics-of-an-algorithmic-trading-startup/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>lock free</title>
		<link>http://www.puppetmastertrading.com/blog/2010/02/16/lock-free/</link>
		<comments>http://www.puppetmastertrading.com/blog/2010/02/16/lock-free/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 00:55:38 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[EMS Internals]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=1010</guid>
		<description><![CDATA[
One of the recurring technology themes in these pages has been the ongoing and dramatic move from single to multi-core systems and the need to seriously increase the parallelism in our software designs. For me, one of the seminal, large-grained design patterns was the SEDA Architecture. For years, this informed my systems&#8217; designs and formed [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="margin-left: 5px; margin-right: 5px;" src="/images/lockfree.jpg" alt="" width="310" height="324" /></p>
<p>One of the recurring technology themes in these pages has been the ongoing and dramatic move from single to multi-core systems and the need to seriously increase the parallelism in our software designs. For me, one of the seminal, large-grained design patterns was the <a title="SEDA Architecture" href="http://www.eecs.harvard.edu/~mdw/proj/seda/" target="_blank">SEDA Architecture</a>. For years, this informed my systems&#8217; designs and formed a conceptual backbone for development. That said, I&#8217;ve been broadly aware for some time that SEDA&#8217;s golden age has (incredibly!) already passed us by, but haven&#8217;t identified what might replace it as a reference point for my design efforts.</p>
<p>Before considering tools, languages or patterns that might help, we need to reflect on the problem(s) we&#8217;re trying to solve. The problems inside an EMS look to me, after years of development, a lot like network routing problems. Indeed, my current view is that this (not just concurrency as I&#8217;d suggested at the time) is why the <a title="FT: Aleynikov indicted" href="http://www.ft.com/cms/s/0/235b1260-1776-11df-87f6-00144feab49a.html" target="_blank">unfortunate</a> Aleynikov &amp; co. at GS were <a title="the other interesting thing about the serge aleynikov story" href="http://www.puppetmastertrading.com/blog/2009/07/08/the-other-interesting-thing-about-the-serge-aleynikov-story/" target="_blank">using erlang</a>.</p>
<p>Why network routing? Think about the load on an EMS. The main issue is that you&#8217;re getting many thousands of teeny little messages per second and only a relatively small number of them matter to only a relatively small subset of &#8216;agents&#8217; within the system. Reducing latency is all about making sure the time you spend on each message is minimized, and that the agents who are interested in a particular message needn&#8217;t wait for each other to do whatever they care to do based on the message. So, really you&#8217;re trying to route each message through your system with as few &#8216;hops&#8217; possible and as much parallelism as you can muster under the (radically!) new assumption that you may have hundreds or thousands of cores available to you during the lifetime of the design.</p>
<p>I spent some time thinking (hoping) that languages might help furnish an answer. Perhaps a move to a functional language like erlang, ocaml or scala might help furnish at least a partial answer. But erlang is slow and peculiar, ocaml doesn&#8217;t support intra-process concurrency and scala looks like a bloated language on a bloated platform (jvm+java class library). And none of them seem to have achieved anything near the critical mass which is so crucial for the development of usable libraries and the availability of skilled developers with long experience in the technology.  Naturally, reasonable people will disagree about such things, but this is my view (today). Java is ok (and certainly sells servers), but it&#8217;s not obvious how it&#8217;s going to help me offload my work onto a GPU anytime soon (and jni is both painful and slow) and I&#8217;ve never been able to get comfortable with just how damn big VMs get.  Image size isn&#8217;t free and if we&#8217;re looking to go deep into the sub-millisecond response time, <em>while running thousands of concurrent strategies</em>, it seems we need to disintermediate the VMs and interpreters of the world. If they&#8217;re really necessary, they can be happily used for the analysis process (as I currently use R), or they can be lit-up and bridged from some lower-level language for batch-like services.</p>
<p>The <a title="greatest technology advertisement ever?" href="http://www.youtube.com/watch?v=jqLPHrCQr2I" target="_blank">good people</a> at Intel have been thinking about this problem for a while as have many other seriously over-educated people. One of the (sensible sounding) conclusions reached as people look for ways to solve problems similar to my own, is that in such systems we should keep messages waiting as little as possible &#8211; ideally, not at all(!). This can be a problem in SEDA-like architectures which are basically made-up of (non-blocking, asynchronous) i/o processes linked to (blocking) queues linking pools of workers. Blocking queues can pile up and cause all sorts of problems like priority inversion and other such enigmatically named nasties. Lock-free queues and other data structures, algos and techniques promise some ways around this and I&#8217;ve been spending time looking into how they might be employed to address my issues.</p>
<p>Before I&#8217;m besieged by throngs of angry erlang/ocaml/scala/java developers, allow me one last observation on the topic.  (Peeved python and ruby users may rant away &#8211; vous m&#8217;amusez  ;^)</p>
<p>Why might a lock free algorithm be better than an equivalent, hardware-based locking implementation?  The answer isn&#8217;t obvious.  If locking is implemented in hardware as is typical (eg, with a compare-and-swap (CAS) instruction), then its explicit cost is measurable in (few) nanoseconds.  Hardware is fast.  The issue isn&#8217;t the speed of execution of the underlying primitives so much as it&#8217;s a consequence of the side effects of these operations at a very low level.  For real performance, cache coherence is King.  See <a title="McKenney: Memory Barriers: a Hardware View for Software Hackers" href="/images/hwViewForSwHackers.pdf" target="_blank">here</a> for an accessible discussion by IBM&#8217;s Paul McKenney and <a title="Ostrovsky: gallery of processor cache effects" href="http://igoro.com/archive/gallery-of-processor-cache-effects/" target="_blank">here</a> for some remarkable examples from Igor Ostrovsky.  This indicates that if you want the highest possible performance, you need to be aware of what is happening &#8216;in the metal.&#8217;  So we need to use a system-level language and erlang, java &amp; friends lose their candidacy in spite of any fantastic benefits they might offer.</p>
<p>Given that even the DoD has mostly given up on ADA means that we&#8217;re left with C/C++.</p>
<p>Ok, so language doesn&#8217;t seem to resolve much for us. (Indeed, it was mostly hopeful thinking on my part – design is mostly language agnostic and hardware is hardware&#8230;)</p>
<p>Apart from Intel&#8217;s own <a title="Intel's Threading Building Blocks" href="http://www.threadingbuildingblocks.org/" target="_blank">Threading Building Blocks (TBB) framework</a>, there are a variety of toolkits available for exploiting lock free parallelism. Perhaps the newest and least known is called <a title="FastFlow parallel programming framework" href="http://calvados.di.unipi.it/dokuwiki/doku.php?id=ffnamespace:about" target="_blank">FastFlow</a>, which is a C++ template library that provides a variety of facilities for writing efficient lock-free network models. It also claims to be faster than TBB, <a title="MIT's Cilk" href="http://supertech.csail.mit.edu/cilk/" target="_blank">Cilk</a> and <a title="OpenMP" href="http://openmp.org/wp/" target="_blank">OpenMP</a> while holding out the promise of one day becoming CUDA- (or more generally, GPU-) aware which would be an incredible win. Finally, it is very small &#8211; the current version (not including tests and examples), weighs in at ~5K lines of (mostly) C++ templates.  Thus, it seems to me particularly well-suited for some experimentation to assess the fit of these techniques in this space and the level of difficulty of doing so.</p>
<p>In the remainder of this post, I&#8217;ll briefly describe the FF design and then illustrate a sample C++ program which uses FastFlow to &#8216;architecturally prototype&#8217; a feed handler interacting with strategies inside an EMS / <a title="containing a strategy" href="http://www.puppetmastertrading.com/blog/2009/08/19/containing-a-strategy/" target="_blank">strategy container</a>.</p>
<p><span id="more-1010"></span></p>
<div class="wp-caption aligncenter" style="width: 509px"><img src="/images/fastflow_architecture.png" alt="FastFlow architecture" width="499" height="382" /><p class="wp-caption-text">FastFlow architecture</p></div>
<p>FastFlow&#8217;s (FF) goals seem quite ambitious, but the design is layered to allow users to work at a level that makes sense for the problems they are trying to solve, so they needn&#8217;t worry themselves (or even understand necessarily) layers below where they need to work.  At bottom is a thin layer of hardware-specific code supporting, one level up, single-producer-single-consumer (SPSC) lock-free queues and a threading model for their efficient interaction.  Above this are defined objects for generalizing from simple to arbitrary network types.  Here you see the definition of a composable Node which serves as the key abstraction for general-purpose streaming networks.  Above this are defined a variety of skeleton templates for building commonly useful graph types.  Because they are Nodes themselves, they can be nested and coupled to any depth.</p>
<p>Consider a simple pipeline:</p>
<div class="wp-caption aligncenter" style="width: 300px"><img title="pipeline" src="/images/ff_pipeline.png" alt="" width="290" height="60" /><p class="wp-caption-text">a simple FastFlow pipeline</p></div>
<p>A farm is slightly more complex and acts something like a load balancing threadpool.  The Emitter pushes &#8216;tasks&#8217; of arbitrary type to an arbitrary number of workers who then coalesce back into an (optional) Collector.  A simple Farm makes no promises about the ordering of tasks, but (I believe) FF provides mechanisms for ensuring their ordering at the collector.</p>
<div class="wp-caption aligncenter" style="width: 300px"><img title="FastFlow Farm" src="/images/ff_farm_with_coll.png" alt="" width="290" height="140" /><p class="wp-caption-text">a FastFlow Farm</p></div>
<p>Finally, because of the composable nature of Nodes, all of these graph types can be combined arbitrarily.  Here you see a Farm of pipelines with an &#8216;accelerator&#8217; (which, if I understand correctly is just an integrated thread for pushing tasks into the network) and a feedback channel.</p>
<div class="wp-caption aligncenter" style="width: 340px"><img title="Composition of subnets" src="/images/ff_composition2.png" alt="" width="330" height="140" /><p class="wp-caption-text">composition of FastFlow subnets</p></div>
<p>For a more complete (and probably accurate!) description of FastFlow, I encourage you to visit their site and <a title="FastFlow Tutorial" href="http://calvados.di.unipi.it/dokuwiki/doku.php?id=ffnamespace:usermanual" target="_blank">tutorial</a>.  The documentation remains limited, but there&#8217;s a good and growing selection of examples to examine and all of the source is available for inspection.</p>
<p><strong>a simple example</strong></p>
<p>Given my use-case, my first interest is in seeing how FastFlow might work in the context of asynchronous, non-blocking network handling.  To this end, I&#8217;ve built a simple Farm as depicted above in which the Emitter uses <strong>select()</strong> to read messages off the network which it parses and pushes into the farm for &#8216;processing&#8217; which is currently <a title="Wiki: NOP" href="http://en.wikipedia.org/wiki/NOP" target="_blank">NOP</a>-ed.  The messages/tasks are then coalesced into a collector which does nothing more than free memory allocated in the Emitter.  Within the Farm, each of the nodes inhabits its own thread and outside of the farm I&#8217;ve implemented a very simple &#8216;client&#8217; which connects to the Emitter&#8217;s socket and sends delimited Integral &#8216;messages.&#8217;  Ordinarily this would appear in its own process, but for the sake of only requiring 1 file, I&#8217;ve mashed them all together and the client lives in its own thread.  That&#8217;s it.</p>
<p>It turns out that the FastFlow part of this is, by far, the simplest.  Since the FF skeletons are implemented as templates, extending them couldn&#8217;t be much easier.  Here&#8217;s the definition of the worker and collector components.</p>
<pre class="brush: cpp;">
// typical worker: does little ;^p
class Worker: public ff_node {
public:
  void * svc(void * task) {
    return task;
  }
};

// collector that just frees the malloc'ed memory
class freeing_collector: public ff_node {
public:
  void * svc(void * task) {
    int * t = (int *)task;
    if (*t == -1) return NULL;
    else free(task);
    return GO_ON;
  }
};
</pre>
<p>They are both nodes and their only requirement is to implement the <strong>svc</strong> method which is called by the FF framework when they are meant to service a task.  They can optionally implement <strong>svc_init</strong> and <strong>svc_end </strong>methods which provide an opportunity for initialization and cleanup.  The socket-reading emitter makes use of the <strong>svc_init</strong> method to initially setup the socket.  Later, as it repeatedly reads from the socket into a buffer, it cracks the incoming stream and then calls the <strong>ff_send_out()</strong> method to push those messages out to the downstream workers.  The whole example is about 350 lines of code and nearly 200 lines are consumed by the Emitter.  Almost all of this bulk is network-related, so I won&#8217;t illustrate here.  But highlighted here you can see the main FF-specific part of the Emitter:</p>
<pre class="brush: cpp; highlight: [16,17,18,19];">
 // handle new data coming in
 void new_data(int nbytes, const char* buf) {
   static char remainder[kMaxMsgSz];
   int *t;
   int j = 0;
   int i = 0;
   char msgbuf[kMaxMsgSz];
   for (; i &lt; nbytes; i++) {
     if ( kDelimiter == buf[i] ) {
       int rlen = (j==0) ? strlen(remainder) : 0; // remainder?
       int len = i-j;
       if (rlen&gt;0) strncpy(msgbuf,remainder,rlen);
       int start = (rlen==0) ? 0 : rlen;
       strncpy(&amp;(msgbuf[start]),&amp;(buf[j]),len);
       msgbuf[len+rlen] = '&#92;&#48;';
       t = (int *)malloc(sizeof(int));
       *t = atoi(msgbuf);
       j = i;
       ff_send_out(t);  // push message into farm
     }
   } // for

   int k = j+1;
   if (k &lt; i) { // save 'remainder'
     strncpy(remainder,&amp;(buf[k]),(i-k));
   } else remainder[0] = '&#92;&#48;';
 }
</pre>
<p>Finally, all of the pieces are assembled and launched in the<strong> main()</strong>.</p>
<pre class="brush: cpp;">
//  We construct a 'server' which is a fastflow emitter and which reads
//    integral 'msgs' from a client over a non-blocking socket.  Msgs
//    are parsed and fed into a fastflow farm for further handling.
//    The client is placed within its own thread - this is only so the
//    whole example can be placed in one file.
//
int main(int argc, char * argv[]) {
 // use: argv[0] &lt;#msgs=1024&gt; &lt;#port=9999&gt;

 int msgs = (argc &gt; 1) ? atoi(argv[1]) : 1024;
 int port = (argc &gt; 2) ? atoi(argv[2]) : 9999;

 int nworkers = 5;               // how many workers will recv msgs

 printf(&quot;main: sending #%d msgs to port &lt;%d&gt;\n&quot;,msgs,port);

 select_reader sr(port);         // we create 'server'
 freeing_collector fc;           // and a freeing collector
 ff_farm&lt;&gt; farm;                 // and a farm for it to live in
 farm.add_emitter(&amp;sr);          // add both to the farm
 farm.add_collector(&amp;fc);

 std::vector&lt;ff_node *&gt; workers; // build a collection of workers
 for(int i =0; i &lt; nworkers; i++) { workers.push_back(new Worker); }

 farm.add_workers(workers);      // add all workers to the farm

 farm.run();                     // launch the farm
 printf(&quot;main: started farm.\n&quot;);

 sr.wait_til_ready();            // don't create client til srvr ready

 // create client which will send msgs via socket
 //
 printf(&quot;main: creating client...\n&quot;);
 client_thread* client = new client_thread(msgs,port);
 if (client != NULL) client-&gt;join();

 farm.wait();                    // wait for farm to be done its workload

 // emit some stats
#if defined(TRACE_FASTFLOW)
 std::cout &lt;&lt; &quot;DONE, time= &quot; &lt;&lt; farm.ffTime() &lt;&lt; &quot; (ms)\n&quot;;
 farm.ffStats(std::cout);
#endif

 return 0;
}
</pre>
<p>The whole example can be found <a title="FF networking example: C++ source" href="/images/ttest.cpp" target="_blank">here</a>.</p>
<p>Writing this example was a bit of a &#8216;tale of two frameworks&#8217; for me as I found the FastFlow part to be really easy and powerful.  On the other hand, I wanted to try out the <a title="boost::asio" href="http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio.html" target="_blank">boost::asio</a> framework for non-blocking networking i/o (primarily in the hope it might cut down the code size a bit) and while implementing the trivial (blocking) client was, well, trivial, implementing a non-blocking server with boost::asio was a serious pain and I ultimately decided that <a title="Linus' screed on C++ and boost" href="http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918" target="_blank">Linus just might be on to something wrt to boost</a> and scrapped that part of the effort (but kept the boost client).</p>
<p>Nothing about this example illuminates the potential performance advantages of a lock free approach, but this exercise has certainly convinced me that the FF authors have managed to combine very low-level performance considerations within a package which can be easily used from a high-level perspective.  Most problems will most likely be better served by higher-level programming languages, but some problems remain intractably bound to the metal and I suspect that writing ultra-low-latency trading systems will remain in the latter class for some time to come.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2010/02/16/lock-free/feed/</wfw:commentRss>
		<slash:comments>5</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>Kooderive</title>
		<link>http://www.puppetmastertrading.com/blog/2010/02/03/kooderive/</link>
		<comments>http://www.puppetmastertrading.com/blog/2010/02/03/kooderive/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 15:31:20 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[EMS Internals]]></category>
		<category><![CDATA[dereferenced]]></category>
		<category><![CDATA[monte-carlo methods]]></category>
		<category><![CDATA[open-source software]]></category>
		<category><![CDATA[options pricing]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=1000</guid>
		<description><![CDATA[Some time back, I&#8217;d written about NVidia&#8217;s CUDA noting that it looked ideal for many asset-pricing and monte-carlo type problems in finance.  At the time, I was hopeful that it would be quickly integrated into existing open source efforts like QuantLib, but adoption has proved slower than I&#8217;d hoped, most likely because implementing non-trivial problems [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignleft" style="width: 240px"><img class="   " src="/images/cuda_simonRogerson.jpg" alt="photo by Simon Rogerson" width="230" height="173" /><p class="wp-caption-text">photo by Simon Rogerson</p></div>
<p>Some time back, I&#8217;d <a title="TESLA &amp; CUDA" href="http://www.puppetmastertrading.com/blog/2008/11/29/nvidias-tesla-and-the-compute-unified-device-architecture/" target="_blank">written</a> about NVidia&#8217;s CUDA noting that it looked ideal for many asset-pricing and monte-carlo type problems in finance.  At the time, I was hopeful that it would be quickly integrated into existing open source efforts like <a title="QuantLib: a free/open-source library for quantitative finance" href="http://quantlib.org/" target="_blank">QuantLib</a>, but adoption has proved slower than I&#8217;d hoped, most likely because implementing non-trivial problems on CUDA is, well, even less trivial than doing them without..</p>
<p><strong>LMM on CUDA</strong></p>
<p><strong> </strong>Happily, I&#8217;ve just seen a promising first step in this direction as Über-quant and C++ artisan <a title="Mark Joshi" href="http://www.markjoshi.com/" target="_blank">Mark Joshi</a> recently announced an open-source project, <a title="Sourceforge: Kooderive" href="http://sourceforge.net/projects/kooderive/" target="_blank">Kooderive</a> which looks to implement the <a title="Wiki: LMM" href="http://en.wikipedia.org/wiki/LIBOR_market_model" target="_blank">LIBOR Market Model</a> (LMM)  on top of CUDA.  His announcement on the QuantLib mailing lists reads:</p>
<blockquote><p>Dear All,</p>
<p>various people have shown interest in the use of <span id="lw_1265210335_0">CUDA</span> with QuantLib. I<br />
have now made some progress on a CUDA implementation of the <span id="lw_1265210335_1" style="border-bottom: 1px dashed #0066cc; background: transparent none repeat scroll 0% 0%; cursor: pointer;">LIBOR<br />
market model</span>.</p>
<p>In particular, I now have a path generator for the LMM working which<br />
does 16384 paths for 40 rates, 40 steps, 5 factor model, displaced<br />
diffusion predictor-corrector that takes 0.1 seconds on my Quadro 4600.</p>
<p>The state of the project is code fragments that can be called from<br />
other code. Those who are interested can get the code via<br />
the subversion repository on <a href="http://kooderive.sourceforge.net/" target="_blank"><span id="lw_1265210335_2">kooderive.sourceforge.net</span></a> .  The only<br />
project file is currently for VC9 x64. It also uses thrust and the<br />
CUDA SDK.</p>
<p>The next stage will be writing routines, that use QuantLib for the CPU<br />
stuff and kooderive for the GPU stuff,  to actually price things.</p>
<p>A gentle reminder that I will be giving a course on the LMM and<br />
QuantLib in June in <span id="lw_1265210335_3" style="background: transparent none repeat scroll 0% 0%; cursor: pointer;">London</span>, and I will include a session on kooderive<br />
if there<br />
is sufficient interest.</p>
<p>I am happy to take code contributions for kooderive. However, I am not<br />
looking for a redesign of the library or contributions which introduce<br />
dependence on other libraries. I am interested in contributions of<br />
separate routines and of optimizations of existing routines that do<br />
not change interfaces.</p>
<p>regards</p>
<p>Mark<br />
&#8211;<br />
Pricing exotic <span id="lw_1265210335_4" style="border-bottom: 1px dashed #0066cc; background: transparent none repeat scroll 0% 0%; cursor: pointer;">interest rate derivatives</span> &#8211; The <span id="lw_1265210335_5" style="background: transparent none repeat scroll 0% 0%; cursor: pointer;">LIBOR Market Model</span> in<br />
QuantLib <span id="lw_1265210335_6" style="border-bottom: 1px dashed #0066cc; cursor: pointer;">June 2010</span>, London,<br />
<a href="http://www.moneyscience.com/training/index.html" target="_blank"><span id="lw_1265210335_7">http://www.moneyscience.com/training/index.html</span></a></p>
<p>Assoc Prof Mark Joshi<br />
Centre for Actuarial Studies<br />
<span id="lw_1265210335_8">University of Melbourne</span><br />
My website is <a href="http://www.markjoshi.com/" target="_blank"><span id="lw_1265210335_9">www.markjoshi.com</span></a></p></blockquote>
<p><span><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2010/02/03/kooderive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>dingbat kabuki</title>
		<link>http://www.puppetmastertrading.com/blog/2010/01/28/dingbat-kabuki/</link>
		<comments>http://www.puppetmastertrading.com/blog/2010/01/28/dingbat-kabuki/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 13:08:01 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[execution quality]]></category>
		<category><![CDATA[market structure]]></category>
		<category><![CDATA[our managed markets]]></category>
		<category><![CDATA[post-trade analysis]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=973</guid>
		<description><![CDATA[ Like many Americans, last night I dutifully switched on my TV at 9pm to see the State of our Union.  Always a spectacle, America&#8217;s leadership have upped the surreality ante with the bizarre backdrop of Biden lip-synching amiably in the background whilst Madame Speaker sat with all the calm collection of a fish on [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="/images/kabuki.gif" alt="" width="200" height="304" /> Like many Americans, last night I dutifully switched on my TV at 9pm to see the State of our Union.  Always a spectacle, America&#8217;s leadership have upped the surreality ante with the bizarre backdrop of Biden lip-synching amiably in the background whilst Madame Speaker sat with all the calm collection of a fish on a hook and never seemed fully in control of herself or her eyebrows.  The spectacle of would&#8217;ve-been king McCain sitting there and glowering openly at the lecturn as his confederates sat in stony silence while their &#8216;opposition&#8217; applauded like drunken high schoolers at a home coming at every mundane utterance proved a bit much and I had turned off the glowing beacon of groupthink by 9:25 and gone to investigate something on my computer.  I was surprised and delighted to see that it was still available: dingbatkabuki.com</p>
<p><strong>Dingbat Kabuki and other <em>structural</em> market hacks</strong></p>
<p>When I first started puppetmaster trading, one of my dearest friends, a Yale-educated economist and professor of same, asked me an important question.  He asked:</p>
<blockquote><p>In the markets, there are always &#8216;insiders&#8217; who have the ability to trade on knowledge that you <em>can&#8217;t</em> know or with an advantage that you <em>can&#8217;t</em> have.  How are you going to compete with these players?</p></blockquote>
<p>I provided a variety of answers, but at the time my conception of the universe of people with both inside knowledge and the ability to trade on it was limited to cases like that of Mr Rajaratnam.  I believed that cases like these were constrained by clear laws that were duly surveilled and prosecuted by the appropriate authorities.  The problem seemed like a very real one, but constrained in size and not essential to my enterprise.  I still hope that my belief of the time was true, but since then I&#8217;ve certainly understood that there&#8217;s more than one way to hack the market.</p>
<p>For some, a market hack might consist of some kind of simple (or complex) algorithm(s) applied to some set of markets.  But this really isn&#8217;t a hack so much as it&#8217;s a trading strategy &#8211; like many that have long existed &#8211; only that it&#8217;s now implemented in software where originally it would have been implemented in wetware.  While implementing trading strategies in software does open up new vistas in terms of the kinds of strategies that you can look to implement &#8211; computers are faster than people by a noteworthy amount in many tasks &#8211; but, for the most part, you&#8217;re really still just trading and when you take on positions, you are still bearing risk.  You might be &#8216;hacking&#8217; but it&#8217;s really not a market hack as I&#8217;ve come to appreciate.</p>
<p><span id="more-973"></span></p>
<p><strong>hack the market structure </strong></p>
<p>Another area where my perspective has changed substantively since those halcyon days of &#8216;05 is my appreciation for market (micro) structure.  In futures, market structure is pretty plain as most contracts are effectively monopolies run by their listing exchanges.  There are a few cases of instruments which are tradable across markets, but a rich market microstructure is just not a core identifying characteristic for futures like it is in the fragmented and incredibly dynamic and quickly developing world of equities.  So, while there are some dozens of futures exchanges scattered about the globe, as a futures trader, routing algorithms just don&#8217;t enter the picture except in limited and relatively simple cases.</p>
<p>If I have a view on or a hedging need for interest rates that I see effectively expressed through futures, then I go to e.g. the cme and I don&#8217;t need to worry my pretty head about getting a great execution because the exchange is in one place and it&#8217;s all lit up and filled to the brim with liquidity.  Easy peasy.  But if I have a view on, say, General Electric that I want to express with an equity position and I&#8217;m trading in sufficient size or sufficiently close to the market that I really want to ensure best execution, then I might find the need to look around some dozens of lit exchanges and maybe even ping about in a dark pool or twelve.  This is decidedly not easy peasy and is one of the reasons wall st has an insatiable hunger for propeller heads with advanced degrees in seemingly unrelated fields.</p>
<p>Last summer&#8217;s brouhaha about &#8216;flash&#8217; orders first illuminated for many a rich ground for genuine market hacks: the incredibly dynamic terrain of equity market micro structure which changes almost daily with the emergence of new exchanges, ATSes, order types, rebates and pricing structures and all of the many other critical minutia that differentiate the many venues.  Some of these undoubtedly provide meaningful and important services; contrary to populist inclination, dark pools are largely a defense <em>against</em> frothy HF trading strategies.</p>
<p>But the concern (if perhaps not all of the attention) is <a title="Rosenblatt's view on HF Trading" href="http://hft.thomsonreuters.com/files/2009/11/Rosenblatt-HFTexcerpt4Reuters2.pdf" target="_blank">merited</a>.   Equity microstructural &#8216;rules&#8217; change so quickly that even independent and upright regulators could hardly be expected to keep up.  This is clearly fertile ground for genuine &#8211; if perhaps fleeting &#8211; market hacks.</p>
<p><strong><a title="Wiki: Steganography" href="http://en.wikipedia.org/wiki/Steganography" target="_blank">steganography</a> and hacking the market<br />
</strong></p>
<p>What characteristics make equity market structure a fertile ground for these kinds of genuine market hacks which I&#8217;m describing?  I think the main answer is to be found in the ancient art of steganography &#8211; hiding in plain site.  Everything about equity market microstructure is public.  All of the rules for each of the venues are available to the people who might make use of them.  Unraveling what they <em>imply</em> about where you should be executing for any given order is the tricky bit which is hardly revealed through a simple reading of all of the various rules.</p>
<p>Where else do we see this phenomenon?  The US Tax code comes to mind (sort of like the iPhone: &#8220;there&#8217;s a loophole for that&#8221;).  The 2,000 page health care bill comes to mind.  Everybody seems to care about health care, but who&#8217;s actually read that bill?  Who could?</p>
<p>Totally public yet it may as well be encrypted.  Steganography.</p>
<p>Elizabeth Warren has also made this observation in the context of contracts made between banks and their retail clientele.  Noted scholar Scott Adams dubbed it a &#8216;<a title="Wiki: Confusopoly" href="http://en.wikipedia.org/wiki/The_Dilbert_Future" target="_blank">confusopoly</a>.&#8217;</p>
<blockquote><p><em>a group of companies with similar products who intentionally confuse customers instead of competing on price</em></p></blockquote>
<p>So, could people hack the tax code?  <a title="Hanky panky" href="http://www.puppetmastertrading.com/blog/2009/01/08/and-this-little-piggy-hollowed-out-our-nation/" target="_blank">Hank</a> and I think so.  So do my friends in the <a title="Play by the rules" href="http://www.puppetmastertrading.com/blog/2009/04/13/playing-by-the-rules/" target="_blank">lobbying business</a>.  How about all those recently converted bank holding companies &#8211; hack much?  In my last post we read one insider&#8217;s view that Madoff had effectively hacked the SEC&#8230; perhaps regulatory organizations themselves are also hackable instruments!  How about that health care bill?  &#8230;</p>
<p><strong>misdirecting the hack</strong></p>
<p>A lot of attention has focused recently on exchange traded markets and people are up in arms about HF traders and proprietary trading.  I&#8217;ve argued <a title="it's not about microstructure" href="http://www.puppetmastertrading.com/blog/2009/08/07/its-not-about-microstructure/" target="_blank">before</a> that this appears to be a great ploy to take attention away from the real issues at hand; in the worst case, HFT improprieties might account for no more than 1% of the money <em>disappeared</em> in the last few years as part of the so-called &#8216;credit crisis&#8217;.  It&#8217;s easy for non-finance-professionals not to understand that the big bad wolves of the credit crisis essentially all happened off market in essentially unregulated multi-trillion dollar otc markets of <a title="perfect crime" href="http://www.puppetmastertrading.com/blog/2009/11/02/perfect-crime/" target="_blank">ingeniously engineered</a> structured products. These are the <em>real</em> market hackers.  Exchange traded instruments had effectively nothing to do with our current circumstances but remain a convenient scapegoat.</p>
<p>Some argue persuasively that there are fundamental, <a title="Murray Rothbard: The Case Against the Fed" href="http://mises.org/books/fed.pdf" target="_blank">structural market hacks</a> at the very foundations of our financial system.  I wouldn&#8217;t know.  But it is the kind of thing one might think about while watching the highly stylized performance of our leaders last night.</p>
<p><strong>dingbat kabuki and the transparent market hack</strong></p>
<p>To my knowledge, Cal&#8217;s (go bears!) Professor Brad DeLong coined the term &#8216;dingbat kabuki&#8217; back in 2005 in <a title="the original" href="http://delong.typepad.com/sdj/2005/10/dingbat_kabuki_.html" target="_blank">shrill response</a> to a Washington Post article.  He reprised the term this week in response to the latest bit of <a title="Andrew Mellon's rotting corpse" href="http://delong.typepad.com/sdj/2010/01/barack-herbert-hoover-obama.html" target="_blank">macroeconomic genius</a> out of washington.  What an inspired phrase.  Yesterday at 2:30 and last night at 9pm the markets voiced their applause and cheered on the performance.</p>
<p>Indeed, it is masterful.</p>
<p>&#8211;</p>
<p>A technical note about this post.  While writing it, I seem to have accidentally published it at some point and then realized the error and &#8216;unpublished&#8217; it.  I apologize if this had any untoward effects on you or your RSS reader.</p>
<p><strong><br />
</strong></p>
<p style="text-align: center;"><img class="aligncenter" src="/images/musashi.jpg" alt="" width="677" height="325" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2010/01/28/dingbat-kabuki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;the SEC made Madoff&#8221;</title>
		<link>http://www.puppetmastertrading.com/blog/2010/01/17/the-sec-made-madoff/</link>
		<comments>http://www.puppetmastertrading.com/blog/2010/01/17/the-sec-made-madoff/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 14:32:59 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[dereferenced]]></category>
		<category><![CDATA[our managed markets]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=944</guid>
		<description><![CDATA[Bill Harts, a friend of mine who has, as they say, forgotten more about electronic trading and market structure than most will ever be burdened by, has recently taken an interest in the public letters written to the SEC in response to their requests for public comments on dark pools.  Mostly, these letters are funny [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Bill Harts &amp; Co." href="http://hartsandco.blogspot.com/" target="_blank">Bill Harts</a>, a friend of mine who has, as they say, forgotten more about electronic trading and market structure than most will ever be burdened by, has recently taken an interest in the <a title="public letters to the SEC on dark pools" href="http://hartsandco.blogspot.com/2010/01/dark-pool-letters-to-sec.html" target="_blank">public letters written to the SEC</a> in response to their requests for public comments on dark pools.  Mostly, these letters are funny and reveal people&#8217;s propensity to point shoot and aim in that untidy order.</p>
<p>But some are revealing and one in particular is <a title="Steve Wunsch letter to SEC" href="http://www.sec.gov/comments/s7-27-09/s72709-32.pdf" target="_blank">100% required reading</a> for anyone interested in electronic markets.</p>
<p>The writer introduces himself thusly:</p>
<blockquote><p>I am Steve Wunsch, the principal inventor of two SEC‐regulated stock exchanges, the Arizona Stock Exchange “AZX” (originally called Wunsch Auction Systems, Inc. “WASI”) and the ISE Stock Exchange, both of which include dark pools. In fact, both of them, like all modern stock exchanges, have both lit and dark components and, thus, have provided me with potentially useful perspective on the dark pool question and on transparency in general. I will focus heavily on the latter, for it is impossible to understand the dark pool issues raised without understanding the value of transparency or, if improperly applied, the lack thereof. The AZX experience was, I believe, particularly instructive in this regard. Its highly transparent call market structure, combined with its unique regulatory status as a “low volume exempt”exchange, enabled me to see transparency and the role of regulation in promoting it from a perspective that I don’t believe anyone else has.</p></blockquote>
<p>He deftly mixes snark and a historical perspective on regulation with an opinionated and informed view on the forces driving current equity markets&#8217; microstructure arguing that the worst issues are due to regulatory failures.  He concludes, logically enough, that the SEC should be disbanded.  Perhaps his most inflammatory bit is his claim that the &#8220;SEC made Madoff.&#8221;  For effect, the section is entitled &#8220;An American Oligarchy&#8221;:</p>
<blockquote><p>AN AMERICAN OLIGARCHY</p>
<p>It is not in the Commission’s interest to admit failures of policy, such as the ones I have described in this letter, and I have never seen it done. It was not in the Commission’s interest to admit that Bernie Madoff was the SEC’s most trusted and intimate confidante in formulating and selling transparency, electronic trading and<br />
the whole NMS concept to Wall Street, the public and Congress. His legitimate business was the epitome of the kind of transparent electronic competition that NMS’s leveling policies were trying to create, and he occupied the most favored place of all industry advisors on policy and rules as NMS was being created. In a very real and literal sense, Madoff’s legitimate business and NMS were made for each other. NMS cleared a path for the application of continuous transparency by new electronic competitors, very visibly led by Madoff, enabling him to become at one time the third largest market in the United States, even though he wasn’t officially registered as anything but a broker‐dealer.</p>
<p>Had the SEC not emasculated the rules by which the NYSE controlled its members, Madoff would never have happened. In the time before NMS, when the exchange had Rule 390 or the stronger Rule 394 before it, diverting orders away from the floor or selling them to Madoff would have been banned. But on antitrust principles, the SEC wanted to foster NYSE‐busting competition in NMS, and Madoff became its PosterBoy for such competition. In order to make way for him, the SEC opened up a variety of loopholes that allowed orders to be diverted from NYSE to Madoff and printed on regionals like Cincinnati. Rules 19c‐1, 19c‐2 and 19c‐3 were in this vein. There were perennial attempts by the NYSE to plug the loopholes and rein in the membership, but the SEC batted them all away, enabling Madoff to continually grow his business. Eventually, the NMS environment forced the NYSE to abandon Rule 394, then Rule 390 and ultimately its membership organization altogether when it demutualized. This was all very good for Madoff. And Madoff was very good for NMS, giving it industry cred far in excess of what this poorly articulated socialist leveling theory could have had without his support.</p>
<p>In spite of a 457‐page SEC investigation into Madoff and how his Ponzi scheme was missed, the most obvious reasons were not considered, namely, that Madoff played a central role in helping the Commission design and sell NMS, and that NMS made him rich long before the Ponzi scheme. Most importantly, the credibility that theCommission’s collaboration with Madoff on NMS conferred on him was the principal factor enabling him to bring in money for the Ponzi scheme. Although the investigation’s report notes his credibility in the industry, it is mentioned as if itwere just a fact of life and was already there. Not mentioned is that his superior access to the SEC and apparent influence over the Commission, both of which were implicitly proved by his ability to get rich on NMS, are the most important reasons that he had such extraordinary credibility in the industry. The truth is that the SEC made Madoff. He could not have existed as a threat to investors without the Commission’s active and dedicated support over several decades.</p></blockquote>
<p>Although, in typical blogger fashion, I&#8217;ve highlighted his spiciest claim, the rest of the letter is more technical and informative while just as entertaining.  I encourage you to read it and then engage in a thought experiment in which You are the designer of an electronic exchange and must balance the needs of a very heterogeneous set of users and stakeholders while ensuring transparency, liquidity, profitability, &#8220;fairness&#8221;, performance (he references an exchange targeting 100M executions per second) and utterly fail-safe transactional integrity&#8230;</p>
<p>I have embedded the full letter below the break&#8230;</p>
<p><span id="more-944"></span></p>
<p><object style="width: 600px; height: 475px;" classid="clsid:166b1bca-3f9c-11cf-8075-444553540000" width="600" height="475" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0"><param name="sound" value="true" /><param name="progress" value="true" /><param name="autostart" value="true" /><param name="swliveconnect" value="false" /><param name="swstretchstyle" value="meet" /><param name="swstretchhalign" value="none" /><param name="swstretchvalign" value="none" /><param name="src" value="/images/steveWunsch.pdf" /><param name="align" value="left" /><embed style="width: 600px; height: 475px;" type="application/x-director" width="600" height="475" src="/images/steveWunsch.pdf" align="left" swstretchvalign="none" swstretchhalign="none" swstretchstyle="meet" swliveconnect="false" autostart="true" progress="true" sound="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2010/01/17/the-sec-made-madoff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>core arb</title>
		<link>http://www.puppetmastertrading.com/blog/2009/12/15/core-arb/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/12/15/core-arb/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 15:05:17 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[FIX Protocol]]></category>
		<category><![CDATA[dereferenced]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=918</guid>
		<description><![CDATA[Cloud computing looks to have turned yet another interesting corner.   This time the turn leads towards the development of a liquid, fully electronic new marketplace in &#8220;spot instances&#8221;.
&#8216;Spot&#8216; means what you would expect it to in the context of trading: the current pricing for immediate delivery of a commodity.  &#8216;Instance&#8216; is the atomic element [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignleft" style="width: 95px"><img src="/images/core.jpeg" alt="core arbitrage?" width="85" height="127" /><p class="wp-caption-text">FIX interface?</p></div>
<p>Cloud computing looks to have turned yet <a title="Amazon EC2 Spot Instances Blog post" href="http://aws.typepad.com/aws/2009/12/ec2-spot-instances-and-now-how-much-would-you-pay.html" target="_blank">another interesting corner</a>.   This time the turn leads towards the development of a liquid, fully electronic new marketplace in &#8220;spot instances&#8221;.</p>
<p>&#8216;<a title="wikipedia: spot priing" href="http://en.wikipedia.org/wiki/Spot_price" target="_blank"><em>Spot</em></a>&#8216; means what you would expect it to in the context of trading: the current pricing for immediate delivery of a commodity.  &#8216;<em>Instance</em>&#8216; is the atomic element within Amazon&#8217;s cloud environment; an instance is the smallest chunk of computing capability which can be provisioned within the cloud.</p>
<p><strong>Amazon is making markets in <em>cores</em> and they&#8217;re exposing functionality just as a regular exchange would: both through user interface &#8217;screens&#8217; as well as programmable APIs.</strong></p>
<p>From their <a title="spot instances announcement" href="http://aws.amazon.com/ec2/spot-instances/" target="_blank">announcement</a>:<strong><br />
</strong></p>
<blockquote><p>Spot Instances enable you to bid for unused Amazon <span>EC2</span> capacity.  Instances are charged the Spot Price set by Amazon <span>EC2</span>, which fluctuates periodically depending on the supply of and demand for Spot Instance capacity. To use Spot Instances, you place a Spot Instance request, specifying the instance type, the region desired, the number of Spot Instances you want to run, and the maximum price you are willing to pay per instance hour. To determine how that maximum price compares to past Spot Prices, the Spot Price history is available via the Amazon <span>EC2 API</span> and the <span>AWS</span> Management Console. If your maximum price bid exceeds the current Spot Price, your request is fulfilled and your instances will run until either you choose to terminate them or the Spot Price increases above your maximum price (whichever is sooner).</p></blockquote>
<h5>embedded optionality</h5>
<p>While the inclusion of, effectively, a market data service is neat, probably the most interesting aspect of the initial protocol they&#8217;ve designed is that it contains embedded optionality and behaves a bit like <a title="wikipedia: barrier options" href="http://en.wikipedia.org/wiki/Barrier_option" target="_blank">barrier options</a>.  That is, when I setup an &#8216;order&#8217;, I need specify a maximum price I&#8217;m willing to pay.  When the spot price drops below my max, I get &#8220;knocked-into&#8221; a contract and instances are allocated to me.  If the spot price rises above my max while I&#8217;m running, I get &#8220;knocked-out&#8221; of the contract and my jobs get terminated.</p>
<p>The intent is to allow for low-priority jobs to be dynamically run whenever pricing drops below a user&#8217;s threshold, but the (intended?) consequence is that it adds the <em>delicious and malleable tang of path dependency</em> to these instruments&#8230;</p>
<h5>secondary markets, FIX, arbitrage..?</h5>
<p>Amazon currently controls the market entirely, but it&#8217;s not hard to imagine a secondary market evolving.  Given that others are beginning to copy Amazon&#8217;s APIs, one can also imagine markets which operate across providers &#8230;  perhaps accessed via FIX?&#8230;</p>
<p>Who knows?  In the not-too-distant future, we may well be able to implement &#8216;<strong><em>core arb</em></strong>&#8216; strategies&#8230;or make markets in cores&#8230; or find that we can effectively hedge with disciplined exposure to the &#8216;core market&#8217; or &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/12/15/core-arb/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>peaky</title>
		<link>http://www.puppetmastertrading.com/blog/2009/12/08/peaky/</link>
		<comments>http://www.puppetmastertrading.com/blog/2009/12/08/peaky/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 14:41:51 +0000</pubDate>
		<dc:creator>tito</dc:creator>
				<category><![CDATA[dereferenced]]></category>
		<category><![CDATA[market data]]></category>
		<category><![CDATA[our managed markets]]></category>

		<guid isPermaLink="false">http://www.puppetmastertrading.com/blog/?p=894</guid>
		<description><![CDATA[I came across this compelling site which uses a hardware-based ticker plant (Exegy) in a colo environment to measure peak bandwidth across scads of NA feeds and then, every minute, updates a chart like the above to capture the average messages/sec across all of them.  Pretty swank.
While the uninformed may rail against colocation rather than [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption aligncenter" style="width: 453px"><a href="http://www.marketdatapeaks.com/"><img title="peaky" src="/images/peaky.png" alt="messages per second across all feeds" width="443" height="294" /></a><p class="wp-caption-text">messages per second across &quot;all&quot; feeds</p></div>
<p>I came across this compelling <a title="Market Data Peaks" href="http://www.marketdatapeaks.com/" target="_blank">site</a> which uses a hardware-based ticker plant (<a title="Exegy ticker plant" href="http://www.exegy.com/" target="_blank">Exegy</a>) in a colo environment to measure peak bandwidth across scads of NA feeds and then, every minute, updates a chart like the above to capture the average messages/sec across all of them.  Pretty swank.</p>
<p>While the uninformed may rail against colocation rather than focus on less intriguing issues like banana-variety corruption, they miss the basic point that colo can be done by anyone with the checkbook and the wish to do so.</p>
<div class="wp-caption alignright" style="width: 144px"><img class="   " src="/images/forrest-gump-shrimping.jpg" alt="unfair advantage?" width="134" height="134" /><p class="wp-caption-text">unfair advantage?</p></div>
<p>It&#8217;s sort of like that boat in Forrest Gump.  Forrest wanted to be a shrimper.  So he invested in a boat.  With his initial capital, hard work, perseverance and a bit of luck, Forrest made a go of it.  He might easily have not made it.  Colo is like that.  You can shrimp without a boat if you have a mask and fins, but it&#8217;s likely not a sustainable model&#8230; either way, it&#8217;s hard to see the harm in Gump&#8217;s boat.  Or colocation.</p>
<p>Hat-tip to <a title="Rodrick's Web Log !!" href="http://rodrickbrown.com/blog/" target="_blank"><em>Rodrick&#8217;s Web Log !!</em></a> for spotting the market data peaks site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.puppetmastertrading.com/blog/2009/12/08/peaky/feed/</wfw:commentRss>
		<slash:comments>0</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>
	</channel>
</rss>
