Skip to Main Content
POST/NorenWClientAPI/ProductConversion

Product Conversion

Convert an existing position from one product type to another (e.g. Intraday to Delivery) without squaring off and re-entering.

Overview

Product Conversion changes the product tag on a quantity you already hold — moving MIS to CNC before end-of-day auto square-off, or converting a carry-forward F&O position to intraday — without an offsetting trade. It only relabels an existing position; it does not place a new order.

Match against the actual position firstprevious_product_type must match the product the position is currently held under, and quantity can't exceed what's actually held — fetch the position from Positions immediately before converting rather than assuming your local state is current.

Parameters

FieldTypeRequiredDescription
uid / actidstringRequiredUser and account ID of the logged-in account.
exchstringRequiredExchange segment of the position.
tsymstringRequiredTrading symbol of the position. Must match exactly — URL-encode symbols with special characters like M&M.
qtyintegerRequiredQuantity to convert. Can be less than the full position for a partial conversion.
prdstringRequiredProduct to convert to. See Product Type Codes.
prevprdstringRequiredThe position's current product — must match what's actually held.
trantypestringRequiredTransaction type of the position being converted — B or S.
postypestringRequiredWhether converting a Day or carry-forward (CF) position.

Request example

import requests, json
 
# Fetch the position first, then convert it — don't guess prevprd/qty
positions = requests.post("https://api.shoonya.com/NorenWClientAPI/PositionBook",
                           data=f"jData={json.dumps({'uid':'AB1234','actid':'AB1234'})}&jKey={accessToken}").json()
p = positions[0]
 
payload = {
    "uid": "AB1234", "actid": "AB1234",
    "exch": p["exch"], "tsym": p["tsym"], "qty": p["netqty"],
    "prd": "I", "prevprd": p["prd"],
    "trantype": "B", "postype": "Day",
}
data = f"jData={json.dumps(payload)}&jKey={accessToken}"
resp = requests.post("https://api.shoonya.com/NorenWClientAPI/ProductConversion", data=data)
print(resp.json())
const payload = {
  uid: "AB1234", actid: "AB1234",
  exch: "NSE", tsym: "RELIANCE-EQ", qty: "1",
  prd: "I", prevprd: "C",
  trantype: "B", postype: "Day",
};
const data = `jData=${JSON.stringify(payload)}&jKey=${accessToken}`;
 
const res = await fetch("https://api.shoonya.com/NorenWClientAPI/ProductConversion", {
  method: "POST",
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
  body: data,
});
console.log(await res.json());
curl -X POST https://api.shoonya.com/NorenWClientAPI/ProductConversion \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode 'jData={"uid":"AB1234","actid":"AB1234","exch":"NSE","tsym":"RELIANCE-EQ","qty":"1","prd":"I","prevprd":"C","trantype":"B","postype":"Day"}' \
  --data-urlencode "jKey=$ACCESS_TOKEN"

Response

json
// Success
{ "stat": "Ok", "request_time": "10:52:12 02-06-2024" }
 
// Failure
{ "stat": "Not_Ok", "emsg": "Invalid Input : Invalid Position Type" }

Error handling

ErrorCause
Invalid Input : Invalid Position Typeprevprd doesn't match the position's actual current product.
Invalid Quantityqty exceeds the held position quantity.
Session ExpiredToken invalid or expired — re-authenticate.

Best practices

  • Always re-fetch Positions right before converting — a fill or partial square-off between your last read and the conversion request will cause a mismatch.
  • For intraday-to-delivery conversions ahead of auto square-off, build in a time buffer — don't run this at the exact square-off cutoff.

Notes

This does not create a new order or trade — it only relabels the product tag on an existing position. It has no effect on average price or realized P&L.