API function to read positions from your trading platform. APIs are available in AmiBroker, MetaTrader, Excel, Java, C#, Python, HTTP REST.
Api function will read positions from Supports leading Indian Stock Brokers.
Signatures
/*
* Retrieve positions's trading account.
*/
function getPositionTradingAccount(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's MTM (Mtm calculated by your stock broker).
*/
function getPositionMtm(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's PNL (Pnl calculated by your stock broker).
*/
function getPositionPnl(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's AT PNL (Pnl calculated by AutoTrader Web).
*/
function getPositionAtPnl(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's buy quantity.
*/
function getPositionBuyQuantity(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's sell quantity.
*/
function getPositionSellQuantity(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's net quantity.
*/
function getPositionNetQuantity(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's buy value.
*/
function getPositionBuyValue(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's sell value.
*/
function getPositionSellValue(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's net value.
*/
function getPositionNetValue(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's buy average price.
*/
function getPositionBuyAvgPrice(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's sell average price.
*/
function getPositionSellAvgPrice(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's realised pnl.
*/
function getPositionRealisedPnl(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's unrealised pnl.
*/
function getPositionUnrealisedPnl(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's overnight quantity.
*/
function getPositionOvernightQuantity(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's multiplier.
*/
function getPositionMultiplier(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's LTP.
*/
function getPositionLtp(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's (platform specific) exchange.
*/
function getPositionExchange(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's (platform specific) symbol.
*/
function getPositionSymbol(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's date (DD-MM-YYYY).
*/
function getPositionDay(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's trading platform.
*/
function getPositionPlatform(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's account id as received from trading platform.
*/
function getPositionAccountId(pseudoAccount, category, type,
independentExchange, independentSymbol)
/*
* Retrieve positions's stock broker.
*/
function getPositionStockBroker(pseudoAccount, category, type,
independentExchange, independentSymbol)
Examples
// Category can be (DAY, NET)
category = "DAY";
// Type can be (MIS, NRML, CNC, BO, CO)
type = "MIS";
// We are using chart parameters like AT_EXCHANGE & AT_SYMBOL.
// But you can directly substitute values like "NSE" & "BANKNIFTY_25-JUN-2020_FUT"
/*
* Retrieve positions's trading account.
*/
tradingAccount = getPositionTradingAccount(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's MTM.
*/
mtm = getPositionMtm(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's PNL.
*/
pnl = getPositionPnl(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's buy quantity.
*/
buyQuantity = getPositionBuyQuantity(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's sell quantity.
*/
sellQuantity = getPositionSellQuantity(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's net quantity.
*/
netQuantity = getPositionNetQuantity(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's buy value.
*/
buyValue = getPositionBuyValue(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's sell value.
*/
sellValue = getPositionSellValue(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's net value.
*/
netValue = getPositionNetValue(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's buy average price.
*/
buyAvgPrice = getPositionBuyAvgPrice(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's sell average price.
*/
sellAvgPrice = getPositionSellAvgPrice(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's realised pnl.
*/
realisedPnl = getPositionRealisedPnl(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's unrealised pnl.
*/
unrealisedPnl = getPositionUnrealisedPnl(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's overnight quantity.
*/
overnightQuantity = getPositionOvernightQuantity(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's multiplier.
*/
multiplier = getPositionMultiplier(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's LTP.
*/
ltp = getPositionLtp(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's (platform specific) exchange.
*/
rawExchange = getPositionExchange(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's (platform specific) symbol.
*/
rawSymbol = getPositionSymbol(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's date (DD-MM-YYYY).
*/
day = getPositionDay(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's trading platform.
*/
platform = getPositionPlatform(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's account id as received from trading platform.
*/
accountId = getPositionAccountId(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
/*
* Retrieve positions's stock broker.
*/
stockBroker = getPositionStockBroker(AT_ACCOUNT, category, type,
AT_EXCHANGE, AT_SYMBOL);
Signatures
/*
* Retrieve positions's trading account.
*/
string getPositionTradingAccount(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's MTM (Mtm calculated by your stock broker).
*/
double getPositionMtm(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's PNL (Pnl calculated by your stock broker).
*/
double getPositionPnl(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's AT PNL (Pnl calculated by AutoTrader Web).
*/
double getPositionAtPnl(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's buy quantity.
*/
long getPositionBuyQuantity(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's sell quantity.
*/
long getPositionSellQuantity(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's net quantity.
*/
long getPositionNetQuantity(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's buy value.
*/
double getPositionBuyValue(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's sell value.
*/
double getPositionSellValue(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's net value.
*/
double getPositionNetValue(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's buy average price.
*/
double getPositionBuyAvgPrice(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's sell average price.
*/
double getPositionSellAvgPrice(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's realised pnl.
*/
double getPositionRealisedPnl(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's unrealised pnl.
*/
double getPositionUnrealisedPnl(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's overnight quantity.
*/
long getPositionOvernightQuantity(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's multiplier.
*/
double getPositionMultiplier(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's LTP.
*/
double getPositionLtp(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's (platform specific) exchange.
*/
string getPositionExchange(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's (platform specific) symbol.
*/
string getPositionSymbol(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's date (DD-MM-YYYY).
*/
string getPositionDay(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's trading platform.
*/
string getPositionPlatform(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's account id as received from trading platform.
*/
string getPositionAccountId(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
/*
* Retrieve positions's stock broker.
*/
string getPositionStockBroker(string pseudoAccount,
string category, string type, Exchange independentExchange,
string independentSymbol)
Examples
// Category can be (DAY, NET)
string category = "DAY";
// Type can be (MIS, NRML, CNC, BO, CO)
string type = "MIS";
/*
* Retrieve positions's trading account.
*/
string tradingAccount = getPositionTradingAccount(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's MTM.
*/
double mtm = getPositionMtm(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's PNL.
*/
double pnl = getPositionPnl(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's buy quantity.
*/
long buyQuantity = getPositionBuyQuantity(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's sell quantity.
*/
long sellQuantity = getPositionSellQuantity(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's net quantity.
*/
long netQuantity = getPositionNetQuantity(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's buy value.
*/
double buyValue = getPositionBuyValue(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's sell value.
*/
double sellValue = getPositionSellValue(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's net value.
*/
double netValue = getPositionNetValue(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's buy average price.
*/
double buyAvgPrice = getPositionBuyAvgPrice(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's sell average price.
*/
double sellAvgPrice = getPositionSellAvgPrice(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's realised pnl.
*/
double realisedPnl = getPositionRealisedPnl(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's unrealised pnl.
*/
double unrealisedPnl = getPositionUnrealisedPnl(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's overnight quantity.
*/
long overnightQuantity = getPositionOvernightQuantity(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's multiplier.
*/
double multiplier = getPositionMultiplier(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's LTP.
*/
double ltp = getPositionLtp(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's (platform specific) exchange.
*/
string exchange = getPositionExchange(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's (platform specific) symbol.
*/
string symbol = getPositionSymbol(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's date (DD-MM-YYYY).
*/
string day = getPositionDay(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's trading platform.
*/
string platform = getPositionPlatform(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's account id as received from trading platform.
*/
string accountId = getPositionAccountId(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
/*
* Retrieve positions's stock broker.
*/
string stockBroker = getPositionStockBroker(AT_ACCOUNT,
category, type, NSE,
AT_SYMBOL);
Signature
/**
* Read trading platform positions from the trading
* account mapped to the given pseudo account.
*
* @param pseudoAccount pseudo account id
* @return positions trading platform positions
*/
IOperationResponse<Set<PlatformPosition>>
readPlatformPositions(final String pseudoAccount);
Example
IOperationResponse<Set<PlatformPosition>> response =
this.autotrader.readPlatformPositions("ACC_NAME");
Set<PlatformPosition> positions = null;
if(response.success()) {
// Extract the result
positions = response.getResult();
}
This will retrieve positions from your trading account that is mapped to the passed pseudo account. The function will return a response object.
Response object has a function called success(), which returns true on successful execution.
We can then use the method getResult() to get a set containing positions.
It is recommended to periodically download and cache the positions to avoid hitting the api limit. You can lookup the returned set and find your relevant order.
PlatformPosition class
Here is a look at the public methods of the PlatformPosition class.
/**
* Pseudo account id
*/
String getPseudoAccount();
/**
* Trading account id
*/
String getTradingAccount();
/**
* Stock broker
*/
String getStockBroker();
/**
* Broker specific exchange
*/
String getExchange();
/**
* Broker specific symbol
*/
String getSymbol();
/**
* Broker independent exchange
*/
String getIndependentExchange();
/**
* Broker independent symbol
*/
String getIndependentSymbol();
/**
* Buy quantity
*/
Integer getBuyQuantity();
/**
* Sell quantity
*/
Integer getSellQuantity();
/**
* Net quantity
*/
Integer getNetQuantity();
/**
* Position type {@link com.dakshata.constants.trading.PositionType}
*/
PositionType getType();
/**
* Net returns on the position
*/
Float getPnl();
/**
* Mark to market returns (computed based on the last close and the last traded
* price)
*/
Float getMtm();
/**
* Total value of the bought quantities
*/
Float getBuyValue();
/**
* Total value of the sold quantities
*/
Float getSellValue();
/**
* Net value
*/
Float getNetValue();
/**
* Average price at which quantities were bought
*/
Float getBuyAvgPrice();
/**
* Average price at which quantities were sold
*/
Float getSellAvgPrice();
/**
* Day
*/
LocalDate getDay();
/**
* Some platforms return multiple sets of positions. For example, see below
* response format from Zerodha:<br>
* <br>
* The positions API returns two sets of positions, net and day. net is the
* actual, current net position portfolio, while day is a snapshot of the buying
* and selling activity for that particular day.
*/
String getCategory();
/**
* Raw trading account id
*/
String getAccountId();
/**
* LTP isn't really a part of position, but many platforms return it inside
* position object.
*/
Float getLtp();
/**
* Represents the trading platform to which this position belongs.
*/
TradingPlatform getPlatform();
/**
* Quantity held previously and carried forward over night
*
*/
Integer getOvernightQuantity();
/**
* The quantity/lot size multiplier used for calculating P&Ls
*/
Integer getMultiplier();
/**
* Realised intraday returns
*/
Float getRealisedPnl();
/**
* Unrealised intraday returns
*/
Float getUnrealisedPnl();
/**
* Pnl calculated by AutoTrader Web.
*/
Float getAtPnl();
/**
* Position direction (LONG, SHORT, NEUTRAL).
*/
PositionDirection getDirection();
Signature
/// <summary>
/// Read trading platform positions from the trading account mapped to the given
/// pseudo account.
/// </summary>
/// <param name="pseudoAccount"> pseudo account id </param>
/// <returns> positions trading platform positions </returns>
IOperationResponse<ISet<PlatformPosition>> ReadPlatformPositions(
string pseudoAccount);
Example
IOperationResponse<ISet<PlatformPosition>> response =
autoTrader.ReadPlatformPositions("XX1234");
foreach (PlatformPosition p in response.Result)
Console.WriteLine("{0}", p);
This will retrieve positions from your trading account that is mapped to the passed pseudo account. The function will return a response object.
Response object has a function called Success(), which returns true on successful execution.
We can then use it’s Result property to get a set containing positions.
It is recommended to periodically download and cache the positions to avoid hitting the api limit. You can lookup the returned set and find your relevant order.
PlatformPosition
Here is a look at the public methods of PlatformPosition model class:
string PseudoAccount { get; }
string TradingAccount { get; }
string StockBroker { get; }
string Exchange { get; }
string Symbol { get; }
string IndependentExchange { get; }
string IndependentSymbol { get; }
int? BuyQuantity { get; }
int? SellQuantity { get; }
int? NetQuantity { get; }
PositionType Type { get; }
float? Pnl { get; }
float? AtPnl { get; }
float? Mtm { get; }
float? BuyValue { get; }
float? SellValue { get; }
float? NetValue { get; }
float? BuyAvgPrice { get; }
float? SellAvgPrice { get; }
string Category { get; }
string AccountId { get; }
float? Ltp { get; }
TradingPlatform Platform { get; }
int? OvernightQuantity { get; }
int? Multiplier { get; }
float? RealisedPnl { get; }
float? UnrealisedPnl { get; }
Signature
def read_platform_positions(self, pseudo_account):
Example
response = autotrader.read_platform_positions('XX1234')
if response.success():
# Result will be a list of objects of type
# com.dakshata.trading.model.platform.PlatformPosition
for o in response.result:
pretty = "[Category: {}, Type: {}, Pseudo acc.: {}, Trading acc.: {}, " + \
"Ind. exch: {}, Ind. symbol: {}, Pnl: {}, Mtm: {}, Net qty.: {}, " + \
"Buy qty.: {}, Sell qty.: {}, Net value: {}, Buy value: {}, Sell value: {}, " + \
"Buy avg. price: {}, Sell avg. price: {}, Realised pnl: {}, " + \
"Unrealised pnl: {}, Broker: {}, Platform: {}]"
print(pretty.format(o.category, o.type, o.pseudo_account, o.trading_account,
o.independent_exchange, o.independent_symbol, o.pnl, o.mtm, o.net_quantity,
o.buy_quantity, o.sell_quantity, o.net_value, o.buy_value, o.sell_value,
o.buy_avg_price, o.sell_avg_price, o.realised_pnl, o.unrealised_pnl,
o.stock_broker, o.platform))
print("\n----------------------------------------------------------------------\n")
else:
print("Message: {0}".format(response.message))
Note: Our libraries use object oriented programming in Python. The response.result
object from above function will be a list of objects of class PlatformPosition
. You can then iterate or loop over the list & read each object’s properties via object.property
notation. You can find all available properties in PlatformPosition.py which is a derived from Position.py.
It is recommended to periodically download and cache the orders to avoid hitting the api limit. You can lookup the returned set and find your relevant order.
Example
curl https://api.stocksdeveloper.in/trading/readPlatformPositions \
-H "api-key: <your_api_key>" \
-d "pseudoAccount=ACC_NAME"
Response
{
"result":[
{
"id":null,
"instrument":null,
"buyQuantity":1,
"sellQuantity":1,
"netQuantity":0,
"type":"MIS",
"pnl":0.0,
"atPnl":0.0,
"mtm":0.0,
"buyValue":185.35,
"sellValue":185.35,
"netValue":0.0,
"buyAvgPrice":185.35,
"sellAvgPrice":185.35,
"account":null,
"day":[
2020,
7,
2
],
"pseudoAccount":"XX9999",
"tradingAccount":"XX9999",
"stockBroker":"Zerodha",
"exchange":"NSE",
"symbol":"SBIN",
"independentExchange":"NSE",
"independentSymbol":"SBIN",
"version":null,
"category":"DAY",
"ltp":185.45,
"platform":"KITE",
"accountId":"XX9999",
"overnightQuantity":0,
"multiplier":1,
"realisedPnl":0.0,
"unrealisedPnl":0.0
},
{
"id":null,
"instrument":null,
"buyQuantity":1,
"sellQuantity":1,
"netQuantity":0,
"type":"MIS",
"pnl":-0.05,
"atPnl":-0.05,
"mtm":-0.05,
"buyValue":225.05,
"sellValue":225.0,
"netValue":-0.05,
"buyAvgPrice":225.05,
"sellAvgPrice":225.0,
"account":null,
"day":[
2020,
7,
2
],
"pseudoAccount":"XX9999",
"tradingAccount":"XX9999",
"stockBroker":"Zerodha",
"exchange":"NSE",
"symbol":"WIPRO",
"independentExchange":"NSE",
"independentSymbol":"WIPRO",
"version":null,
"category":"DAY",
"ltp":224.2,
"platform":"KITE",
"accountId":"XX9999",
"overnightQuantity":0,
"multiplier":1,
"realisedPnl":0.0,
"unrealisedPnl":-0.05
},
{
"id":null,
"instrument":null,
"buyQuantity":1,
"sellQuantity":1,
"netQuantity":0,
"type":"MIS",
"pnl":0.0,
"mtm":0.0,
"buyValue":185.35,
"sellValue":185.35,
"netValue":0.0,
"buyAvgPrice":185.35,
"sellAvgPrice":185.35,
"account":null,
"day":[
2020,
7,
2
],
"pseudoAccount":"XX9999",
"tradingAccount":"XX9999",
"stockBroker":"Zerodha",
"exchange":"NSE",
"symbol":"SBIN",
"independentExchange":"NSE",
"independentSymbol":"SBIN",
"version":null,
"category":"NET",
"ltp":185.45,
"platform":"KITE",
"accountId":"XX9999",
"overnightQuantity":0,
"multiplier":1,
"realisedPnl":0.0,
"unrealisedPnl":0.0
},
{
"id":null,
"instrument":null,
"buyQuantity":1,
"sellQuantity":1,
"netQuantity":0,
"type":"MIS",
"pnl":-0.05,
"mtm":-0.05,
"buyValue":225.05,
"sellValue":225.0,
"netValue":-0.05,
"buyAvgPrice":225.05,
"sellAvgPrice":225.0,
"account":null,
"day":[
2020,
7,
2
],
"pseudoAccount":"XX9999",
"tradingAccount":"XX9999",
"stockBroker":"Zerodha",
"exchange":"NSE",
"symbol":"WIPRO",
"independentExchange":"NSE",
"independentSymbol":"WIPRO",
"version":null,
"category":"NET",
"ltp":224.2,
"platform":"KITE",
"accountId":"XX9999",
"overnightQuantity":0,
"multiplier":1,
"realisedPnl":0.0,
"unrealisedPnl":-0.05
}
],
"message":null,
"status":true,
"commandId":"099c75ff-6987-4d8a-b42b-5627338a94ae"
}
The response contains result (which is an array of positions in json format sourced from your trading platform).
If there is any error, then you will get status as false & message will have error text.
It is recommended to periodically download and cache the positions to avoid hitting the api limit.
Signatures
' Retrieve positions's trading account.
Public Function GetPositionTradingAccount(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As String
' Retrieve positions's MTM.
Public Function GetPositionMtm(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's PNL.
Public Function GetPositionPnl(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's buy quantity.
Public Function GetPositionBuyQuantity(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Long
' Retrieve positions's sell quantity.
Public Function GetPositionSellQuantity(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Long
' Retrieve positions's net quantity.
Public Function GetPositionNetQuantity(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Long
' Retrieve positions's buy value.
Public Function GetPositionBuyValue(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's sell value.
Public Function GetPositionSellValue(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's net value.
Public Function GetPositionNetValue(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's buy average price.
Public Function GetPositionBuyAvgPrice(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's sell average price.
Public Function GetPositionSellAvgPrice(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's realised pnl.
Public Function GetPositionRealisedPnl(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's unrealised pnl.
Public Function GetPositionUnrealisedPnl(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's overnight quantity.
Public Function GetPositionOvernightQuantity(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Long
' Retrieve positions's multiplier.
Public Function GetPositionMultiplier(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Long
' Retrieve positions's LTP.
Public Function GetPositionLtp(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As Double
' Retrieve positions's (platform specific) exchange.
Public Function GetPositionExchange(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As String
' Retrieve positions's (platform specific) symbol.
Public Function GetPositionSymbol(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As String
' Retrieve positions's date (DD-MM-YYYY).
Public Function GetPositionDay(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As String
' Retrieve positions's trading platform.
Public Function GetPositionPlatform(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As String
' Retrieve positions's account id as received from trading platform.
Public Function GetPositionAccountId(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As String
' Retrieve positions's stock broker.
Public Function GetPositionStockBroker(pseudoAccount As String, _
category As String, posType As String, independentExchange As String, _
independentSymbol As String) As String
Postman is widely used tool for API testing. We have provided below a collection of all of our APIs in postman collection format. Click postman collection to know more about how to use it.
Notes
M2M and PnL data is not available from certain brokers (see limitations). Hence, the values you see are calculated by our system. If you see any issues, then please notify us.