Can someone please help me with placing of Bracket order for FNO category using python3

Hi Team

I am trying to place bracket order for below scenario.
lets suppose current buy price 23500 CE is 100 rs
I want to buy if the price reaches 110 rs with SL of 90 rs and target of 120 rs.

So basically after the instrument is bought SL and target orders should be placed automatically.

Can someone please help me with the payload.

1 Like

@Hardik can you please help

I tried below payload, it does places the order but SL and Target doesn’t get set.

Please help.

        order = dhan.place_order(
            tag='',
            transaction_type=dhan.BUY,
            exchange_segment=dhan.NSE_FNO,
            product_type=dhan.INTRA,
            order_type=dhan.SL,
            validity='DAY',
            security_id=symbol,
            quantity=qty,
            price=price,
            trigger_price=trigger_price,
            after_market_order=False,
            amo_time='OPEN',
            bo_profit_value=bo_profit_value,
            bo_stop_loss_Value=bo_stop_loss_Value,
            drv_expiry_date=None,
            drv_options_type=None,
            drv_strike_price=None    
        )```

Hello @Manan_Shah

Over here, you need to place BO order:

order_type=dhan.BO

Do try with this and let me know if you are able to do this. Note that Trigger will not work with BO as BO itself is a special order and trigger orders are separate which are placed separately on exchange.

1 Like

Hi @Hardik

I tried order type BO. Order got placed and immediately the product was bought.
Than SL and book profit order were placed respectively.

So if the price was 100rs and trigger price was 110

i was expecting if the prices crosses 110 than only it will buy.
but it bought at market price instead of trigger price.

if this does;t work i am thinking of chaning my strategy.

Can you please help me with placing order of OCO type?
what I am planning to do is place a buy trigger for 110 rs

if the instrument is bought in that case place OCO order.

what should be prodcut type for OCO?
also it will be great if there are any examples or sample payload for OCO

please help

Hello @Manan_Shah

We do not have only OCO order type available on APIs. It is clubbed with Basket Orders only.

Although we are working on something here, it will take some time for that. For the time being, if you are subscribing to the Live Market Feed, you can keep a condition wherein the order is only placed when you find the same price on top bid/ask?

thanks for the suggestion
i will let you know if I will need any help with it

1 Like

Hey @Hardik

Please let me know once your team has added OCO via API

Hello @Manan_Shah

We are working on this, stay tuned.

1 Like

Hi @Hardik

any news on this

Hello @mnikhil

We have added OCO Forever Orders on API with Version 2.

Oh great to hear that!! thanks @Hardik could you please provide code snippets and documentation for the same, I will take it for a spin

Hello @mnikhil

Sure. You can check out the same at: Forever Order - DhanHQ Ver 1.0 / API Document

this is a forever order api in v1 and you mentioned there is a change in v2?

Hello @mnikhil

Fixing the documentation header, it is in V2.