Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Hello! I have some problems with my code, that I'd like help on understanding.

So here is my code, it is very rudimentary as I am just starting out.

def initialize(context):  
    context.stocks = sid(42277)

# Will be called on every trade event for the securities you specify.  
def handle_data(context, data):  
    current_price = data[sid(42277)].price  
    #current_price = history(1, "1m", "price")  
    one_minute = history(2, "1m", "price")  
    two_minute = history(3, "1m", "price")  
    two_min_average = ((one_minute + two_minute) / 2)  
    print "Current price------------------"  
    print current_price  
    print "two min average-------------------"  
    print two_min_average  

For some reason my variable two_min_average does not print out anything when asked to. Any ideas as to why?

2 responses

two_min_average is a panda dataframe having 3 rows
and not single numeric (float or integer)
it looks something like

2011-12-30 21:00:00+00:00 NaN
2012-01-03 14:31:00+00:00 9.57
2012-01-03 14:32:00+00:00 9.61

If you get the type of this variable you will find the details

    print type(two_min_average)  

Thank you so much! I don't have much experience with dataframes and the like.