<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1346045313195961352</id><updated>2012-02-08T09:06:56.863-08:00</updated><category term='python'/><category term='algorithmic trading tutorial'/><title type='text'>Quantum blog</title><subtitle type='html'>The physics of trading</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>46</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-3630547537482667428</id><published>2011-10-14T11:47:00.000-07:00</published><updated>2011-10-14T11:47:33.732-07:00</updated><title type='text'>Which programming language to choose?</title><content type='html'>&lt;div style="background-color: transparent;"&gt;&lt;span id="internal-source-marker_0.4927170423325151" style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;When I started programming as a kid somewhere in the early nineties, choosing a programming language was easy, as there were not many to choose from.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;I first started in Pascal and since then have programmed in Delphi, C, C++, C#,Java , VB, PHP, Matlab, Python, SPIN and even ASM. All this without even being a professional programmer (I am a physicist). I did not learn all these languages for fun, as I have better things to do (like actual work), but I needed to as I had no ‘swiss army knife’ language for all my needs. &lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Ideally, I would like learn only *one* &amp;nbsp;language that is suited for all kind of stuff: number crunching, application building, web development, interfacing with APIs etc. This language would be easy to learn, the code would be compact and clear, it would run on any platform. It would enable me to work interactively, enabling the code to evolve as I write it and be at least free as in speech. And most importanty, I care much more about my own time than the cpu time of my pc, so performance is less important than productivity.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;I also need a language that is capable of handling large arrays of data in a clear way. Luckily, after considering all these wishes, only two contestants remain: Matlab and Python.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.mathworks.nl/products/matlab/index.html"&gt;&lt;span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;"&gt;Matlab&lt;/span&gt;&lt;/a&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt; is king of the hill when it comes to technical computing. If your tasks a limited to research only, it is probably the best tool there is. Good &lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Integrated_development_environment"&gt;&lt;span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;"&gt;IDE&lt;/span&gt;&lt;/a&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;, fantastic plotting function, great documentation. It is less well suited for application development or as a general purpose language. Expect to pay ~2k$ for a basic commercial license. Extra toolboxes cost more.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.python.org/"&gt;&lt;span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;"&gt;Python&lt;/span&gt;&lt;/a&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt; is very similar to Matlab and is free! Interactive work in Python is a bit less easy as in Matlab, but what you get is a programming language that can complete almost any task, from data mining to web development.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;If I’d have to start all over again, I would choose Python as it would save me the trouble of learning another language for Gui and web development.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;After flirting with Python for some time, I’ve fallen in love with it and decided to use it for most of my work from now on.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;I'll be running a series of Python posts on my other blog:  &lt;/span&gt;&lt;span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;a href="http://tradingwithpython.blogspot.com/"&gt;http://tradingwithpython.blogspot.com/&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: transparent;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-3630547537482667428?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/3630547537482667428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/10/which-programming-language-to-choose.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3630547537482667428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3630547537482667428'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/10/which-programming-language-to-choose.html' title='Which programming language to choose?'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-4558072591902005339</id><published>2011-10-09T05:35:00.000-07:00</published><updated>2011-10-09T05:35:09.309-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='algorithmic trading tutorial'/><title type='text'>Why should I learn a programming language?</title><content type='html'>&lt;div style="background-color: transparent;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: 15px; white-space: pre-wrap;"&gt;People are bad at math. Some are better than others, but who can calculate ln(sqrt(345)*34)^3.4 in less than 1/1000th of a second? Even the simplest computer can calculate at a rate million times faster than a human, in fact this is the main reason computers have been invented. To use the full capacity of a computer the user should learn how to progam it.&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: transparent;"&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;People are quickly bored. Imagine you'd have to download around 1500 excel sheets of stock data and then combine them together? Unless you have an autistic disorder you would probably get bored to death. A computer would not mind doing the task, but you'd have to program it.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Another example is reaction speed. &amp;nbsp;It takes ages measured in computer time, for a human to see a price change in a stock and then just press a button.Curious about how fast you can react? Take a test &lt;/span&gt;&lt;a href="http://www.humanbenchmark.com/tests/reactiontime/index.php"&gt;&lt;span style="background-color: transparent; color: #000099; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;. Your reaction speed should be around 0.2s, &amp;nbsp;while even a simple microcontroller (the ones you’ll find almost in any electronic gadget) &amp;nbsp;will do the same task in 0.0000001s. &amp;nbsp;Want to compete? If you know what action should be taken in a certain sitiuation, a computer can do the job for you a couple of million times faster, but still you need to tell it what to do by means of programming.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Still, even with all that raw computer power nowadays, measured in gigahertz and terabytes, the 'heart' of computers haven't changed much since their invention: they are still not much more than 'calculators'. Yes, we've come a long way in terms of size factor, power consumption, user friendliness and price, but still, computers are incapable of creative thinking, adaptation to new environments and unpredictable situations. A cockroach is more intelligent measured by these standards than the most advanced computer. By combining the human power of creative thinking with the raw processing power of a computer a trader can become supertrader, achieving a consistent return.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Financial markets are just like nature, the smartest ones with the best skills for the current (and ever changing) environment survive. The ones that do not adapt get extinct at some point.&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Using computers for trading today is a fact of life, and a trader has got no choice but to adapt. Who does not use some form of charting tool to find entry and exit points or an excel sheet to keep track of performance? Not much algorithm here, but it is already a form of computer-assisted trading. Another level is to purchase special purpose software, like spread trading tools.  Often it includes some form of 'black box' logic, so you can only hope that it works and continues to work in the future. But why not move to the top of the food chain and learn how to process incredible amounts of data, design own algorithms, backtest strategies, automatically place hundreds of orders and analyze trading performance? By&amp;nbsp;writing your own tools and programs, you'll be able to quickly adapt to every new market environment.&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: transparent;"&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Your time invested in learning programming techniques will have a ten-fold return in time saved from doing boring daily trading tasks.&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: transparent;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 15px; white-space: pre-wrap;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: transparent;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 15px; white-space: pre-wrap;"&gt;Coming next: which programming language to choose?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-4558072591902005339?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/4558072591902005339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/10/why-should-i-learn-programming-language.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4558072591902005339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4558072591902005339'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/10/why-should-i-learn-programming-language.html' title='Why should I learn a programming language?'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-5526277419503132568</id><published>2011-09-25T11:45:00.000-07:00</published><updated>2011-10-12T09:54:44.781-07:00</updated><title type='text'>Getting started with Matlab &amp; finance</title><content type='html'>I am thinking about creating a series of screencasts showing how to use Matlab for financial research. This is the first one, covering the basics and aimed at people not yet familiar with Matlab.&lt;br /&gt;The whole series would include (among others) topics like:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Getting data from the web (yahoo, google, CBOE etc)&lt;/li&gt;&lt;li&gt;Aligning and filtering datasets&lt;/li&gt;&lt;li&gt;Nearest-neighbor classification&lt;/li&gt;&lt;li&gt;Designing &amp;amp; backtesting strategies&lt;/li&gt;&lt;li&gt;Interfacing with Interactive Brokers&lt;/li&gt;&lt;li&gt;Keeping track of strategy performance&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://1.gvt0.com/vi/CKhQ5yBRtQE/0.jpg" height="266" width="320"&gt;&lt;param name="movie" value="http://www.youtube.com/v/CKhQ5yBRtQE&amp;fs=1&amp;source=uds" /&gt;&lt;param name="bgcolor" value="#FFFFFF" /&gt;&lt;embed width="320" height="266"  src="http://www.youtube.com/v/CKhQ5yBRtQE&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;Creating quality material takes a lot of time and effort, so I don't think that I will be able to offer whole material for free.&lt;br /&gt;If you are interested in the series please let me know what you think by filling in the poll on the right.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://quantum.meplaza.nl/01_introduction.zip"&gt;Get source files&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-5526277419503132568?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/5526277419503132568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/09/getting-started-with-matlab-finance.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5526277419503132568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5526277419503132568'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/09/getting-started-with-matlab-finance.html' title='Getting started with Matlab &amp; finance'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-7470105406432354841</id><published>2011-08-10T14:04:00.000-07:00</published><updated>2011-08-10T15:35:32.947-07:00</updated><title type='text'>XIV is stealing my money!</title><content type='html'>With current volatility exceeding 40, it seemed like a good idea to short the VIX. Two very popular ways to do this is either to short VXX or go long XIV. I choose to go long XIV a couple of days ago, after making sure that it tracks the inverse daily return of VXX.&lt;br /&gt;Now a strange thing has happened that both puzzles me and pisses me off: yesterday there was a tracking error of 2% between the two and today another 1%, both in my disadvantage. It seemed like somebody 'stole' 3% of my position! At this moment I am less than happy with this XIV product.&lt;br /&gt;Take a look at this chart:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-qlEKGS80NIk/TkL4H1cS6AI/AAAAAAAADNA/T_KXS2Cv0q4/s1600/xiv_tracking_error.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://1.bp.blogspot.com/-qlEKGS80NIk/TkL4H1cS6AI/AAAAAAAADNA/T_KXS2Cv0q4/s320/xiv_tracking_error.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;Here I plotted daily returns of VXX and XIV against each other, where the outliers have been plotted in red. Please note that there are another 2 outliers of similar magnitude, occuring on &amp;nbsp;4 and 5 January 2011, but these two cancel each other out pretty nicely.&lt;br /&gt;I thought that both etfs were based on the same SPVXSTR index, but while their intraday path relative to each other is very &amp;nbsp;stable (no arbitrage possibilities), the tracking offset was present&amp;nbsp;throughout&amp;nbsp;the whole day.&lt;br /&gt;I understand that XIV could get a positive tracking error because it was banned from short selling on both days (just like VXX), but a negative tracking error is a&amp;nbsp;mystery&amp;nbsp;to me.&lt;br /&gt;&lt;br /&gt;Can someone shed a light on what is going on here???&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-7470105406432354841?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/7470105406432354841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/08/xiv-is-stealing-my-money.html#comment-form' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7470105406432354841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7470105406432354841'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/08/xiv-is-stealing-my-money.html' title='XIV is stealing my money!'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-qlEKGS80NIk/TkL4H1cS6AI/AAAAAAAADNA/T_KXS2Cv0q4/s72-c/xiv_tracking_error.png' height='72' width='72'/><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-1003554434652517441</id><published>2011-08-04T14:38:00.000-07:00</published><updated>2011-08-04T14:38:17.234-07:00</updated><title type='text'>Are we in for a rebound?</title><content type='html'>Today we've had a pretty heavy drop in the SPY, that has been&amp;nbsp;preceded&amp;nbsp;by a series of down days. It could be tempting to join the&amp;nbsp;panicking&amp;nbsp;crowd, but the crowd usually gets it wrong.&lt;br /&gt;The put/call ratio and the VIX/VXV ratio tell their own story:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-2hO7evD6Jlk/TjsQ2HofjZI/AAAAAAAADMY/eeEBShK4THc/s1600/four_percent_drop.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://3.bp.blogspot.com/-2hO7evD6Jlk/TjsQ2HofjZI/AAAAAAAADMY/eeEBShK4THc/s320/four_percent_drop.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;Both of them are pretty high, the situation that is usually accompanied by a pop in the market.&lt;br /&gt;Disclosure: I'm long.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-1003554434652517441?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/1003554434652517441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/08/are-we-in-for-rebound.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1003554434652517441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1003554434652517441'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/08/are-we-in-for-rebound.html' title='Are we in for a rebound?'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-2hO7evD6Jlk/TjsQ2HofjZI/AAAAAAAADMY/eeEBShK4THc/s72-c/four_percent_drop.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-8861722340694968817</id><published>2011-07-28T12:29:00.000-07:00</published><updated>2011-07-28T12:29:57.792-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Going Python II</title><content type='html'>The trading platform to be now has got a name: Nautilus. It is available on&lt;a href="http://code.google.com/p/nautilus/"&gt; Google code&lt;/a&gt;.&lt;br /&gt;I have decided to share the project in an early stage. Because of this it may currently be of interest to a limited group of people willing to write more than a couple of lines of code.&lt;br /&gt;Python is very new to me. That, combined with the fact that I am more of a researcher than a programmer, can lead to a less-than-optimal code. I hope that the open nature of the project will help it to improve in quality and grow.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-8861722340694968817?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/8861722340694968817/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/07/going-python-ii.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/8861722340694968817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/8861722340694968817'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/07/going-python-ii.html' title='Going Python II'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-3159891283516730780</id><published>2011-07-18T10:48:00.000-07:00</published><updated>2011-07-18T10:48:36.599-07:00</updated><title type='text'>Going Python</title><content type='html'>It was a tough decision to make, but &amp;nbsp;I decided against using Matlab as an intraday trading platform. It is still the best data digging tool out there, but for application development it just doesn't cut it.&lt;br /&gt;Luckily, there are tools that are just perfect for the task, like Python. Unfortunately I'm very new to Python programming so the learning curve will be steep and initial products will be far from optimal.&lt;br /&gt;I am currently building a framework on top of the excellent&amp;nbsp;&lt;a href="http://code.google.com/p/ibpy/"&gt;IbPy&lt;/a&gt;, capable of connecting to Interactive Brokers and executing orders.&lt;br /&gt;The goal is to create a simple trading platform, and running strategies as plug-ins.&lt;br /&gt;I'll be keeping this project open-sourced, hosted on Google Code.&lt;br /&gt;&lt;br /&gt;Stay tuned....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-3159891283516730780?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/3159891283516730780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/07/going-python.html#comment-form' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3159891283516730780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3159891283516730780'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/07/going-python.html' title='Going Python'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-552101563662083715</id><published>2011-06-15T14:29:00.000-07:00</published><updated>2011-06-15T14:29:18.850-07:00</updated><title type='text'>Implied vs Realized volatility premium</title><content type='html'>There is a funny thing that I've come across while trying to build a volatility model. According to my estimations the VIX&amp;nbsp;is usually higher than the actual volatility (RV) &amp;nbsp;realized for that same period. Just take a look at the following chart:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-CQ5xFyiKmfU/Tfkf3s7XfeI/AAAAAAAADHI/oEb46Jgc3WE/s1600/impliedVol_vs_realizedVol.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://4.bp.blogspot.com/-CQ5xFyiKmfU/Tfkf3s7XfeI/AAAAAAAADHI/oEb46Jgc3WE/s320/impliedVol_vs_realizedVol.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;In the top chart I've plotted the VIX (IV) and RV estimate for a 3-year period. The bottom chart is the difference between the IV &amp;amp; RV . To estimate the RV I've used a function from &amp;nbsp;&lt;a href="http://tradingwithmatlab.blogspot.com/"&gt;tradingwithmatlab blog&lt;/a&gt;. It uses several common estimators for RV (I've used the average value for RV ).&lt;br /&gt;It looks like IV on average &amp;nbsp;is&amp;nbsp;7%&amp;nbsp;higher than the RV. So one could just sell volatility and get a steady profit, right? Knowing that there is no free lunch in trading, it seems that I'm missing out something. Is my estimation of RV incorrect? Is it unjustified to compare VIX and SP500 volatility? All feedback is very welcome...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-552101563662083715?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/552101563662083715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/06/implied-vs-realized-volatility-premium.html#comment-form' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/552101563662083715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/552101563662083715'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/06/implied-vs-realized-volatility-premium.html' title='Implied vs Realized volatility premium'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-CQ5xFyiKmfU/Tfkf3s7XfeI/AAAAAAAADHI/oEb46Jgc3WE/s72-c/impliedVol_vs_realizedVol.png' height='72' width='72'/><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-1117561132747456200</id><published>2011-05-16T13:30:00.000-07:00</published><updated>2011-05-16T13:30:31.295-07:00</updated><title type='text'>Guess what, leveraged etfs don't decay!</title><content type='html'>While writing the previous posts and doing the math I still had a feeling that something in my reasoning was not quite right. I could not put a finger on it, but with the help of the author of &lt;a href="http://onlyvix.blogspot.com/"&gt;OnlyVix blog&lt;/a&gt;, I seem to have figured it all out.&lt;br /&gt;Let me start with an old problem of 50/50 chance of winning 1% every timestep. Here is a puzzle from E.Chans blog (and book):&lt;br /&gt;&lt;blockquote&gt;"&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; font-size: 13px; line-height: 20px;"&gt;Here is a little puzzle that may stymie many a professional trader. Suppose a certain stock exhibits a true (geometric) random walk, by which I mean there is a 50-50 chance that the stock is going up 1% or down 1% every minute. If you buy this stock, are you most likely, in the long run, to make money, lose money, or be flat?&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; line-height: 20px;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;Most traders will blurt out the answer “Flat!”&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 20px;"&gt;...And they would be&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 20px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 20px;"&gt;&lt;b&gt;right.&amp;nbsp;&lt;/b&gt;&lt;/span&gt;To prove this, let's write down a binomial tree for this case. I'll use 10% step to simplify the math:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-6iYbDklTmeU/TdGDNaFzNbI/AAAAAAAADEY/CnQABgAMO9s/s1600/binomial_tree.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="298" src="http://4.bp.blogspot.com/-6iYbDklTmeU/TdGDNaFzNbI/AAAAAAAADEY/CnQABgAMO9s/s320/binomial_tree.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Here we start with initial 100$. Every branch has 50% probability. Notice that the expected value at each time step is exactly 100$. However, on the third timestep the most probable value is 99$ .&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;To double-check it, I've run a Monte-Carlo simulation of the above problem. Here is the result:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-JIj3Qq1aDME/TdGBZpGM_MI/AAAAAAAADEU/a3h9oZWe0Dw/s1600/mc_single_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://2.bp.blogspot.com/-JIj3Qq1aDME/TdGBZpGM_MI/AAAAAAAADEU/a3h9oZWe0Dw/s320/mc_single_1.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;The average value is 0, while the median is -0.5% for 100 steps or -0.005% for one step.&lt;br /&gt;&lt;br /&gt;The case for 5% change per timestep looks like this:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-XuNmW0lENY4/TdGFm2lRRVI/AAAAAAAADEc/6E6sZTsmAEk/s1600/mc_single_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="230" src="http://1.bp.blogspot.com/-XuNmW0lENY4/TdGFm2lRRVI/AAAAAAAADEc/6E6sZTsmAEk/s320/mc_single_2.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;The distribution shifts to the left, bu again, average value is zero, and median is&amp;nbsp;-0.1176.&lt;br /&gt;&lt;br /&gt;So the answer to above puzzle is indeed &lt;b&gt;'flat'&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Now returning to a leveraged pair like FAS&amp;amp;FAZ, here is a Monte-Carlo simulation of a leveraged pair:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-ln-lryDXT9E/TdGILd2E2JI/AAAAAAAADEg/WqEF360aCsQ/s1600/3x_pair.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://1.bp.blogspot.com/-ln-lryDXT9E/TdGILd2E2JI/AAAAAAAADEg/WqEF360aCsQ/s320/3x_pair.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;Here I've used a normal distribution for returns of the underlying with sigma = 1%. Once again, the average return over 100 periods is zero, while most of the occurrences are negative.&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;This means that leveraged etfs don't decay over time, they just &lt;i&gt;look&lt;/i&gt;&amp;nbsp;like they do, because that is the most likely outcome.&lt;/span&gt;&lt;br /&gt;So here we go, contrary to common belief, the leveraged etfs don't decay after all!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-1117561132747456200?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/1117561132747456200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/05/guess-what-leveraged-etfs-dont-decay.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1117561132747456200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1117561132747456200'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/05/guess-what-leveraged-etfs-dont-decay.html' title='Guess what, leveraged etfs don&apos;t decay!'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-6iYbDklTmeU/TdGDNaFzNbI/AAAAAAAADEY/CnQABgAMO9s/s72-c/binomial_tree.png' height='72' width='72'/><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-7890375097947002811</id><published>2011-05-15T03:53:00.000-07:00</published><updated>2011-05-15T03:54:37.023-07:00</updated><title type='text'>The problem with shorting leveraged etfs</title><content type='html'>As I've described in my previous post, inverse etfs decay relative to each other.&amp;nbsp;After looking at their charts it is not difficult to imagine earning 'easy mony' by shorting a pair of leveraged etfs. Max Dama &lt;a href="http://www.maxdama.com/?p=443"&gt;has done this&lt;/a&gt;&amp;nbsp;and there are more people doing this according to Google,&amp;nbsp;but I think this type of strategy is pretty risky.&lt;br /&gt;&lt;br /&gt;Here is an example of 'easy money'.&amp;nbsp;I've simulated a random walk (upper chart in blue) that has 50/50% chance of going up or down every day. And it always moves exactly by 3% (log, so it should be flat over the long run ). From this reference I've created two leveraged trackers, with +2x and -2x leverage, I'll call them 'up' and 'down'.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-Bj-WLC6zfHQ/Tc-qpjhsZyI/AAAAAAAADEM/MJcZdvJuLRA/s1600/good_decay.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://4.bp.blogspot.com/-Bj-WLC6zfHQ/Tc-qpjhsZyI/AAAAAAAADEM/MJcZdvJuLRA/s320/good_decay.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Suppose we start a 100 day period with a pair &amp;nbsp;consisting of equal amounts of capital in 'up' and 'down', both equal to 100$. So the pair value on day 1 is $200. Pair value is plotted in the lower chart. &amp;nbsp;Without a trend in the reference, the pair value decays at a constant rate &lt;i&gt;exp(0.5log(leverage*(1+daily_delta))+0.5log(&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;i&gt;leverage*(1-daily_delta)&lt;/i&gt;&lt;/span&gt;))&lt;/i&gt;. &amp;nbsp;If we short both 'up' and 'down' the lower chart will flip upside down, producing pretty good looking pnl.&lt;br /&gt;But before you short sell &amp;nbsp;every available leveraged etf out there, take a look at the next chart:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-EmDaqYKYMFE/Tc-u3CjODPI/AAAAAAAADEQ/m-QsEZGuc3o/s1600/bad_decay.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://2.bp.blogspot.com/-EmDaqYKYMFE/Tc-u3CjODPI/AAAAAAAADEQ/m-QsEZGuc3o/s320/bad_decay.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;All the parameters here are the same, only the underlying has two brief periods of consecutive wins or losses. This results in two heavy spikes in the pair value. If we would have shorted both 'up' and 'down' the result would be a pretty heavy drawdown. No easy money here...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-7890375097947002811?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/7890375097947002811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/05/problem-with-shorting-leveraged-etfs.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7890375097947002811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7890375097947002811'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/05/problem-with-shorting-leveraged-etfs.html' title='The problem with shorting leveraged etfs'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-Bj-WLC6zfHQ/Tc-qpjhsZyI/AAAAAAAADEM/MJcZdvJuLRA/s72-c/good_decay.png' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-8307487124432724521</id><published>2011-05-14T11:25:00.000-07:00</published><updated>2011-05-14T12:42:37.965-07:00</updated><title type='text'>FAS vs FAZ - inverse etf behavior</title><content type='html'>There has been a lot of talk about leveraged etf (under) performance . In general, these etfs seem to underperform their benchmark. A google search for 'leveraged etf decay' will provide a couple of hours worth of reading material, so &amp;nbsp;I will try to limit information redundancy to a minimum.&amp;nbsp;I'll limit myself to a single sentence introduction: 'leveraged and inverse etfs are based on the &lt;i&gt;arithmetic&lt;/i&gt; returns of their benchmark, which introduces a negative tracking error'.&lt;br /&gt;If you have little idea about what I'm talking about, take a look &lt;a href="http://www.calculatinginvestor.com/2011/04/29/geometric-vs-arithmetic/"&gt;here&lt;/a&gt; for an explanation of the difference between the arithmetic and geometric returns.&lt;br /&gt;So I'll continue the examination of inverse etf dynamics from what is already known: underperformance.&lt;br /&gt;&lt;br /&gt;Let's first take a look at the relation between FAS and FAZ. Both are 3x leveraged versions of the same underlying index, FAZ being the inverse one.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-0C62OELqBL4/Tc64bM6tb6I/AAAAAAAADD8/Yv_weIKsoYM/s1600/fas-faz_price.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="250" src="http://1.bp.blogspot.com/-0C62OELqBL4/Tc64bM6tb6I/AAAAAAAADD8/Yv_weIKsoYM/s320/fas-faz_price.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;Here can be seen clearly that while the etfs move in the opposite directions, FAS in the long run outperforms FAZ.&lt;br /&gt;Their daily &lt;i&gt;arithmetic&amp;nbsp;&lt;/i&gt;returns however are performing exactly as advertised:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-izTUEkgVtSg/Tc65M36XKPI/AAAAAAAADEA/PfYRnVNNVbA/s1600/arithmetic_returns.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="239" src="http://2.bp.blogspot.com/-izTUEkgVtSg/Tc65M36XKPI/AAAAAAAADEA/PfYRnVNNVbA/s320/arithmetic_returns.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;However, anybody holding a position for longer than one time period (being a day) should be only interested in &lt;i&gt;geometric &lt;/i&gt;returns, or &lt;i&gt;log&lt;/i&gt;&amp;nbsp;returns.&lt;br /&gt;When log returns of these two are examined, the picture changes:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-MJ1AiiYmmf8/Tc66aO1Q5-I/AAAAAAAADEE/ItAL-O-cnJk/s1600/geometric_returns.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="239" src="http://1.bp.blogspot.com/-MJ1AiiYmmf8/Tc66aO1Q5-I/AAAAAAAADEE/ItAL-O-cnJk/s320/geometric_returns.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;Instead of following a straight line, the returns are skewed in favor of FAS. The green line here is a theoretical estimation of inverse relation based on algebraic returns.&lt;br /&gt;For example: FAS gains 10% on a given day and FAZ follows with a 10% decline. In log returns this would translate to FAS:&amp;nbsp;&lt;i&gt;log(1.1) = 0.0953 &amp;nbsp; &lt;/i&gt;FAZ:&lt;i&gt;&amp;nbsp;log(0.9)=-0.1054. &amp;nbsp;&lt;/i&gt;&amp;nbsp;The log returns are not equal (duh!) but skewed in favor of FAS . When the position is held for a longer time and the pair moves 10% every day (no matter in which direction), we loose approx 0.5% per day of the total position.&lt;br /&gt;Please take a note that this 'skew' is not about leverage, but inverse algebraic relationship. Leverage only provides more daily movement, exaggerating the skew.&lt;br /&gt;A handy chart below shows the under performance of inverse etf as a function of its underlying daily change. One can see that the error is relatively small for &amp;lt;1% moves, but increases rapidly with bigger moves.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-kgaC0cr50g4/Tc7H0-zQSlI/AAAAAAAADEI/MkBbpGbvkSE/s1600/inverse_loss.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="239" src="http://3.bp.blogspot.com/-kgaC0cr50g4/Tc7H0-zQSlI/AAAAAAAADEI/MkBbpGbvkSE/s320/inverse_loss.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The difference between geometric and algebraic returns has been explained by E.Chan on his &lt;a href="http://epchan.blogspot.com/2006/10/maximizing-compounded-rate-of-return.html"&gt;blog&lt;/a&gt; (and in his book) . However, he made a mistake in the calculation of average loss per time period stating it to be -0.5%.&lt;br /&gt;When we have a 50/50 chance of winning or loosing 1% , in fact the expected return per minute is&amp;nbsp;exp(0.5*log(1.01)+0.5*log(0.99)), which translates to -.005 % per minute, which is equivalent to -7% &amp;nbsp;in 24 hours ;-).&lt;br /&gt;&lt;br /&gt;There are a couple of very interesting strategies that can be derived from this&amp;nbsp;asymmetry, if one can handle the &amp;nbsp;math and rebalancing logic.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-8307487124432724521?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/8307487124432724521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/05/fas-vs-faz-inverse-etf-behavior.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/8307487124432724521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/8307487124432724521'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/05/fas-vs-faz-inverse-etf-behavior.html' title='FAS vs FAZ - inverse etf behavior'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-0C62OELqBL4/Tc64bM6tb6I/AAAAAAAADD8/Yv_weIKsoYM/s72-c/fas-faz_price.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-5399847895601516318</id><published>2011-05-11T13:51:00.000-07:00</published><updated>2011-05-13T13:22:49.784-07:00</updated><title type='text'>In trading no one should  ever be absolutely sure</title><content type='html'>...and the one who is will get punished sooner or later. This has happened countless times, to traders of all skill levels. Once you think you've got a trade on your hands that can't possibly go wrong, you're brewing a recipe for disaster. Everybody knows this, me included, however I just barely escaped such a situation by plain luck.&lt;br /&gt;&lt;br /&gt;A couple of days ago I ran my spread scanner and the good old GLD-GDX spread caught my eye. It was so streched up, that I decided to trade it. In fact it was at an extreme that has not happened for a very verly long time. This spread is a 'classic' for spread traders and it has been mean reverting for years now. I'm was sure that it would mean &amp;nbsp;revert again, and quickly got on board. The only thing that prevented me from betting big was the shortage of free cash and I did not want to close any other positions. So I ended up with a usual size of a spread bet, that I don't allow to produce more than 2% of portfolio volatility.&lt;br /&gt;What happened next is a short story. The spread moved further against me, knocking 2% off my portfolio. A pity, but not a disaster. &lt;br /&gt;The good part is that I can still handle this situation with calmness and make reasonable decisions about keeping this spread or taking a loss. Things could be different if my position was larger and I lost months worth of work on a single trade.&lt;br /&gt;This reminded me again that trading should not be convinced with gambling or one will end up the as &amp;gt;90% of amateur day traders- with a blown account, but more on this later...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-5399847895601516318?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/5399847895601516318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/05/in-trading-no-one-should-never-be.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5399847895601516318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5399847895601516318'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/05/in-trading-no-one-should-never-be.html' title='In trading no one should  ever be absolutely sure'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-4650039249990631434</id><published>2011-04-16T09:34:00.000-07:00</published><updated>2011-04-16T09:34:48.722-07:00</updated><title type='text'>When Sharpe is useless</title><content type='html'>During development of an intrady strategy I've come across a case where Sharpe ratio (and Sortino too) is a very bad way to benchmark performance. To illustrate this case, imagine a strategy that enters a position and 'brackets' the exit levels with a limit and a stop-loss order. This results in the pnl distribution as shown in the graph:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-UwEMIPfGbng/TanETBdVVXI/AAAAAAAADDw/Kx300Htpcpo/s1600/deltas.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="220" src="http://3.bp.blogspot.com/-UwEMIPfGbng/TanETBdVVXI/AAAAAAAADDw/Kx300Htpcpo/s320/deltas.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;The position is either closed at the limit or the stop-loss level, but not in between. Because Sharpe is all about normal distribution, it just does does not work for this case. A better solution here is to use win %, especially in the case of symmetric brackets.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-4650039249990631434?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/4650039249990631434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/04/when-sharpe-is-useless.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4650039249990631434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4650039249990631434'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/04/when-sharpe-is-useless.html' title='When Sharpe is useless'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-UwEMIPfGbng/TanETBdVVXI/AAAAAAAADDw/Kx300Htpcpo/s72-c/deltas.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-5560880280305010941</id><published>2011-03-03T13:50:00.000-08:00</published><updated>2011-03-03T15:00:41.576-08:00</updated><title type='text'>HOWTO: Signal filtering, the better way.</title><content type='html'>It is hard to find a trading system that does not employ signal filtering through use of &lt;i&gt;sma, ema, wma&lt;/i&gt; &amp;nbsp;and the likes. I'm not going to dive in detail on the inner workings of these filters as this info is widely &lt;a href="http://en.wikipedia.org/wiki/Moving_average"&gt;available&lt;/a&gt;.&lt;br /&gt;Filters that prioritize recent data are more suitable taking market dynamics into account but implementing these filters using a &lt;i&gt;for&lt;/i&gt;&amp;nbsp;loop in Matlab is anything but efficient. Luckily, Matlab provides the &lt;a href="http://www.mathworks.com/help/toolbox/signal/filter.html"&gt;filter &lt;/a&gt;function, that can be used to calculate all these types of moving averages and even more.&lt;br /&gt;In the code attached to this post I'm going to show how to filter signals based on an excellent &lt;a href="http://quantum.meplaza.nl/Ehlers%20(Hybrid%20FIR%20IRR%20Filters).doc"&gt;article written by John F.Ehlers&lt;/a&gt;. (more articles can be found &lt;a href="http://www.mesasoftware.com/technicalpapers.htm"&gt;here&lt;/a&gt;) Please read it before playing with the code. I've implemented the different filters mentioned to compare their characteristics.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://lh5.googleusercontent.com/-qjVL0HCOdrU/TXALsNKoXuI/AAAAAAAADDQ/CF_6t7AJMs8/s1600/filter_application.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="https://lh5.googleusercontent.com/-qjVL0HCOdrU/TXALsNKoXuI/AAAAAAAADDQ/CF_6t7AJMs8/s320/filter_application.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp;Looking at the data, I must draw a conclusion that the hybrid filter provides an improvement in terms of lag over the standard ema.&lt;br /&gt;Using this hybrid filter one can create a simple indicator of the current price imbalance, like shown in the next graph. For this I've used the difference between the current price and &lt;i&gt;&lt;a href="http://quantum.meplaza.nl/emaHybrid.m"&gt;emaHibrid(price,0.85,0.3)&lt;/a&gt;.&amp;nbsp;&lt;/i&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://lh5.googleusercontent.com/-lP1f1UMWLzs/TXAaRNooqcI/AAAAAAAADDU/EGz4a3ioArs/s1600/hybrid_oscillator.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="230" src="https://lh5.googleusercontent.com/-lP1f1UMWLzs/TXAaRNooqcI/AAAAAAAADDU/EGz4a3ioArs/s320/hybrid_oscillator.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Source: &lt;a href="http://quantum.meplaza.nl/demoFilter.m"&gt;demoFilter.m&lt;/a&gt;, &amp;nbsp;&lt;a href="http://quantum.meplaza.nl/emaHybrid.m"&gt;emaHybrid.m&lt;/a&gt; data: &lt;a href="http://quantum.meplaza.nl/price.mat"&gt;price.mat&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-5560880280305010941?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/5560880280305010941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/03/howto-signal-filtering-better-way.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5560880280305010941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5560880280305010941'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/03/howto-signal-filtering-better-way.html' title='HOWTO: Signal filtering, the better way.'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='https://lh5.googleusercontent.com/-qjVL0HCOdrU/TXALsNKoXuI/AAAAAAAADDQ/CF_6t7AJMs8/s72-c/filter_application.png' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-76943583006384955</id><published>2011-02-28T10:21:00.000-08:00</published><updated>2011-03-03T13:55:58.770-08:00</updated><title type='text'>Gaps, part 3</title><content type='html'>Recently I've come to realise that I've made quite a mistake calculating the 'fill' ratio for the gaps. It's time to correct it, before somebody will embarrass me in the comments ;-).The problem is that I've used &lt;i&gt;asymmetric&lt;/i&gt;&amp;nbsp;boundaries when calculating the&amp;nbsp;&amp;nbsp;statistics. By doing this, the statistics shift in favor of the nearest stop. The closer the stop, the higher the chances of hitting it, but by no means does this mean profit. And previous close is usually not far from the open so chances of hitting it are quite high.&lt;br /&gt;To make statistics fair, I've set the levels &lt;i&gt;symmetric&lt;/i&gt;&amp;nbsp;around the open, like this:&lt;br /&gt;&lt;i&gt;gap = open-prevClose&lt;/i&gt;&lt;br /&gt;&lt;i&gt;winLevel = open+gap&lt;/i&gt;&lt;br /&gt;&lt;i&gt;lossLevel = open-gap&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;With this calculation* the chances are quite different and closer to my results using the intraday data:&lt;br /&gt;down gap: 52% fill&lt;br /&gt;up gap: 48% fill&lt;br /&gt;&lt;br /&gt;*geek note: when both win and loss levels are reached for the same day, it is counted both as win and loss (with daily ohlc data there is no way of knowing which one was reached first) . Data for SPY Feb.2000- Feb-2011.&lt;br /&gt;&lt;br /&gt;Code: &lt;a href="http://quantum.meplaza.nl/dumbGaps.m"&gt;dumbGaps.m&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-76943583006384955?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/76943583006384955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/02/gaps-part-3.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/76943583006384955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/76943583006384955'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/02/gaps-part-3.html' title='Gaps, part 3'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-3876075224170910112</id><published>2011-02-25T11:36:00.000-08:00</published><updated>2011-02-25T11:36:10.106-08:00</updated><title type='text'>Looking for cooperation</title><content type='html'>Quite a time ago I've written a post about &amp;nbsp;&lt;a href="http://matlab-trading.blogspot.com/2009/12/can-open-innovation-give-competitive.html"&gt;open innovation&lt;/a&gt;, the reason I've started this blog. Looking back, this 'loose cooperation' was very fruitful. &amp;nbsp;During past year and a half this blog has given me a lot in return for the efforts of writing it. Next to the obvious personal goal of getting my thoughts straight, I've had many quite inspiring discussions with some of the people from the blogphere.&lt;br /&gt;&lt;br /&gt;So far, so good, but my experiences had made me realize that I've still some time to go before I can afford to live from trading. I am confident that I'll get there some day, but I'd like it to happen rather sooner than later.&lt;br /&gt;So what's keeping me back? Here is a little SWOT analysis of my trading venture:&lt;br /&gt;&lt;br /&gt;Strengths:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;masters degree in Applied Physics, high level of creativity.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Experience with signal processing, artificial intelligence and pattern recognition.&lt;/li&gt;&lt;li&gt;Programming skills in several languages.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Knowledge of IB API.&lt;/li&gt;&lt;li&gt;Strictly&amp;nbsp;quantitative&amp;nbsp;approach.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Weakness:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Little hands-on experience with trading.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Limited knowledge of the financial markets.&lt;/li&gt;&lt;/ul&gt;Opportunities:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Strategies that are just too boring to do by hand or require automation, like scalping.&lt;/li&gt;&lt;li&gt;Strategies that cannot be traded with conventional software (multiple assets, custom metrics etc.)&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Threats:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Blowing my account through inexperience.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;I'm sure there are some people around with goals similar to mine, but with strengths where I have weakness and the other way around. Joined effort in this case would be more than just a sum of the parts.&lt;br /&gt;&lt;br /&gt;Now the point that I was getting to:&lt;br /&gt;Life is just too short to do everything by yourself. I'm open to cooperation with someone who has hands-on experience with trading and wants to make a step towards automation or quantitative trading. If you are interested, &amp;nbsp;drop me an e-mail.&lt;br /&gt;&lt;br /&gt;-Jev&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-3876075224170910112?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/3876075224170910112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/02/looking-for-cooperation.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3876075224170910112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3876075224170910112'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/02/looking-for-cooperation.html' title='Looking for cooperation'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-7016855594050571673</id><published>2011-02-06T03:24:00.000-08:00</published><updated>2011-02-06T03:24:14.663-08:00</updated><title type='text'>Closing the gap, part 2</title><content type='html'>I felt the need to verify the calculations in the previous post, just to be sure no coding error was made, or at least not a serious one. To do this, I've rewritten the strategy using vector operations rather than 'for' loops and I'm happy to say, the result still stands. Sharpe is a little lower at 1.13, but the curves are quite similar.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_j6utrVcrL9k/TU6Cwb_fc_I/AAAAAAAADC0/9yzW9gJF4sc/s1600/pnl2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://2.bp.blogspot.com/_j6utrVcrL9k/TU6Cwb_fc_I/AAAAAAAADC0/9yzW9gJF4sc/s320/pnl2.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;To make this post a worthy follow up, I've also included the code:&lt;br /&gt;&lt;a href="http://quantum.meplaza.nl/dumbGaps.m"&gt;dumbGaps.m&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="http://quantum.meplaza.nl/download_hist_yahoo_data.m"&gt;download_hist_yahoo_data.m&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The following remarks are still very appropriate:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It is very hard to get a fill at the opening price.&lt;/li&gt;&lt;li&gt;Results are frictionless.&lt;/li&gt;&lt;li&gt;All this is just a basic concept&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Your feedback is very much appreciated.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-7016855594050571673?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/7016855594050571673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/02/closing-gap-part-2.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7016855594050571673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7016855594050571673'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/02/closing-gap-part-2.html' title='Closing the gap, part 2'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_j6utrVcrL9k/TU6Cwb_fc_I/AAAAAAAADC0/9yzW9gJF4sc/s72-c/pnl2.png' height='72' width='72'/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-2920321542416909979</id><published>2011-02-04T05:58:00.000-08:00</published><updated>2011-02-04T05:58:54.062-08:00</updated><title type='text'>Closing the gap strategy</title><content type='html'>Fading the opening gap is a well-known strategy, promising acceptable results with minimal efforts. A great article about trading gaps is written by&amp;nbsp;&lt;a href="http://club.ino.com/trading/2009/07/why-fading-the-opening-gap-is-the-ideal-setup-for-me/"&gt;Scott Andrews&lt;/a&gt;. It sounded interesting, so I've decided to spend an hour or so to check if the numbers are right. The basic 'Dumb gap' strategy that I've simulated always trades the opening gap in the direction of the previous days close. In other words, if opening above yesterdays close, go short. Take profit level is set on yesterdays close, if it is not reached, the strategy &amp;nbsp;closes the position on the days close.&lt;br /&gt;As a test set I've chosen past 10 years of the SPY, ignoring transaction costs and slippage. And the results are:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The gaps fully closed on about 75% of occasions&lt;/li&gt;&lt;li&gt;The strategy has a sharpe of 1.3&lt;/li&gt;&lt;li&gt;Using 'BLUD' (below low of an up day) compensation introduces only marginal improvement. These days are quite rare, ~3% of all occurences.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;And as a picture speaks a thouthand words, here are the pnl curves.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_j6utrVcrL9k/TUwFTg1XT3I/AAAAAAAADCw/-mSZiUMxN3U/s1600/gap_close.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="239" src="http://1.bp.blogspot.com/_j6utrVcrL9k/TUwFTg1XT3I/AAAAAAAADCw/-mSZiUMxN3U/s320/gap_close.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Disclaimer: this is just an idea that that needs some work before a tradeable stragegy is achieved. I do not recommend anyone trading using the rules described above.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-2920321542416909979?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/2920321542416909979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/02/closing-gap-strategy.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/2920321542416909979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/2920321542416909979'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/02/closing-gap-strategy.html' title='Closing the gap strategy'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_j6utrVcrL9k/TUwFTg1XT3I/AAAAAAAADCw/-mSZiUMxN3U/s72-c/gap_close.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-9122563633814387054</id><published>2011-01-24T13:59:00.000-08:00</published><updated>2011-01-24T13:59:49.323-08:00</updated><title type='text'>Nearest neighbour classification</title><content type='html'>I've been following &lt;a href="http://www.tradingtheodds.com/"&gt;trading the odds&lt;/a&gt; blog&amp;nbsp;&amp;nbsp;for some time now.&amp;nbsp;It surprised me how well &amp;nbsp;Frank was able to predict the short-term movement of the S&amp;amp;P500. At first I was quite sceptical about the predictability of the directional stock movement, but had to admit now that there is some sense to it.&lt;br /&gt;Previously I've been playing around with some techniques from pattern recognition field, especially the 'nearest neigbours' approach. Just as one could get an impression of somebody by meeting his friends, the same can be said about stocks. By finding some 'examples' most related to an 'new' situation, a statistical picture could be made of the things to come.&lt;br /&gt;To provide a simple illustration, I've taken the intraday SPY and TICK data for 2010. Some traders are using the first hour of trading to decide what kind of strategy they need to implement for that situation. But is the first hour of trading representative for the rest of the day? It turns out it is. Take a look at the chart below.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_j6utrVcrL9k/TT3zoM8VSAI/AAAAAAAADCo/tAMASwngW8s/s1600/day_regime.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="188" src="http://1.bp.blogspot.com/_j6utrVcrL9k/TT3zoM8VSAI/AAAAAAAADCo/tAMASwngW8s/s320/day_regime.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;Here I've classified the intraday SPY data based on the first hour of the TICK reading. For this I've used the mean and standard deviation of the 30-sec TICK-NYSE data. &amp;nbsp;Green lines in the chart represent ten days with minimal mean and minimal std of the TICK in the first hour (closest to [0,0]). Blue lines are days with large positive mean of the tick and &amp;nbsp;low std ([max, 0]). &amp;nbsp;It turns out that days with large positive bias int the first hour of trading have a quite strong negative bias for the rest of the day, who would have thought?&lt;br /&gt;Predicting the market regime for the rest of the trading day is not very profitable by itself, but can be very well used for choosing the right strategy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-9122563633814387054?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/9122563633814387054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/01/nearest-neighbour-classification.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/9122563633814387054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/9122563633814387054'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/01/nearest-neighbour-classification.html' title='Nearest neighbour classification'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_j6utrVcrL9k/TT3zoM8VSAI/AAAAAAAADCo/tAMASwngW8s/s72-c/day_regime.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-6137648676919191095</id><published>2011-01-15T07:07:00.000-08:00</published><updated>2011-01-15T07:16:42.673-08:00</updated><title type='text'>XVIX performance</title><content type='html'>In a reaction to my previous post about the VXX-VXZ combo, a kind reader has pointed me to the newly launched&amp;nbsp;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; line-height: 20px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; line-height: 20px;"&gt;UBS XVIX&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; line-height: 20px;"&gt;&amp;nbsp;&amp;nbsp;etn. &amp;nbsp;From the first look it does not seem to be that liquid, so its ability to track the VXZ-0.5VXX is somewhat questionalble.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; line-height: 20px;"&gt;I've decided to take a quick look at the fist month of its existance to check if it is really performing as advertised.&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_j6utrVcrL9k/TTG1OmFyOhI/AAAAAAAADCg/53vgsc6EjEo/s1600/xvix.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://2.bp.blogspot.com/_j6utrVcrL9k/TTG1OmFyOhI/AAAAAAAADCg/53vgsc6EjEo/s320/xvix.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif;"&gt;&lt;span class="Apple-style-span" style="line-height: 20px;"&gt;In the graph I've plotte the cumulative change in VIX (index), VXZ, VXX, XVIX and a synthetic VXZ-0.5VXX pair. &amp;nbsp;It seems that XVIX performing exactly as promised, providing performance very close to the underlying pair, without the cost of rebalancing.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif;"&gt;&lt;span class="Apple-style-span" style="line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif;"&gt;&lt;span class="Apple-style-span" style="line-height: 20px;"&gt;The following plot shows cumulative tracking error:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_j6utrVcrL9k/TTG5zAQ0M9I/AAAAAAAADCk/LqSorym8CKQ/s1600/xvix_error.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://3.bp.blogspot.com/_j6utrVcrL9k/TTG5zAQ0M9I/AAAAAAAADCk/LqSorym8CKQ/s320/xvix_error.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; line-height: 20px;"&gt;An interesting observation is that it does have some occasional tracking errors, of about ~0.3%, providing some arbitrage opportunities.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-6137648676919191095?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/6137648676919191095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/01/xvix-performance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/6137648676919191095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/6137648676919191095'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/01/xvix-performance.html' title='XVIX performance'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_j6utrVcrL9k/TTG1OmFyOhI/AAAAAAAADCg/53vgsc6EjEo/s72-c/xvix.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-8952281637131672286</id><published>2011-01-10T14:07:00.000-08:00</published><updated>2011-01-10T14:09:48.381-08:00</updated><title type='text'>What if S&amp;P 500 lost 50% on a single day?</title><content type='html'>Most of us know that there are leveraged ETFs, providing up to 3x daily exposure, in decimal percent. Usually these etfs &amp;nbsp;perform just as advertised, but imagine a situation where the index looses a very large portion (~50%). Such an event unlikely, but is not impossible if you think about the 'fat tails' and ~20% loss on black monday in 1987.&lt;br /&gt;Now imagine you are unfortunate enough to own one of the 3X leveraged etfs on while S&amp;amp;P looses 50% of its value. will 3x exposure result in a 150% loss??? Ok, you probably will face a margin call before that, but I'm having a hard time trying to imagine what would happen to the leveraged etf &lt;i&gt;price&lt;/i&gt; on such a day.&lt;br /&gt;What do you think?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-8952281637131672286?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/8952281637131672286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/01/what-if-s-500-lost-50-on-single-day.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/8952281637131672286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/8952281637131672286'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/01/what-if-s-500-lost-50-on-single-day.html' title='What if S&amp;P 500 lost 50% on a single day?'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-513568832156559801</id><published>2011-01-05T12:47:00.000-08:00</published><updated>2011-01-05T12:48:30.373-08:00</updated><title type='text'>Yahoo quote downloader</title><content type='html'>Here is a simple function to get current yahoo data for a bunch of symbols :&amp;nbsp;&lt;a href="http://quantum.meplaza.nl/get_yahoo_quote.m"&gt;get_yahoo_quote.m&lt;/a&gt;&lt;br /&gt;It downloads quotes from yahoo (take a look&lt;a href="http://www.gummy-stuff.org/Yahoo-data.htm"&gt; here&lt;/a&gt; at what is possible) and returns them in a struct.&lt;br /&gt;&lt;br /&gt;example usage:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;quote = get_yahoo_quote({'SPY','IWM'}) &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;result:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;symbol: 'SPY'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; desc: 'SPDR S&amp;amp;P 500'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lastTrade: [127.5695]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;lastTradeTime: '3:30pm'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; dividendDate: 'Dec 17'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; open: [126.58]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lastClose: [126.98]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; symbol: 'IWM'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; desc: 'iShares Russell 2'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lastTrade: [79.26]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;lastTradeTime: '3:30pm'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; dividendDate: 'Dec 22'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; open: [78.4]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lastClose: [78.422]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-513568832156559801?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/513568832156559801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2011/01/yahoo-quote-downloader.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/513568832156559801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/513568832156559801'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2011/01/yahoo-quote-downloader.html' title='Yahoo quote downloader'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-3452619976548607544</id><published>2010-12-07T07:52:00.000-08:00</published><updated>2010-12-07T07:52:32.873-08:00</updated><title type='text'>VIX buy  &amp; hold strategy</title><content type='html'>Here is a simple buy&amp;amp;hold strategy that popped up while I was playing with &amp;nbsp;some VIX based ETNs . The volatility was extremely high through the end 2008- beginning 2009, presenting a good opportunity to go short on the VIX. A good way to go was probably the &amp;nbsp;VXX etn, however one would suffer some substantial losses through the summer of 2010.&lt;br /&gt;Now take a look what happens if the upside risk of the VXX (short term futures) is hedged by the VXZ (long term futures). It turns out that a the summer 2010 dip can be completely 'ironed out' by constructing a pair of short VXZ-long VXX, allocating 2x of the capital to VXX. &amp;nbsp;The graph below shows a portfolio of&amp;nbsp;-22 shares VXX, &amp;nbsp;46 shares VXZ. Sharpe is just above 2.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_j6utrVcrL9k/TP5WKJyqveI/AAAAAAAADBk/D_44OyyTEnA/s1600/vxx_vxz.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="243" src="http://2.bp.blogspot.com/_j6utrVcrL9k/TP5WKJyqveI/AAAAAAAADBk/D_44OyyTEnA/s320/vxx_vxz.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;Of course past returns are not necessarily representative for the future, but I imagine that during the next crisis this behavior could be repeated.&lt;br /&gt;At this moment this strategy may be turning around, as downwards potential of the VIX seemes limited for now. But I can't wait for the next crisis. ;-).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-3452619976548607544?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/3452619976548607544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/12/vix-buy-hold-strategy.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3452619976548607544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3452619976548607544'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/12/vix-buy-hold-strategy.html' title='VIX buy  &amp; hold strategy'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_j6utrVcrL9k/TP5WKJyqveI/AAAAAAAADBk/D_44OyyTEnA/s72-c/vxx_vxz.png' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-6429187360488389237</id><published>2010-11-25T14:32:00.000-08:00</published><updated>2010-11-25T14:32:19.902-08:00</updated><title type='text'>ActiveX vs Java API what's the difference?</title><content type='html'>There has been quite a discussion on &lt;a href="http://epchan.blogspot.com/2009/07/free-matlab-to-interactive-brokers-api.html"&gt;Chans&lt;/a&gt; blog about ActiveX vs Java API. One of the claims presented by Anonymous is that ActiveX is missing ticks when another function is executing. This alarmed me as I rely heavily on the &amp;nbsp;ActiveX api.&lt;br /&gt;So I've tested this claim: while tws events are handled in the background by the wrapper and listener classes, I start a ~10 second 100% cpu intensive task in the foreground. After this I examine the timestamps of each tick.&lt;br /&gt;The results are in the figure:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_j6utrVcrL9k/TO7iWl2xY2I/AAAAAAAAC7s/ZbO7jSCLkaI/s1600/tick_timing.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="236" src="http://4.bp.blogspot.com/_j6utrVcrL9k/TO7iWl2xY2I/AAAAAAAAC7s/ZbO7jSCLkaI/s320/tick_timing.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;On the horizontal axis is the logged tick number and tick timestamp is plotted vertically. The cpu is loaded between the red lines. This graph shows that during cpu load no ticks reach the listener class, however no events are lost as they are all fired up just after the cpu has some available time.&lt;br /&gt;The other claims were quite vague as 'performance', as far as I'm concerned I've never had any performance issues using activeX. And last but not least, if you need 'performance' why do you use Matlab??? I would directly go for some native language and FIX CTCI api.&lt;br /&gt;&lt;br /&gt;So I'm sticking with the ActiveX for now.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-6429187360488389237?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/6429187360488389237/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/11/activex-vs-java-api-whats-difference.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/6429187360488389237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/6429187360488389237'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/11/activex-vs-java-api-whats-difference.html' title='ActiveX vs Java API what&apos;s the difference?'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_j6utrVcrL9k/TO7iWl2xY2I/AAAAAAAAC7s/ZbO7jSCLkaI/s72-c/tick_timing.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-3346579596277111379</id><published>2010-11-15T10:52:00.000-08:00</published><updated>2010-11-15T10:53:34.943-08:00</updated><title type='text'>HOWTO: Wrap Interactive Brokers TWS api in a Matlab class.</title><content type='html'>There are many ways of interfacing Matlab with Interactive Brokers API. The main choice is of course&amp;nbsp;whether you are going to buy a commercial product (like quant2ib) or go the DIY route (a-la&amp;nbsp;&lt;a href="http://www.maxdama.com/2008/12/interactive-brokers-via-matlab.html"&gt;Max Dama&lt;/a&gt;). For me it was the second option. The reason is that not only am I short of $600 for an interface, but in most cases a commercial product will have some limitations compared to your own or open-source code.&lt;br /&gt;I've started with the code from Max that really got me a flying start, but his approach to interfacing is far from optimal. One would need a bunch of global variables and separate functions to get the data back and forth.&amp;nbsp;Synchronization&amp;nbsp;to events also becomes very difficult with this approach. Without object oriented design, one would quickly become bogged down in 'spaghetti' code.&lt;br /&gt;So I went another route: wrapping all of the tws stuff in a single class and using events for&amp;nbsp;synchronization. This was not trivial to do, as passing class methods as a callback function proved quite tricky. &amp;nbsp;With code from &lt;a href="http://leptokurtosis.com/main/node/15"&gt;leptokurtosis.com&lt;/a&gt;&amp;nbsp;(thanks!) this issue was solved and I finally managed to create a descent wrapper.&lt;br /&gt;&lt;br /&gt;Here is the base code for the wrapper : &lt;a href="http://quantum.meplaza.nl/ib_matlab_tutorial.zip"&gt;ib_matlab_tutorial.zip&lt;/a&gt;&lt;br /&gt;It's a basic skeleton that can be extended further. At this moment only market data subscriptions &amp;nbsp;are implemented. To add order placing, historical data etc. you'll need to add some code, but from here on most of the heavy lifting is already done.&lt;br /&gt;&lt;br /&gt;How to use:&lt;br /&gt;- install tws ActiveX , enable api connection in tws&lt;br /&gt;- start TWS&lt;br /&gt;- open demoScript.m &amp;nbsp;and step through the code blocks to see what happens.&lt;br /&gt;&lt;br /&gt;File description:&lt;br /&gt;CTws - main wrapper class .&lt;br /&gt;CSymbolData - used by CTws as a data container&lt;br /&gt;CListener - basic example of a listener class, listening to tws events.&lt;br /&gt;GenericIbEvent - used for passing symbol data within an event (written by leptokurtosis.com)&lt;br /&gt;demoScript - basic tws/listener demo&lt;br /&gt;&lt;br /&gt;Have fun!&lt;br /&gt;Any remaks/improvements are welcome!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-3346579596277111379?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/3346579596277111379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/11/howto-wrap-interactive-brokers-tws-api.html#comment-form' title='19 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3346579596277111379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3346579596277111379'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/11/howto-wrap-interactive-brokers-tws-api.html' title='HOWTO: Wrap Interactive Brokers TWS api in a Matlab class.'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>19</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-2886407289490672213</id><published>2010-10-09T12:41:00.000-07:00</published><updated>2010-10-09T12:41:42.030-07:00</updated><title type='text'>Behold the ideal database tooling combination</title><content type='html'>As I've mentioned earlier, I've spent most of my time in the last year managing data instead of developing strategies. Its a dirty job... &lt;s&gt;but somebody's gonna do it&amp;nbsp;&lt;/s&gt;&amp;nbsp;and with the right tooling somebody has already done it for you.&lt;br /&gt;In my search for the ideal database tooling I've tried native matlab files, excel, MySql, Access and plain csv, before settling for far-from-ideal xml - *.mat combination. Still, a lot of programming is required to manage data this way.&lt;br /&gt;A couple of days ago I finally found the solution: &lt;a href="http://www.sqlite.org/"&gt;SQLite &lt;/a&gt;+ &lt;a href="http://mksqlite.berlios.de/mksqlite_eng.html"&gt;mksqlite &lt;/a&gt;. Both packages are simply excellent: a serverless database contained in a single file plus a very fast matlab interface. The best thing with this combination is that one does not need a db server or any drivers to take full advantage of an SQL database.&lt;br /&gt;Thanks to the open source community, I can now really start focusing on strategy development instead of data management.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-2886407289490672213?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/2886407289490672213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/10/behold-ideal-database-tooling.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/2886407289490672213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/2886407289490672213'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/10/behold-ideal-database-tooling.html' title='Behold the ideal database tooling combination'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-2257215889191437841</id><published>2010-09-26T12:57:00.000-07:00</published><updated>2010-09-26T12:57:18.878-07:00</updated><title type='text'>Yahoo historical data downloader</title><content type='html'>I've taken a look inside the&lt;i&gt; get_hist_stock_data.m&lt;/i&gt; from &lt;a href="http://luminouslogic.com/matlab-stock-market-scripts"&gt;Luminous Logic&lt;/a&gt;&amp;nbsp;, the script that I was using for a looong time. The code seemed like it could use a little bit of cleaning up, but I've ended up rewriting it completely. The resulting code is just several lines long , accepts precise historical period and returns a struct.&lt;br /&gt;&lt;br /&gt;Code: &amp;nbsp;&lt;a href="http://quantum.meplaza.nl/download_hist_yahoo_data.m"&gt;download_hist_yahoo_data.m&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-2257215889191437841?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/2257215889191437841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/09/yahoo-historical-data-downloader.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/2257215889191437841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/2257215889191437841'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/09/yahoo-historical-data-downloader.html' title='Yahoo historical data downloader'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-6667956371904336762</id><published>2010-06-27T13:32:00.000-07:00</published><updated>2010-06-27T13:32:00.295-07:00</updated><title type='text'>Where did all the money go???</title><content type='html'>We've seen the markets rise and fall all over again. Sometimes I've asked myself a question : ' When the prices fall, where does all the money go?' I could imagine that 'smart money' left first and somebody made a huge profit (just like in any pyramid scheme). Never really got the time to think about it, until today. Today somebody asked me this question and while trying to explain it all suddenly became clear. The 'money' was never really there. A good illustration are the house prices. Imagine you bought a house for $500k a couple of years ago. The prices have risen since then to 550k, so you've made a virtual profit of 10%. Now the prices fall again and you start loosing 'virtual' money. This is the same as unrealized pnl. The good thing with real estate is that they have some real underlying value, while for the stocks the underlying value is often completely unclear.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-6667956371904336762?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/6667956371904336762/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/06/where-did-all-money-go.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/6667956371904336762'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/6667956371904336762'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/06/where-did-all-money-go.html' title='Where did all the money go???'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-3915209878762656754</id><published>2010-06-07T09:05:00.000-07:00</published><updated>2010-06-07T09:05:46.537-07:00</updated><title type='text'>Strange things that happen at the open</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_j6utrVcrL9k/TA0Xgv9d5SI/AAAAAAAACv0/r9prB8d0mTE/s1600/SSI_opening.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_j6utrVcrL9k/TA0Xgv9d5SI/AAAAAAAACv0/r9prB8d0mTE/s320/SSI_opening.png" /&gt;&lt;/a&gt;&lt;/div&gt;Each stock has its quoted open price. But how is it formed? I've logged tick data during todays opening&amp;nbsp; and plotted it in the figure below. Each point represents a tick, the color tick type (ask, bid, trade). Take a note that NYSE opens at 15:30 in my time zone. According to Google finance, the stock opened at $37.5.&lt;br /&gt;As you can see, the opening price jumps all over the place in the first minutes of trading. Seems that traders are not sure of what the fair price is, but it does settle after about one minute.&lt;br /&gt;One conclusion is clear, if you want a stock against its opening price, you got to act &lt;b&gt;fast.&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-3915209878762656754?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/3915209878762656754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/06/strange-things-that-happen-at-open.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3915209878762656754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3915209878762656754'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/06/strange-things-that-happen-at-open.html' title='Strange things that happen at the open'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_j6utrVcrL9k/TA0Xgv9d5SI/AAAAAAAACv0/r9prB8d0mTE/s72-c/SSI_opening.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-2394813398699900309</id><published>2010-05-31T03:00:00.000-07:00</published><updated>2010-05-31T03:00:06.056-07:00</updated><title type='text'>Estimating the fair price of ETF components</title><content type='html'>The essence of every arbitrage strategy (in any timeframe) is an estimator of a 'fair price'. Once you got that, the rest is easy: just buy the stocks that are too low relative to the fair value and sell the overpriced ones.&lt;br /&gt;Now the hard part: how do we estimate the fair value? Solutions could be countless: linear regression, neural networks, kalman filter, weight in the index, mean value, ... you name it. And of course the ETF tracker itself.&lt;br /&gt;In the example below I've taken a look at the old time favorite group of stocks : the XLE. The data&amp;nbsp; plotted is a cumulative return for 1 week history with 15 minutes sampling rate. Notice the fat lines: the blue one is just the mean return of the group and the red one is the return of XLE itself.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_j6utrVcrL9k/TAOIjnhg3cI/AAAAAAAACvs/4xrK_p_f1R8/s1600/xle_returns.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_j6utrVcrL9k/TAOIjnhg3cI/AAAAAAAACvs/4xrK_p_f1R8/s320/xle_returns.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;It turns out that the returns of XLE are almost identical to the mean of the group! A quick conclusion from this is that the ETF itself is as good estimator as just the mean value!. Another conclusion could be that one does not need a phd-rocket-science-chaos-theory sophistication to&amp;nbsp; design a descent arbitrage strategy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-2394813398699900309?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/2394813398699900309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/05/estimating-fair-price-of-etf-components.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/2394813398699900309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/2394813398699900309'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/05/estimating-fair-price-of-etf-components.html' title='Estimating the fair price of ETF components'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_j6utrVcrL9k/TAOIjnhg3cI/AAAAAAAACvs/4xrK_p_f1R8/s72-c/xle_returns.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-3066826538961104857</id><published>2010-05-29T07:16:00.000-07:00</published><updated>2010-05-29T07:22:49.766-07:00</updated><title type='text'>Intraday data downloader for TWS</title><content type='html'>Having descent historical data is essential for developing a good strategy. But access to (free) intraday data is almost non-existent. However, if you have an account at interactive brokers, they let you download historical data for free.&lt;br /&gt;In the last couple of weeks I've been very busy with implementing an intraday arbitrage strategy. The strategy itself is very simple with zero (!!!)&amp;nbsp; parameters, but the amount of code needed for data and error handling is much more than I've anticipated. Have been coding data handling and conversion for a couple of weeks now with one clear conclusion: I hate programming. So this is how it feels to be the low-level software engineer aka code-monkey ;-). &amp;nbsp; &lt;br /&gt;However, during this process I managed to get Matlab to talk to TWS through their API and written a historic data downloader that could spare some boring work for other people.&lt;br /&gt;The code is based on tutorial written by &lt;a href="http://www.maxdama.com/2009/02/more-matlabib-code.html"&gt;Max Dama&lt;/a&gt; (thanks Max!). You should follow the steps described on his page to install and configure the tws api. After that just fire it up:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;hDataIntraday = getHistoryTws(tickers, filename_copy ,period, barsize);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Keep in mind that IB imposes restrictions on data download :&amp;nbsp; &lt;a href="http://www.interactivebrokers.com/php/apiUsersGuide/apiguide/api/historical_data_limitations.htm#XREF_93621_Historical_Data"&gt;Historical Data Limitations&lt;/a&gt;&lt;br /&gt;The data is downloaded to a structure:&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;hDataIntraday :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stocks: [1x20 struct]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ticker: 'AEE'&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; history: [1x1 struct]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dates: [253x1 double]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; open: [253x1 double]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; close: [253x1 double]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; volume: [253x1 double]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ticker: 'AEP'&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; history: [1x1 struct]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dates: [253x1 double]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; open: [253x1 double]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; close: [253x1 double]&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; volume: [253x1 double]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; last_update: '29-May-2010 16:07:21'&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The code: &lt;a href="http://www.quantum.meplaza.nl/tws_history_downloader.zip"&gt;tws_history_downloader.zip&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-3066826538961104857?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/3066826538961104857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/05/intraday-data-downloader-for-tws.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3066826538961104857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3066826538961104857'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/05/intraday-data-downloader-for-tws.html' title='Intraday data downloader for TWS'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-7295243689147537499</id><published>2010-03-22T16:51:00.000-07:00</published><updated>2010-03-22T16:51:57.411-07:00</updated><title type='text'>Forex costs</title><content type='html'>Once again I must come to the conclusion that Forex costs are too high for a descent high frequency strategy. By high frequency I mean time windows of less than an hour. Everything I've tried so far gets killed by the spreads, very frustrating. When the arbitrage spread is just 2-3 times larger than the broker spread all the odds shift against my favor.&lt;br /&gt;As the arbitrage combinations are quite limited in Forex, there are probably just too many players with access to much tighter spreads playing this game. No easy money here, moving on...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-7295243689147537499?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/7295243689147537499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/03/forex-costs.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7295243689147537499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7295243689147537499'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/03/forex-costs.html' title='Forex costs'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-7497332525956955083</id><published>2010-03-21T05:43:00.000-07:00</published><updated>2010-03-21T05:43:20.620-07:00</updated><title type='text'>Transaction costs : forex vs stocks</title><content type='html'>I've decided to take a quick look at the transaction costs involved in forex versus stock trading.&amp;nbsp;Most of the forex brokers brag about 'no transaction costs', but the impact of the ask-bid spread is often unclear. The results were&amp;nbsp; as expected: forex has higher transaction costs than the stock market. .&lt;br /&gt;To enable the comparison of the costs I've defined a &lt;i&gt;cost_ratio=spread/(max(bid)-min(bid)); &lt;/i&gt;. In other words, the cost ratio is the transaction cost divided by the price range in some given period of time. I am using a week. To calculate the cost ratio for forex I've taken the spreads for 'USD/CAD'&amp;nbsp;&amp;nbsp;&amp;nbsp; 'USD/CHF'&amp;nbsp;&amp;nbsp;&amp;nbsp; 'USD/DKK'&amp;nbsp;&amp;nbsp;&amp;nbsp; 'USD/NOK'&amp;nbsp;&amp;nbsp;&amp;nbsp; 'USD/SEK' pairs relative to their weekly range and then averaged them. (data source: Gain Capital)&lt;br /&gt;&lt;br /&gt;The cost ratio for a stock is calculated in a similar way. SPY has a weekly range of about 2% (rough estimate) , one share price is around&amp;nbsp; $115, so the weekly range is 0.02*115 = $2.3. Transaction costs at IB are $0.005 a share, resulting in a cost ratio of&amp;nbsp; 2.2e-3. &lt;br /&gt;&lt;br /&gt;The results are in the graph below:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_j6utrVcrL9k/S6YSxqqxjTI/AAAAAAAACvA/84KZkP5JnnY/s1600-h/transaction_costs.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_j6utrVcrL9k/S6YSxqqxjTI/AAAAAAAACvA/84KZkP5JnnY/s320/transaction_costs.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The cost ratio for forex seemst to be around 5 times higher than for stocks. This changes of course if a lower priced stock is traded. For a $20 share with the same weekly range , the price ratios between forex and stock market are roughly equeal.&lt;br /&gt;&lt;br /&gt;I guess the difference in cost ratios is the price you pay for liquidity, minimal slippage and real-time data.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-7497332525956955083?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/7497332525956955083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/03/transaction-costs-forex-vs-stocks.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7497332525956955083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/7497332525956955083'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/03/transaction-costs-forex-vs-stocks.html' title='Transaction costs : forex vs stocks'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_j6utrVcrL9k/S6YSxqqxjTI/AAAAAAAACvA/84KZkP5JnnY/s72-c/transaction_costs.png' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-1369169302264569280</id><published>2010-03-18T13:19:00.000-07:00</published><updated>2010-04-06T00:53:27.702-07:00</updated><title type='text'>Intraday data handling can be easy, when you've got the right tools.</title><content type='html'>The title of this post could be just as well 'In praise of Matlab' ( or possibly SciLab or R, but &lt;b&gt;not &lt;/b&gt;Excel). Yesterday it took me only a couple of hours to complete a task that otherwise would be almost impossible to achieve without the right tooling. I was so excited about how easy it turned out to be that I decided to share my experience.&lt;br /&gt;For some time now I was going to take a look at Forex intraday data. It tempted me because of the law of&amp;nbsp; 'large numbers'. A model should be allowed to make a couple of hundred of trades before its profitability can be estimated reliably. For a swing-trading system this should mean at least half a year paper trading and I just don't like to wait. In case of an intraday system, one only needs a couple of days!&amp;nbsp; Forex data is freely available (&lt;a href="http://ratedata.gaincapital.com/"&gt;intraday data archive&lt;/a&gt;) &amp;nbsp; making it a good candidate to test some intraday strategies.&lt;br /&gt;But once you download some data, a problem becomes obvious: the data is sampled at irregular intervals, making it very difficult to compare one dataset to another. Take a look at the beginning of the data files:&lt;br /&gt;USD/CHF: &lt;br /&gt;lTid,cDealable,CurrencyPair,RateDateTime,RateBid,RateAsk&lt;br /&gt;1051976017,D,USD/CHF,2010-01-31 17:04:45,1.060100,1.060600&lt;br /&gt;1051976080,D,USD/CHF,2010-01-31 17:05:20,1.060200,1.060600&lt;br /&gt;1051976102,D,USD/CHF,2010-01-31 17:05:22,1.060100,1.060600&lt;br /&gt;1051976119,D,USD/CHF,2010-01-31 17:05:22,1.060200,1.060700&lt;br /&gt;------------------------------------------------------------------------&lt;br /&gt;USD/CAD&lt;br /&gt;lTid,cDealable,CurrencyPair,RateDateTime,RateBid,RateAsk&lt;br /&gt;1051975015,D,USD/CAD,2010-01-31 17:01:50,1.070500,1.071000&lt;br /&gt;1051975069,D,USD/CAD,2010-01-31 17:01:56,1.070500,1.071100&lt;br /&gt;1051976049,D,USD/CAD,2010-01-31 17:05:14,1.070500,1.071200&lt;br /&gt;1051976441,D,USD/CAD,2010-01-31 17:06:10,1.070600,1.071200&lt;br /&gt;&lt;br /&gt;The sampling time seems to vary between less than a second to more than a minute! Even if you don't want to compare these two datasets, the data is still unusable for a backtest.&lt;br /&gt;&lt;br /&gt;Now imagine trying to align these datasets in Excel. If somebody has an idea, please let me know ;-).&lt;br /&gt;However, in a technical software tool (like Matlab ) there should be an interpolation function.&lt;br /&gt;In Matlab it is the wonderful &lt;i&gt;interp1&lt;/i&gt; . It accepts available data along with a new vector of time values for interpolation.&lt;br /&gt;I've used a 10-second interval for interpolation, while synchronizing start times between different datasets. The result is a neat matrix with prices at even time periods. Of course this introduces an error , but looking at the interpolated data (see graph below, deeply zoomed in), less than 1/2 pip, nothing serious.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_j6utrVcrL9k/S6KJ-dAbSRI/AAAAAAAACuw/gXXvPWA0jAk/s1600-h/data_interpolation.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_j6utrVcrL9k/S6KJ-dAbSRI/AAAAAAAACuw/gXXvPWA0jAk/s320/data_interpolation.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;Again, it gives me a headache just thinking about having to complete this task without the right tooling.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-1369169302264569280?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/1369169302264569280/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/03/intraday-data-handling-can-be-easy-when.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1369169302264569280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1369169302264569280'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/03/intraday-data-handling-can-be-easy-when.html' title='Intraday data handling can be easy, when you&apos;ve got the right tools.'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_j6utrVcrL9k/S6KJ-dAbSRI/AAAAAAAACuw/gXXvPWA0jAk/s72-c/data_interpolation.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-4845865223434336515</id><published>2010-03-13T15:55:00.000-08:00</published><updated>2010-03-13T15:55:49.434-08:00</updated><title type='text'>The temptation of overfitting and how to resist it.</title><content type='html'>One of the greatest temptations when designing a&amp;nbsp; quantitative system is&amp;nbsp; without a doubt overfitting (or data snooping). Sometimes it is so evident that only a novice can get fooled by it, sometimes really hard to point out. For example, everybody knows that you should not try to predict the future prices by linear extrapolation. The higher the polinome order you are using, the better it will fit the training data and the worse it will fit the test data.&lt;br /&gt;Still, I often come across traders running insane optimizations of a 10+ parameter model. But the truth is, if your &lt;b&gt;data is bad&lt;/b&gt; , no amount of optimization will help. Imagine a true random walk process. It can not be predicted by definition, but by pure chance it can produce something that *looks* predictable. These situations can lead to a life-long quest for a 'jesus indicator', which of course can not be found. Speaking of indicators I must say that I do not believe in them. Well, I do use a couple occasionally, but for me it is only tooling. Just like a wrench could be useful from time to time as a tool, but there is really no need to 'believe' in it.&lt;br /&gt;I've spent a lot of time lately developing a robust model and things are going in the right direction. Here is an example of a P&amp;amp;L from one of the better models. It does not account for transaction costs and slippage yet, but the good thing is that the result is not optimized in any way.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_j6utrVcrL9k/S5wjZrjKvAI/AAAAAAAACug/44nD5irLEKY/s1600-h/pnl_portfolio.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_j6utrVcrL9k/S5wjZrjKvAI/AAAAAAAACug/44nD5irLEKY/s320/pnl_portfolio.png" /&gt;&lt;/a&gt;&lt;/div&gt;My way of avoiding overfitting is&lt;br /&gt;&lt;ul&gt;&lt;li&gt;making a hypothesis of a physical phenomenon, and testing it on multiple datasets. If the existence of&amp;nbsp; the phenomenon is proven, only then a robust model can be bult.&lt;/li&gt;&lt;li&gt;avoiding models that produce negative sharpe for any model settings&lt;/li&gt;&lt;li&gt;optimizing the &lt;b&gt;data instead of the&lt;/b&gt; &lt;b&gt;model. &lt;/b&gt;In other words, if a general model does not work on your data, go find a better one.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-4845865223434336515?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/4845865223434336515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/03/temptation-of-overfitting-and-how-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4845865223434336515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4845865223434336515'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/03/temptation-of-overfitting-and-how-to.html' title='The temptation of overfitting and how to resist it.'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_j6utrVcrL9k/S5wjZrjKvAI/AAAAAAAACug/44nD5irLEKY/s72-c/pnl_portfolio.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-1424928805627280170</id><published>2010-02-25T15:35:00.000-08:00</published><updated>2010-02-26T03:51:16.796-08:00</updated><title type='text'>Using VIX for volatility correction</title><content type='html'>Market neutral strategies often rely on a relative mispricing of two instruments. One of the challenges I've been facing is how to keep this mispricing constant in time, allowing it to stretch much further before initiating a trade in times of high market volatility. &lt;br /&gt;A solution I've come up with is using the VIX index as a correction measure. It seems to work much better than a moving window estimation based on the data itself.&amp;nbsp; The formula I'm using for correction is&amp;nbsp; C = (100-VIX)/100 . The spread is then multiplied by C.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_j6utrVcrL9k/S4cISsZRRPI/AAAAAAAACtI/tk70HL2LD5k/s1600-h/vix_correction.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_j6utrVcrL9k/S4cISsZRRPI/AAAAAAAACtI/tk70HL2LD5k/s320/vix_correction.png" /&gt;&lt;/a&gt;&amp;nbsp; &lt;/div&gt;Upper graph: VIX , lower graph : real and corected spreads. &lt;br /&gt;&lt;br /&gt;Notice how the corrected spread remains stable through the end of 2008.&lt;br /&gt;&lt;br /&gt;P.S. The spread shown is a relative mispricing in time an not an actual X/Y ratio.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-1424928805627280170?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/1424928805627280170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/02/using-vix-for-volatility-correction.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1424928805627280170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1424928805627280170'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/02/using-vix-for-volatility-correction.html' title='Using VIX for volatility correction'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_j6utrVcrL9k/S4cISsZRRPI/AAAAAAAACtI/tk70HL2LD5k/s72-c/vix_correction.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-57886452022433528</id><published>2010-02-17T14:30:00.000-08:00</published><updated>2010-02-17T14:44:32.575-08:00</updated><title type='text'>Probability mapping (2)</title><content type='html'>While building a model based on the probability mapping from the previous post I wasn't quite satisfied with the initial results. So I took a step back to a one dimensional state space and plotted the 5 day forecast of the XLE/XOM vs bollinger %b. Zero on the x-axis corresponds with -3 sigma and 100 with +3 sigma deviation . Y-axis shows the ratio between XLE/XOM&amp;nbsp; 5 days into the future and today .&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_j6utrVcrL9k/S3xtpqZ5lFI/AAAAAAAACtA/O-er9YmWAAY/s1600-h/bollinger_classification.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_j6utrVcrL9k/S3xtpqZ5lFI/AAAAAAAACtA/O-er9YmWAAY/s320/bollinger_classification.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The figure shows just how difficult it is to forecast the movement of the ratio. Ideally, the data should follow a band from upper left to lower right corner. Instead, it is quite hard to see any trend present. After a linear fit (red line) some trend can be found still. Note that around 50 pct_b it is exactly coin flip between increase and&amp;nbsp; decrease in XLE/XOM.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-57886452022433528?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/57886452022433528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/02/probability-mapping-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/57886452022433528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/57886452022433528'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/02/probability-mapping-2.html' title='Probability mapping (2)'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_j6utrVcrL9k/S3xtpqZ5lFI/AAAAAAAACtA/O-er9YmWAAY/s72-c/bollinger_classification.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-4864420297203593742</id><published>2010-02-16T06:40:00.000-08:00</published><updated>2010-02-17T11:01:30.039-08:00</updated><title type='text'>Probability mapping</title><content type='html'>Here is a nice idea I've got during cross-country skiing this weekend. The 'classic' way of trading pairs is defining some measure of divergence from the mean, such as z-score. Outside some threshold a buy or sell signal is triggered. This brought me to thinking about what we are actually doing here. In essence, we are using a linear classifier in a 1-d space. By optimizing the model, the classifier is trained for an optimal value. People familiar with pattern recognition know that the linear classifier is the most basic and limited tool there is.&lt;br /&gt;Having quite a background in &lt;a href="http://en.wikipedia.org/wiki/Q-learning"&gt;Q-learning&lt;/a&gt; (my masters thesis), I understand its beautiful ability to map a state space to an expected reward, elegantly and without any models. Doesn't trading in general boil down to state-reward mapping? For sure!&lt;br /&gt;I have tried different implementations of reinforcement learning without much success. But this weekend I managed to combine some ideas from pattern recognition and RL to an implementation that could work.&lt;br /&gt;Some people are probably wondering by now: ' Here we go with the AI bullshit again!'. I'd like to call it probability mapping. Also, probably many of the advanced quantitative traders are already using it. Its all about estimating the chances of a bet at a set of certain conditions.&lt;br /&gt;First, I define the conditions, called 'feature 1' and 'feature 2'. Two features means a two dimensional feature space, nothing keeps us from making it more (or less) dimensional, but since my monitor can best visualize two dimensions I choose that number. In my case, both features are oscillators based on cumulative returns over past x days. Feature 1 uses 3 days averaging and feature 2 20 days. Any other measure could be used (RSI, Stochastics, etc).&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_j6utrVcrL9k/S3qoo4Kb7wI/AAAAAAAACso/ghijamEPCCM/s1600-h/features.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_j6utrVcrL9k/S3qoo4Kb7wI/AAAAAAAACso/ghijamEPCCM/s320/features.png" /&gt;&lt;/a&gt;&lt;/div&gt;In the figure above the ratio between XLE and XOM is plotted along with two oscillators. It is clear that a high oscillator value correlates with the subsequent drop in the ratio.&lt;br /&gt;Normally you could start applying threshold conditions from here based on oscillator levels, but i want to go a couple of steps further.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_j6utrVcrL9k/S3qps9Y45YI/AAAAAAAACsw/WXTDONljz9o/s1600-h/feature_map.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_j6utrVcrL9k/S3qps9Y45YI/AAAAAAAACsw/WXTDONljz9o/s320/feature_map.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;So now I plot my state map for all values of feature 1 and 2 along with the corresponding future XLE/XOM ratio after 5 days. A green dot represents increase and red dot decrease of the XLE/XOM ratio.&lt;br /&gt;From this map an estimation can be made how likely it is for the ratio to go up or down for each combination of the features. Let's call it 'Sharpe surface'.&amp;nbsp; I define it similar to the sharpe ratio:&amp;nbsp; &lt;i&gt;mean(20 nearest neighbors)/std(20 nearest neighbors).&lt;/i&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a aiotarget="false" aiotitle="" href="http://1.bp.blogspot.com/_j6utrVcrL9k/S3qrfGQg0JI/AAAAAAAACs4/6WFShPlWSYo/s1600-h/probability_surface.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_j6utrVcrL9k/S3qrfGQg0JI/AAAAAAAACs4/6WFShPlWSYo/s320/probability_surface.png" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&amp;nbsp;Scanning the feature space gives me the nice plot as above (note that the vertical axis is flipped over compared to the previous figure).&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;The interpretation of the sharpe surface is very simple: expect the XLE/XOM ratio to rise in red areas and drop in the blue. This is very much in line with common sense:&amp;nbsp; low values of both features correspondent with anticipated increase of the ratio (see feature 2 &amp;lt;20 or feature 1 &amp;lt; 20).&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Again, normally we would use just one of the dimensions and put thresholds somewhere around 20 and 80. But with this probability mapping we can go for cherry picking!&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Files: &lt;a href="http://www.quantum.meplaza.nl/probability_mapping.zip"&gt;probability_mapping.zip&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Any remarks about the code are very welcome.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-4864420297203593742?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/4864420297203593742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/02/probability-mapping.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4864420297203593742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4864420297203593742'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/02/probability-mapping.html' title='Probability mapping'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_j6utrVcrL9k/S3qoo4Kb7wI/AAAAAAAACso/ghijamEPCCM/s72-c/features.png' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-5117740559467169112</id><published>2010-01-30T04:59:00.000-08:00</published><updated>2010-01-30T04:59:39.962-08:00</updated><title type='text'>Which sharpe is good enough?</title><content type='html'>I've made some progress designing a market neutral strategy. My test set is &lt;a href="http://www.quantum.meplaza.nl/stocks_XLE.mat"&gt;XLE&lt;/a&gt; (stocks and its component stocks (2001-2009). The strategy trades each stock against the XLE using bollinger bands. A trade is entered when the spread between XLE and a stock exceedes 2. A position is closed after the spread crosses zero. As a safety measure, a stop-loss at 5% is implemented together with a maximum holding period of 60 days. Transaction costs are 0.2% one-way.&lt;br /&gt;Generally I get sharpe ratios around 0.8&amp;nbsp; without optimization ( z-score and window size are fixed).&lt;br /&gt;&lt;br /&gt;Now I'm unsure how far can I push the simple stock-index arbitrage. If I start optimizing for a specific stock, overfitting seems to occur very fast.&lt;br /&gt;&lt;br /&gt;I still see some possible improvements to the strategy, but I'm not sure if I'll be able to push it above 1. There should be a limit how much profit you can squeeze from stock-etf arbitrage anyway.&lt;br /&gt;&lt;br /&gt;The question I'm asking myself now 'is this good enough?'. Apart from a personal preference about risk I'm very curious about the results achieved by others.&lt;br /&gt;&lt;br /&gt;Which Sharpe ratio is 'good enough' for stock-index arbitrage in your opinion?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-5117740559467169112?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/5117740559467169112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2010/01/which-sharpe-is-good-enough.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5117740559467169112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5117740559467169112'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2010/01/which-sharpe-is-good-enough.html' title='Which sharpe is good enough?'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-1459395720285663591</id><published>2009-12-29T14:11:00.000-08:00</published><updated>2009-12-29T14:14:43.743-08:00</updated><title type='text'>A note on index tracking</title><content type='html'>A couple of years ago,  Ernie has started an interesting discussion on his &lt;a href="http://epchan.blogspot.com/2007/02/in-looking-for-pairs-of-financial.html"&gt;blog&lt;/a&gt;. A reader named 'L' was having doubts about ability of a small portfolio to track an index out of sample. And to be honest, he has a point, starting with only one stock in the portfolio you are most likely to get a random walk instead of tracking. On the other hand, having N-1 stocks in the portfolio should result in almost perfect tracking.&lt;br /&gt;I've decided to verify the results and test tracking portfolios for the XLE. The results for 5 'best' portfolios consisting of only 5 stocks are given below.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_j6utrVcrL9k/Szp9hBP4IlI/AAAAAAAACrk/B7SPY3is96s/s1600-h/xle_portfolios.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_j6utrVcrL9k/Szp9hBP4IlI/AAAAAAAACrk/B7SPY3is96s/s320/xle_portfolios.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;Blue charts are in-sample training and red is true out-of-sample data (no re-balancing). Look how well three of them survived the 2008 debacles. &lt;br /&gt;I must note that these portfolios have probably not enough variance for profitable trading, but that should be easy to fix.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-1459395720285663591?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/1459395720285663591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/note-on-index-tracking.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1459395720285663591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1459395720285663591'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/note-on-index-tracking.html' title='A note on index tracking'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_j6utrVcrL9k/Szp9hBP4IlI/AAAAAAAACrk/B7SPY3is96s/s72-c/xle_portfolios.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-4723173384015225703</id><published>2009-12-25T13:30:00.000-08:00</published><updated>2009-12-25T13:48:06.767-08:00</updated><title type='text'>Overachievers vs underperformers</title><content type='html'>&lt;a href="http://www.quantum.meplaza.nl/CarolAlexanderCoint.pdf"&gt;This paper &lt;/a&gt;got me thinking: market-neutral trading of two stock baskets seems like an elegant strategy. A 'long' basket should mainly consist of favorable stocks, performing above the index. It is then traded against a 'short' basket of underperformers. So each trade should deliver the alpha of the long and -alpha of the short basket. Seems like a great idea, but how to identify the right stocks? How consistent is the over- and underperformance?&lt;br /&gt;&amp;nbsp;Here is my first shot at this. &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_j6utrVcrL9k/SzUs4wd5aQI/AAAAAAAACrU/6pFTBW3Ce6g/s1600-h/xle_components_performance.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_j6utrVcrL9k/SzUs4wd5aQI/AAAAAAAACrU/6pFTBW3Ce6g/s320/xle_components_performance.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;In the graph above the average 10-day performance of a stock is plotted relative to the XLE index. Some patterns can be clearly seen, but to be honest, I'm not really thrilled.&lt;br /&gt;Maybe I'll try using bollinger next time.&lt;br /&gt;&lt;br /&gt;However, the cumulative returns seem much more interesting, through I don't have any particular use for it.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_j6utrVcrL9k/SzUxAOWRsHI/AAAAAAAACrc/zL8s6NH3xGM/s1600-h/xle_components_performance_cum.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_j6utrVcrL9k/SzUxAOWRsHI/AAAAAAAACrc/zL8s6NH3xGM/s320/xle_components_performance_cum.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I think a better way to approach stock rating is to look at the stationarity of the tracking error.&lt;br /&gt;But for now, I'll stick with building a cointegrating portfolio and trading it against a benchmark.&lt;br /&gt;&lt;br /&gt;Files: &lt;a href="http://www.quantum.meplaza.nl/stocks_XLE.mat"&gt;stocks_XLE.mat&lt;/a&gt;, &lt;a href="http://www.quantum.meplaza.nl/lag.m"&gt;lag.m&lt;/a&gt;, &lt;a href="http://www.quantum.meplaza.nl/analizeStock.m"&gt;analizeStock.m&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-4723173384015225703?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/4723173384015225703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/overachievers-vs-underperformers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4723173384015225703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/4723173384015225703'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/overachievers-vs-underperformers.html' title='Overachievers vs underperformers'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_j6utrVcrL9k/SzUs4wd5aQI/AAAAAAAACrU/6pFTBW3Ce6g/s72-c/xle_components_performance.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-8632790901514044807</id><published>2009-12-23T08:45:00.000-08:00</published><updated>2009-12-23T11:45:33.850-08:00</updated><title type='text'>What does Dickey-Fuller test tell us (not)?</title><content type='html'>I've been trying to build an index-cointegrating portfolio in the last couple of days. One of the crucial questions here is which criterion to use for stock combination ranking. Dickey-Fuller test is the first option that comes to mind. I know it tests for stationarity, but that is just a&amp;nbsp; part of what I'm looking for.&lt;br /&gt;You see, even when you have a stationary time series that has very little variance, it is also of very little use for trading, as you will probably&amp;nbsp; not earn the transaction costs back. (low variance is&amp;nbsp; a sign of market efficiency, in an ideal efficient market variance will be zero, eliminating any arbitrage opportunities). On the other hand, if a series is instationary with a low drift, but has plenty of variance, many good trading opportunities will exist.&lt;br /&gt;To test the DF-test I've simulated a combination of two AR(1) time series I(0.95) and I(1):&lt;br /&gt;&lt;i&gt;y&amp;nbsp; = (1-drift)*s + drift*d&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;/i&gt;&lt;br /&gt;where&lt;br /&gt;&lt;i&gt;s&lt;/i&gt; - stationary I(0.95) time series.&lt;br /&gt;&lt;i&gt;d-&amp;nbsp; &lt;/i&gt;non-stationary I(1) time series&lt;br /&gt;Both series have variance &lt;i&gt;alpha&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;I've varied &lt;i&gt;drift&lt;/i&gt; from 0 to 1 and&amp;nbsp; &lt;i&gt;alpha&lt;/i&gt; from 0.2 to 5.&amp;nbsp;&amp;nbsp; (0, 5) combination being most profitable. Increasing the &lt;i&gt;drift&lt;/i&gt; value effectively means a transition from stationary signal to random walk.&lt;br /&gt;The results are in the figure below:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_j6utrVcrL9k/SzJjkmPYOGI/AAAAAAAACq4/OHUS94_CmpU/s1600-h/df_performance.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_j6utrVcrL9k/SzJjkmPYOGI/AAAAAAAACq4/OHUS94_CmpU/s320/df_performance.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Just as I've thought, DF can not distinguish between different levels of variance. &lt;br /&gt;&lt;br /&gt;I clearly have a need for a better estimator, not looking for stationarity but for &lt;b&gt;variance/drift ratio&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Maybe it's time to blow the dust off the good old Fourier transform, looking for high spectral peaks.&lt;br /&gt;Probably an even better idea is to use wavelets for spectral decomposition and filtering, then estimate spectral density of each frequency band.&lt;br /&gt;Any other ideas?&lt;br /&gt;&lt;br /&gt;Files: &lt;a href="http://www.quantum.meplaza.nl/drift_model.m"&gt;drift_model.m&lt;/a&gt; , &lt;a href="http://www.quantum.meplaza.nl/semistat.m"&gt;semistat.m&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-8632790901514044807?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/8632790901514044807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/what-does-not-dickey-fuller-test-tell.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/8632790901514044807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/8632790901514044807'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/what-does-not-dickey-fuller-test-tell.html' title='What does Dickey-Fuller test tell us (not)?'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_j6utrVcrL9k/SzJjkmPYOGI/AAAAAAAACq4/OHUS94_CmpU/s72-c/df_performance.png' height='72' width='72'/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-3227351119621089305</id><published>2009-12-21T16:40:00.000-08:00</published><updated>2009-12-21T16:40:01.457-08:00</updated><title type='text'>Can open innovation give a competitive edge?</title><content type='html'>I believe it certainly can! Even more so, I believe a small company must use it to be able to compete against 'big boys'.&amp;nbsp; (if you don't know what open innovation is, take a look at the&amp;nbsp;&lt;a href="http://en.wikipedia.org/wiki/Open_innovation"&gt;Wikipedia&lt;/a&gt; ). My current full-time job is in the technology sector, working inside an RnD site about 1000 people strong. In my daily work I get to work with small(er) size subcontractors, companies ranging from 10 to 150 employees. My observation in the past couple of years is that 'big' is not always beautiful and 'small' is not much better. But open innovation could change this in favor of smaller sized companies.&amp;nbsp; What are the strengths of a big RnD? Usually it is a decent research budget and a large knowledge pool. Project organization is usually well organized, making it possible to handle very large projects (&amp;gt;50 fte). I've also experienced that these advantages come at a cost: bureaucracy, ill communication, heavy overhead, 'political' decisions etc. This is common to most large RnD's , as illustrated by Dilbert cartoons. Reading them daily I often find them spot-on, equally applicable to European and American companies alike.&lt;br /&gt;Smaller companies have their own disadvantages. While being extremely agile and efficient, they often lack professional organization and broad know-how. If only they could get the knowledge they need....&lt;br /&gt;This is where open innovation provides a competitive edge. I believe that the ways of doing research have been changing for the last couple of years and the rate of change is increasing. Information becomes readily available making it easier to build on ideas of others rather than reinventing the wheel. &lt;br /&gt;I've started this blog with open innovation in mind. Here I'll try to&lt;br /&gt;- share my ideas. Many of them will be incomplete, unpractical or just plain wrong. I really hope to get enough feedback to filter out the better ones.&lt;br /&gt;- share specifics on things that &lt;b&gt;don't&lt;/b&gt; work. In my professional work the 'don't do this' advice has proven to be most valuable. Hopefully I'll help somebody spare some time to come up with really great ideas (and then of course share them).&lt;br /&gt;A great example of open innovation in action: today I've come across &lt;a href="http://tradingwithmatlab.blogspot.com/2009/12/pairs-trading-cointegration-testing.html"&gt;this&lt;/a&gt; post. It really helped me to get a couple of thoughts together that have been floating in my head for weeks. Thinking of these ideas as puzzle pieces, I now know that all the pieces are there. Now I can start the tedious work of putting them in place.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-3227351119621089305?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/3227351119621089305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/can-open-innovation-give-competitive.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3227351119621089305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/3227351119621089305'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/can-open-innovation-give-competitive.html' title='Can open innovation give a competitive edge?'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-1093044642450495556</id><published>2009-12-15T07:52:00.000-08:00</published><updated>2009-12-15T08:30:28.497-08:00</updated><title type='text'>Where is the catch?</title><content type='html'>...is a question I usually ask myself when something  seems to be  going 'too well'. Up till now things were looking much too easy, so now seems the right time to start asking questions.&lt;br /&gt;Here is what I did:&lt;br /&gt;1. got a list of 800+ etfs in to Matlab from Yahoo.&lt;br /&gt;2. run a Dickey-Fuller test to establish potential trading pairs. Cointegration was only tested inside a category to avoid pairs with no 'physical' cointegration. Setting a threshold to 3.9 t-static I've got about 900 pairs. Later I've decided to ditch some categories like 'N/A' and 'Bear Market'.&lt;br /&gt;3. Let the 'Duck' strategy loose on the pool pair, let it figure out the optimal sharpe. (I've decided to use animal names for strategy tracking. Of course starting with 'not so cool' animals as rabbits, ducks is logical as early strategies will be not really great. I'll be  moving to panthers and tigers in the later stages of develpment). To elaborate more on the Duck, which I'll post later: this strategy tracks the ratio of a pair. Optimization is done on the moving window and z-level threshold.  For example: a trade is entered when z-spread is higher than 1.5 and exited when it reverts back to zero. Duck is plain and  simple, no fancy stuff like stop-loss or time limits.  I've let some big holes in backtesting, like not using training and test sets, not testing the data-snooping to the finest detail etc. But still, this step should give an *indication* on the returns achievable by the pairs.  After this step I'll reduce the 900 pair set to a 'profitable' set on which I'll continue my research.&lt;br /&gt;&lt;br /&gt;Good, quick and dirty, but let's take a look at the results.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_j6utrVcrL9k/Sye108BHlfI/AAAAAAAACqY/CVK5l4UC6lk/s1600-h/etf_pool.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 226px;" src="http://4.bp.blogspot.com/_j6utrVcrL9k/Sye108BHlfI/AAAAAAAACqY/CVK5l4UC6lk/s320/etf_pool.png" alt="" id="BLOGGER_PHOTO_ID_5415496998004954610" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The results provided by Duck are very encouraging: almost all pairs have positive sharpe, but the top of the list alarmed me. Take a closer look at the figure: sharpe ratios of well above 3 a possible even with a dumb duck strategy. Either I'm going to become rich much faster than expected  or I haven't thought about something important. I guess the latter.&lt;br /&gt;&lt;br /&gt;Ok, let's look at our runner-up, the MZO.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_j6utrVcrL9k/Sye3pQnbu2I/AAAAAAAACqg/NrdZlu2F2sc/s1600-h/mzo.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 182px;" src="http://2.bp.blogspot.com/_j6utrVcrL9k/Sye3pQnbu2I/AAAAAAAACqg/NrdZlu2F2sc/s320/mzo.png" alt="" id="BLOGGER_PHOTO_ID_5415498996399192930" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;This is where my bad feeling is justified: MZO has zero trading volume for many days! This would result in slippage (I guess) and all other sorts of trouble, like being unable to short the share.&lt;br /&gt;Now, what really confuses me is the fact that liquidity of an etf should be based on the underlying stock as explained &lt;a href="http://finance.yahoo.com/etf/education/05"&gt;here&lt;/a&gt;. And MZO has some really heavy weights behind it.&lt;br /&gt;&lt;br /&gt;The same goes for many of the promising etf pairs, they seem to miss liquidity.&lt;br /&gt;So now I'm a little confused: is it better to filter out the non-liquid etfs or start building my own share baskets and trading them against each other or bigger sized etfs?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-1093044642450495556?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/1093044642450495556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/where-is-catch.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1093044642450495556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/1093044642450495556'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/where-is-catch.html' title='Where is the catch?'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_j6utrVcrL9k/Sye108BHlfI/AAAAAAAACqY/CVK5l4UC6lk/s72-c/etf_pool.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-6097110944510986057</id><published>2009-12-13T01:55:00.001-08:00</published><updated>2009-12-13T02:07:32.498-08:00</updated><title type='text'>The most important question</title><content type='html'>when starting something is 'What do you want to achieve?'. And it is certainly true in case of quatitative trading. Even more so, this question should be answered in a measurable manner.&lt;br /&gt;It took me a couple of month and a lot of research to come up with a descent answer and here it is:&lt;br /&gt;- I'm looking for a way to start a small independent trading business. This is only possible when a steady income is generated at least monthly, so steady profits are more important than high profits. Translating this to trading strategies puts most directional trades out of the scope due to their unstable nature. Mean-reverting &amp;amp; market neutral is going to be my style.&lt;br /&gt;- On a short term my goal is to find a reliable trading strategy with a sharpe of at least 1.5.&lt;br /&gt;&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-6097110944510986057?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/6097110944510986057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/most-important-question.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/6097110944510986057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/6097110944510986057'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/most-important-question.html' title='The most important question'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1346045313195961352.post-5001352323427507663</id><published>2009-12-11T04:19:00.001-08:00</published><updated>2009-12-15T08:39:52.860-08:00</updated><title type='text'>and so it started.</title><content type='html'>I finally decided to start a blog. The reason for this is that I've been bugging most of my friends for the past two  month with my quantitative trading adventures. Usually, if you are passionate about something, you just must share it with everybody around you and you are in great luck if the people around you share the same passion. It is plain ok if they are just agree to listen. And if they don't, you  just have to start a blog.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1346045313195961352-5001352323427507663?l=matlab-trading.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://matlab-trading.blogspot.com/feeds/5001352323427507663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/and-so-it-started.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5001352323427507663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1346045313195961352/posts/default/5001352323427507663'/><link rel='alternate' type='text/html' href='http://matlab-trading.blogspot.com/2009/12/and-so-it-started.html' title='and so it started.'/><author><name>sjev</name><uri>http://www.blogger.com/profile/17452562180989360928</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
