Hello!
I have been trying to do this for a while, but it just doesn't seem to work. How do I create a limit order that sells a security after it reaches a price 1% higher than what it was purchased for? Also, how do I output the time that the order is filled (if it even is filled)?
for i in range(-5, 0):
amount = int(size/data[gaps[i][0]].price)
context.buy_order_id = order(gaps[i][0], amount)
buy_price = data[gaps[i][0]].price
log.info('entry %s %s %s %s' % (get_order(context.buy_order_id).dt, gaps[i][0], amount, buy_price))
sell_limit_price = 1.01*buy_price
context.sell_order_id = order_target_value(gaps[i][0], 0, style=LimitOrder(sell_limit_price))
The code above loops through an array (gaps), and gaps[i][0] is the "sid" of the security. This is what I have so far. Please help me figure out how to create the limit order.
Thanks in advance for your help!