I have made use of the pipeline to selected a series of stocks to purchase about 30-45 minutes after the opening of the market. While I have intensions to hold the stocks for period of time (over a day), if the stock has a 3-4% increase or decrease on the day it is purchased, I would prefer to simply sell the security. I have tried to make use of a Limit order, but the order never seems to be filled. The syntax is as follows:
for security in context.purchase:
if security not in context.open_orders:
if data.can_trade(security):
order_target_percent(security, context.weight)
order_target_percent(security, 0, style=LimitOrder(1.03*purchase_price[security]))
order_target_percent(security, 0, style=LimitOrder(0.97*purchase_price[security]))
#the purchase_price represents the approximate price at which the stock was purchased
However, when running back test, the securities that I know for certain do increase/decrease by 3 percent are never sold. I have tried using the order_target syntax to order a distinct number of shares, and in that case the limit orders are ignored. I have also tried scheduling a function about 10 minutes after the stocks are purchased (to ensure those positions are actual held, before setting a limit), and yet again, the limit order always seems to be ignored, and never filled. I am writing to see if anyone here has encountered this problem, and knows of any possible solutions. Thanks in advance!