<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CkQCSXszcCp7ImA9WhVbE04.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206</id><updated>2012-05-29T15:26:08.588-07:00</updated><category term="assignment of stock" /><category term="iron condor" /><category term="calendar" /><category term="futures" /><category term="Jascha Heifetz" /><category term="data mining" /><category term="trading" /><category term="potato vodka martini" /><category term="C" /><category term="system development" /><category term="money management" /><category term="market study" /><category term="deflation" /><category term="Pau Casals" /><category term="Weezer" /><category term="QQQQ" /><category term="mission statement" /><category term="Monte Carlo simulation" /><category term="prolog" /><category term="corn" /><category term="perfect profit" /><category term="risk arbitrage" /><category term="psychology" /><category term="awk" /><category term="double diagonal" /><category term="Git" /><category term="NDX" /><category term="tlt" /><category term="backtesting" /><category term="TextMate" /><category term="Czech music" /><category term="Bumblebee" /><category term="straddle" /><category term="bayes" /><category term="OEX" /><category term="put calendar" /><category term="humor" /><category term="volatility" /><category term="Benny Moten" /><category term="position sizing" /><category term="call spreads" /><category term="XEO" /><category term="Ladybug" /><category term="logarithm" /><category term="gnat" /><category term="skip-strike butterfly" /><category term="inflation" /><category term="vertical spreads" /><category term="algorithm" /><category term="COP" /><category term="SPX" /><category term="trading models" /><category term="NVRX" /><category term="trade system" /><category term="USO" /><category term="naked call" /><category term="allegory" /><category term="stocks" /><category term="panic" /><category term="butterfly" /><category term="vertical roll" /><category term="coding" /><category term="Vladimir Visotsky" /><category term="SPY" /><category term="Black Box Chronicles" /><category term="statistics" /><category term="correlation" /><category term="RUT" /><category term="Optimization" /><category term="strangle" /><category term="Excel" /><category term="FAZ" /><category term="walk forward" /><category term="forex" /><category term="stress testing" /><category term="trade management" /><category term="pairs trade" /><category term="system trading" /><category term="environment" /><category term="mydumbwebsite" /><category term="MNX" /><category term="OS X" /><category term="GLD" /><category term="fitness function" /><category term="silver" /><category term="python" /><category term="zoo" /><category term="Velvet Underground" /><category term="ETFs" /><category term="FAS" /><category term="Ruby on Rails" /><category term="svm" /><category term="intermarkets" /><category term="treasuries" /><category term="Mississippi John Hurt" /><category term="DIA" /><category term="Sebastian Bach" /><category term="cigars" /><category term="neural networks" /><category term="Australian Dollar" /><category term="equity curve" /><category term="covered call" /><category term="DIA calendar" /><category term="VIX" /><category term="Rusty Apple" /><category term="programming" /><category term="Niccolo Paganini" /><category term="QE" /><category term="discretionary trading" /><category term="trend following" /><category term="tbt" /><category term="euro" /><category term="yen" /><category term="AAPL" /><category term="commodities" /><category term="options" /><category term="paper trading" /><category term="Beethoven" /><category term="John Fahey" /><category term="odds" /><category term="Ruby" /><category term="probability of success" /><category term="Smiths" /><category term="tbt tlt" /><category term="R" /><category term="natural_gas" /><title>Milk Trader</title><subtitle type="html">Milktrader</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.milktrader.net/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://www.milktrader.net/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>181</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/MilkTrader" /><feedburner:info uri="milktrader" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;D0cCSX46fyp7ImA9WhVXF00.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-5007274842549310598</id><published>2012-04-17T16:23:00.001-07:00</published><updated>2012-04-17T16:24:28.017-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-17T16:24:28.017-07:00</app:edited><title>Takes Two To Tango</title><content type="html">Yoga on the guitar:&lt;br /&gt;
&lt;br /&gt;
&lt;iframe width="560" height="315" src="http://www.youtube.com/embed/-lvMQCmUVv8" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-5007274842549310598?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TuFIeVCnlr8sAR2qRKegd2c8yfw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TuFIeVCnlr8sAR2qRKegd2c8yfw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TuFIeVCnlr8sAR2qRKegd2c8yfw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TuFIeVCnlr8sAR2qRKegd2c8yfw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/sYz63-Ezi4U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/5007274842549310598/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2012/04/takes-two-to-tango.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/5007274842549310598?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/5007274842549310598?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/sYz63-Ezi4U/takes-two-to-tango.html" title="Takes Two To Tango" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/-lvMQCmUVv8/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.milktrader.net/2012/04/takes-two-to-tango.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0EERnk_fyp7ImA9WhVRGUU.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-3855595983476806683</id><published>2012-03-28T19:53:00.000-07:00</published><updated>2012-03-28T19:53:27.747-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-28T19:53:27.747-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="NDX" /><title>Nasdaq 100 going to 5,500 (in 14 months)</title><content type="html">Alright, it's a bold statement. And as you will see below, it's based on the premise that this is an interation, or a a "quote" -- recurrence of 1999. But that's what it is. Let's start with exhibit A:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-GIHpgdTVoYM/T3PNIFAaxMI/AAAAAAAAAPU/Qo-QriUjwpI/s1600/1999.png" imageanchor="1" style=""&gt;&lt;img border="0" height="400" width="400" src="http://4.bp.blogspot.com/-GIHpgdTVoYM/T3PNIFAaxMI/AAAAAAAAAPU/Qo-QriUjwpI/s400/1999.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Wow, that's a wicked weekly chart. Clearly oversold, right. Well that was 1999. Let's see where we are now. Stage hands: Exhibit B!&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-il3xx7toIuU/T3PNd570gRI/AAAAAAAAAPg/qv9xB1kmBdE/s1600/2012.png" imageanchor="1" style=""&gt;&lt;img border="0" height="400" width="400" src="http://1.bp.blogspot.com/-il3xx7toIuU/T3PNd570gRI/AAAAAAAAAPg/qv9xB1kmBdE/s400/2012.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This is where we are now. Not to say history repeats itself, but if it ever did what do you suppose would happen next? Well if you are guessing a great meltdown, think again. Stage hands, please present Exhibit C!&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-p47ZxhK2nr8/T3PN5ReuEJI/AAAAAAAAAPs/AyuH5GlNNiY/s1600/big.png" imageanchor="1" style=""&gt;&lt;img border="0" height="400" width="400" src="http://1.bp.blogspot.com/-p47ZxhK2nr8/T3PN5ReuEJI/AAAAAAAAAPs/AyuH5GlNNiY/s400/big.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Conclusion: We have room to go.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-3855595983476806683?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/O9RdkKIMhT8l1Nm4ecIfbVun4oM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/O9RdkKIMhT8l1Nm4ecIfbVun4oM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/O9RdkKIMhT8l1Nm4ecIfbVun4oM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/O9RdkKIMhT8l1Nm4ecIfbVun4oM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/wqRXAcgilVs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/3855595983476806683/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2012/03/nasdaq-100-going-to-5500-in-14-months.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3855595983476806683?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3855595983476806683?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/wqRXAcgilVs/nasdaq-100-going-to-5500-in-14-months.html" title="Nasdaq 100 going to 5,500 (in 14 months)" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-GIHpgdTVoYM/T3PNIFAaxMI/AAAAAAAAAPU/Qo-QriUjwpI/s72-c/1999.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://www.milktrader.net/2012/03/nasdaq-100-going-to-5500-in-14-months.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQBQX8yeSp7ImA9WhVSFko.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-3130919950363552836</id><published>2012-03-13T14:15:00.000-07:00</published><updated>2012-03-13T14:15:50.191-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-13T14:15:50.191-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SPX" /><title>Mission Aborted</title><content type="html">They say that markets can remain solvent longer than short sellers can maintain their sanity, and I think this holds true for our current situation. I'm aborting the short bias. I'm also re-assessing whether I will trade equities ever again, but that's a different story. This market is truly unreal. It's on the fat tail distribution of all markets that have come before it, and it continues to stretch the tail. &lt;br /&gt;
&lt;br /&gt;
What started out as a great year with some killer trades in energy and the euro have been vaporized by trying to short sell this bull market. I was able to dodge the rippers for the most part from 1308, but today's abnormal 1.8% rally has taken me out. &lt;br /&gt;
&lt;br /&gt;
I don't doubt that this is a market will pull back, but I can't risk the account given the circumstances. I'm still short a little ES from 1362 and quite frankly, I'll be happy to get my money back.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-3130919950363552836?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/xfzPI9LwPCsMOBmprfzR9v4bx6U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xfzPI9LwPCsMOBmprfzR9v4bx6U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/xfzPI9LwPCsMOBmprfzR9v4bx6U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xfzPI9LwPCsMOBmprfzR9v4bx6U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/ftppj8oRa6U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/3130919950363552836/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2012/03/mission-aborted.html#comment-form" title="9 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3130919950363552836?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3130919950363552836?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/ftppj8oRa6U/mission-aborted.html" title="Mission Aborted" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>9</thr:total><feedburner:origLink>http://www.milktrader.net/2012/03/mission-aborted.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8FSHwycSp7ImA9WhVQEkw.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-5718044676137433643</id><published>2012-03-06T05:28:00.008-08:00</published><updated>2012-03-31T10:10:19.299-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-31T10:10:19.299-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SPX" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Screencast: The Making of 17018d5488</title><content type="html">The following screencast demonstrates the use of R, the quantmod R package and bash to process SPX data from 1950. An explanation on how to access a git repository that includes the plots and the R console history is also provided. This screencast produced the data and the plot for the &lt;a href="http://algorithmzoo.com/blog/2012/03/05/17018d5488/"&gt;17018d5488&lt;/a&gt;&amp;nbsp;post on algorithmzoo.com&lt;br /&gt;
&lt;br /&gt;
&lt;iframe src="http://player.vimeo.com/video/39521438?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="400" height="300" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href="http://vimeo.com/39521438"&gt;17018d5488.mp4&lt;/a&gt; from &lt;a href="http://vimeo.com/user11068094"&gt;milktrader&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;
Alternate site:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://screencast-o-matic.com/watch/cleio1ATs"&gt;Part 1/2&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://screencast-o-matic.com/watch/clei2DATt"&gt;Part 2/2&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-5718044676137433643?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8g1-hkZ3VeaRTd5b2SjtIKnK_PI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8g1-hkZ3VeaRTd5b2SjtIKnK_PI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8g1-hkZ3VeaRTd5b2SjtIKnK_PI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8g1-hkZ3VeaRTd5b2SjtIKnK_PI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/-0NiwmEwpCw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/5718044676137433643/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2012/03/screencast-making-of-17018d5488_06.html#comment-form" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/5718044676137433643?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/5718044676137433643?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/-0NiwmEwpCw/screencast-making-of-17018d5488_06.html" title="Screencast: The Making of 17018d5488" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>6</thr:total><feedburner:origLink>http://www.milktrader.net/2012/03/screencast-making-of-17018d5488_06.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMNSXc5fCp7ImA9WhRaFUk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-292909152902790022</id><published>2012-02-17T20:48:00.000-08:00</published><updated>2012-02-17T20:48:18.924-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T20:48:18.924-08:00</app:edited><title>The Unbearable Being of Lightness</title><content type="html">Alright, let's get serious for a moment. Check that, let's "quote" -- &amp;nbsp;not get serious for a moment. Let's instead pretend. That things that are bad are contained by wise sage-like men and women. That there is always an accounting technique that explains why things don't add up. That bull markets never behave badly.&lt;br /&gt;
&lt;br /&gt;
Those of us who prefer listening to Beethoven's Last Quartets are being assaulted by Cindy Lauper melodies of the banal. While prancing optimists make money every other breath, plodding realists are forced to cover or hedge or both. It's maddening when dumb people make money at the expense of smart people.&lt;br /&gt;
&lt;br /&gt;
But all the smart ones losing money lately have learned one thing that will be lost on the Pollyanna. How to &amp;nbsp;survive when the market goes against you. You see, realists are quite accustomed to a slow unwinding. Trivial optimists have no idea what it feels like to have things not play out according to their charts, and to the levels that have been foretold by a 10th century mathematician.&lt;br /&gt;
&lt;br /&gt;
For now, bulls are right. Bears are wrong. Those who claim to be neither are either scalpers (which there's nothing wrong with that) or delusional. It's almost too much to withstand the preening of long-term agnostics.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-292909152902790022?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/JCmTRJJzZufB_P8Kx0KXnDo3op4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JCmTRJJzZufB_P8Kx0KXnDo3op4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/JCmTRJJzZufB_P8Kx0KXnDo3op4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JCmTRJJzZufB_P8Kx0KXnDo3op4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/4JnXf60r2Bk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/292909152902790022/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2012/02/unbearable-being-of-lightness.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/292909152902790022?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/292909152902790022?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/4JnXf60r2Bk/unbearable-being-of-lightness.html" title="The Unbearable Being of Lightness" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://www.milktrader.net/2012/02/unbearable-being-of-lightness.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0EDQH05eip7ImA9WhRaFUk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-1354678468716430506</id><published>2012-02-08T14:26:00.001-08:00</published><updated>2012-02-17T21:07:51.322-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T21:07:51.322-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SPX" /><title>My name is Milk and I am short this market</title><content type="html">There aren't many of us left. We've lost many to attrition and a few to defection. Our group grows smaller with each passing day of higher highs and higher lows. We are short this market and the object of scorn and ridicule. We are being kicked around like degenerates addicted to pain. Not only have we suffered damage to our trading portfolios, but we have to deal with intervention attempts from those know better than us. They know this is a bull market and that means you should not be short. You should be long.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Some of us are bears, other bulls and still others indifferent. Some of us see a "quote" -- healthy pullback. Others see us going to test 1160 and below. A few see us going to zero (not many, mind you). In any case, it's difficult to have a meaningful conversation with the trend-is-your-frienders.&lt;br /&gt;
&lt;br /&gt;
We point out that "we're a bit stretched here as we sit about 6% above the 50-day moving average."&lt;br /&gt;
&lt;br /&gt;
"Nope, doesn't matter. You're just an unhappy vagrant who is suppressing anger because you missed the move."&lt;br /&gt;
&lt;br /&gt;
"But we are getting a little frothy up here and people who have no business trading are making money."&lt;br /&gt;
&lt;br /&gt;
"Ah, so you're not only bitter, but you're jealous."&lt;br /&gt;
&lt;br /&gt;
"The european crisis is far from resolved, can't you see the chicanery going on there?"&lt;br /&gt;
&lt;br /&gt;
"Doesn't matter, already priced in."&lt;br /&gt;
&lt;br /&gt;
"Nobody is buying puts!"&lt;br /&gt;
&lt;br /&gt;
"Nobody? Obviously some people are. Now you're exaggerating"&lt;br /&gt;
&lt;br /&gt;
And so on. In the end, everyone trades what they see. Not everyone sees the same thing.&lt;br /&gt;
&lt;br /&gt;
Be careful fellow contrarians. If holders of near zero-interest rate bonds get coaxed back into this market it can get very bad for us. Once that happens, it will be lights out for any and all skeptics (at least those with short positions).&lt;br /&gt;
&lt;br /&gt;
My name is Milk and I am short this market.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-1354678468716430506?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/27b84kCwLOthrO-1p55WAHscpDY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/27b84kCwLOthrO-1p55WAHscpDY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/27b84kCwLOthrO-1p55WAHscpDY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/27b84kCwLOthrO-1p55WAHscpDY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/ARByo0yQBR0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/1354678468716430506/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2012/02/my-name-is-milk-and-i-am-short-this.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1354678468716430506?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1354678468716430506?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/ARByo0yQBR0/my-name-is-milk-and-i-am-short-this.html" title="My name is Milk and I am short this market" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://www.milktrader.net/2012/02/my-name-is-milk-and-i-am-short-this.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0EAQHw_fip7ImA9WhRaFUk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-4847017422116967212</id><published>2012-01-24T07:50:00.001-08:00</published><updated>2012-02-17T21:07:21.246-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T21:07:21.246-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="natural_gas" /><title>batty natty</title><content type="html">Rumors of a hedgefund blowing up and frantically selling out a long position. Mild winter weather across the country. Oversupply. Calls for prices to reach $1 and below. All the melodrama you could ask for is playing out in natural gas.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
I glibly declared the sell-off ridiculous and went long the Feb contract of the NG future a few days back. No stops, because I was confident. When I woke in the morning I was awash in a 50+ tick profit and asked my 7-year old if I should take the $500 or not. He said 'take it Dad.' Of course I didn't. I judiciously placed a stop at break-even though. It took all of about an hour for my stop to get hit, and for 50+ ticks evaporate into a 1 tick profit.&lt;br /&gt;
&lt;br /&gt;
I can say I felt annoyed. But also amused that something like this could happen so suddenly. I got back in long that same morning and after a meager 10 tick profit decided to place a stop at break even again. And again, it was hit in short order. I'm thinking, hmmm. This is curious indeed. One more trade for the morning. This time it goes against me right away for about 15 ticks. Wow, what a fine mess I've gotten into I think to myself. I take a breath and wait. It comes back to break even. It catapults to plus 16 ticks in what seems like seconds and I get out. Phew. It was fun. My 7-year old was unimpressed though that I blew a $500 profit. This is toy money (as in money for toys) we're talking about here!&lt;br /&gt;
&lt;br /&gt;
Next day I'm at work and not trading. That's when the real rally happens of course, when I'm flat. Did I miss making over $4,000? No, not really. That's just not the way I see things. I get long that evening and repeat my previous mistakes. With my position positive 35+ ticks by morning, I set a stop at break-even. Where do you suppose it ends up going in the next couple hours? Yep, out for a 1-tick profit.&lt;br /&gt;
&lt;br /&gt;
Mental note to myself. Take 30 ticks when you can. Next, I go long again about 20 ticks from where I was stopped out and push aside the feeble thoughts of ... 'if you didn't get stopped out, you'd be up 20 now ...'. Yeah sure. Whatever. I'm long now. It takes but a few minutes and I'm up 20 ticks again. Stop at 10 ticks. Up 30 ticks, stop at 20. And so on until I have a locked in profit of 40 ticks. It gets filled and I'm done for now.&lt;br /&gt;
&lt;br /&gt;
When my 7-year-old comes home from school today, I'll have a better story to tell. I have no doubt he'll expect some free money for Hero Factory toys. I'll probably give it to him, along with his brother. You can never have too many legos in the house.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-4847017422116967212?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/9tJ7J7FUCO5lNowzzwfXymhcMrg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/9tJ7J7FUCO5lNowzzwfXymhcMrg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/9tJ7J7FUCO5lNowzzwfXymhcMrg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/9tJ7J7FUCO5lNowzzwfXymhcMrg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/NvfRIBXAA_c" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/4847017422116967212/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2012/01/batty-natty.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/4847017422116967212?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/4847017422116967212?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/NvfRIBXAA_c/batty-natty.html" title="batty natty" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://www.milktrader.net/2012/01/batty-natty.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0EFRXsyfCp7ImA9WhRaFUk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-1033778683730791042</id><published>2012-01-18T11:06:00.001-08:00</published><updated>2012-02-17T21:06:54.594-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T21:06:54.594-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="euro" /><title>eurochatter</title><content type="html">Things have been quite at the zoo recently so I've been assigned a project to capture chatter amongst the resident creatures. I'm taking a very learn-as-you-go approach to this challenge and so far have managed to create a working app that captures the twitter stream chattering about the eur/usd currency pair. You can see my progress at&amp;nbsp;&lt;a href="http://www.eurochatter.com/"&gt;www.eurochatter.com&lt;/a&gt;&amp;nbsp;but be fore-warned that it's a work in progress. Once you start seeing ads you'll know that I've solved most of the programming issues.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Here is a screenshot of what it looks like today:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-12ftph43w98/TxcVPwuPC0I/AAAAAAAAAOw/xZmP1Wlp4AQ/s1600/Screen+shot+2012-01-18+at+1.52.10+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="261" src="http://2.bp.blogspot.com/-12ftph43w98/TxcVPwuPC0I/AAAAAAAAAOw/xZmP1Wlp4AQ/s320/Screen+shot+2012-01-18+at+1.52.10+PM.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Of course, this will not likely be its final styling format, but it's a start. The chart is generated by an open-source javascript library and has some cool features including the ability to get the values of various datapoints by mousing over the chart. Also, you can zoom in. Reloading the page brings it back to its original state.&lt;br /&gt;
&lt;br /&gt;
The programming behind the app is a Ruby. It uses the Sinatra gem to serve the web page and it's currently being hosted at Heroku. I'm also using a Mongo database in the cloud, courtesy of MongoLab.&lt;br /&gt;
&lt;br /&gt;
I still have a substantial hurdle to overcome in this app with regards to managing the database. I'm currently using a capped collection to store all tweets. I query the database as to its total and that's how the data is generated for the chart. But, as you can imagine, a capped collection reaches a limit at which point its total doesn't change. Only the contents does. I'm thinking that in the code block where I insert records into the database I can increment something there to avoid this limit problem, but I'm not sure.&lt;br /&gt;
&lt;br /&gt;
Another problem will be that when I push changes up to the hosting company, the record of timestamped tweet totals will be erased. This is because the tweets.csv is being updated on Heroku servers. Meh, just another problem to solve. Kinda like a crossword.&lt;br /&gt;
&lt;br /&gt;
I hope you enjoy the site. And remember to click on the ads after I get them up. I promise not to put up too many.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-1033778683730791042?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/d3dPLoUNmpfMi3pyDqGDlZHqABo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d3dPLoUNmpfMi3pyDqGDlZHqABo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/d3dPLoUNmpfMi3pyDqGDlZHqABo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d3dPLoUNmpfMi3pyDqGDlZHqABo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/lqFupaLsPvE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/1033778683730791042/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2012/01/eurochatter.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1033778683730791042?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1033778683730791042?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/lqFupaLsPvE/eurochatter.html" title="eurochatter" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-12ftph43w98/TxcVPwuPC0I/AAAAAAAAAOw/xZmP1Wlp4AQ/s72-c/Screen+shot+2012-01-18+at+1.52.10+PM.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.milktrader.net/2012/01/eurochatter.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0IMSX4_cCp7ImA9WhRaFUk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-49794028418615068</id><published>2011-11-21T08:36:00.001-08:00</published><updated>2012-02-17T21:06:28.048-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T21:06:28.048-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>A Simple R Script for Traders</title><content type="html">Now that we've got the Python implementation under out belts, let's do the same thing with R. We'll still be able to pass command-line arguments to get a quick look at what our stock of interest is doing during the day. And we start with the familiar incantation of enabling our script to run from command-line.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ chmod +x yahoo.r&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This is a further abuse of starting the story in the middle. So let's get to the beginning. Here is the R script that we'll be invoking from command-line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#!/usr/bin/Rscript&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;require(quantmod)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;arg &amp;nbsp; &amp;nbsp;&amp;lt;- commandArgs(trailingOnly = TRUE)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;stock &amp;nbsp;&amp;lt;- getQuote(arg)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;last &amp;nbsp; &amp;lt;- stock[2]&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;high &amp;nbsp; &amp;lt;- stock[6]&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;low &amp;nbsp; &amp;nbsp;&amp;lt;- stock[7]&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pctile &amp;lt;- (last-low)/(high-low)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;bingo &amp;nbsp;&amp;lt;- round(pctile * 100)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;b &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;- as.integer(bingo) &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sprintf("%s is trading at the %ith percentile of its daily range", arg ,b)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We only need to call one package here, the inimitable &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;quantmod&lt;/span&gt;. That's were we get access to the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;getQuote&lt;/span&gt; function. From there, it's basic boilerplate. I am by no means a professional programmer, so there are some issues with this script that I'm just living with for now including the fact that when this is invoked, R just doesn't shut up with it's messages. Let's run this on ^GSPC, which is the Yahoo symbol for S&amp;amp;P 500. You'll see what I mean.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ ./yahoo.r ^GSPC&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;WARNING: ignoring environment value of R_HOME&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Loading required package: quantmod&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Loading required package: Defaults&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Loading required package: xts&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Loading required package: zoo&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Loading required package: TTR&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Loading required package: methods&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[1] "GSPC is trading at the 3th percentile of its daily range"&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
First, you notice that the first line is what we typed in command-line. Starting at WARNING is where R starts to chatter. The last line is the one we expect to get returned. (Happened to catch the market at a low point). All of this Loading is necessary, but I'd like to silence it.&lt;br /&gt;
&lt;br /&gt;
Our second issue is that '3th' isn't a word. It's supposed to be '3rd'. This can be programmatically corrected, but then the code starts getting dense. Better to live with it or find a better way to phrase the return phrase.&lt;br /&gt;
&lt;br /&gt;
Also with &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;quantmod&lt;/span&gt;, you can go to the races and calculate all manner of technical analysis data and have that output to terminal. Now I need to go figure out what's going on with the market...&lt;br /&gt;
&lt;br /&gt;
EDITOR NOTE:&lt;br /&gt;
&lt;br /&gt;
There is nothing going on in the market so I decided to start googling how get rid of Loading messages. Sure enough I found&amp;nbsp;&lt;span style="background-color: #f8f8f8; color: #003399; font-family: monospace; font-weight: bold; line-height: 15px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; white-space: pre;"&gt;&lt;a href="http://inside-r.org/r-doc/base/suppressPackageStartupMessages" style="background-color: #f8f8f8; color: #0077df; font-family: monospace; line-height: 15px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; white-space: pre;"&gt;suppressPackageStartupMessages&lt;/a&gt;.&lt;/span&gt;&lt;span style="background-color: #f8f8f8; line-height: 15px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Now I have to solve the WARNING message issue. That one I'm afraid is going to   be a rat's nest. &lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-49794028418615068?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_8LNxEjwXOEF5u3Hvm3NUgdYcCM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_8LNxEjwXOEF5u3Hvm3NUgdYcCM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_8LNxEjwXOEF5u3Hvm3NUgdYcCM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_8LNxEjwXOEF5u3Hvm3NUgdYcCM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/F6TLZv01lyo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/49794028418615068/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/11/simple-r-script-for-traders.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/49794028418615068?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/49794028418615068?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/F6TLZv01lyo/simple-r-script-for-traders.html" title="A Simple R Script for Traders" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://www.milktrader.net/2011/11/simple-r-script-for-traders.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0IBQ3Y6fSp7ImA9WhRaFUk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-3309088148856908936</id><published>2011-11-20T13:38:00.001-08:00</published><updated>2012-02-17T21:05:52.815-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T21:05:52.815-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>A Simple Python Script for Traders</title><content type="html">My latest polyglot excursion has landed my in the world of snakes. I've started playing around with Python a few weeks ago and have to report that I'm very pleased with how well this programming language performs. I decided to take it out for a little run on Yahoo stock data and came up with a little script that returns the current state of your stock in relation to the current day's trading range.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
To run this script from command line, you first need to give it execution permission. This is time to call the oft-run bash command:&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;$ chmod +x yahoo.py&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Of course I'm getting a little ahead of things. We haven't defined the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;yahoo.py&lt;/span&gt; program. It utilizes three modules:&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; re&lt;/span&gt; (regex), &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sys&lt;/span&gt; (defining argv) and &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;urllib&lt;/span&gt; (for opening an url). These modules provide the functions we need. Some more preliminaries. We start our program with the shebang line so the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;chmod&lt;/span&gt; invocation actually works. Next, I have used a &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;main()&lt;/span&gt; function here when you really don't need it in its current implementation. The last two lines make reference to the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;main()&lt;/span&gt; function sentinel but it's virtually useless for our purposes. The reason to include it is if we decide to grow this program to do other stuff and import it into another script at some later time. Okay, here it is.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#!/usr/bin/python&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import re&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import urllib&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import sys&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;site &amp;nbsp;= "http://finance.yahoo.com/d/quotes.csv?s="&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sym &amp;nbsp; = sys.argv[1]&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;h &amp;nbsp; &amp;nbsp; = urllib.urlopen(site + sym + "&amp;amp;f=shgl1")&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;j &amp;nbsp; &amp;nbsp; = h.read()&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;h.close()&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;k &amp;nbsp; &amp;nbsp; = re.findall('(\w+)",(\d+.\d\d),(\d+.\d\d),(\d+.\d\d)',j)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;stock = k[0][0]&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;hi &amp;nbsp; &amp;nbsp;= float(k[0][1])&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;lo &amp;nbsp; &amp;nbsp;= float(k[0][2])&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;last &amp;nbsp;= float(k[0][3])&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;z &amp;nbsp; &amp;nbsp; = (last-lo)/(hi-lo)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def main():&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; if z &amp;gt;= 0.5:&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; print "%s is trading in the top half of it's range" % stock&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; else:&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; print "%s is trading in the bottom half of it's range" % stock&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;if __name__ == '__main__':&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; main()&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
There really isn't much to it, as you can plainly see. I've used the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;main()&lt;/span&gt; function to print two options based on the trading price of your stock. The way to input the stock you're interested in is to pass it as a command-line argument like this:&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ ./yahoo.py SPY&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;The &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sys.argv[1]&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; is the first argument from command-line (that's not totally true, but this isn't a computer science course either) and that's all this little script can currently handle. The url address is a little cryptic, so I've chunked it out into three sections. First the&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; http://&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; part, which is always the same. Then the stock you entered in command-line. And finally a bizarre looking string that has Yahoo values that you're interested in. In our case, we want the stock name, high, low and last price. This gets converted into a string that our regex engine begins to work on. It returns a list of tuples (or single tuple in our case), where we can subset the values we're interested in.&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;span class="Apple-style-span" style="font-family: inherit;"&gt;One can see how this program can easily be expanded to include much more information. You could also offer the option to pass flags to the script which tells it what path you want to take to get your desired result. I'm thinking it may be useful to pass a set of stocks to the script and have it tell what percent of the group is doing well or not that day.&amp;nbsp;&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;span class="Apple-style-span" style="font-family: inherit;"&gt;This program is obviously a toy program as written, but it's a good beginning for something a little more useful. I'm setting up camp in this snake pit to check it out. I'm not scared of snakes. At least not yet.&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;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-3309088148856908936?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3_rOGn4AEHSGeKeh3HcaA_NIJ0I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3_rOGn4AEHSGeKeh3HcaA_NIJ0I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3_rOGn4AEHSGeKeh3HcaA_NIJ0I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3_rOGn4AEHSGeKeh3HcaA_NIJ0I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/uwqf9nQC9dw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/3309088148856908936/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/11/simple-python-script-for-traders.html#comment-form" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3309088148856908936?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3309088148856908936?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/uwqf9nQC9dw/simple-python-script-for-traders.html" title="A Simple Python Script for Traders" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>6</thr:total><feedburner:origLink>http://www.milktrader.net/2011/11/simple-python-script-for-traders.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0IFSX05fip7ImA9WhRaFUk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-7587238494341337651</id><published>2011-11-09T09:09:00.001-08:00</published><updated>2012-02-17T21:05:18.326-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T21:05:18.326-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="correlation" /><title>My Kids Are Correlated</title><content type="html">I have three kids. Two boys and a girl. They are so different in so many ways that it's amazing they all come from the same genes. But sometimes, they're correlated. This week I told them that they are absolutely banned from any electronic devices after 8:00 pm on school nights. They all reacted the same way. Absolute incredulity. "How can this be?" they all three asked.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
They all have different plans of defiance, but they will all fail. Because I'm one step ahead of them. They are all facing a unmovable force and they know it. They just want to make sure.&lt;br /&gt;
&lt;br /&gt;
If I were to try to describe my kids, the last thing I would use is a mathematical concept that regresses them on a linear surface. Even though they appear to be behaving in unison, it's only because they all share a dominant force. And that would be their mother. In that way, I'm correlated to them.&lt;br /&gt;
&lt;br /&gt;
The other night, just before the 8:00 pm pumpkin call, we all decided to dance to some tunes. It was a most interesting thing to observe how they were correlated to the notes and lyrics of the song. They knew the lyrics and sang them in unison. They were correlated.&lt;br /&gt;
&lt;br /&gt;
In the right environment, everyone and everything is correlated. Once that environment erodes, there is the inevitable "quote" -- decoupling. Our song was over and they all went to their separate bedrooms. They decoupled from a momentary correlation. Or was it an opaque relationship? I'm still tapping my foot trying to get it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-7587238494341337651?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sG9JKhHRIf6wwb5GRPUmyoE5wHc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sG9JKhHRIf6wwb5GRPUmyoE5wHc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sG9JKhHRIf6wwb5GRPUmyoE5wHc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sG9JKhHRIf6wwb5GRPUmyoE5wHc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/xrcdD-5lzcs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/7587238494341337651/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/11/my-kids-are-correlated.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/7587238494341337651?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/7587238494341337651?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/xrcdD-5lzcs/my-kids-are-correlated.html" title="My Kids Are Correlated" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.milktrader.net/2011/11/my-kids-are-correlated.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MNQH47eCp7ImA9WhRaFUk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-1281197026377628541</id><published>2011-10-20T14:15:00.001-07:00</published><updated>2012-02-17T21:04:51.000-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T21:04:51.000-08:00</app:edited><title>Algorithm Zoo</title><content type="html">I suppose it was inevitable that once I started messing around with statistics and curve-fitting of data, I would find myself in a menagerie of equations and scripts. And so I'm moving into the&amp;nbsp;&lt;a href="http://algorithmzoo.com/"&gt;Algorithm Zoo&lt;/a&gt;. It's my new home. It seems like a friendly place so far. The animals misbehave themselves as one would expect. And the weather is often nice.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
I'll be honest though and admit that I think I've seen some unnatural things. It may have been my imagination, but sometimes at night I swear I see strange creatures roaming around outside of the exhibits. &amp;nbsp;I haven't gotten to visit some places yet, including a secret laboratory cordoned off in the back. I think I'll have access to it at some point. I'll report back here about anything I find that may be of interest.&lt;br /&gt;
&lt;br /&gt;
I'm spending most of my time at the zoo messing around with data mining market behavior, and plotting out distributions. The work is not so easy I'm afraid. It turns out that this menial set of tasks I've been assigned is fraught with danger. Avoiding the perilous OBO error keeps me up at night. Data mining is very willing to accept your erroneous code so great care must be taken in the work. Already, I've had one exhibit taken down by management.&lt;br /&gt;
&lt;br /&gt;
I'm restricted at the zoo as to how much color I can add, but I'll try to push the envelope when I can. Stop by and say "quote" -- hello. Great trading! I'll see you at the zoo!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-1281197026377628541?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/IEm1bl8ij4hQxA7ddJEP_3hWJi0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/IEm1bl8ij4hQxA7ddJEP_3hWJi0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/IEm1bl8ij4hQxA7ddJEP_3hWJi0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/IEm1bl8ij4hQxA7ddJEP_3hWJi0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/VR-RW1a00AY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/1281197026377628541/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/10/algorithm-zoo.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1281197026377628541?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1281197026377628541?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/VR-RW1a00AY/algorithm-zoo.html" title="Algorithm Zoo" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://www.milktrader.net/2011/10/algorithm-zoo.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MHSHgyfCp7ImA9WhRaFUk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-3267974482164848004</id><published>2011-09-22T08:05:00.001-07:00</published><updated>2012-02-17T21:03:59.694-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T21:03:59.694-08:00</app:edited><title>The Luckiest Man Next Week</title><content type="html">My best birthday present ever was the birth of my daughter almost 12 years ago. Next week I get to celebrate the oddity again, of sharing my birthday with my child. Of course I'm not the only person on the planet whose birthday coincides with their child's, but I feel strangely privileged regardless. "You're birthday's coming up," I say. "&lt;i&gt;Our&lt;/i&gt; birthday Dad." Dad smiles inside.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
The chances of you sharing a birthday with your child are obviously 1 in 365. It's a longshot, but it happens. Odds mean nothing though. Who cares about them? You've got something special.&lt;br /&gt;
&lt;br /&gt;
It was about two years ago that I had a parent/teacher conference with my daughter's substitute teacher. The regular one, as odds would have it, was having a baby. We started talking about babies and I mentioned, quite proudly, that I share the same birthday as my daughter. The substitute did the pencil-drop and incredulous stare that you get from someone who doesn't believe what you've just told them. "Yep," I said. I thought she would make some comment about "what's the odds of that happening" but instead she replied, "Wow, so do I."&lt;br /&gt;
&lt;br /&gt;
I knew I wasn't the only one, but what are the chances you'd meet someone who shares your birthday secret at a parent/teacher conference? Chances are I would never have met this woman if the regular teacher hadn't gotten pregnant, and what's the chances of that?&lt;br /&gt;
&lt;br /&gt;
"Our birthday is in September," I said.&lt;br /&gt;
&lt;br /&gt;
"Really, so is ours. September 27 in fact," she replied.&lt;br /&gt;
&lt;br /&gt;
This time, it was my turn to drop the jaw and stare with incredulity.&lt;br /&gt;
&lt;br /&gt;
Next week on September 27, my daughter will turn 12. I am one of the luckiest men around.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-3267974482164848004?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sst7tCuqAeXo52by2oQqoeg5eww/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sst7tCuqAeXo52by2oQqoeg5eww/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sst7tCuqAeXo52by2oQqoeg5eww/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sst7tCuqAeXo52by2oQqoeg5eww/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/Ro2AvCfutuY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/3267974482164848004/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/09/luckiest-man-next-week.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3267974482164848004?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3267974482164848004?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/Ro2AvCfutuY/luckiest-man-next-week.html" title="The Luckiest Man Next Week" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>4</thr:total><feedburner:origLink>http://www.milktrader.net/2011/09/luckiest-man-next-week.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQCQno4cSp7ImA9WhdQF0g.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-573007566174843008</id><published>2011-08-18T08:10:00.000-07:00</published><updated>2011-08-19T04:46:03.439-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-19T04:46:03.439-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="odds" /><category scheme="http://www.blogger.com/atom/ns#" term="prolog" /><category scheme="http://www.blogger.com/atom/ns#" term="SPX" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Get Used To It</title><content type="html">This is a brain teaser. You've been warned.&lt;br /&gt;
&lt;br /&gt;
The S&amp;amp;P 500 is in a bear market (defined as the 50-day MA being below the 200-day MA) 30.8% of the time. Also, the S&amp;amp;P 500 has experienced single-day 4% declines 0.242% of the time. Of the times we experienced single-day selloffs exceeding 4%, 75.7% of the time we were in a bear market.&lt;br /&gt;
&lt;br /&gt;
How much more likely are we to experience single-day losses exceeding 4% now that we're in a bear market, compared to the likelihood of such an event in a bull market?&lt;br /&gt;
&lt;br /&gt;
Odds are you stopped reading this puzzle after the first three sentences. In the unlikely event that you're still with me, I've created a &lt;a href="https://gist.github.com/1154255"&gt;link&lt;/a&gt; to some code that holds the answer.&amp;nbsp; It's a prolog script whose knowledge-base is derived from data-mining in R.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-573007566174843008?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hr8iye8BkrHv_pPEtJcncQYidKs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hr8iye8BkrHv_pPEtJcncQYidKs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hr8iye8BkrHv_pPEtJcncQYidKs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hr8iye8BkrHv_pPEtJcncQYidKs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/q4pzEqqRw5M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/573007566174843008/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/08/get-used-to-it.html#comment-form" title="10 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/573007566174843008?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/573007566174843008?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/q4pzEqqRw5M/get-used-to-it.html" title="Get Used To It" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>10</thr:total><feedburner:origLink>http://www.milktrader.net/2011/08/get-used-to-it.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D04HRXwzfSp7ImA9WhdQFkU.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-2027512270991076578</id><published>2011-08-15T07:20:00.000-07:00</published><updated>2011-08-18T09:45:34.285-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-18T09:45:34.285-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="prolog" /><category scheme="http://www.blogger.com/atom/ns#" term="bayes" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Making Stuff is Scary</title><content type="html">My daughter's best friend lives just down the street. Her mother runs a cupcake shop that's just a little further down the street. Being eleven going on sixteen, my daughter fancies herself a "quote" -- worker at the shop. She's not paid in actual money, given child labor laws and all, but sometimes she brings home some cupcakes. The family enjoys them, fighting over certain ones but eating them all in the end. When it's scary story night at the dinner table, I'm always ready with a fan-cheeky paluki tale if not a binglebot story. Our daughter tells the scariest stories though. The stories of what happens to ingredients that come in the back door of the cupcake shop.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
As she relates it, all manner of horrifying things happen to the unsuspecting goods. Eggs get broken, their shells carelessly discarded. Butter gets melted, sugar gets pulverized to dust and flour gets churned while wet stuff gets incorporated into it. My youngest son can almost not bear these stories. His eyes drop to table level when the story starts.&lt;br /&gt;
&lt;br /&gt;
After dinner and our night-time routine, when the lights are dimmed and the doors locked, I sometimes go into my own laboratory. What happens here though is simply too scary to tell to the children. Our bed is not large enough for three extra children, all of whom would likely come during the middle of the night from nightmares if they new this story. In my lab, I do things to data that must not be spoken of.&lt;br /&gt;
&lt;br /&gt;
My intentions are good. I'm not trying to create the bizarre creatures that sometimes form from seemingly nowhere. I'm trying to manufacture nice things. Sweet things that people can enjoy. But sometimes the ingredients get mixed in just the wrong way. It's why the lab is double-bolted and hidden in a secret location. Protected with lasers and in-the-wall machine guns. Alright, no lasers or guns, but it is, shall we say, secure.&lt;br /&gt;
&lt;br /&gt;
The latest malformed creature to escape is the product of my Bayesian Prolog machine. I either put in the wrong ingredients (not likely) or my logic machine is missing a critical sprocket or gear. I'm not sure yet. The plan after the initial, requisite clean-up effort is complete, is to create a smaller version of this machine where I know what the answer should be. If I get a working model at the simple level, I can expand it. Here is the prolog code that I have so far. The mysterious &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;!&lt;/span&gt; symbol in the rules section is a cut, and behaves like the &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;ifelse&lt;/span&gt; in an imperative language. Careful, like I said it's either missing something or something is in the wrong place.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;prob(spx(bear), 0.3039216).&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;prob(spx(bull), 0.6960784).&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;prob(spx(up_two), 0.02173633).&lt;/span&gt;&lt;br /&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;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;conprob(spx(bear) ^ spx(up_two), 0.0125129).&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;conprob(spx(bull) ^ spx(up_two), 0.009158927).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;isprob(A,P) :-&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; prob(A,P), !.&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;isprob(A^B, P) :-&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; conprob(A^B, P), !.&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;isprob(A^B, P) :-&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; conprob(B^A, PBA),&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; isprob(A, PA),&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; isprob(B, PB),&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; P is PBA * PA / PB.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I used my new R data mining script to get the percentage values you see in the first part fact section. I also used R to get the conditional fact values. The function downloads all the SPX data (passed in as parameter &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;sym="^GSPC"&lt;/span&gt;&amp;nbsp;in the function) from Yahoo with the following line:&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;x &amp;lt;- getSymbols(sym, from="1900-01-01", &amp;nbsp;auto.assign=FALSE)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I set &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;auto.assign&lt;/span&gt; to &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;FALSE &lt;/span&gt;because I need the object to be manipulated in the function. I return an object after doing simple look-forward and look-backward manipulations. I also employ the &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;TTR&lt;/span&gt; R package's &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;SMA()&lt;/span&gt; function to keep a running total of the 50-day and 200-day moving averages. I use these average to define bull and bear markets. Let's define the &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;S&lt;/span&gt; variable as containing the complete set of data from the data mining function. To get a slice of it (ie, bear and bull markets) requires a simple indexing operation. Like this:&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;gt; bull &amp;lt;- S[S$r.50 &amp;gt; S$r.200]&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;span class="Apple-style-span" style="font-family: inherit;"&gt;The &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;r.50&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; and &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;r.200&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; vectors are where the 50- and 200-day average values are stored. I'm not sure why I called them &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;r.50&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; and &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;r.200&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;. Come to think of it, it's not very intuitive is it? &amp;nbsp;I'll get to that later. In any case, to get the percentage of time the SPX is a bull market requires a grade-school calculation:&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;gt; nrow(bull)/nrow(S)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;[1] 0.683243&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Now you know where I get the probability fact that goes into the beginning of the Prolog script. The contingency fact (I think this is where my problem is) is calculated below. The &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;bull.up&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; object is all instances where the return was greater than 2% and the market was in a bull regime.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;bull.up &amp;lt;- S[S$RET &amp;gt; 0.02 &amp;amp; S$r.50 &amp;gt; S$r.200 ]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Then to get the value:&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;gt; nrow(bull.up)/nrow(S)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;[1] 0.009158927&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Well, after all of this is compiled in a Prolog session, the following query generates the following result:&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp;?- isprob(spx(up_two) ^ spx(bull), P).&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;P = 0.000286004363470997&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;But a direct calculation in R gives the following result (which I trust more):&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;gt; ans &amp;lt;- bull[bull$RET &amp;gt; 0.02]&lt;br /&gt;
&amp;gt; nrow(ans)/nrow(bull)&lt;br /&gt;
[1] 0.01340508&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;So it's back to the algorithm drawing board I suppose. Tomorrow night is joke night at the dinner table. I think I've got some good material.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;br /&gt;
&lt;/span&gt; &lt;br /&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/3910008585223856206-2027512270991076578?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Pz0uFt70fX0vQCxa13JXFd_8GXk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Pz0uFt70fX0vQCxa13JXFd_8GXk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Pz0uFt70fX0vQCxa13JXFd_8GXk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Pz0uFt70fX0vQCxa13JXFd_8GXk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/00EsFDeArRw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/2027512270991076578/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/08/making-stuff-is-scary.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/2027512270991076578?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/2027512270991076578?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/00EsFDeArRw/making-stuff-is-scary.html" title="Making Stuff is Scary" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.milktrader.net/2011/08/making-stuff-is-scary.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8EQX04fip7ImA9WhdQEEo.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-1046231582737276482</id><published>2011-08-11T06:53:00.000-07:00</published><updated>2011-08-11T06:53:20.336-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-11T06:53:20.336-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SPY" /><category scheme="http://www.blogger.com/atom/ns#" term="data mining" /><title>The Apocalypse Data Mining Trade</title><content type="html">The logic behind this trade is based on the observation that the SPX has responded consistently through the decades in the subsequent days after an Apocalypse day (6.5% selloff or more). Today is Day 3. The in.3 column are the historical returns for Day 3  from the close of Apocalypse day. The S&amp;amp;P 500 has never closed below  the close of Apocalypse day by Day 3. This is also true of Day 2 (which is not shown). &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-UxCRlcdYHnI/TkPZWhh5ZOI/AAAAAAAAAOE/yRkiqktlGlg/s1600/Screen+shot+2011-08-11+at+9.29.26+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="187" src="http://3.bp.blogspot.com/-UxCRlcdYHnI/TkPZWhh5ZOI/AAAAAAAAAOE/yRkiqktlGlg/s320/Screen+shot+2011-08-11+at+9.29.26+AM.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;The 30-day return ranges from a loss of 24% to a gain of 28%.  There have been 8 of 12 times when the return was positive. The average return is 1.7%. &lt;br /&gt;
&lt;br /&gt;
I went long SPY at $111.46 in pre-market today. I'll close it in 6 weeks and my returns will become part of the distribution. &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-1046231582737276482?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-7PfZjEK40dat9C1d2Hu1sv14CI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-7PfZjEK40dat9C1d2Hu1sv14CI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-7PfZjEK40dat9C1d2Hu1sv14CI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-7PfZjEK40dat9C1d2Hu1sv14CI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/OOGm0Qi1iBM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/1046231582737276482/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/08/apocalypse-data-mining-trade.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1046231582737276482?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1046231582737276482?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/OOGm0Qi1iBM/apocalypse-data-mining-trade.html" title="The Apocalypse Data Mining Trade" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-UxCRlcdYHnI/TkPZWhh5ZOI/AAAAAAAAAOE/yRkiqktlGlg/s72-c/Screen+shot+2011-08-11+at+9.29.26+AM.png" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://www.milktrader.net/2011/08/apocalypse-data-mining-trade.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEYBQXg5eCp7ImA9WhdQEEU.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-7604349386270977097</id><published>2011-08-09T09:04:00.000-07:00</published><updated>2011-08-11T10:02:30.620-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-11T10:02:30.620-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="data mining" /><category scheme="http://www.blogger.com/atom/ns#" term="SPX" /><title>This Time Is Not So Different</title><content type="html">The first time it happened was September 26, 1955. Earlier that same year, Ray Kroc started McDonald's, Elvis made his first TV appearance and Congress ordered all US coins bear the "quote" -- &amp;nbsp;In God We Trust. &amp;nbsp;Just two days prior, President Eisenhower suffered a heart attack. That was the first time the S&amp;amp;P recorded a single-day 6.5% loss. In the intervening years it would happen 11 more times. Yesterday was the thirteenth time it's ever happened.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;To say this time is different is self-evident. McDonald's is not a start-up and Elvis is dead. Of course it's different. This is enough to persuade most that data mining what happened afterwards is a futile effort. Most of the time, what happened next is an almost perfectly distributed result around a mean of zero. But this event has a unique distribution on what happened next. The next day has historically experienced a positive return. Not every time, but just 11 of the past 12 times. Based on that edge and with the help of a little Haskell and R, I calculated that on Tuesday August 9, 2011, the SPX should close at 1160.65 (calculated when ES futures where trading around 1080 mind you).&amp;nbsp;This is of course a silly prediction. But it's a marker of sorts. It tells me that pressing a short is probably a really bad idea.&lt;br /&gt;
&lt;br /&gt;
It wasn't enough for me long the future. I'm thinking next time I see something like this it should be worth a shot though. If you look at returns over Day 2 and Day 3 after such a precipitous drop, you'll see that every time the index experienced a positive return. Every time. On Day 2 the total returns from the close of Apocalypse day had a minimum of 0.82% and a maximum of 14.91% with a mean of 6.38%. On Day 3 the min was 0.71% , max was 13.94% and mean was 5.94%.&lt;br /&gt;
&lt;br /&gt;
Present events are not bound to the past. Obviously if the President had a heart attack three days ago, we would have heard about it by now.&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/3910008585223856206-7604349386270977097?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/c_gYELJxV2r1YQtN8I2i-P9ZZgo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/c_gYELJxV2r1YQtN8I2i-P9ZZgo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/c_gYELJxV2r1YQtN8I2i-P9ZZgo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/c_gYELJxV2r1YQtN8I2i-P9ZZgo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/1nAMDiC2LZU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/7604349386270977097/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/08/this-time-is-not-so-different.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/7604349386270977097?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/7604349386270977097?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/1nAMDiC2LZU/this-time-is-not-so-different.html" title="This Time Is Not So Different" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://www.milktrader.net/2011/08/this-time-is-not-so-different.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQGRHw4eSp7ImA9WhdRGU0.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-2154406895636219781</id><published>2011-07-31T05:20:00.000-07:00</published><updated>2011-08-09T09:12:05.231-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-09T09:12:05.231-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="prolog" /><title>Logical Nonsense</title><content type="html">In 1979, rock band Supertramp released their Logical Song. It's a plaintive melody that compares two sets of values with an obvious bias against acting "quote" -- logical. But what's wrong with logical? Isn't the world made that way, and doesn't our ability to perceive it correctly rest on our understanding of its constraints? Our long-haired, falsetto-voiced friends from the 1980s may have been unto something though. Sometimes logic will lead you to draw silly conclusions.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
A good way to test this idea is to run a simple program in Prolog, the logic programming language. This obscure little programming language is particularly useful in sorting out logic problems from scheduling applications to Bayesian networks. It does voodoo on facts and rules to answer questions. Let's try it out with some simple facts. I'm using the &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;Yap&lt;/span&gt; implementation by the way. The following code snippet looks like a function, but read it differently. Read the following snippet as saying "euro is the currency of greece". Ignore the lower case for now. It must be. Look into it later if it's important to you.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;currency(euro, greece).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This is a fact in prolog. It uses it to build its perception of the world that you're describing. Let's put some more in our program.&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;currency(euro, germany).&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; currency(euro, france).&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; currency(euro, spain).&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; currency(euro, portugal).&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; currency(euro, italy).&lt;/div&gt;&lt;br /&gt;
There are more we can add, but that'll do for now. Next, we'll create a rule to expand the knowledge of the program.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;friends(X, Y) :-&lt;/span&gt;&lt;br /&gt;
&lt;div 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; currency(Z, X),&amp;nbsp;&lt;/div&gt;&lt;div 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; currency(Z, Y).&lt;/div&gt;&lt;br /&gt;
We've introduced some variables and they're upper-case. Again, it must be so. We've also introduced a strange symbol with :- that looks to separate two parts of an argument. Indeed, that's exactly what it does. Sometimes its called the neck because it joins the head to the tail. Prolog considers the tail first and if it is true, applies the head to its knowledge as being true. Read the tail first. If Z is the currency of X and Z is the currency of Y (they share the same currency), then ... read the head ...&amp;nbsp; X and Y are friends. &lt;br /&gt;
&lt;br /&gt;
Save the above script in a file called&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt; fiasco&lt;/span&gt; by doing something simple from command line such as this:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;$ vi fiasco&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;:wq&lt;/span&gt; it and in the same directory start up a Prolog session and type in the following after the&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt; ?- &lt;/span&gt;prompt:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt; ?- [fiasco].&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This should get the program ready for query. Let's ask a question, which is basically the tail of a predicate.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt; ?- friends(greece, germany).&lt;/span&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;/div&gt;&lt;br /&gt;
We ask if Greece and Germany are friends and based on the knowledge that we've input it tells us that &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;yes&lt;/span&gt; it's true. They are friends. This is logical and though you may argue it's nonsense, it really isn't because we've made it so. But now let's push this idea a little bit more.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;?- friends(greece, greece).&lt;/span&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;/div&gt;&lt;br /&gt;
Well, there you have it. Greece is friends with itself! Now that is truly ridiculous. But it is logical because it meets the requirements we've put in place. It turns out that logic sometimes needs a little filtering to make sense, something humans are quite good at. And since we're so good at it, let's let Prolog in on our secret with the following snippet, added to the &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;friends&lt;/span&gt; rule:&lt;br /&gt;
&lt;div style="font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;dif(X,Y).&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&lt;span style="font-family: inherit;"&gt;You'll need to change the period after the previous tail sequence to a comma because comma is a conjunction operator while the period concludes the tail.&lt;/span&gt; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;To recompile the program after you've edited it, type in the following:&lt;/div&gt;&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span style="font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;?- [-fiasco].&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span style="font-family: inherit;"&gt;&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
You can't be friends with yourself because friendship is a relationship between two, duh Prolog. You don't get by with a little help from yourself, you get by with a little help from your friends.&amp;nbsp; It has been written in song, and it is true. &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-2154406895636219781?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/aTnPBGN43Vt9LSOwHOTGJpQDITY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aTnPBGN43Vt9LSOwHOTGJpQDITY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/aTnPBGN43Vt9LSOwHOTGJpQDITY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aTnPBGN43Vt9LSOwHOTGJpQDITY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/Qxop4-L6zs8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/2154406895636219781/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/07/logical-nonsense.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/2154406895636219781?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/2154406895636219781?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/Qxop4-L6zs8/logical-nonsense.html" title="Logical Nonsense" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.milktrader.net/2011/07/logical-nonsense.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4HRnY5eSp7ImA9WhdREUw.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-4901375398738127765</id><published>2011-07-23T13:30:00.000-07:00</published><updated>2011-07-31T05:22:17.821-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-31T05:22:17.821-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="euro" /><title>Fruit Fly Rodeo</title><content type="html">I was reading up on the debt-ceiling crisis and thought yawn, can we get a little more dramatic about this? Just like the Greek or Portuguese or Italian or Irish debt crisis. Whatever, that's all we hear about anymore. Everyone's got troubles with their debts and spending. These things never get solved because some Bilderberg would be out of a job. And that's when I saw the first fruit fly in my kitchen. Annoying little bugger. They're not fast so I slapped him between my palms with a clap. There, back to reading up on Obama and Boehner making jello or some such thing.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
But then I saw the second one. And a third. Time to step back from my twitter-generated debt-story links and find what piece of rotten fruit was generating interest for these bothersome pests. I knew that contrary to folk wisdom, fruit flies are not spawned from the fruit. They come from elsewhere (probably my neighbor's trash) because they're attracted to fermenting sugars generated by a rotting fruit. I found an over-ripe onion and potato, but no fruit. Probably the end of my troubles for now, I thought, but I wasn't sure.&lt;br /&gt;
&lt;br /&gt;
I decided to get on the offense and fashioned a fruit-fly trap. I filled a jar with compost-ready fruit and covered it with cellophane that I poked through with tiny one-way holes. I hated sacrificing perfectly good compost for this idea, but sometimes that's what it takes. I made two other traps in different flavors. My thought process here being that I'd give the tiny vultures a choice of trap to make it a little less conspicuous. There's nothing more conspicuous to a fruit fly than a single trap.&lt;br /&gt;
&lt;br /&gt;
My bet is that the fermenting Greek fruit is the rottenest trap of the group and that's where the fruit fly swarm ends up going. So I'm short the euro and long the dollar. I just hope they hate jello.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;FULL DISCLOSURE: I'm short from 1.4361 going into the weekend. This was before Obama held a press conference at 7 p.m.&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-4901375398738127765?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TyG1V1QV0D25myHTr1acw2uSyro/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TyG1V1QV0D25myHTr1acw2uSyro/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TyG1V1QV0D25myHTr1acw2uSyro/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TyG1V1QV0D25myHTr1acw2uSyro/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/w3KZ7evPKpM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/4901375398738127765/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/07/fruit-fly-rodeo.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/4901375398738127765?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/4901375398738127765?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/w3KZ7evPKpM/fruit-fly-rodeo.html" title="Fruit Fly Rodeo" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.milktrader.net/2011/07/fruit-fly-rodeo.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUIGSX88cCp7ImA9WhdSFEg.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-46608345787583115</id><published>2011-07-16T07:33:00.000-07:00</published><updated>2011-07-23T13:38:48.178-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-23T13:38:48.178-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tlt" /><category scheme="http://www.blogger.com/atom/ns#" term="strangle" /><title>How To Make Money When You're Confused</title><content type="html">I bought TLT about three weeks ago for $96.85. It's an ETF that tracks 20+ year US Treasuries. I owned this stock last year and when I was doing taxes discovered that my lazy strategy of selling calls and puts and collecting dividends actually yielded some nice returns. But I sold out completely earlier this year (for a loss) because it was "quote" -- technically in a bear market phase. And I listened to some commentary that said bonds were going to zero, or something like that. I can't remember. All I remember is that I was scared. Three weeks ago I wasn't scared anymore and I jumped back in. Three days after I bought back in I was scared again. I picked a local top to go long. Again.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
When I bought back in, I did so with gusto. Not only did I buy the stock, but I sold a naked put at 96 (with July expiration). I was taunting the market (not really, but kinda) to go lower. Technicals were in my favor with a golden cross in play. The put was sold for $1.07. This was very clever, I thought to myself, because if the stock goes down I will have added to my collection at a lower price. If I am exercised, I will own the stock at $94.93. I can live with that. My new cost-basis will be $95.89.&lt;br /&gt;
&lt;br /&gt;
Adding to loser is a sticky issue. If you hear never-add-to-a-loser evangelism, it's likely coming from the pulpit of a scalper. Traders with a horizon of greater than a couple days don't mind building a position over the course of a week, and they are successful with doing things this way. If you're adding with the "it can't go lower" mentality, then go back to paper trading. Or just don't add. I want to play TLT all year, so I can add lower.&lt;br /&gt;
&lt;br /&gt;
The problem with planning to add lower is if the stock actually goes lower and you have to follow through with your plan. When I bought my first lot of TLT along with my naked put, the stock started down. I suffered the typical anxiety, confusion and frustration that comes with picking a top. My solution was to sell an out-of-the-money call immediately. I sold the 97 call (July expiration again) for $0.93. Now I felt better because if TLT's little pullback became a death spiral, then I would own stock at even a lower cost-basis. I just paid myself $2.00 to help deal with the stress of it all.&lt;br /&gt;
&lt;br /&gt;
Over the next couple days TLT continued to sell off. Maybe Gross was right. It sold off four days straight and traded in the low 93s. Uggh. This is when I started data mining how often this type of sell-off occurs, and what happens next. It turned out that there was a small edge for a bounce, so I stayed pat. We bounced off the lows and I let it ride towards expiration.&lt;br /&gt;
&lt;br /&gt;
When expiration week rolled around, TLT was starting to show some life. On Tuesday, Wednesday and Thursday, it breached my short call strike of $97 and now I began to worry that I was giving up my TLT on the cheap. Who knows, maybe Hendry is right and we could go to the moon. Then how would I feel? I breathed the box and decided to let this ride. I would entertain myself watching it trade between $96 and $97, because if it closed there on Friday I would keep the $2.00 synthetic dividend and be on my merry way. On Thursday we closed at $96.01. The drama was becoming intoxicating. On Friday we gapped down to $95.29 and I consoled myself that I would double my TLT position come the weekend. But then we rallied and began trading above $96 again, but below $97. TLT was trading at $96.01 an hour before the close and closed at $96.17. I keep the proceeds with no exercise to the call or the put. &lt;br /&gt;
&lt;br /&gt;
The technical name for my trade is a short strangle. There is no upside risk if you have stock to cover the call, unless you consider getting a small profit a risk and that's just plain dumb. The risk is to the downside. If TLT goes to zero, I lose it all. Twice because of the naked put.&lt;br /&gt;
&lt;br /&gt;
If you have a favorite stock you trade and don't mind getting extra or giving away what you have, short strangles and straddles might be a candidate. I say might. The TLT trade&amp;nbsp;requires one-contract un-leveraged capital north of $19,000 so I don't recommend this strategy until you can become comfortable with being confused.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-46608345787583115?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/SX9jlThFCNw2FYXfbAI4nT9cXi8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SX9jlThFCNw2FYXfbAI4nT9cXi8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/SX9jlThFCNw2FYXfbAI4nT9cXi8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SX9jlThFCNw2FYXfbAI4nT9cXi8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/oi4DAXC1hEo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/46608345787583115/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/07/how-to-make-money-when-youre-confused.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/46608345787583115?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/46608345787583115?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/oi4DAXC1hEo/how-to-make-money-when-youre-confused.html" title="How To Make Money When You're Confused" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://www.milktrader.net/2011/07/how-to-make-money-when-youre-confused.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04BQXo4fCp7ImA9WhZaFks.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-5165073297085832541</id><published>2011-06-30T21:25:00.000-07:00</published><updated>2011-07-02T19:59:10.434-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-02T19:59:10.434-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="backtesting" /><category scheme="http://www.blogger.com/atom/ns#" term="SPX" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Last Time That Happened</title><content type="html">I bought a lottery ticket yesterday. I hardly ever buy them. The last time I did I lost a dollar. Actually, every time I've bought a ticket I've lost.&amp;nbsp; Yesterday I was at the local gas station in line behind a bloke who had a comprehensive folder of tickets. Kinda like those extreme coupon people, but he had lotto tickets instead. I thought to myself "why not?" This morning I checked the numbers. I lost my dollar. I hope whoever won it is happy to have it. &lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
We are all compelled to use our experiences as factors to our judgment. There is no guarantee that history repeats itself, of course. But it's good to have some perspective on last time something happened. Sort of like the meltup we had the last four days. The S&amp;amp;P 500 returned over 0.85 percent for four days in a row. Wow. When was the last time that happened?&lt;br /&gt;
&lt;br /&gt;
Well, good thing we have R to do some data mining for us. Here is a nifty function that returns a data series complete with my own preferences on how to view things. It defaults to using the Federal Reserve of St. Louis for its data source. That takes us back to 1957.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;future &amp;lt;- function(sym="SP500", source="FRED"){&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; require("quantmod")&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;- getSymbols(sym, src=source, auto.assign=FALSE)&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; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$ret&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;- dailyReturn(x, type="log")&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; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$ago.1&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$ago.2&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=2)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$ago.3&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=3)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$ago.4&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=4)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$next.1&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=-1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$next.2&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=-2)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$next.3&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=-3)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$next.4&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=-4)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$next.5&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=-5)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$next.6&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=-6)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$next.7&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=-7)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$next.8&amp;nbsp;&amp;nbsp; &amp;lt;- lag(x$ret, k=-8)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x$in.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; exp(x$next.1)-1&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; x$in.2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; exp(x$next.1 + x$next.2)-1&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; x$in.3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; exp(x$next.1 + x$next.2 + x$next.3)-1&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; x$in.4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; exp(x$next.1 + x$next.2 + x$next.3 + x$next.4)-1&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; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; x$in.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; exp(x$next.1 + x$next.2 + x$next.3 + x$next.4 + x$next.5)-1&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; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; x$in.6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; exp(x$next.1 + x$next.2 + x$next.3 + x$next.4 + x$next.5 + x$next.6)-1&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; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; x$in.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; exp(x$next.1 + x$next.2 + x$next.3 + x$next.4 + x$next.5 + x$next.6 + x$next.7)-1&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; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; x$in.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; exp(x$next.1 + x$next.2 + x$next.3 + x$next.4 + x$next.5 + x$next.6 + x$next.7 + x$next.8)-1&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; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; food&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;- paste(sym,"future.returns",&amp;nbsp;&amp;nbsp; sep=".")&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; assign(food, x, envir=.GlobalEnv)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you run this program, you will get an unwieldy monstrosity. First, re-assign the name of the object returned by the function to &lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;S&lt;/span&gt;. Then, you need to do a little indexing to get the data you want. To get only those days where the last four days each had returns that exceeded 0.85%, run this little command from the R command prompt:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;s &amp;lt;- S[(exp(S$ret)-1) &amp;gt; .0085 &amp;amp; (exp(S$ago.1)-1) &amp;gt; .0085 &amp;amp; (exp(S$ago.2)-1) &amp;gt; .0085 &amp;amp; (exp(S$ago.3)-1) &amp;gt; .0085 ]&lt;/div&gt;&lt;br /&gt;
It's a little verbose, but I prefer using log returns so sometimes it requires a little extra jumping around. This gives you a smaller data set, of length 9. We are interested in next.1, which are the returns the next day. Again with the dog-and-pony show with logs, but it must be done. It makes sense to plot it with a histogram, so let's do that all with one fell swoop.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;hist((exp(s$next.1)-1), col="burlywood", main="Next Day Returns After Four Consecutive Up Days\n of Over 0.85% Each", xlab="1957 to Present")&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
And here is the resulting chart:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-NB_fxpBu3hI/Tg1K2fIntjI/AAAAAAAAAMY/iPt8a1QIikI/s1600/Screen+shot+2011-06-30+at+11.38.33+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="261" src="http://3.bp.blogspot.com/-NB_fxpBu3hI/Tg1K2fIntjI/AAAAAAAAAMY/iPt8a1QIikI/s320/Screen+shot+2011-06-30+at+11.38.33+PM.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;There you have it. Seven out of nine times the next day is a loser. Even with those odds, I would hesitate to bet a dollar on it though. Okay, maybe one dollar.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-5165073297085832541?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/SHkpmQrcnGRjlU-5_NC6sDz7jlo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SHkpmQrcnGRjlU-5_NC6sDz7jlo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/SHkpmQrcnGRjlU-5_NC6sDz7jlo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SHkpmQrcnGRjlU-5_NC6sDz7jlo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/VpJiRPf5jhI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/5165073297085832541/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/06/last-time-that-happened.html#comment-form" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/5165073297085832541?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/5165073297085832541?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/VpJiRPf5jhI/last-time-that-happened.html" title="Last Time That Happened" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-NB_fxpBu3hI/Tg1K2fIntjI/AAAAAAAAAMY/iPt8a1QIikI/s72-c/Screen+shot+2011-06-30+at+11.38.33+PM.png" height="72" width="72" /><thr:total>5</thr:total><feedburner:origLink>http://www.milktrader.net/2011/06/last-time-that-happened.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUADRnk7eCp7ImA9WhZaFEo.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-1144373510602357341</id><published>2011-06-26T10:06:00.000-07:00</published><updated>2011-06-30T15:42:57.700-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-30T15:42:57.700-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="statistics" /><category scheme="http://www.blogger.com/atom/ns#" term="trading models" /><title>Hello, Goodbye Linear Regression</title><content type="html">Summer is the time to visit family. Kids get some grandma and grandpa time, parents get to spend some time with siblings and their parents or in-laws. It's a grand time of the year. For some, these summer relationships are a little "quote" -- complicated. "Well it's good to see things are going well." Ten minutes pass. "I think we'd better go to the airport a little early since there is so much traffic and with the new security issues and all." Hello, goodbye is a common meme.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
I decided to pick up a book on statistics this past week to help pass some time during these hot days. I can't remember when we started a relationship, but I know it's been a long time. And often frustrating. After pondering how linear regression modeling can help me with building trading models, I decided that it can't. These statistical techniques have too much baggage and I don't have time to deal with it. Everything has to be perfect for them. Zero mean of disturbances, constant variance of errors (homoscedasticity, if you prefer six-syllable words),&amp;nbsp; non-stochastic predictor variables. Really?&amp;nbsp; People live like this? In what universe if you don't mind me asking?&lt;br /&gt;
&lt;br /&gt;
I've also changed through the years, so maybe I shouldn't be too hard on linear regression. These days, I much prefer questions that are framed where the dependent variable is dichotomous. This is asking too much from linear regression modeling. Sure they try with dummy variables, but then they suffer from nonsense predictions given the nature of boundary problems. They try to compensate for this with truncating regression lines at boundaries, but then they're saying that predictor variables have no influence at these points, which is troublesome as I'm sure you'd agree. By the time they start modifying their straight line predictions to an S-shaped curve, which is more appropriate, we have our last vestige of hope that this relationship can be meaningful dashed. You see, once you start curving a linear regression model to accommodate for a boundary, you've violated just about every assumption that linear regression has. There is probably a warrant out for your arrest. Not to mention that you're saying sayonara to making sense of additivity with this approach.&lt;br /&gt;
&lt;br /&gt;
There is a statistical technique related to linear regression called non-linear regression. If you familiarize yourself with her it will remind you of when you first got married and pondered how such a lovely person could come from such people who have so little in common with you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-1144373510602357341?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/lo9AAyS0FbYy5Srlt8-IL74WKvo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lo9AAyS0FbYy5Srlt8-IL74WKvo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/lo9AAyS0FbYy5Srlt8-IL74WKvo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lo9AAyS0FbYy5Srlt8-IL74WKvo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/p8WrBv-RCYg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/1144373510602357341/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/06/hello-goodbye-linear-regression.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1144373510602357341?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/1144373510602357341?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/p8WrBv-RCYg/hello-goodbye-linear-regression.html" title="Hello, Goodbye Linear Regression" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://www.milktrader.net/2011/06/hello-goodbye-linear-regression.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0EGRno9fip7ImA9WhZaEU0.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-608950755074844209</id><published>2011-06-20T17:36:00.000-07:00</published><updated>2011-06-26T09:27:07.466-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-26T09:27:07.466-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="system trading" /><title>Trading Model Derby</title><content type="html">This past year was the first year I made two models. That's because my youngest son has joined his older brother in Cub Scouts and the annual ritual of Pinewood Derby Car building became twice the fun.&amp;nbsp; I've been "quote" -- helping -- my oldest for two years now, so I've got some experience. I've learned quite a bit from watching how others have built their cars. I look at both winners and losers to form my theories on how a model should be constructed. Losers typically have some piece of Lego attached to it, creating a pretty car with catastrophic drag. The winners tend to be modestly built (not over-engineered, mind you) and properly weighted.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
This year as I had both models resting on a table near my kitchen, my neighbor came over and decided to make some comments. This is the neighbor who takes great pleasure in contradicting everything I say. I could say "the sky is blue" and he would invariably respond with "the sky is&lt;i&gt; not&lt;/i&gt; blue." I call him Null Hypothesis. I take pleasure in watching his silly comments laid waste, but sometimes it takes more effort than I'm willing to expend at the moment. This year he proclaimed "those cars will lose, they are too simple." I could not prove him wrong on the spot, but the die was cast. I responded "they will not lose, but &lt;i&gt;you&lt;/i&gt; will lose. These cars will win first place!" It would take racing day results to reject my neighbor's proclamation.&amp;nbsp; I couldn't wait.&lt;br /&gt;
&lt;br /&gt;
While it's true that I'm a Cub-Scout Pinewood Derby car-builder dad by day, I'm also a algorithm trading model builder by night. I've got the Bumblebee, Gnat, Monkey, Pelican and a whole host of others sitting on the shelf. These vary in construction from simple trading-rule algos to more sophisticated predictors that implement radial-basis function support vector machines. I do suffer from&amp;nbsp; an ambitious curiosity as to how others are building their models though, so I tend to look around and survey the landscape often.&amp;nbsp; I've lately glanced over to a group of builders called Econometricians. No, not electricians. I mean practitioners of the black art of Econometrics.&lt;br /&gt;
&lt;br /&gt;
Econometrics is the science, art and voodoo of building financial models. They are typically frequentists so I found it important to familiarize myself with their methods and terms. When they build their models, they save the wood chips for analysis. Yes, they are indeed a serious group.&lt;br /&gt;
&lt;br /&gt;
One of their favorite modeling techniques is called regression. All types including simple linear regression, polynomial and multiple linear regressions. Regression is basically the process of fitting a line or curve to describe the relationship between a dependent variable and an independent variable or variables. Kind of like the return tomorrow of the S&amp;amp;P 500 will have a relationship with the return of the range of the VIX today. Something like that. &lt;br /&gt;
&lt;br /&gt;
Building the model is not the difficult part. It's analyzing the model and the wood chips (commonly referred to as disturbances) where things can get a little complicated. If the wood chips are too cozy with each other, as in they are serially correlated, there's a problem. If the goodness of fit (R-squared) is low, there's a problem. If the F-statistic isn't large enough or the p-value isn't small enough, there's a problem. You spend most of the time trying to prove that the opposite of what you're trying to show is false. I can sort of relate to this, with my neighbor being who he is. But I know what my neighbor looks like, a 50-something male with kids already out of the house. They don't tell you up front who their pesky neighbor is so you need to listen carefully. Actually, you don't have to listen because I'll just tell you. It's the hypothesis that there is no relationship, or that the slope of the regression is zero.&lt;br /&gt;
&lt;br /&gt;
It isn't good enough to reject this null hypothesis of course, but that's the minimum. I'm going to take a shot soon at this wily art and build myself my own model or two. I'm expecting the first few attempts to fail miserably because this process includes a laundry list of assumptions that I can't keep track of ranging from &lt;i&gt;expected mean of errors is zero&lt;/i&gt; to &lt;i&gt;explanatory variables must be non-stochastic&lt;/i&gt;. I really can't tell you if anyone ever races one of these models though, so I can't tell you how well they will perform.&lt;br /&gt;
&lt;br /&gt;
You have to race your model eventually, and on race day back at Cub Scouts I was able to prove my neighbor Null Hypothesis wrong. My boys' cars didn't lose. They won a couple of heats. I wasn't really right to say they would win first place because they didn't (silly dad forgot to sand off the burrs on the nail axles!), but at least my neighbor Null Hypothesis was rejected. Next year, the Den Leaders have agreed that dads will be able to build their own dad-only cars for a special race. The only rules are no thermonuclear powered devices. I can't wait.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-608950755074844209?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/qCkC6hR_plJxFpFGZ4Wo4LjYwO8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qCkC6hR_plJxFpFGZ4Wo4LjYwO8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/qCkC6hR_plJxFpFGZ4Wo4LjYwO8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qCkC6hR_plJxFpFGZ4Wo4LjYwO8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/Rh9dSzVZPS8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/608950755074844209/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/06/trading-model-derby.html#comment-form" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/608950755074844209?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/608950755074844209?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/Rh9dSzVZPS8/trading-model-derby.html" title="Trading Model Derby" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>7</thr:total><feedburner:origLink>http://www.milktrader.net/2011/06/trading-model-derby.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UGSX07eyp7ImA9WhZbFkk.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-3308604882647034987</id><published>2011-06-08T14:29:00.000-07:00</published><updated>2011-06-21T02:40:28.303-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-21T02:40:28.303-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>vRoom vRoom : Speeding up R with C</title><content type="html">Many times you don't want to trouble friends for help with menial tasks like moving furniture. But sometimes you need to step out and ask. Your friends are always happy to help, and after the heavy lifting is done you see how easy it can be. R likes to move furniture. It's okay with moving a small table across the room, but when you need to bring a large sofa up three flights of stairs, it's time to ask for help. Your best friend is C.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
The basic idea behind speeding up R with a C script is to write a C script, compile it, load it into the environment (ask it over to the house, so to speak) and call it from R with a built-in R function. There are some choices here but for our test case, we're going to use the &lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;.C() function&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
A couple ground rules first. The C function must be of type void (does not return nothing) and needs to accept pointer arguments. You define the argument in R as an object, and it gets passed as a pointer to the C function. R objects are basically pointers anyway so this is not terribly difficult. Let's illustrate before this becomes a lecture on pointers and objects.&lt;br /&gt;
&lt;br /&gt;
Here is the code for an R function that uses an R loop to print out permutations of a double loop. It's the guts of a brute force search but only returns a string saying that it was able to locate and print each permutation. You can either copy and paste it into R or save it and &lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;source()&lt;/span&gt; it.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt; twoloop &amp;lt;- function(){&lt;br /&gt;
for(i in seq(10, 50, 1 ))&lt;br /&gt;
&amp;nbsp; for(j in seq(80, 240, 4))&lt;br /&gt;
cat("Parameter one is", i, "and Parameter two is",j,"\n" )&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
We are stepping from 10 to 50 in increments of 1 (40 events) and also from 80 to 240 in steps of 4 (40 events again). The permutation total is those two multiplied, which comes to 1600. The size of a large sofa basically. R can do it, but it takes some time because of the explicit looping. Here is the tail of the output along with performance statistics.&amp;nbsp;The &lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;system.time()&lt;/span&gt; function is used to calculate performance.&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;system.time(twoloop())&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 224&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 228&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 232&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 236&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 240&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp;user &amp;nbsp;system elapsed&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp; 0.070 &amp;nbsp; 0.031 &amp;nbsp; 0.139&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To get some help from C, we write the following script:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt; R.h &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;#include &lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt; stdio.h &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;void twoloop(int *startOne, int *stopOne, int *stepOne, int *startTwo, int *stopTwo, int *stepTwo)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;int i,j;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;for(i = *startOne; i &amp;lt; *stopOne+1; i = i + *stepOne)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;for(j = *startTwo; j &amp;lt; *stopTwo+1; j = j + *stepTwo)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;Rprintf("Parameter one is %d and Parameter two is %d\n", i, j);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Notice the pointer arguments. Also, notice we include R.h header file. Save this script as twoloop.c and then from command line, use the following instruction to compile it.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;R CMD SHLIB twoloop.c&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This creates a new file called twoloop.so that will be loaded into R with the following function inside of an R session.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;dyn.load("twoloop.so")&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Great, now we use the &lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;.C() function&lt;/span&gt; to call the function. But first we need to create some R objects. There are six variables so here is what we'll do.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;a &amp;lt;- 10&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;b &amp;lt;- 50&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;c &amp;lt;- 1&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;p &amp;lt;- 180&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;q &amp;lt;- 240&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;r &amp;lt;- 4&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now we simply pass those objects in as integers. Remember, that is what the C function is expecting so let's not mess around. It is here to help us after all.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;.C("twoloop", as.integer(a), as.integer(b), as.integer(c), as.integer(p), as.integer(q), as.integer(r))&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Of course if you're like me, you run the function first because you're so excited to see if it actually works. It does and then you remember that you were supposed to time it. No worry here, hit the up arrow to prompt R to display the last command (the monstrosity above) and hit Ctrl-A to get to the beginning of the command. Insert system.time() like thus:&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;system.time(.C("twoloop", as.integer(a), as.integer(b), as.integer(c), as.integer(p), as.integer(q), as.integer(r)))&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Here is the tail of the C function's output along with its performance.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 224&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 228&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 232&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 236&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;Parameter one is 50 and Parameter two is 240&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue; font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp;user &amp;nbsp;system elapsed&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&amp;nbsp; 0.002 &amp;nbsp; 0.002 &amp;nbsp; 0.017&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nice. Time to crack a beer on the new sofa. With our best friend C.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-3308604882647034987?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/twSKdVWP-pj49qjlVOpiszI9q-0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/twSKdVWP-pj49qjlVOpiszI9q-0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/twSKdVWP-pj49qjlVOpiszI9q-0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/twSKdVWP-pj49qjlVOpiszI9q-0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/eDuZD2OyKNI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/3308604882647034987/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/06/vroom-vroom-speeding-up-r-with-c.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3308604882647034987?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/3308604882647034987?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/eDuZD2OyKNI/vroom-vroom-speeding-up-r-with-c.html" title="vRoom vRoom : Speeding up R with C" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>4</thr:total><feedburner:origLink>http://www.milktrader.net/2011/06/vroom-vroom-speeding-up-r-with-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak4MQHc7eip7ImA9WhZUFUs.&quot;"><id>tag:blogger.com,1999:blog-3910008585223856206.post-5832532774935046707</id><published>2011-06-06T15:52:00.000-07:00</published><updated>2011-06-08T14:36:21.902-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-08T14:36:21.902-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="system trading" /><title>An Pre-Introduction to Brute Force Parameter Search in C</title><content type="html">It used to be that our culture was simple technology and sophisticated people. Now the technology is sophisticated and the people are simple. But you don't need to feel trapped. You can always get into a time machine (I know, sophisticated technology) and go back in time to when technology was not so complex. You know, back when people wrote programs in C. From command line. With vi. Ah yes, those were the days.&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
We shall travel there now, and find a way to create a series of permutations between two parameters. If this sounds crazy, well it just means you haven't been stress testing your favorite trading system, that's all. You know the system I'm talking about. The one where you place trades based on where the 50-day and 200-day moving averages are in relation to one another. You can backtest this strategy based on these simple rules, but the true curve-fitting fun starts when you backtest a whole bunch of parameters. For example, the 50-day and the 180-day. Or the 40-day and the 160-day. You get the idea.&lt;br /&gt;
&lt;br /&gt;
I wrote one such program in R recently, but I must admit it was a bit ... yawn ... slow. It was actually painful to watch. I felt bad for R, really. Well not to worry, we can amp it up a bit with a little C program that takes the burden off R and busts out the parameters lickety-split. The first part of this process is to get the C code right. There is no better way than to fire up vi and start a typing.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;code&gt;$ vi parameter_cruncher.c&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
That opens up a new window where you can start typing in the following code. Remember that to actually type in vi you have to select the "i" key. That puts you in insert mode. Anyway, here is the code:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;// takes 6 arguments&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv) &lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;int m = atoi(argv[1]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;int n = atoi(argv[2]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;int p = atoi(argv[3]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;int q = atoi(argv[4]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;int r = atoi(argv[5]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;int s = atoi(argv[6]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int i;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int j;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; for( i=m; i&amp;lt;n+1; i=i+p)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( j=q; j&amp;lt;r+1; j=j+s)&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;printf("Parameter 1 is %d, Parameter 2 is %d\n", i, j);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;&lt;br /&gt;
}&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Once you get that saved, you can compile it from command line with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;code&gt;$ gcc parameter_cruncher.c -o parm&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
This makes our executable a bit more manageable to type. Then we type the following with 6 arguments (it's in the comments, but you can also count the variables that call the atoi (ASCII to Integer) function).&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;code&gt;$ ./parm 10 50 10 150 250 50&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
This reads as from 10 to 50 in steps of 10 and from 150 to 250 in steps of 50. Basic permutation stuff, nothing complicated really. I wrote this to test that the code actually does what I want it to do before I implement it by calling it from R.&lt;br /&gt;
&lt;br /&gt;
This list isn't too long (can you calculate the correct permutation count in your head? quick!). Here it is below:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;Parameter 1 is 10, Parameter 2 is 150&lt;br /&gt;
Parameter 1 is 10, Parameter 2 is 200&lt;br /&gt;
Parameter 1 is 10, Parameter 2 is 250&lt;br /&gt;
Parameter 1 is 20, Parameter 2 is 150&lt;br /&gt;
Parameter 1 is 20, Parameter 2 is 200&lt;br /&gt;
Parameter 1 is 20, Parameter 2 is 250&lt;br /&gt;
Parameter 1 is 30, Parameter 2 is 150&lt;br /&gt;
Parameter 1 is 30, Parameter 2 is 200&lt;br /&gt;
Parameter 1 is 30, Parameter 2 is 250&lt;br /&gt;
Parameter 1 is 40, Parameter 2 is 150&lt;br /&gt;
Parameter 1 is 40, Parameter 2 is 200&lt;br /&gt;
Parameter 1 is 40, Parameter 2 is 250&lt;br /&gt;
Parameter 1 is 50, Parameter 2 is 150&lt;br /&gt;
Parameter 1 is 50, Parameter 2 is 200&lt;br /&gt;
Parameter 1 is 50, Parameter 2 is 250&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3910008585223856206-5832532774935046707?l=www.milktrader.net' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3TlqvdpFzWsDGSEdSxdawaw4qOM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3TlqvdpFzWsDGSEdSxdawaw4qOM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3TlqvdpFzWsDGSEdSxdawaw4qOM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3TlqvdpFzWsDGSEdSxdawaw4qOM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilkTrader/~4/9VGckHKyYGY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.milktrader.net/feeds/5832532774935046707/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.milktrader.net/2011/06/pre-introduction-to-brute-force.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/5832532774935046707?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3910008585223856206/posts/default/5832532774935046707?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilkTrader/~3/9VGckHKyYGY/pre-introduction-to-brute-force.html" title="An Pre-Introduction to Brute Force Parameter Search in C" /><author><name>Milk Trader</name><uri>http://www.blogger.com/profile/15008769973064875700</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="31" src="http://1.bp.blogspot.com/_6QnR1wYKwPU/SYnKYac4-pI/AAAAAAAAACg/a5Va4sEaNc0/S220/milkman6.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.milktrader.net/2011/06/pre-introduction-to-brute-force.html</feedburner:origLink></entry></feed>

