Position book
A trading or position book is an up-to-date record of a trader's open positions.
The Position Book holds the user's collection of short-term to medium-term derivative instruments such as futures and options contracts, as well as intraday equity stocks. These instruments remain within the portfolio until they are sold or reach their expiration date.Any equity positions that are held overnight will be transferred to the Holding Portfolio the following day.
Method: POST
https://connect.thefirstock.com/api/V3/positionBook
Request details
Parameter | Description | Data types | Example |
---|---|---|---|
userId | User Id of the login user | String | "AA1999" |
jKey | Key Obtained on login success. | String | "d9b4e1b1c79042476fd96 11eed81003b2dc34c3f13b 0b60a4842fd5a24c9f3f2" |
- cURL
curl --location 'https://connect.thefirstock.com/api/V3/positionBook' \
--header 'Content-Type: application/json' \
--data '{
"userId": "AA123",
"jKey": "e6a211bea63adff386578988e1cf4a9521c4744e6a39ad63174c8797e2af8c38"
}'
from thefirstock import thefirstock
PB= thefirstock.firstock_PositionBook()
const Firstock = require("thefirstock");
const firstock = new Firstock();
firstock.positionsBook((err, result) => {
console.log("Error, ", err);
console.log("Result: ", result);
});
using thefirstock;
class Program
{
public static void Main()
{
Firstock firstock = new Firstock();
var result = firstock.positionBook();
}
}
Response details
Response data will be in json Array of objects with below fields in case of success.
Parameter | Description | Data types | Examples |
---|---|---|---|
status | Success | String | "Success" |
data.userId | User Id | String | "AA0011" |
data.exchange | Exchange Segment | String | "NSE" |
data.tradingSymbol | Trading symbol / contract. | String | "ITC-EQ" |
data.product | Product name to be shown. | String | "I" |
data.token | Contract token | String | "1660" |
data.pricePrecision | Price precision | String | "2" |
data.RealizedPNL | RealizedPN | String | "7.85" |
data.unrealizedMTOM | UnrealizedMTOM.(Can be recalculated in LTP update : = netqty * (lp from web socket - netavgprc) * prcftr | String | "0.00" |
data.priceFactor | priceFactor | String | "1.000000" |
data.lotSize | lotSize | String | "1" |
data.tickSize | tickSize | String | "0.05" |
data.mult | Multiplier | String | "1" |
data.netUploadPrice | netUploadPrice | String | "0.00" |
data.dayBuyQuantity | Day Buy Quantity | String | "4" |
data.daySellQuantity | Day Sell Quantity | String | "4" |
data.dayBuyAveragePrice | Day Buy average price | String | "326.48" |
data.daySellAveragePrice | Day buy average price | String | "326.48" |
data.dayBuyAmount | Day Buy Amount | String | "1305.90" |
data.netQuantity | Net Position quantity | String | "0" |
data.netAveragePrice | Net position average price | String | "0.00" |
data.uploadPrice | Average price uploaded along with holdings | String | "0.00" |
Failure response details
Parameter | Description | Data Type | Example |
---|---|---|---|
status | Failed | String | "Failed" |
code | HTTP Code | String | "404" |
name | Type of error | String | "ORDERS_NOT_FOUND" |
error.field | Error field | String | "orderDetails" |
error.message | Error message | String | "No data on the orders was found" |
Sample response
- Success response
- Failure response
{
"status": "Success",
"data": {
"userId": "AA0011",
"exchange": "NSE",
"tradingSymbol": "ITC-EQ",
"product": "I",
"token": "1660",
"pricePrecision": "2",
"lotSize": "1",
"tickSize": "0.05",
"mult": "1",
"priceFactor": "1.000000",
"dayBuyQuantity": "4",
"daySellQuantity": "4",
"dayBuyAmount": "1305.90",
"dayBuyAveragePrice": "326.48",
"datSellAveragePrice": "328.44",
"netQuantity": "0",
"netAveragePrice": "0.00",
"uploadPrice": "0.00",
"netUploadPrice": "0.00",
"unrealizedMTOM": "0.00",
"RealizedPNL": "7.85"
}
}
{
"status": "Failed",
"code": "404",
"name": "ORDERS_NOT_FOUND",
"error": {
"field": "orderDetails",
"message": "No data on the orders was found"
}
}