Turn-of-the-month effect strategy

Discussion in 'Automated Trading' started by 123tempid, Sep 7, 2011.

  1. 123tempid


    I would like to execute a very simple strategy with an automated program, which will trade for me without me having to be remember to physically do it 4 times a month:

    Buy ticker SPY on the 27th of every month (on open) and sell it on the 5th (on close) , then buy it again on the 12th (on open) and sell it on the 18th (on close). If these dates fall on weekends / holidays adjust accordingly (I can manually write out the exact dates for the next 20 years myself). I also want the program to calculate the amount of shares to be bought automatically based on my available capital and the current price of SPY.

    I contacted some API developers that IB recommended on their website and the quotes I was getting were in the thousands. This is cost prohibitive for me as I'm only looking to employ $20k into the strategy. It's been frustrating for me, because this seems like such a simple task, but I can't seem to find a cheap way of accomplishing it.

    I'd be grateful for any feedback you guys may have.
  2. http://www.youtube.com/watch?v=MvrpfGrHFSA

    I've written this to interface with TWS IB and I'm sure I can easily code your strategy.

    Contact me with the details (private PM and I'll give you my contact details) if you can write Java you can code it yourself if not I'll do it.

    Should be a fun little project!!


  3. You might be able to get an approximation of what you are looking for simply by using the IB orders: "Good After Date" and "Good Until Date"

    It won't do the automatic sizing for you, but maybe you have a set size and review your orders once a month or something to modify the working orders.

    This way, all the orders are kept on the IB servers and you don't need to worry about auto starting your software on reboot, power outages, etc. Also, I don't know how you'd get around the TWS auto-logoff/log-on feature as they use the keycard protection. Sure, you can request that they disable that feature, but then you're hanging yourself out to dry if someone compromises your account.
    I haven't tried the TWS gateway yet, but I think it operates the same as the desktop as far as security logon/log-off goes.
  4. 123tempid


    The Goonier: Per IB's website:

    Good After Time (GAT) Orders will be canceled automatically under the following condition:

    At the end of business on the last day of the following calendar quarter.

    It's nice thought, but it's far from a perfect solution, especially since I have to keep adjusting order size
  5. Quickly tested this. The 27 - 5 trade is actually not too bad. I didn't put in rules for wknds/holidays, but I believe you would hit as many big winners as losers, if the 5th got skipped until the next month for example. Slightly higher risk though.

    Shows a 63% win rate over the last 10 years - about the same as the "normal" 60% monthly long wins over time - but avg profit was slightly better than avg loss (3.29% vs -3.1%). Costs were .01/shr and PF was 1.79.

    The strategy easily beat Buy-hold over the time period, but only because of the nasty 08-09 drop. Interestingly, before this year, there were only 3 losing years back to 1988 (SPY extended by Worden). This year it caught that bad July-Aug dump.
  6. It should be apparent IF you bought SPY 7/27 on open and sold 8/5 MOC, you would have pissed away 12 points unlevered.

    What you have is a seasonal bias. Hardly infallible.

    Consider buying the Thursday before expiration and sell after assignment on the following Friday afternoon. It too is a bias.
  7. 123tempid


    I backtested the strategy since 1950 using the S&P 500 data from yahoo finance as a proxy for SPY. The strategy had an CAGR of 11% vs buy & hold 7%. Max drawdown was also much lower (-40% vs -57%). I ignored bid-ask spread and transaction costs, but I think the dividends that the yahoo finance data lacks which should have been included more than makes up for that.

    I'm old school so I did this all in excel. Would be happy to share my spreadsheet if anyone wants to take a glance. It is has breakdowns by 5 year periods, which can be adjusted.