Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Running into weird Errors with an Algo, Undeclared variables

So the algo that I am working on right now is not something too special, and at its heart all I am doing at this point is plugging more and more factors into it under the impression that it will improve. It is a little more complicated than that, but I don't want to go into details.

Where I am now is I have a notebook all setup that can run through new factors and calculations that runs everything through alphalens such that at the end of it I even coded it together so it gives me the code to copy and paste it into the algorithm, if there was anything I was looking for in the factor.

This was working well for a few rounds, but now I am running into errors.
First off, it gave me the "Something went wrong. Sorry for the inconvenience. Try using the built-in debugger to analyze your code. If you would like help, send us an email. " Which by itself is not that bad, as from that I recognize the most probable problem is from one of the factors that I had just put in.

So, the old take one out at a time until it works again was the plan, except that when I took one out, it began erroring, and saying that one of the variables from that factor was not defined. Well of course it wasn't defined, because I had just taken it out, but going through line by line, it is not being called anywhere in the code, and yet it wants it to be defined.

Refreshing the browser at this point returns me to the previous error, where it doesn't point to anything useful.

I have tried adding some logging to find where exactly it is failing, but it seems to make it all the way through the pipeline, and through initialization, but never to before_start_trading and rebalancing.

It seems as though everything I have added in is broken, which seems unlikely, and on a whim I am wondering if the problem may be that I am simply asking the pipeline to output too many factors.
Normally I would not output all the factors individually, except that I need to perform operations on them that I have not figured out how to do in the pipeline, and since up until this point, doubling, even tripling the original number of factors that I had going in has not slowed down the backtest.

As a note, a fair number of my factors are from the 101 Alphas, but I have steered clear of all the ones using correlation, and as everything I am adding in make it through the notebook alright I do not know where my problem here may lie.

Thank you for any help

2 responses

Edit to above post, after some rejiggering of how its put together, the algorithm now times out during rebalancing, and occasionally runs out of memory, and the running out of memory part is probably why the errors were being so sporadic before.

It is still weird that before the last additions to it, it went rather speedy, and now is timing out, but I guess maybe since I'm at the ram limit, sometimes it just tries to keep going and times out, instead of stopping due to ram limitaitons

Another Edit, I found out that it was timing out on the order optimal function call, and by commenting it out got everything running smooth again, except for the actual ordering and such, and after some rejiggering, the apparent culprit was using MaximizeAlpha. By switching this to TargetWeights it works now, but I have no idea why then that it would not work with maximize alpha.

Anyway, I guess I solved my problem, but im sure by adding another round of factors ill break something else..