Hi,
I am using order_target_percent(security, weight, limit_price) to place an order for a security, now since there is a limit price, its possible i will not be able to buy the stock. How can store the result of the order being successul in a variable ?
My assumption is that this order will only be valid for a day, is that correct ?
I am trying to test the strategy to only hold on to the stock for 10 days since i bought it. Any suggestions on how i can go about it ?
when you place a new order (using any of the ordering function), it returns an order id. Subsequently, you can query the curren open orders (see here) and check the status of the order using the order Id (i.e. poll to see if the order is executed). This works in backtesting and live trading. In addition, in live trading, you can use event callback function (see here) to check the order status, instead of querying it mechanically (polling). For a defined holding period, it is best to use schedule_function - e.g. checking each day at a given time if the holding period condition is satisfied, and trigger a sell.
Thanks @Prodipta!!