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

[amibroker] Re: PositionSize / Capital



PureBytes Links

Trading Reference Links


--- In amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso" <ajf1111@xxxx>
wrote:
> Hello Al,
> 
> You stated:
> 
> "the lower the volatility, the lower the risk and therefore, the
smaller the positionsize for that stock. "
> 
> Is this a correct assumption ? ...Would you want a larger
positionsize on a less risk position , and a smaller position on a
more volatile one ?
> 
> Anthony

Hi, Anthony:

You want a larger positionsize on a less volatile stock because the
assumption is that it will not move as fast as a more volatile stock.
You want to equalize your volatility. If you look at the formula
PositionSize = -1*C/StopAmt, where StopAmt is 2*ATR, you would infer
that a lower volatility stock will have a lower point value for ATR.
Thus, since StopAmt is in the denominator, the positionsize in terms
of dollars allocated is larger for a less volatile stock. HOWEVER,
your RISK of loss is still the same 1% for any position placed
irrespective of the dollar amount allocated to the position. Is that
clearer? 

Al Venosa 


>   ----- Original Message ----- 
>   From: Al Venosa 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Saturday, December 11, 2004 7:53 AM
>   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 
>       To: amibroker@xxxxxxxxxxxxxxx 
>       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 
> 
> 
>         Yahoo! Groups Sponsor 
>               ADVERTISEMENT
>              
>        
>        
> 
> 
>
------------------------------------------------------------------------------
>   Yahoo! Groups Links
> 
>     a.. To visit your group on the web, go to:
>     http://groups.yahoo.com/group/amibroker/
>       
>     b.. To unsubscribe from this group, send an email to:
>     amibroker-unsubscribe@xxxxxxxxxxxxxxx
>       
>     c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/