Back to Community
New to the platform


I'm struggling to get my first algorithm running, the goal is simple:

- ranking stocks on past 60 days return by mean/var  
- enter long on top 300 stocks and short on lowest 300

I don't understand what is going on. I would like to add that I watched tutorials and read the API reference but don't seem able to run a code written by myself on the algorithm builder.

Thank you! :)

Loading notebook preview...
Notebook previews are currently unavailable.
4 responses

Hi Quentin,

I don't understand what is going on.

Let me try my best to explain.

An immediate answer is that function np.average raises TypeError: unsupported operand type(s) for /: 'BoundColumn' and 'int'.

    inputs = [USEquityPricing.close]  
    window_length = 60  


Why? Roughly speaking because it expects an array of numbers to take an average of, but you are giving it an array of objects of type BoundColumn.

A more general answer is that once you manage to fix that bug (probably by taking a closer look at built-in factors DailyReturns and SimpleMovingAverage), you will encounter a set of the other ones. There is a tab "Build Errors" in the Quantopian IDE, I suggest that you start there.

You did not ask for advice, but here it is: do not rush to build an algorithm. Take your time to understand it's building blocks, and only then assemble them all together. After you've researched your idea and concluded that it is worth doing at all.

Hope it helps :)

Thank you for the timely answer and the advice which I particularly appreciate, I ended up being able to run
I attached the code as it might help others. There is definitely room for improvement x)

Clone Algorithm
Backtest from to with initial capital
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5c87f4a0b0c2474b26973d18
There was a runtime error.

Can someone provide a simple example of "BoundColumn" in this sense?

There are 194,002 web pages on it. I haven't checked all of them but the trend looked like "blah blah foo yadda ..." as my mind can't seem to gain any traction except from specific examples, thanks. Maybe consider including an unbound column example also, eh.

depends on what you try to do.
my guess is that you are trying to create a custom factor?