Skip to content

Trades & Positions

Use the below apis to see and manage positions:

method endpoint use case Rate Limit
GET /trades?limit={limit}&offset={offset} Fetch all trades 10/sec
GET /portfolio/positions Fetch all positions 10/sec
PUT /portfolio/positions Convert Position 10/sec
GET /portfolio/holdings Fetch holdings 10/sec

Get Trades

Endpoint: /orders?limit={limit}&offset={offset}

Note

  • Offset should atleast be 1
  • Limit is the number of orders to be fetched.

Trade Book Response

{
    "status": "success",
    "trades": [
        {
            "order_id": "NXAAE00002@6",
            "exchange": "NSE_EQ",
            "token": 22,
            "trade_no": "2416756",
            "exchange_order_no": "1000000016120889",
            "transaction_type": "SELL",
            "product": "INTRADAY",
            "variety": "RL",
            "trade_quantity": 1,
            "trade_price": 1856.75,
            "symbol": "ACC",
            "series": "EQ",
            "instrument_name": "",
            "expiry_date": "",
            "strike_price": 0.00,
            "option_type": "",
            "traded_at": "2023-06-16 13:06:43",
            "initiated_by": "MOBILE-Ex",
            "modified_by": "MOBILE-Ex",
            "order_identifier": "app=DEMO"
        },
        {
            "order_id": "NXAAE00001@6",
            "exchange": "NSE_EQ",
            "token": 22,
            "trade_no": "2413994",
            "exchange_order_no": "1000000016098874",
            "transaction_type": "BUY",
            "product": "INTRADAY",
            "variety": "RL",
            "trade_quantity": 1,
            "trade_price": 1857.00,
            "symbol": "ACC",
            "series": "EQ",
            "instrument_name": "",
            "expiry_date": "",
            "strike_price": 0.00,
            "option_type": "",
            "traded_at": "2023-06-16 13:06:17",
            "initiated_by": "MOBILE-Ex",
            "modified_by": "MOBILE-Ex",
            "order_identifier": "app=DEMO"
        }
    ],
    "metadata": {
        "total_records": 2
    }
}

Fetch All Positions

Positions returns the open and closed outstanding positions carried forward from the previous days and scrips that are traded today. In the below sections we explain what the position api returns and how to use them to calculate different type of gains

Sample Response

{
   "status": "success",
   "data": {
       "net": [
           {
               "exchange": "NSE_EQ",
               "symbol": "ITC",
               "expiry_date": "",
               "option_type": "",
               "token": 1660,
               "product": "MTF",
               "quantity": 2,
               "overnight_buy_value": 380.00,
               "overnight_sell_value": 0.00,
               "overnight_average_price": 190.00,
               "lot_size": 1,
               "multiplier": 1.00,
               "average_price": 357.30,
               "value": -714.60,
               "buy_value": 714.60,
               "sell_value": 0.00,
               "buy_quantity": 2,
               "sell_quantity": 0,
               "buy_price": 357.30,
               "sell_price": 0.00,
           },
       ],
       "day": [
           {
               "exchange": "NSE_EQ",
               "symbol": "ITC",
               "expiry_date": "",
               "option_type": "",
               "token": 1660,
               "product": "MTF",
               "quantity": 1,
               "overnight_buy_value": 0.00,
               "overnight_sell_value": 0.00,
               "overnight_average_price": 0.00,
               "lot_size": 1,
               "multiplier": 1.00,
               "average_price": 380.00,
               "value": -380.00,
               "buy_value": 380.00,
               "sell_value": 0.00,
               "buy_quantity": 1,
               "sell_quantity": 0,
               "buy_price": 380.00,
               "sell_price": 0.00,
           }
       ]
   }
}

Note

There are two arrays, net and day. The day array contains information of positions entered today while the net array gives information of positions carried forward plus the positions taken today.

Net Position

field description
product Can be [INTRADAY, DELIVERY, MTF]
quantity Total outstanding quantity from carried forward position and today's position
overnight_buy_value Value of long carried forward position
overnight_sell_value Value of short carried forward position
overnight_average_price Average price of carried forward position
lot_size Should be used for exchange NSE_CUR & MCX_FO. For these exchanges,actual quantity = quantity * lot_size * multiplier
multiplier Should be used for exchange NSE_CUR & MCX_FO. For these exchanges,actual quantity = quantity * lot_size * multiplier
average_price Average price of the entire outstanding quantity from carried forward position and today's position
value Equal to sell_value - buy_value
buy_value Total buy value of the entire outstanding quantity from carried forward position and today's position
sell_value Total sell value of the entire outstanding quantity from carried forward position and today's position
buy_quantity Total buy quantity from carried forward position and today's position
sell_quantity Total sell quantity from carried forward position and today's position
buy_price Average buy price of all quantity from carried forward position and today's position
sell_price Average sell price of all quantity from carried forward position and today's position

