Monday, June 20, 2005

If I feel great about the market, does that mean I should get short now?

I bought some in-the-money QQQQ July 42.5 puts today. I feel really good about my portfolio. It's at all time high's. Just about every stock I own in my long-term portfolio today was up quite a bit...SHLD, CMCSA, even LU! When I feel this good about my long-term stock holdings often this means it's time to short the Q's. I hope I'm not shorting too early here. Most of the time I've been actively trading has been during markets where this type of strategy has worked well. (range-bound and bear markets).

I hope past success hasn't conditioned me to get hurt by shorting an extended rally. I do feel bullish long-term, but my gut tells me to get short for a counter-trend. This is a very small position. However, one of the happy consequences of writing this blog is that I now pay more attention to my small side-trades. One thing that has become apparent under this increased scrutiny is the small really losses add up. Since my main strategy (selling option premium) is to take lots of small gains...I need to be careful about allowing myself to take too many small losses as well while trading these random "gut feelings" I get.

I got all of my stricknet.com options data imported into my database by Friday night. The next step here is to compute implied volatilities for every price-record. Saturday, I wrote some routines to work with the Black-Scholes equation in C#. The appendix in Option Volatility & Pricing by Natenberg was especially invaluable for this. This was my main source for this undertaking. The information in this book's appendix was refreshingly complete and concise. I also cross-referenced with Options as a Strategic Investment by McMillan. One of the things I love about McMillan's book is he throws in so much practical stuff for programmers...not just formulas and theories, but actual sample data and sample step-by-step calculations so you can check your work. This was key for me while debugging my code.

Next, I needed a source of historical interest rates. (The "risk-free" interest rate is one of the variables in the Black-Scholes equation.) The daily Fed-Funds rates are available at the federal reserve's website. I wrote a parser to pull this data into my database. Now I was armed with everything I needed to compute IV's for each of the 83 million individual option price records.
At this point I started to get excited. Could it be that in another few hours I would have 3 years of historical options data for backtesting at my virtual finger-tips? I wrote an sql query to query all of the variables to compute IV, and executed it to make sure the syntax was right. I waited about an hour and it still wasn't done running, so I decided to check this out in the MySQL query analyzer. Well without getting into too many more boring details, it turns out the query was very bad. I bet the universe would end before it was done. So I decided to add 2 indexes that I thought would help matters considerably. I added one to the daily equity prices table, and one to the daily option prices table, and then I waited, and waited and waited and waited. Then finally, Sunday night after I had gone to bed, I walked past my computer on the way to the kitchen to get a glass of water, when I heard a little "beep". Just at that moment, it had finally finished computing the index on the equities price table. This table is considerably smaller than the option price table and it took what? over 48 hours maybe?

Well, it doesn't even take that long to import the options data in the first place. So I decided what I'll do is delete the options data, add my index to the empty table, then re-import all of the data. I am going to write code to compute IV's and put this in the database along with the data to save myself having to re-read all of the data later. I think this will save me a lot of time in the longer run. I've also decided to bite the bullet and set up a separate database server, so that in the future I can run long operations without slowing down my main working computer.

Holy crap! What a pain in the ass this has been! I thought I was used to working with fairly large and complicated databases with my main business. These were nothing compared to this option price data. One pleasant result is that while waiting for the re-indexing to complete I wrote a program I have been meaning to write for some time. On page 800 of Options as a Strategic Investment by McMillan, he writes about a technique for ranking the historical volatilities of a stock, to get a picture of where current volatilities are in relation to the stock's past volatility behavior. This can be easily implemented using the AdjustedClose field from the historical stock market data at finance.yahoo.com. I wrote a neat little windows-forms app to do this analysis using the historical yahoo data I allready have. I will write more about this program, the technique, and what the next steps I hope to undertake to enhance it, in a later post after I find a place to host some screen-shots.

2 Comments:

At 10:08 PM, Blogger Alien Shaman said...

Did you finish your data import w/ index yet? How long did it take this time?

 
At 2:17 PM, Blogger Quant Trader said...

No, I am unsure of exactly how I want to structure the data so I've been working on other things in the meantime while I think about it. For example, I think that I've decided that it will be a bad idea to pre-calculate iv's, and I've also decided to eliminate a table, but I'm still not sure about these changes so I am reluctant to do any work on this importer until I am sure.

Mainly, I've been refactoring my code to impliment techniques I've learned with the options data-import in my other data-importers. I've also been preparing the code so that I can move the software and database to a dedicated database server.

 

Post a Comment

Links to this post:

Create a Link

<< Home