Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
help setting up a print lock

I don't know what I'm doing wrong here... trying to get the price of a filled order printed once and not a thousand times by setting up a simple printlock list but not sure why it's not printing anything... (i don't want to use the schedule function..) Any help would be appreciated!

def initialize(context):
context.stock = sid(24)

def handle_data(context, data):
printlock=[]
if sid(24) not in context.portfolio.positions:
order(sid(24),100)
printlock.insert(0,"aaple")

if sid(24) in context.portfolio.positions and "aaple" in printlock:  
    print(context.portfolio.positions[sid(24)].cost_basis)  
    printlock[0]="orange"  
else:  
    pass