Off late i can see some error like below in logs...
"Trigger price for stoploss buy orders should be higher than the last traded price (772). Try limit order to buy at a lower price."
The error message is very clear, and i have applied a try box and put a limit order in exception box, to handle it as of now.
However, as a second thought, think about the below argument...
i am getting this error while placing order with order_type ="SL", which is essentially a Stop-Loss-*Limit* order... Had the error been for "SL-M" (Stop Loss Market) orders, i wouldnt have said anything.
But what do you think...? Should this error check be there for "SL" (Stop-Loss-*Limit* ) orders too ? The Main leg of SL-Limit orders is sent as Limit order to Exchange... So, if in case of Buy above order, when ltp is already above the entry price, shouldnt the order get executed at the best available price between the ltp and entry price..? without giving this error. Just like any other Limit order...
In other words, if there is no error in placing a Limit order with entry above LTP. Then why is there an error while placing a SL-Limit order with entry/trigger below LTP?
What do u say...?
PS: Earlier this piece of code wasnt giving any error (from over an year) . Seems like after recent release which introduced "Better error messages", this came up... So i am more interested in knowing that is it a mistake by oversight, or intentional addition of a error check, carefully crafted.