Calculate Beta of Stock Pair Ratio to SPX
Author: Shourui
Creation Date: 9/21/2010 11:15 AM
profile picture

Shourui

#1
I want to use the community indicator Beta to calculate the beta of a pair stock ratio to SPX. Below is the code. Error msg is " the best overloaded method mathc for 'community.indicators.beata.series(Wealthlab.bars, wealthlab.bars, int)' has some invalid arguments." Beta indicator only accepts Bars Object for its first argument. Is there any way to work around it? Thanks a lot.


CODE:
Please log in to see this code.
profile picture

Eugene

#2
Beta accepts 2 Bars objects as parameters, not DataSeries.
CODE:
Please log in to see this code.
profile picture

Shourui

#3
When calculating Beta, we only need close prices of broad market and single stock(or pair ratio in my case). Why do the first two parameters have to be Bars Objects?
Is there any other way to calculate Beta of Pair Ratio to SPX when Ratio is a DataSeries or make the Ratio as Bar Objects?
Thanks.
profile picture

Eugene

#4
QUOTE:
Why do the first two parameters have to be Bars Objects?

Long story short, workaround for a limitation i.e. inability to call GetExternalSymbol outside of a WealthScript Strategy.

Fortunately, the workaround for a formal Indicator is obvious, but for (say) IndexDefinition - nowhere near as easy. So just use the code suggested above, please be assured that we know the Beta formula! :)
profile picture

Shourui

#5
Eugene,
Thanks for your reply.
Do you have a quick solution to calcualte beta of Top/Bottom(unfortunately, not a Bar object) to SPX Close withouting coding the function?
profile picture

Eugene

#6
No, coding the function is necessary. You may take the Beta.cs class from Community Indicators source code and:

1) Either replace the 1st Bars parameter with a DataSeries (and consequently apply whatever changes further down the code + IndicatorHelper it may take)
2) Or modify the source code to have this custom Beta coded as on-the-fly indicator, i.e. one that exists in your Strategy only.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).