I was trying to place order using API, but the order was failing repeatedly
Although , the api response that i am getting looks like this
{‘data’: {‘order_id’: ‘240703026113829’}, ‘status’: ‘success’}
The webinterface of upstox shows that the placed order was failed (as shown in image).
[Note: the trigger price passed is integer type of python, not string.]
Please Help.
@chandan22140, please make sure that the trigger_price for your buy order is higher than the last traded price of the specified stock.
Similarly, for a stop-loss market sell order, the trigger_price must be lower than the last traded price.
As you can see the code I posted, I am placing a buy order of type SL-M.
which means my trigger price should be smaller than the LTP. As you can see the screenshot attached in first post the trigger price is indeed smaller than the LTP. please clarify how to solve this problem. I have also posted the order ID in the first post for your reference @Ketan
I reviewed your order and noticed you placed an Infosys equity SL-M order with a trigger price of 1615 when the last traded price was 1643.
I hope there is no confusion between limit orders and SL-M orders. If you want to buy at 1615 when the current price is 1643, you should place a limit order instead of a stop loss order.
Ideally, a stop-loss market buy order is used to cover sell positions. As the name suggests, it is used to stop losses on your sell position. A sell position incurs a loss when the price increases from the point where you sold it. To prevent further losses, you would place a stop-loss market buy order with a trigger price that is higher than the last traded price.
I wanted to place a market order when LTP was 1643 with stoploss at 1615
Based what I have understood from documentation (please correct me if I am wrong)
In SL-M, TRIGGER PRICE acts as the stoploss price. I think in sl-m buy order, buy happens in market price.
I don’t think, trigger price 1615 means I want to buy at 1615.
Also, here does “sell position” mean “short position”?
Please enlighten me.
Oh, I understand your case now. Currently, the API does not support two-legged orders. To replicate the case you mentioned, you need to place two separate orders:
Market buy order
Stop loss market SELL order with a trigger price of 1615.
And yes, by “sell position,” I meant short positions.