Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Change Benchmark, Add breakpoints, TA-Lib beta function (relative index)?

Is there a method to change the benchmark from the SPY?

Also, is there a method to add breakpoints in the code? And a workspace that details what values my parameters are assigned as I step thru the code?

Lastly, for the TA-Lib function ta.BETA...what is the relative index when this beta is calculated? is it SP500?

Thanks!

8 responses

Hi Adam,

Is there a method to change the benchmark from the SPY?

Not currently but it's on our (very long) to-do list but not ETA.

Also, is there a method to add breakpoints in the code? And a workspace that details what values my parameters are assigned as I step thru the code?

Debugging is on that list as well. You can just do log.debug(my_var) to get it printed to the log console.

Lastly, for the TA-Lib function ta.BETA...what is the relative index when this beta is calculated? is it SP500?

I'm actually not sure about that one, will have to look into it. Do you not pass it another series as a parameter?

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Hello Adam/Thomas,

These are comments from the the 'C' source for ta.BETA:

/** DESCRIPTION OF ALGORITHM:
    *   The Beta 'algorithm' is a measure of a stocks volatility vs from index. The stock prices  
    *   are given in inReal0 and the index prices are give in inReal1. The size of these vectors  
    *   should be equal. The algorithm is to calculate the change between prices in both vectors  
    *   and then 'plot' these changes are points in the Euclidean plane. The x value of the point  
    *   is market return and the y value is the security return. The beta value is the slope of a  
    *   linear regression through these points. A beta of 1 is simple the line y=x, so the stock  
    *   varies percisely with the market. A beta of less than one means the stock varies less than  
    *   the market and a beta of more than one means the stock varies more than market. A related  
    *   value is the Alpha value (see TA_ALPHA) which is the Y-intercept of the same linear regression.  
    */  

P.

I suspect that we implemented ta.BETA incorrectly. We intended to only release ta-lib functions that only accept one stock. This one appears to have slipped through. I don't know what it actually does =)

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Hello Dan,

I've never used ta.BETA before but it might offer a customisable benchmark - see attached. If you set context.sid and context.benchmark to be the same SID you get a flat line.

P.

It is possible that we implemented it correctly after all. That would be a pleasant surprise - it didn't receive a lot of deep thought.

Hi Guys,
If possible, please make changing benchmark a high priority :)

Regarding beta, this is how i understand the calculation:
beta = COVAR(Return % EQUITY, Return % INDEX) / VAR(Return % INDEX)

Peter: I'm assuming the "index" that's being used as default is the SP500? However, based on your code above, i could conceivably set the context.benchmark to what i want it to be?

...context.benchmark with respect to beta

Hello Adam,

To be honest you know as much as I do. The TA-Lib library is great but documentation is lacking which is why I sometimes look at the 'C' source code for some ideas or even just for the parameters and their order. It looks as though ta.BETA is the slope of the regression line in the CAPM - see http://www.moneychimp.com/articles/risk/regression.htm. Although mentioned in my first post above I don't immediately see that ta.ALPHA - the intercept of the line - was ever implemented. If my understanding is correct you can use ta.BETA to calculate beta with any 'index' you choose.

P.