Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Error when I try to build algorithm, but none when running in research

Hello!

I'm new here and trying to get my code to run. I've managed to fix all the errors that have popped up in the notebook and even got alphalens to run everything, but for some reason when I attempt to build it into an algorithm it won't compile and just says "Something went wrong. Sorry for the inconvenience." I've tried debugging it myself, but I don't think I am setting up the right tests. If anyone has any idea what or where the problem is, then it would be greatly appreciated!

2 responses

First off, welcome to Quantopian!

Would it be possible to attach your algo (ie an algo backtest) to your post? That will make it much clearer to debug.

However, this can be problematic if you can't even get a backtest to run. Sort of a 'Catch-22'.

One workaround for this is to 'comment out' your entire code. Put 3 single or double quotes at the very top and very bottom of your code. This will turn it all into a comment (ensure your code doesn't include triple quotes anywhere or this won't work). Then, at the very end put an empty initialize function. This is the single function required to generate a backtest. Run the backtest (it won't do anything) and attach it to your post. That will allow others to more easily see your code and potentially help debug it.

Comment out and add the initialize function something like this

# Put triple single or double quotes at the very top of your code  
'''
this is where you code is....

'''
# Put triple single or double quotes at the very bottom of your code  
# Your entire code should now appear in red as a comment  
# Now add the two lines below

def initialize(context):  
    pass

Try that. With the code attached to a post others can more easily help debug. Good luck.

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.

Hi Dan,

Yeah I wanted to do that, but that whole 'Catch 22' business made it impossible. I ended up going line by line and imputing everything into an already functioning code with a similar structure. Turns out that sentiment is not playing nice for whatever reason and can just be excluded for other factors.
Thanks for the advice though! Will definately be using that in the future when debugging!