[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] PositionSize / Capital



PureBytes Links

Trading Reference Links

hi Al,
 
I trade with IB also but only get a little better result if I use round lot 1, min. shares 1.  I actually started using round lots so that I could simulate the commisions more precisely. But I could also set the commissions to 0 and add the commission cost in the code itself. Because I trade frequent and the nature of the trades are scalp-like commissions do matter for me and I want to simulate it as precisely as possible. If a system makes not more than 60% per year every dollar is important.
 
I understand the second part of your Email. My point was that in my case it could be that the higher volatile stocks might give winners more often than the less volitile. By reducing their size with respect to the lower volatile ones in order to reduce the risk one also reduces the profit of the system. Maybe that is the reason this particular MM doesn't work on my system. But I need to test this still,
 
rgds, Ed
 
 
----- Original Message -----
From: Al Venosa
Sent: Saturday, December 11, 2004 3:33 PM
Subject: Re: [amibroker] PositionSize / Capital

Yes, Ed, you are right. If your equity is $50 K, and  your positionsize is -10, your maximum position you can allocate to one trade is $5,000. Since EBAY is selling for $114/shr right now, and your round lot size is set to 100, then you cannot make that trade since your allocation would be $11,400, which is more than $5,000. Why do you want to limit your trade to 100 shares? In these days of deep discount brokers like IB, you needn't worry about odd lots anymore. The commission on a 43-share purchase would only be a buck at IB. If your system picks EBAY as the top stock, then by all means, don't limit yourself with round lots of 100. Go for minimum round lots of 1 so that you can buy the top stocks on your positionscore list.

I don't think volatility and reliability are synonymous. A more volatile stock will move faster, but your positionsize is smaller, so therefore, you are limiting your risk of failure if the stock goes against you. You are also allowing it to move more against you since you are giving it more room to wiggle. You don't want volatility to kill you. By the same token, a lower volatility stock will mover slower, so you take on a bigger position because you want to get your dollar profit and get out with a smaller point move. That's the beauty of equal volatility positionsizing.

Al

ed nl wrote:
Al,
 
what noticed the backtester doing is that say if you start of with $50000 and you set the "round lot size" to 100 (what I do) and your PositionSize = -10 then if a stock like EBAY is on top of the entry list (highest rank) the backtester will not enter any stock because a 100 shares EBAY corresponds to an amount higher than allowed.  But this doesn't seem to explain why my simple PositionSize approach works better.
 
