Confusion in Covert position

maheshsolanke
Hello all,
i want to convert only product type of my position via api call and got the funtion which is convert_position(), we need to pass following parameter in that

exchange,
tradingsymbol,
transaction_type,
position_type,
quantity,
old_product,
new_product

in above parameter we get exchange,tradingsymbol,quantity,and product from position book.
where to get position_type, transaction_type to pass in the function for that position.
@sujith @rakeshr
Tagged:
  • sujith
    sujith edited June 2021
    The position type can be either day or overnight.
    Following are the steps,
    1. Use the positions list from net array of positions response.
    2. The formula for checking if it is day or overnight position_type, if you have only one type of Qty i.e either day or overnightQty, is as follows
    dayQty = qty - overnightQty
    if(dayQty > 0)
    position_type = 'day'
    else
    position_type = 'overnight'
    But, if you have both overnight and day qty as well, then it will be something like:
    1> If you want to convert only overnight_quantity, then you will have to use position_type = overnight
    2> If you want to convert only day qty, i.e qty-overnightQty, then you will have to use position_type= day.

    The transaction type can be either BUY or SELL
    if (position_type == day && position.overnight_qty != 0)
    if(qty - overnight_qty > 0)
    transaction_type = 'BUY'
    else
    transaction_type = 'SELL'
    else
    if(qty > 0)
    transaction_type = 'BUY'
    else
    transaction_type = 'SELL'
  • maheshsolanke
    Thank you so much @sujith , this will very helpful.
This discussion has been closed.