Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
basic order execution algorithmfor my strategy!

I'm trying to write a basic execution algorithm for my trading. Say x is the stock, when market opens x=10 (price), when x=5 place a buy-limit order at x=7 with stop at 2 and limit at 12 good till cancelled. Another condition that if the profit= 100 move the stop order 3 points under the current market price. if any of the orders get hit stop or limit then remove all pending orders!...Any help appreciated!

this is what i hav written so far...

def initialize(context):

context.NTAP = sid(13905)  

def handle_data(context, data):
# Implement your algorithm logic here.
price = data[context.NTAP].price

if price < 27:  
    order(sid(13905), 1000, style=LimitOrder(28))  
    order(sid(13905), 1000, style=StopOrder(20))  
    order(sid(13905), 1000, style=StopOrder(40))  


notional = context.portfolio.positions[context.NTAP] * price  

if notional > 100:  
    order(sid(13905), -1000)