I did not test this volatility based management technique extensively yet. But on a first glance it also might be that the more volatile the trade (and more risky therefor) the more reliable also (I didn't test this yet). Guess it depends on the kind of system you have. If one trades short term (like my system) then taking larger positions in non-volatile stocks might increase the risk because you end up with a whole bunch of non-risky losing trades  :)
 
It will be nice to play with. I'll let you know if I find something interesting,
 
rgds, Ed
 
 
----- Original Message -----
From: Al Venosa
Sent: Saturday, December 11, 2004 1:53 PM
Subject: Re: [amibroker] PositionSize / Capital

Ed,

I, too, have confirmed many times with backtesting what you report, viz,, that positionsize = -x gives better performance results than using volatility-based MM positionsizing. The non-MM code I've used in the past is:

posqty = Optimize("posqty",5,2,10,1); // no. of stocks active at any given time
PositionSize = -100/posqty; //equal equity model

I think I know what the problem is, but I have not as yet figured out how to solve the problem with AFL. If you use the MM-based positionsize statement as we have discussed (equal volatility model), i.e.,
PositionSize = -1 * C/StopAmt, and examine the tradelist, you will likely discover that, often, not all 5 stocks are active all the time. In other words, either you have idle capital earning nothing or you have fewer active stocks than you want. Why is this? Because some stocks, which might not be as volatilie as others, use up more of your capital to initiate a position than a more volatile stock. Consequently, your capital is used up before you have a chance to enter into your 4th or 5th stock. Instead of having 5 open positions, you might only have 3 because of this. Checking positionsize shrinking doesn't help because you'll discover you might have tiny positions in your 5th stock. The fewer stocks you have, the less diversified you are, and therefore the more risky your portfolio. The more risk, the higher the DDs. This problem cannot happen with the equal equity model since all positions are equal in size, by definition.

One possible way around this might be to increase your margin so that equity is expanded enough to allow full funding of all positions. But, again, this also increases your risk. Another way might be dynamically setting your risk to fit the volatility of each stock individually (the lower the volatility, the lower the risk and therefore, the smaller the positionsize for that stock). However, this changes your model so that you no longer have equal volatility/equal risk (getting closer to the equal equity model). So, the problem remains unsolved for the moment. I have not had time to devote to cracking this problem yet, but some day I hope to do this. If you have any ideas, I'm all ears.

Al Venosa


ed nl wrote:
Thanks for your effort Al. It is very clear,
 
In one of my earlier posts I posted
 
// money management block
stopLoss = Ref(bbb*ATR(20),-1);
// trade risk
tr = IIf(Buy,(stopLoss / BuyPrice),stopLoss / (ShortPrice + stopLoss));
// renormalisation coefficient
rc = 0.02 / tr;
// positionsize
PositionSize =
rc * -100
 
 
it actually gives the same result as your:
PositionSize = -2.0 * IIf(Buy,BuyPrice,ShortPrice) / stopLoss
except for short positions. Exact the same it would be if I use: tr = IIf(Buy,(stopLoss / BuyPrice),stopLoss / (ShortPrice));
 
Unfortunatelly I do not get better results this way. Using just a simple PositionSize = -10 still gives somewhat better results.

 
rgds, Ed
 
 
----- Original Message -----
From: Al Venosa
Sent: Saturday, December 11, 2004 4:19 AM
Subject: Re: [amibroker] PositionSize / Capital

ed nl wrote:
Al,
 
but how do you implement the risk factor now?
 
ed
Ed:

Let us suppose you have established your risk as 1% (i.e., the maximum you are willing to lose on a trade). Let us also suppose your initial equity is $100,000. So, if the stock you buy (or short) goes down by the amount based on your system, you lose only $1000, keeping you in the game. Now, let us say you defined your
volatillty-based stop in terms of 2*ATR(20), which you incorrectly assigned to the variable TrailStopAmount. I say 'incorrectly' because the TrailStop in AB was designed to mimic the Chandelier exit, which is basically a profit target type of stock (it hangs down like a chandelier from the highest high since the trade was initiated, if long). I don't think you want the TrailStop to be your money management stop. Rather, the MM stop is the max stoploss, defined as:

StopAmt = 2*ATR(20);
ApplyStop(0,2,StopAmt,1);

So, if your stock declines by 2*ATR(20) from your entry, you exit with a 1% loss. Let's take an example. Stock A is selling for $40/share. It's ATR(20) is $1/shr or 2.5% of 40. Your stop amount is 2*ATR(20), which is $2/shr. How much stock do you buy? You simply divide your risk, $1000, by 2*1, which is 500 shares. This amounts to an investment of $40/shr * 500 shrs or $20,000. All of this can be coded in one simple line of AFL plus the 2 lines above defining the MM stoploss:

PositionSize = -1 * BuyPrice/StopAmt;

where -1 is 1% of current equity (0.01 * 100,000 or $1000), BuyPrice = $40/shr, and StopAmt is 2. Keep in mind that a negative sign means 1% of CURRENT equity, which means compounded equity, not just a constant initial equity of $100,000. If you carry through the above math with your renormalization coefficient notation, you wind up with the exact same answer.

One more thing. When you place your order, assuming you are trading with EOD data, you do not know what the buyprice is until you buy the stock, which is the next day. So, what most traders do is base their positionsize on the closing price of the night before the entry. Therefore, to place an order in the evening to be filled in the morning at the open, your positionsize statement would actually be:

PositionSize = -1 * C/StopAmt;

where C is the closing price on the night before you buy. So, if you use the code SetTradeDelays(1,1,1,1), then the above formula is OK. However, if you use SetTradeDelays(0,0,0,0), then you have to ref the C back a day.

This is probably more information than you were asking about, but I hope it helps.

Cheers,

Al Venosa



Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html





Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html





Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html





Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links