Closed moganraj closed 3 years ago
Read and follow this before creating a new issue.
Price try should be float.
Yes Sir, I have the value in float and did not find any existing case match with the below issue.
Kindly correct me if I am doing anything wrong. It would be very helpful.
Let me give the sequence of execution.
1st Execution: I will run this below TransactionType.Sell when the market is live. once it reaches the price the order will be executed and Sell-Stoplosslimit order is place successfully.
Data: trigger_price = 710.35 fl_price = 710.30
alice.place_order(transaction_type=TransactionType.Sell,
instrument=bn_fut,
quantity=cnt_Quantity,
order_type=OrderType.StopLossLimit,
product_type=ProductType.Intraday,
price=fl_price,
trigger_price=triggerprice,
stop_loss=None,
square_off=None,
trailing_sl=None,
is_amo=False)
2nd Execution: Once Sell-Stoplosslimit order(refer to 1st Execution) is placed successfully, then I will execute the below 2 orders.
In the 2nd execution, the order_SellTarget was placed successfully in automation without any issues but the order_SellStoploss is rejected with the reject reason "600 : Invalid trigger price for stop loss order."
Issue: For a Sell StopLoss Limit(refer to 1st Execution), Stoploss(refer to 2nd Execution) order should be a TransactionType.Buy. Since its Buy transaction, I need to have the trigger price < price, but my order is rejected as Aliceblue allows only if trigger price > price for a stoploss order.
Note: When I place the same order manually with same values as mention above in the application its working fine. Issue is only via automation.
Data: target_fl_price = 707.55 target_triggerprice = 707.50
buy_triggerprice = 712.00 buy_fl_price = 712.05
order_SellTarget = {"transaction_type": TransactionType.Buy,
"instrument": bn_fut,
"quantity": cnt_Quantity,
"order_type": OrderType.Limit,
"product_type": ProductType.Intraday,
"price": **target_fl_price**,
"trigger_price": target_triggerprice,
"stop_loss": None,
"square_off": None,
"trailing_sl": None,
"is_amo": False}
order_SellStoploss = {"transaction_type": TransactionType.Buy,
"instrument": bn_fut,
"quantity": cnt_Quantity,
"order_type": OrderType.StopLossLimit,
"product_type": ProductType.Intraday,
"price": buy_fl_price,
"trigger_price": buy_triggerprice,
"stop_loss": None,
"square_off": None,
"trailing_sl": None,
"is_amo": False}
order = [order_SellStoploss, order_SellTarget]
alice.place_basket_order(order)
Let me know if you have any other questions.
Note: Same issue happen for Buy - Stoplimit order too.
Your use case is similar to bracket order. Don't use basket order for this purpose. It will initiate new positions as per your explanation above. It won't square off as you expected. Explore bracket order.
Hi Sir, I have used Bracket order and its not allowed until old contract is completed. For Example: Until Aug contract end date, Alice blue doesn't allow Bracket Order in Sep Contract. Hence we approached the above way to execute orders in the Sep contract until Aug contact is completed.
The above way was working fine for me when I am doing manually.
Even in automation, Buy/Sell order executed successfully Buy Target/Sell Target executed successfully Stoploss order is rejected. I hope there is bug in the stoploss order module. it will be very helpful if the bug is fixed. Correct me if it's not a bug.
For Sell Stoploss --> we should have Trigger Price < Price. But Aliceblue is not allowing to have the above condition rather its asking us to keep Trigger Price > Price which is the opposite condition for Sell Stoploss.
Note: This happen same for Buy Stoploss too.
This library just passes on the information to the Alice server. And Alice server should behave the same both in API and manual trading. Replicate the same using web UI. You'll face the same issue. In API you are using basket order. Did you try the same basket order in web UI also? Also in the first order of basket order, why there is a trigger price when the order type is limit? A simple limit order should not contain trigger price.
Hi Sir,
kindly find my response below,
Method 1: Placing Individual order I have tried manually in web UI and it was working fine. The issue for stoploss was only via automation. The order details is passed to the Alice blue server and then the order is rejected.
Method 2: Basket Order Basket orders is only via automation we don't have such option in WebUI.
Method 3: Bracket Order Bracket Order is working fine for me both via automation and webUI(manually). The only restriction is that Bracket Order can't be place for new contract until old contract is completed. Hence I was using method 1.
Last question - why there is a trigger price when the order type is limit? A simple limit order should not contain trigger price.
This is not a normal limit order which execute in LTP. Our logic will calculate the price and trigger price placed in advance and then the order will execute only after the value hit the trigger price. [Note: I can't keep trigger price and price same because Alice blue representative requested us to keep a difference. else our order will be skipped. ]
I found an example in zerodha to explain the issue. https://support.zerodha.com/category/trading-and-markets/margin-leverage-and-product-and-order-types/articles/im-trying-to-place-a-stop-loss-order-but-im-getting-the-error-limit-price-is-worse-than-the-trigger
OrderType.Limit Cannot have trigger price. Remove that, else change the order type and see. That’s what causing problem.
Here is a video of basket order. https://youtu.be/3gPMt5AI90g
Your 1st order type in 2nd execution should be stop loss limit. Else keep the order type as same and remove the trigger price.
As I said before. There shouldn’t be any difference between api and web ui. If you try the same in web ui you should get the same result. In web ui you cannot set the order type as limit and set a trigger price. That’s what the difference is from web and api in your case.
Hope your issue is resolved, reopen if not.
Hello Sir, I am placing a Stoploss for Sell order and getting an error after order placement as "600 : Invalid trigger price for stop loss order." in Aliceblue UI. I have provided the below code with an example.
For Sell Stoploss --> I need to have trigger_price < price but this is not allowed in automation, When I do manually my Sell-Stoploss is placed without any issue
Example: buy_triggerprice = 712.00 buy_fl_price = 712.05
Reference Link: https://aliceblueonline.com/support/services/all-types-of-order-rejections-and-the-solution-for-them/ 600 : Invalid trigger price for stop loss order. ---> For Sell SL orders, Trigger Price > Price
Code: order_SellStoploss = {"transaction_type": TransactionType.Buy, "instrument": bn_fut, "quantity": cnt_Quantity, "order_type": OrderType.StopLossLimit, "product_type": ProductType.Intraday, "price": buy_fl_price, "trigger_price": buy_triggerprice, "stop_loss": None, "square_off": None, "trailing_sl": None, "is_amo": False}