Simulating a Bracket Order

Hello Team,

Full Disclosure : Am a newbie trader. Am just looking for some answers to questions as mentioned below. Also if an experienced person can find a caveat which I missed, please don’t hesitate to point it out… :slight_smile:

Given that most of the times BO is unavailable due to “volatile markets…” but I still kinda feel the requirement of safety net, which is a three leg position = Position Order + Stoploss(Trailing) Order + Target Order

==================================================

Assumptions for taking this trade :
  • I am talking about Algorithmic Trading, so basically there is code running which is managing my trades and communication from exchange (directed via KiteConnect WebSockets)

  • I am not keen on using Cover Orders alongside the another Target order. Also since there are restriction on to the band in which the stoploss values can lie.

  • BO orders are usually not available through the day/weeks (in the current case for almost an year) depending on the market volatility. Hence are unreliable.

  • Reliance VaR+ELM right now is = 17.75 %; Reliance is currently trading at : Rs ; 2,094.45. My current trading account balance is Rs 10,000.
    table

  • I have no other active positions.

  • I have gone through this article - Margins- 2 Exit orders for 1 position; but as this article is too old (2013) am unsure of the applicability of it in 2021 also unsure of the implications of new margin rules.

==================================================

I will need to have 3 corresponding LEGS to a position which will be punched by my RMS system - ACTUAL ORDER + STOPLOSS (Trailing) ORDER + TARGET ORDER

  • Actual Position Order : An MIS order of Instrument RELIANCE LONG @26 quantity at price 2094.45 with LIMIT type is placed. Total Margin Blocked : Rs 9665.89

    • Timestamp T01@POSITION_ORDER[a new MIS buy order] : 26 QTY buy @ 2094.45
    • Lets say this order is executed at the exchange in succession like, at
      - Timestamp T11@POSITION_TRADE1 : 10 QTY filled @ 2094.45
      - Timestamp T21@POSITION_TRADE2 : 10 QTY filled @ 2094.45
      - Timestamp T31@POSITION_TRADE3 : 06 QTY filled @ 2094.45
  • Stoploss Order : My code keeps on listening to the filled_quantity in the WebSocket on_order_update and as the new trades are executed, and as soon as I get new fill I will send an update to stoploss order for the new total fill quantity.

    • Timestamp T12@SL_ORDER[a new MIS sell order] : 10 QTY sell order @ LIMIT @ 2085.25
    • Timestamp T22@SL_ORDER_UPDATE1 : +10 QTY sell order @ LIMIT @ 2085.25
    • Timestamp T32@SL_ORDER_UPDATE2 : +06 QTY sell order @ LIMIT @ 2085.25
  • Target Order : My code keeps on listening to the filled_quantity in the WebSocket on_order_update and as the new trades are executed, and as soon as I get new fill I will send an update to target order for the new total fill quantity

    • Timestamp T13@TG_ORDER[a new MIS sell order] : 10 QTY sell order @ LIMIT @ 2105.25
    • Timestamp T23@TG_ORDER_UPDATE1 : +10 QTY sell order @ LIMIT @ 2105.25
    • Timestamp T33@TG_ORDER_UPDATE2 : +06 QTY sell order @ LIMIT @ 2105.25
  • The order of succession will be as below

My Question

  • I am unsure of the calculations in the red cells, i.e what will be my margin requirements when I spawn two New sell trades one for Stoploss and one for Target even though my trading account has only 334.11 cash left.
  • How will the calculations be different when the Stoploss and Target orders are updated.

I am unable to see a file attachment option otherwise I would have attached the table. Although if you want kindly post your email address. @siva @nithin @ShubhS9 any sort of help would be appreciated! Thanks

[UPDATE]
Since i cant update the original post anymore here is a small update

Stoploss Order needs to be a MIS SL(Limit Order with a Trigger Price) Order, basically it will live in the Exchanges Books until the trigger is hit and then it will be activated.

Otherwise if i had punched an Stoploss MIS Limit Order at 2085.25 it would had been instantly executed at Timestamp T12 itself. I think Target MIS Limit Order should be ok, if i had punched it at Timestamp T13 itself…

  • Stoploss Order : My code keeps on listening to the filled_quantity in the WebSocket on_order_update and as the new trades are executed, and as soon as I get new fill I will send an update to stoploss order for the new total fill quantity.
    • Timestamp T12@SL_ORDER[a new MIS SL order with Trigger at 2085.15] : 10 QTY sell order @ LIMIT @ 2085.25
    • Timestamp T22@SL_ORDER_UPDATE1 : +10 QTY sell order @ LIMIT @ 2085.25
    • Timestamp T32@SL_ORDER_UPDATE2 : +06 QTY sell order @ LIMIT @ 2085.25