Monitor Order Status

Hi, so I was planning to write a code that will monitor the status of my buy order and as soon as the status is complete, it will place a SL automatically.

I am using while loop for it, it’s working for sometime and later ti throws error :

{“status”:“error”,“errors”:[{“errorCode”:“UDAPI10005”,“message”:“Too Many Request Sent”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI10005”,“property_path”:null,“invalid_value”:null}]}

I am using 1 Sec sleep time, so it will check for order status for each second. Other than increasing sleep time, what are the option I can use to check for order status each second? Or is there any trigger kind of option available that I can use, so instead of using while, I can place SL as soon as the first order trigger is complete.

Thanks
Ashish

To address the issue you are encountering, you can subscribe to the Portfolio Websocket and set the update_types parameter to position. This will allow you to receive websocket message when your pending order is converted to a position.

For your convenience, you can use the PortfolioStreamer class, which allows you to enable position and holding updates by setting the respective flags to True in the constructor.

2 Likes

Thanks a lot @Ketan I will surely try this.