Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Problems Converting Research to IDE

This is my first post-worthy notebook/algorithm so far. I got my pipeline to work just fine on the notebook and I even got it to run on the IDE ("Build Algorithm" mode). But all of a sudden, it's throwing an error on the IDE from a class I wrote to get natural log returns for BIL (a.k.a. risk_free) that says:

Blockquote

ValueError: could not broadcast input array from shape (0) into shape (8237)
USER ALGORITHM:217, in compute
out[:] = np.log(close[-1, risk_free_close]/close[-2, risk_free_close])

Blockquote

However, there is another class just before it that does the exact same operation with the SPY (a.k.a. benchmark):

{ class Return_Ln_Benchmark(CustomFactor):
window_safe = True
window_length = 2
inputs = [USEquityPricing.close]
def compute(self, today, asset_ids, out, close):
benchmark_close = np.where(asset_ids == sid_benchmark)
out[:] = np.log(close[-1, benchmark_close]/close[-2, benchmark_close])

class Return_Ln_Risk_Free(CustomFactor):
window_safe = True
window_length = 2
inputs = [USEquityPricing.close]
def compute(self, today, asset_ids, out, close):
risk_free_close = np.where(asset_ids == sid_risk_free)
out[:] = np.log(close[-1, risk_free_close]/close[-2, risk_free_close])
}

Looks to me that if it is broadcasting 0 then it's just not able to get the data. I've thrown every trick I know at adapting the symbols methods to work for the IDE and nothing yet. It's late so it's likely something small that I inadvertently did since it apparently was working before, but I'd like some help with it if anyone could.

Also, if anyone has any feed back about how I could do what I am trying to do more efficiently (CAPM model), I'd gladly appreciate it. I know I need to divide up my longs and shorts into two groups, possibly use just the top and bottom 350 assets, assign a negative to the short alphas, re-rank, and concatenate the long and short lists together before optimizing on alpha rank . . . but that's for another day. lol

Thanks and Cheers !