How to create Bracket order in Commodity segment using java code ?

jhansisiri
Hi ,

Can someone let me know how can I code the Bracket order using java code ? If anyone has done please share the java code ?

My requirement
1)Place the main or parent order // I could do this
2)If the status of the parent order is executed , then I want to place 2 more orders // I need help in tracking this order status
a) Place the target order
b)Place the stoploss order with trailing stoploss
3) If the target order or Stopless order excuted , then the other one shall cancel by itself .

I went through the api documnetation and also Example.java but couldn't figure out how to go ahead . The web socket code is supposed to help but could not able to figure it out . Please help.

Please add more examples on how to use websocket code .

Thanks in Advance
  • jhansisiri
    This listener code seems to be never triggering .

    /** Set listener to get order updates. */
    tickerProvider.setOnOrderUpdateListener(new OnOrderUpdate() {
    @Override
    public void onOrderUpdate(Order order) {
    System.out.println("order update " + order.orderId);

    }
    });


    I created an order programtically and once I got the orderId , I cancelled the order immediately in the program. But the above code never triggering .
    When I login to Zerodha browser , I see the order is placed and cancelled too .

    Please let me know what is the issue.

    This listener is working fine though.
    tickerProvider.setOnTickerArrivalListener(new OnTicks() {
  • sujith
    sujith edited April 2021
    Bracket orders are not supported anymore. You can use a combination of regular order and GTT instead.
    For regular order, postbacks should be fine. We don't send postbacks for amo.
  • jhansisiri
    Thanks for the response from your end .
    I was testing my strategy with AMO then . Because of AMO order it didn't work then . However today when market is open I tried the same , post back I received .

    If I use the GTT type of order , I guess I need to pay full margin . Also I want to implement the Bracket order kind of order on commodity segment. GTT is not possible on commodities right ?
  • sujith
    sujith edited April 2021
    Apologies, I missed it. GTT is not available for MCX. But bracket order was not available for MCX when it was provided back then.
    You will have to place two orders and keep modifying the order, that is the only feasible solution.
  • jhansisiri
    I could make my own Bracket orders strategy . It worked fine . You can close this ticket .

    Want to write super-trend code in Java . Refer to any right link .

Sign In or Register to comment.