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

[amibroker] Re: Alpha/Beta for Daily and Monthly Data



PureBytes Links

Trading Reference Links

I ripped this code out of my Custom Backtest Metrics afl, that is why 
the reference to Eq.  I also use multiple benchmarks, hence the 1 
after the B.

EqCAR = Compound Ann Ret of Equity line (or security)
B1CAR = Compound Ann Ret of Benchmark
n = number of periods

When comparing to Morningstar results, remember that they use monthly 
data for trailing three years (36 periods).

A good sanity check for Alpha calculation is to use S&P Total Ret as 
security and S&P Price as benchmark.  The correlation is 1, so Alpha 
should be apprx equal to dividend yield.


--- In amibroker@xxxxxxxxxxxxxxx, Ken Close <ken45140@xxx> wrote:
>
> Thanks Ron:
> 
> Before I get further into comparisons, please confirm EqCAR formula 
for me.
> I realize it is the Compound Annual Return for Eq, but please 
confirm
> formula.
> Further assume B1CAR is annual return of benchmark.
> I assume n = lookback period 
> 
> Ken
> -----Original Message-----
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] 
On Behalf
> Of Ron Rowland
> Sent: Sunday, August 31, 2008 12:50 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: Alpha/Beta for Daily and Monthly Data
> 
> Ken,
> I did not study your code in detail, but here is what I have been 
using.  I
> did not compare the results directly to MorningStar since I was 
using daily
> data instead of monthly.  However, I did some rough comparisons and
> everything seemed to be in the right neighborhood.  
> (be careful of line wraps below).
> 
> One thing to remember is that alpha calculation is for whatever 
interval you
> are using and needs to be annualized.
> 
> // Correlation
> B1Cor		= Correlation(EqROC, B1ROC, n-1);		
> 	// Correlation Coef (r) to Benchmark 1
> B1Corr		= B1Cor * B1Cor;			
	
> 				// Coef of Deter(r-sqrd) to Benchmark
> 1
> 
> // Beta 
> B1Beta		= (n * Sum(EqROC * B1ROC , n) - Sum(EqROC, n) 
* Sum
> (B1ROC, n) ) 
>           / (n * Sum(B1ROC ^ 2 , n)    - Sum(B1ROC, n) ^ 2 );
> 
> // MPT Alpha (traditional)
> B1Alphad	= (MA(EqROC, n-1) - B1Beta * MA(B1ROC, n-1));	// 
> Daily Alpha
> B1AlphaA	= 100*((1+B1Alphad/100)^252 -1);		
> 			//	Annualized Daily Alpha
> B1Alpha	= EqCAR - B1Beta*B1CAR;				
	
> 			// Alpha from Annualized data
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Ken Close" <ken45140@> wrote:
> >
> > Can someone help on this question:
> >  
> > I need to calculate Alpha and Beta for two sets of symbols for
> equity, one
> > having daily data, and another set having monthly data.
> >  
> > 1.  I am using these formulas for Alpha and Beta, yet the units 
for
> Alpha do
> > not match those I can find on various web sites.
> >  
> > Formulas:
> >  
> > Beta = (( Periods * Sum(ROC( C,1) * ROC(Mkt,1),Periods )) -
> > 
> > (Sum(ROC(C,1),Periods) * Sum(ROC( Mkt,1),Periods))) /
> > 
> > ((Periods * Sum((ROC(Mkt,1)^2 ),Periods)) - (Sum(ROC
> (Mkt,1 ),Periods)^2 ));
> > 
> > Alpha = (Sum(ROC( C,1) ,Periods) - ( Beta ) * Sum( ROC(
> Mkt,1) ,Periods ) )
> > / Periods;
> >  
> > One article states that Alphas, according to Morningstar, range
> from -11 to
> > 45 with an average of all funds around 2.  One such fund is listed
> having an
> > Alpha of 11.5, and my calculation is 0.36.
> >  
> > So, do the formulas look right and does anyone have a
> representative measure
> > of Alpha?
> >  
> > 2.  I am having fits making the formulas calculate daily vs 
monthly
> data.
> > My attempts to use inMonthly timeframes does not work (values
> either blank
> > or incorrect when compared to other sources.  Thus, I would like 
to
> have a
> > single formula run and then manually select Monthly or Daily
> periodicity in
> > the Settings box.  Is there a Status command that tells the code
> whether the
> > periodicity is set on Monthly or Daily?  
> >  
> > 3.  Further, I would like the "Periods" in the above formula to 
be 
> > determined from the date range, and I can calculate a "Periods"
> value when I
> > am in Daily periodicity.  But, try as I might, I get Periods equal
> to zero
> > unless I put in a manual setting for periods, say Periods = 12;.
> > This works for Daily, what would I use for a Periodicity of 
Monthly?
> > Index1 = ValueWhen( DateNum()== StartDate ,BarIndex(), 1);
> > 
> > Index2 = ValueWhen( DateNum()== EndDate ,BarIndex(), 1);
> > 
> > Enddate = ValueWhen(DateNum()==Enddate,DateTime(),1);
> > 
> > Periods = LastValue(Index2 - Index1);
> > 
> >  
> > Thanks for any suggestions,
> > Ken
> >
> 
> 
> 
> ------------------------------------
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at}
> amibroker.com
> 
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> Yahoo! Groups Links
>



------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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