Saturday 21 April 2012

Week of 2012 AL 20

SPY rose by 0.6% this week, while my account (and loss floor) fell 0.9% to their lowest values ever.

Daily % gain
size
Max lossFinal Gain
Sym  Buy Fri Mon Tue Wed Thu Fri Beg   End
 
TZA  AL04 +1.3  29 +0.9  29 -3.8  0 -0.8%
TNA  AL17 -1.0  15 -3.6  14 -5.3  14 -3.7  14 -8.2 -8.4 -6.0%
SPY +9.3 +9.2 +10.8 +10.4 +9.7 +9.9
me -3.9 -3.9 -4.1 -4.5 -4.8 -4.8
floor -3.9 -3.9 -5.2 -5.2 -4.8 -4.8

TNA: Thursday’s IWM-stop update was “no change”, but there was some wobble in the IWMTNA price conversion, so the max-loss value went down slightly.  Previously I had a TZA stop go up slightly under similar conditions.  This is just something to put with in the current design.

Stock-trading robot

Ticker
Symbol
Buy dateBuy priceSell dateSell priceAcct Profit
ModelActualMAModelActualMAMA
TNA AL 17 11:00 $57.96 $58.15 AL 19 15:00 $54.75 $54.76 -0.8% -0.9%

TNA: Rats!  Fourth loss in a row.  Paid too much on Tuesday, then got very little extra on Thursday, so actual loss ends up 0.1 %-points larger than model.

New rule: When calculating the daily stop, if the lowest price for the last N hours was during the latest hour, then sell immediately rather than raising the stop.  This improves average profit slightly, but more importantly it avoids a potential glitch: suppose the stock is in free-fall, so the current price is the lowest price.  Seconds later the robot tries to set that price as the stop, but the stock has since fallen further and so Schwab rejects the stop-order because it’s already underwater.

Bugfix: The models were not calculating their gains properly.  Basically, they were adding the transaction cost instead of subtracting it.  This is presumably why the last few trades had mismatches between model-profit and actual-profit.  This bugfix reduced apparent profit for 2008…2011 by several percent—but now it’s more realistic.

New trading model

I can haz nu model!  The design target for this model was to catch short downswings like the one that happened last week.  Also, this model avoids real-valued parameters, using moving averages and channels instead.  Because the absolute values of the indicators do not matter, I can use good ol’ MACD instead of PPO.

This is a short-selling model, meaning that I want IWM’s price to go down during the trade.  The “buy” and “sell” actions refer to SRTY, which (like TZA) is a 3× leveraged inverse ETF that tracks the Russell 2000 basket of stocks.

This model has no “buy more” signal.  Only a single tranche is ever purchased.

Buy signal:
  • Time = 10am–3pm, on the hour.
  • This hour’s price is below stop.
  • This hour’s price < SMA( 27 ).
  • Previous hour’s price < SMA( 27 ).
  • MACD( 15, 66, 9 ) < 0.0
  • MACD( 4, 16, 4 ) < its high over the previous 12 hours.
  • MACD( 4, 16, 4 ) > its low  over the previous 12 hours.
  • STDDEV( 7 ) > its EMA( 8 ).
  • I don’t currently own URTY, whose “buy” signal is a strong contrary indicator for SRTY.
  • When buying, lower stop to be no more than 2.7% higher than this hour’s price.
Sell signal:
  • Time = 10am–3pm, on the hour.
  • Either:
    • This hour’s price > SMA( 27 ).
    • MACD( 4, 16, 4 ) > its high over the previous 12 hours.
Stop update:
  • Time = 10am.
  • Calculate new stop = highest price seen in preceding 15 hours.
  • Replace stop with the newly-calculated value, unless I currently own SRTY and the new value is higher than the current one.
  • If the highest price of the last 15 hours was during the last hour, this is a “sell” signal.  Otherwise, if I currently own SRTY, convert this IWM stop to the equivalent SRTY price and update the standing sell-stop order at Schwab.

Below is a chart showing how this model would have behaved over the last four weeeks.  There were three losses and one gain, adding up to -0.1%.  Without the STDDEV requirement, the model would have bought on AL 05 instead of AL 09, for a much bigger gain and overall a profitable month.  But STDDEV is very useful: when volatility is low, most swing trades are losers.  Without it, this model would have a win:loss ratio of 114:189; with STDDEV, it’s 100:116 and the 30% profit over four years is increased to 40%.  But not so hot this month.

Summary of models

Hypothetical Historical Returns
Quarter   TNA TZA URTY SRTY  
qtr
—Total—
yr
2008 Q1 3.2% 0.5% 0.0% 1.7% 5.4% 53.3%
Q2 -2.0% -0.9% 1.1% 0.0% -1.8%  
Q3 2.8% -0.2% 5.4% 2.4% 10.4%
Q4 4.9% 15.5% 3.8% 15.1% 39.3%
2009 Q1 8.6% 4.0% 1.2% 10.3% 24.1% 59.8%
Q2 -1.5% -1.6% 21.6% -1.3% 17.2%  
Q3 7.9% 1.7% -2.0% -0.4% 7.2%
Q4 -0.2% 4.3% 4.5% 2.7% 11.3%
2010 Q1 4.0% -0.8% 0.0% -1.1% 2.1% 45.7%
Q2 -1.9% 8.0% 13.2% 4.0% 23.3%  
Q3 -1.3% 5.4% -0.6% 1.9% 5.4%
Q4 0.2% -1.2% 16.7% -0.8% 14.9%
2011 Q1 0.6% 0.9% -0.5% -1.0% 0.0% 55.4%
Q2 4.8% -1.2% -1.0% 0.2% 2.8%  
Q3 3.9% 24.2% 0.8% 6.5% 35.4%
Q4 2.3% -0.7% 3.1% 1.8% 6.5%
2012 Q1 0.4% -1.7% 12.9% -0.9% 10.7%
Total 36.7% 56.2% 80.2% 41.1% 212.8%

The robot is now using four trading models, identified here by the ticker-symbols they are supposed to trade.  These hypothetical historical returns look great on paper!  I would very much like to be making 45%‒60% per year.

In reality, I did not get the 10.7% profit shown here for 2012 Q1.  Instead, I lost 3.7% because the URTY and SRTY models hadn't been invented yet, the TNA model was improved after the fact, and I made a loser RWM trade that wasn’t justified by any model.

Below is a chart showing weekly results for all models simultaneously.  Of the 221 weeks, there are 84 losses, 41 zeroes, and 96 gains.  Any week with a gain of less than 2.7% is just paying back for the weeks with losses.  About 12% of all weeks have larger gains than that and thus are making actual progress.

Note that 2012 Q1 was a bad quarter with no large gains, except for URTY which I couldn’t actually trade because the model didn't exist yet.


No comments:

Post a Comment