I am trying to print out sorted stocks, but I am getting a strange error (or at least I think it's strange).
def before_trading_start(context, data):
context.output = pipeline_output('example')
context.longs = context.output[context.output.longs]
context.shorts = context.output[context.output.shorts]
context.security_list = context.shorts.index.union(context.longs.index)
longs_to_order = context.longs.sort(['sma_rank'], ascending=False).head(5)
longs_to_order = longs_to_order.index
# Print the 5 securities with the lowest sma_rank.
#print "SHORT LIST"
#log.info("\n" + str(context.shorts.sort(['sma_rank'], ascending=True).head()))
# Print the 5 securities with the highest sma_rank.
print "LONG LIST"
#log.info("\n" + str(context.longs.sort(['sma_rank'], ascending=False).head(5)))
for stock in longs_to_order:
print(data.current(stock, 'last_traded'))
I get this error:
TypeError: unsupported operand type(s) for *=: 'Timestamp' and 'float'
There was a runtime error on line 55.