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

[amibroker] Re: PositionSize / Capital



PureBytes Links

Trading Reference Links


You guys are awesome... thanks for the insight that I would probably
never find on my own.  You're right... my regression line is way off
the equity curve.

So then... what's TJ's take on providing a log format to results?

Or does someone have some reference material on the web I can take
alook at?  I might be able to whip somehting up with excel, and
provide a spreadsheet that would provide the log format.

--- In amibroker@xxxxxxxxxxxxxxx, Al Venosa <advenosa@xxxx> wrote:
> Christopher:
> 
> One thing you have to keep in mind about statistics like K-ratio, 
> standard error, and linregslope: they are based on a LINEAR regression 
> of the equity curve, and if your CAR triples, that means that the
equity 
> curve is becoming more and more exponential in shape, due to 
> compounding. Therefore, K-ratio and standard error are totally useless, 
> since they assume a LINEAR equity curve. If you simply examine a
plot of 
> your equity curve with a linear regression line drawn through it, you 
> will see what I mean. The regression is worthless in that case unless 
> you convert the data to logarithmic format in the AA report, as Fred
has 
> been requesting, or do a more complicated non-linear regression.
> 
> Al Venosa
> 
> Christoper wrote:
> 
> >
> > Jumping in here to make one observation...
> >
> > I've seen much higher returns as well when NOT using volatility based
> > position sizes.  But other stats/metrics really take a plunge.
> >
> > For example - CAR triples while Sharpe becomes 1/5th of previous value
> > and K-Ratio drops to 0.04, from 0.10.  Other things like, Max Sys DD
> > doesn't change that much...
> >
> > That's just my expereince... do other people see these type of results
> > as well?  How much weight can we place on K-Ratio and drop in Sharpe?
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "danielwardadams"
> > <danielwardadams@xxxx> wrote:
> > >
> > > Al & Anthony,
> > > I've also seen the lower returns for volatility based versus equal
> > > equity position sizing in the past and didn't know what to do about
> > > it (assuming I wanted more positions for more diversification).
> > >
> > > I'm not sure how one would code it in .AFL, but would the following
> > > represent a reasonable compromise?
> > >
> > > (1) Start with an equal equity based model based on, say,  5
> > > positions (position size = -20). So each part of the pie equals 20%
> > > of total equity.
> > > (2) Determine actual position size within each piece of the pie
based
> > > on volatility based sizing. So, depending on your risk
parameter, one
> > > might use only 17% of one piece of the pie, 13% of another
piece, and
> > > 20%, 8%, and 11% of the other pieces.
> > > (3) Sum the used portions of the pie (in this case 17+13+20+8+11 =
> > > 69%) and see what you have left. 31% in case.
> > > (4) Allocate the remaining cash according to the equal equity model.
> > > This means you get one more 20% piece of pie and only have 11% cash
> > > remaining.
> > > (5) Apply the above using your ATR based position sizing recursively
> > > until your cash is minimized. So if you only are able to use 9% of
> > > the piece of pie left in (4) you take the 11% left from that piece
> > > plus the 11% cash and you have 22% -- enough for another
position. So
> > > in this case you end up with 7 positions and only 2% left in cash.
> > > So your cash is minimized and all your positions adhere to the ATR
> > > based position sizing.
> > >
> > > Like I say, I have no idea how to code it but intuitively it makes
> > > sense to me.
> > >
> > > Thoughts/comments?
> > >
> > > Dan
> > >
> > > (And, yes, I'm sure I'm not the first person to think of it so my
> > > apologies to those who have gone before).
> > >
> > > --- 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
> > > >   ----- 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.
> >
> >
> >
> >
> >
> > 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 
> >
<http://us.ard.yahoo.com/SIG=1294jpo1e/M=298184.5639630.6699735.3001176/D=groups/S=1705632198:HM/EXP=1102903411/A=2434971/R=0/SIG=11eeoolb0/*http://www.netflix.com/Default?mqso=60185400>

> >
> >
> >
> >
------------------------------------------------------------------------
> > *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
> >      
<mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
> >        
> >     * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> >       Service <http://docs.yahoo.com/info/terms/>.
> >
> >





------------------------ 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/