How to place a Bracket order using python client?

hhemanth
Hello

I am trying to place a bracket order in the python client and I am not able to do so properly.

My assumption is that there will be 3 orders created for 1 bracket order.

1 Current order at market price.
1 Stop Loss order
1 Target Order

But I am able to create only one order. Please help what should be the parameters.

I tried the following parameters


"exchange" = "NSE",
"tradingsymbol" = "SBIN",
"quantity" = "1",
"transaction_type" = "BUY",
"order_type" = "MARKET",
"product" = "MIS",
"price" = "277",
"stoploss_value" = "275",
"target" = "280",
"variety" = "BO"


What should the correct parameters be?
Tagged:
  • sujith
    Hi @hhemanth,
    Once you place BO, only one order is placed which is limit(first leg), once first leg is executed then other two are placed. So when you place BO and fetch orderbook, it will have only one order entry.
  • sujith
    Take a look at example params for BO,
    Map param = new HashMap(){
    {
    put("quantity", "1");
    put("order_type", "LIMIT");
    put("price", "1.4");
    put("transaction_type", "BUY");
    put("tradingsymbol", "ANKITMETAL");
    put("trailing_stoploss", "1");
    put("stoploss_value", "1");
    put("exchange", "NSE");
    put("validity", "DAY");
    put("squareoff_value", "1");
    put("product", "MIS");
    }
    };
  • hhemanth
    thanks Sujith.
  • madhavanmr
    Hi sujith

    Lets say SBIN is trading at 277

    I want to place a bracket order with Limit price as 277, Target as 280 and trailing stop loss as Rs 1
    how do i place it? can you post the parameters for it?

    Thank you
  • Matti
    Matti edited November 2016
    Map param = new HashMap(){
    {
    put("quantity", "1");
    put("order_type", "LIMIT");
    put("price", "277");
    put("transaction_type", "BUY");
    put("tradingsymbol", "SBIN");
    put("trailing_stoploss", "1");
    put("stoploss_value", "2");
    put("exchange", "NSE");
    put("validity", "DAY");
    put("squareoff_value", "3");
    put("product", "MIS");
    }
    };

    In the example above, I've assumed the stoploss is at 275, since stoploss value is mandatory.
  • madhavanmr
    Hi @sujith

    Lets say SBIN is trading at 277

    I want to place a bracket order with Limit price as 277, Target as 280 and trailing stop loss as Rs 1
    how do i place it? can you post the parameters for it?

    Thank you
  • sujith
    sujith edited November 2016
    Map param = new HashMap(){
    {
    put("quantity", "1");
    put("order_type", "LIMIT");
    put("price", "277");
    put("transaction_type", "BUY");
    put("tradingsymbol", "SBIN");
    put("trailing_stoploss", "1");
    put("stoploss_value", "2");
    put("exchange", "NSE");
    put("validity", "DAY");
    put("squareoff_value", "3");
    put("product", "MIS");
    }
    };

    This is the example params for your query same as Nikhil's answer.
    For bracket order, squareoff_value, stoploss_value are compulsory and you will specify these values in points, i.e difference between LTP and desired price.
    Square off value, stoploss and trailing stoploss are always specified in points, not in price.
    Note: minimum value for trailing stoploss is 1.
  • hhemanth
    @sujith I tried exactly the params specified by you, but this is going as a MIS order and not as a BO. I tried with product with "BO". I tried product = "MIS" and variety = "BO" its just not working. Can you please tell me if BO is even supported. Can you verify it yourself and then give the parameters please. We have tried it for 3 days , please help us.
  • madhavanmr
    @sujith
    This is the first order placed as per your reply. I cant see a BO order it is going as a MIS order .(trailing Stop loss 1 , stoploss 2 and sq off 3)

    09:30:28 SBIN NSE BUY 1 / 1 277.5 MIS

    If we change it to BO

    09:29:39 SBIN NSE SELL 1 / 1 277.55 BO COMPLETE
    09:29:39 SBIN NSE BUY 1 / 1 277.6 BO COMPLETE

    I guess something is off
  • sujith
    Hi,
    Product can be only MIS or CNC for equity and MIS or NRML for F&O contracts. Kite considers MIS as intraday and CNC as delivery. BO is a order variety not product. All BO are MIS which means it will be squared off by 3:20 PM. Order variety can be REGULAR, BO, CO and AMO(after market order).

    I will try for SBIN and let you know.

  • sujith
    I tried this and it works,

    Map param10 = new HashMap(){
    {
    put("quantity", "1");
    put("order_type", "LIMIT");
    put("price", "276.8");
    put("transaction_type", "BUY");
    put("tradingsymbol", "SBIN");
    put("trailing_stoploss", "1");
    put("stoploss_value", "2");
    put("exchange", "NSE");
    put("validity", "DAY");
    put("squareoff_value", "3");
    put("product", "MIS");
    }
    };
    Order order10 = kiteconnect.placeOrder(param10, "bo");
    System.out.println(order10.orderId);
Sign In or Register to comment.