Day Position

field description
product Can be [INTRADAY, DELIVERY, MTF]
quantity Total outstanding quantity from today's position
overnight_buy_value Default: 0. Should be omitted
overnight_sell_value Default: 0. Should be omitted
overnight_average_price Default: 0. Should be omitted
lot_size Should be used for exchange NSE_CUR & MCX_FO. For these exchanges,actual quantity = quantity * lot_size * multiplier
multiplier Should be used for exchange NSE_CUR & MCX_FO. For these exchanges,actual quantity = quantity * lot_size * multiplier
average_price Average price of the outstanding quantity from today's position
value Equal to sell_value - buy_value
buy_value Total buy value of today's position
sell_value Total sell value of today's position
buy_quantity Total buy quantity of today's position
sell_quantity Total sell quantity of today's position
buy_price Average buy price of today's position
sell_price Average sell price of today's position

Calculating Gains:

  • To calculate overall gain, use only the net array.

    For Long Position:
    
    Gain = (last_trade_price * quantity * lot_size * multiplier +overnight_sell_value ) - overnight_buy_value
    
    For Short Position:
    
    Gain = overnight_sell_value - (overnight_buy_value + last_trade_price * quantity * lot_size * multiplier)
    
    For Exited Position:
    
    Gain = sell_value - buy_value
    
  • To calculate today's gain, use only the day array.

  • Let's say you bought 1 lot of NIFTY 18000 CE yesterday at 70 rupees. At the end of the day, system will debit 70 * 50 = 3500 Rupees from your ledger. Today when you see the position, its MTM will start from 0. This pattern is valid for all Futures and Options.

  • Let's say you sold bought 1 lot of NIFTY 18000 CE yesterday at 70 rupees. The market closed at 65. At the end of the day, system will credit 70 * 50 = 3500 Rupees in your ledger. Today when you see the position, its MTM will start from 65. This pattern is valid for all Futures and Options.

  • If a position has both net and day positions, during squaroff the system will first square off day position and then carried forward position.

Convert Position

Using this api, you can change the product of the position. INTRADAY product can be converted to DELIVERY and vice versa.

Note

  • Like order placement, a success returned from position conversion API doesnt mean that the position is converted. It simply means that the request has been accepted and the fate of the request will be decided later.
  • Positions in MTF product cannot be converted to any other product. You need to square off MTF position and then take another position in any product of your choosing.

Warning

Position conversion is currently disabled at risk management level

Convert Position Object

{
    "exchange": "NSE_FO",
    "token": 66602,
    "transaction_type": "BUY",
    "quantity": 250,
    "old_product_type": "DELIVERY",
    "new_product_type": "INTRADAY"
}

Success Response

{
    "status": "success",
    "code": "s-101",
    "message": "Position Conversion Request Sent to OMS"   
}

Fetch Holdings

Endpoint: /portfolio/holdings

Holdings Response

{
"status": "success",
"data": [
    {
        "isin": "IN0020210244",
        "nse": {
            "token": 7843,
            "exchange": "NSE_EQ",
            "symbol": "654GS2032",
        },
        "bse": {
            "token": 800440,
            "exchange": "BSE_EQ",
            "symbol": "654GS2032",
        },
        "total_free": 1,
        "dp_free": 1,
        "pool_free": 0,
        "t1_quantity": 0,
        "average_price": 95.00,
        "collateral_quantity": 0,
        "collateral_value": 0.00
    },
    {
        "isin": "INE721Z01010",
        "nse": {
            "token": 1030,
            "exchange": "NSE_EQ",
            "symbol": "AARON",
        },
        "bse": {},
        "total_free": 1,
        "dp_free": 1,
        "pool_free": 0,
        "t1_quantity": 0,
        "average_price": 137.70,
        "collateral_quantity": 0,
        "collateral_value": 0.00
    }]
}
field description
isin ISIN of the stock as registered with SEBI
nse Scrip details as registered with NSE
bse Scrip details as registered with BSE
total_free Total free quantity that can be sold
dp_free Free quantity that can be sold present in trader's demat account
pool_free Free quantity that can be sold present in broker's pool account
t1_quantity Quantity which is bought by the trader in previous trading days but not yet settled in demat account
collateral_quantity Quantity that is blocked as collateral for margin
collateral_value Trading limit increased by keeping collateral

Note

  • Collateral value is not a multiplication of collateral_quantity and price. Brokers are required to first take a haircut out of the stock's value and then increase margin.
  • There may be some holdings present in a trader's account which are not listed in either one of the exchanges. Equities listed only in BSE cannot be sold as Rupeezy is not affiliated with BSE.
  • Even if Rupeezy is not registered with BSE, holdings can contain BSE only stocks. Ususally these are stocks which have come in our depoitory by means of transfer from another broker's depository.
  • If stock is present in both broker's pool account and trader's demat account, stocks will first be sold from pool account and then from demat account