How to convert a pending INTRADAY sell order to market order.

I have a pending INTRADAY sell LIMIT order, using fyers.modify_order(data=data) where data is

data = {
    "id":orderId, 
    "type":2 
}

I am tried to modify it to market order, its giving error 'Invalid order id', I rechecked the order id its fine. I am able to change the price using the API and same orderId. Hence orderId is not the issue. 

This is the data for the trade which I want to modify to market order
{                                       
  exchange: 'NSE',                      
  symbol: 'ONGC-EQ',                    
  type: 1 #'LIMIT',                        
  side: -1 #'SELL',                         
  quantity: 1,                          
  tradedQuantity: 0,                    
  tradedPrice: 0,                       
  productType: 'INTRADAY',              
  limitPrice: 187,                      
  stopPrice: 0,                         
  currentPrice: 185,                    
  status: 'PENDING',                    
  id: 'xxxxx' #orderId,                 
  message: '',                          
  token: '10100000002475'               
}                    

What am I missing?

Hi @shyam.cqj9mxeg
when you placed on order you got the order id
Use that one

Hi Pankaj,

I am using the same order id, as I said I am able to change the limit price, but change from limit type to market for the same order id is giving this error.

Hi @shyam.cqj9mxeg
When you are modifying to the market order

What you are passing can you show me the payload.

Hi Pankaj,

I am only changing the type for sell pending order from 1(limit) to 2(market), do I have to pass any other like limitPrice, stopPrice, qty etc.

This is what I am doing:

data = {
    "id":orderId, 
    "type":2 
}
response = fyers.modify_order(data=data)

Hi @shyam.cqj9mxeg
No , it is working for me I checked from my side

You can use these payload as well.

orderId = "24703400067981"
data = {
    "id":orderId, 
    "type":2,
    "limitPrice": 0,
    "qty":1
}

Or

orderId = "23103124067985"
data = {
    "id":orderId, 
    "type":2,
    "qty":1
}

Can you try with these payloads as well ?

Thanks Pankaj,

This is working provided I give qty in the payload, just modifying the type from limit to market does not work.

This is strange, anyway my issue is solved. Just check if that is how it is suppose to work.

Hi @shyam.cqj9mxeg
you have to provide qty always

For changing the limit price, I don’t provide qty, it works. Hence I expected this also to work without qty.

the API V3 document says “qtyint, Mandatory. Incase you want to modify the quantity”

Hence qty is not required if only type is change and qty is not to be changed.