API function to read orders from your trading platform. APIs are available in AmiBroker, MetaTrader, Excel, Java, C#, Python, HTTP REST.
Api function will read orders from Supports leading Indian Stock Brokers.
Signatures
/*
* Retrieve order's trading account.
*/
function getOrderTradingAccount(pseudoAccount, orderId)
/*
* Retrieve order's trading platform id.
*/
function getOrderId(pseudoAccount, orderId)
/*
* Retrieve order's exchange id.
*/
function getOrderExchangeId(pseudoAccount, orderId)
/*
* Retrieve order's variety (REGULAR, BO, CO).
*/
function getOrderVariety(pseudoAccount, orderId)
/*
* Retrieve order's (broker independent) exchange.
*/
function getOrderIndependentExchange(pseudoAccount, orderId)
/*
* Retrieve order's (broker independent) symbol.
*/
function getOrderIndependentSymbol(pseudoAccount, orderId)
/*
* Retrieve order's trade type (BUY, SELL).
*/
function getOrderTradeType(pseudoAccount, orderId)
/*
* Retrieve order's order type (LIMIT, MARKET, STOP_LOSS, SL_MARKET).
*/
function getOrderOrderType(pseudoAccount, orderId)
/*
* Retrieve order's product type (INTRADAY, DELIVERY, NORMAL).
*/
function getOrderProductType(pseudoAccount, orderId)
/*
* Retrieve order's quantity.
*/
function getOrderQuantity(pseudoAccount, orderId)
/*
* Retrieve order's price.
*/
function getOrderPrice(pseudoAccount, orderId)
/*
* Retrieve order's trigger price.
*/
function getOrderTriggerPrice(pseudoAccount, orderId)
/*
* Retrieve order's filled quantity.
*/
function getOrderFilledQuantity(pseudoAccount, orderId)
/*
* Retrieve order's pending quantity.
*/
function getOrderPendingQuantity(pseudoAccount, orderId)
/*
* Retrieve order's (broker independent) status.
* (OPEN, COMPLETE, CANCELLED, REJECTED, TRIGGER_PENDING, UNKNOWN)
*/
function getOrderStatus(pseudoAccount, orderId)
/*
* Retrieve order's status message or rejection reason.
*/
function getOrderStatusMessage(pseudoAccount, orderId)
/*
* Retrieve order's validity (DAY, IOC).
*/
function getOrderValidity(pseudoAccount, orderId)
/*
* Retrieve order's average price at which it got traded.
*/
function getOrderAveragePrice(pseudoAccount, orderId)
/*
* Retrieve order's parent order id. The id of parent bracket or cover order.
*/
function getOrderParentOrderId(pseudoAccount, orderId)
/*
* Retrieve order's disclosed quantity.
*/
function getOrderDisclosedQuantity(pseudoAccount, orderId)
/*
* Retrieve order's exchange time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
*/
function getOrderExchangeTime(pseudoAccount, orderId)
/*
* Retrieve order's platform time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
*/
function getOrderPlatformTime(pseudoAccount, orderId)
/*
* Retrieve order's AMO (after market order) flag. (True/False)
*/
function getOrderAmo(pseudoAccount, orderId)
/*
* Retrieve order's comments.
*/
function getOrderComments(pseudoAccount, orderId)
/*
* Retrieve order's raw (platform specific) status.
*/
function getOrderRawStatus(pseudoAccount, orderId)
/*
* Retrieve order's (platform specific) exchange.
*/
function getOrderExchange(pseudoAccount, orderId)
/*
* Retrieve order's (platform specific) symbol.
*/
function getOrderSymbol(pseudoAccount, orderId)
/*
* Retrieve order's date (DD-MM-YYYY).
*/
function getOrderDay(pseudoAccount, orderId)
/*
* Retrieve order's trading platform.
*/
function getOrderPlatform(pseudoAccount, orderId)
/*
* Retrieve order's client id (as received from trading platform).
*/
function getOrderClientId(pseudoAccount, orderId)
/*
* Retrieve order's stock broker.
*/
function getOrderStockBroker(pseudoAccount, orderId)
/*
* Checks whether order is open.
* orderId - should be the id returned by placeOrder
* function when you place an order.
*/
function isOrderOpen(pseudoAccount, orderId)
/*
* Checks whether order is complete.
* orderId - should be the id returned by placeOrder
* function when you place an order.
*/
function isOrderComplete(pseudoAccount, orderId)
/*
* Checks whether order is rejected.
* id - should be the id returned by placeOrder
* function when you place an order.
*/
function isOrderRejected(pseudoAccount, orderId)
/*
* Checks whether order is cancelled.
* id - should be the id returned by placeOrder
* function when you place an order.
*/
function isOrderCancelled(pseudoAccount, orderId)
Examples
orderId = placeOrder(AT_ACCOUNT,
AT_EXCHANGE, AT_SYMBOL, "BUY",
"LIMIT", AT_PRODUCT_TYPE, AT_QUANTITY,
buyPrice, defaultTriggerPrice(), True);
// You can save this orderId in a static variable
saveStaticVariableText(AT_ACCOUNT, "ORDER_ID", orderId);
// Somewhere later in your code,
// when you want to read order details
// Read orderId from static variable
orderId = readStaticVariableText(AT_ACCOUNT, "ORDER_ID");
/*
* Retrieve order's trading account.
*/
tradingAccount = getOrderTradingAccount(AT_ACCOUNT, orderId);
/*
* Retrieve order's trading platform id.
*/
platformId = getOrderId(AT_ACCOUNT, orderId);
/*
* Retrieve order's exchange id.
*/
exchangeId = getOrderExchangeId(AT_ACCOUNT, orderId);
/*
* Retrieve order's variety (REGULAR, BO, CO).
*/
variety = getOrderVariety(AT_ACCOUNT, orderId);
/*
* Retrieve order's (broker independent) exchange.
*/
indExchange = getOrderIndependentExchange(AT_ACCOUNT, orderId);
/*
* Retrieve order's (broker independent) symbol.
*/
indSymbol = getOrderIndependentSymbol(AT_ACCOUNT, orderId);
/*
* Retrieve order's trade type (BUY, SELL).
*/
tradeType = getOrderTradeType(AT_ACCOUNT, orderId);
/*
* Retrieve order's order type (LIMIT, MARKET, STOP_LOSS, SL_MARKET).
*/
orderType = getOrderOrderType(AT_ACCOUNT, orderId);
/*
* Retrieve order's product type (INTRADAY, DELIVERY, NORMAL).
*/
productType = getOrderProductType(AT_ACCOUNT, orderId);
/*
* Retrieve order's quantity.
*/
quantity = getOrderQuantity(AT_ACCOUNT, orderId);
/*
* Retrieve order's price.
*/
price = getOrderPrice(AT_ACCOUNT, orderId);
/*
* Retrieve order's trigger price.
*/
triggerPrice = getOrderTriggerPrice(AT_ACCOUNT, orderId);
/*
* Retrieve order's filled quantity.
*/
filledQuantity = getOrderFilledQuantity(AT_ACCOUNT, orderId);
/*
* Retrieve order's pending quantity.
*/
pendingQuantity = getOrderPendingQuantity(AT_ACCOUNT, orderId);
/*
* Retrieve order's (broker independent) status.
* (OPEN, COMPLETE, CANCELLED, REJECTED, TRIGGER_PENDING, UNKNOWN)
*/
indStatus = getOrderStatus(AT_ACCOUNT, orderId);
/*
* Retrieve order's status message or rejection reason.
*/
statusMessage = getOrderStatusMessage(AT_ACCOUNT, orderId);
/*
* Retrieve order's validity (DAY, IOC).
*/
validity = getOrderValidity(AT_ACCOUNT, orderId);
/*
* Retrieve order's average price at which it got traded.
*/
averagePrice = getOrderAveragePrice(AT_ACCOUNT, orderId);
/*
* Retrieve order's parent order id. The id of parent bracket or cover order.
*/
parentOrderId = getOrderParentOrderId(AT_ACCOUNT, orderId);
/*
* Retrieve order's disclosed quantity.
*/
disclosedQuantity = getOrderDisclosedQuantity(AT_ACCOUNT, orderId);
/*
* Retrieve order's exchange time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
*/
exchangeTime = getOrderExchangeTime(AT_ACCOUNT, orderId);
/*
* Retrieve order's platform time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
*/
platformTime = getOrderPlatformTime(AT_ACCOUNT, orderId);
/*
* Retrieve order's AMO (after market order) flag. (True/False)
*/
amo = getOrderAmo(AT_ACCOUNT, orderId);
/*
* Retrieve order's comments.
*/
comments = getOrderComments(AT_ACCOUNT, orderId);
/*
* Retrieve order's raw (platform specific) status.
*/
rawStatus = getOrderRawStatus(AT_ACCOUNT, orderId);
/*
* Retrieve order's (platform specific) exchange.
*/
rawExchange = getOrderExchange(AT_ACCOUNT, orderId);
/*
* Retrieve order's (platform specific) symbol.
*/
rawSymbol = getOrderSymbol(AT_ACCOUNT, orderId);
/*
* Retrieve order's date (DD-MM-YYYY).
*/
day = getOrderDay(AT_ACCOUNT, orderId);
/*
* Retrieve order's trading platform.
*/
platform = getOrderPlatform(AT_ACCOUNT, orderId);
/*
* Retrieve order's client id (as received from trading platform).
*/
clientAccountId = getOrderClientId(AT_ACCOUNT, orderId);
/*
* Retrieve order's stock broker.
*/
stockBroker = getOrderStockBroker(AT_ACCOUNT, orderId);
Signatures
/*
* Retrieve order's trading account.
*/
string getOrderTradingAccount(string pseudoAccount, string orderId)
/*
* Retrieve order's trading platform id.
*/
string getOrderId(string pseudoAccount, string orderId)
/*
* Retrieve order's exchange id.
*/
string getOrderExchangeId(string pseudoAccount, string orderId)
/*
* Retrieve order's variety (REGULAR, BO, CO).
*/
Variety getOrderVariety(string pseudoAccount, string orderId)
/*
* Retrieve order's (platform independent) exchange.
*/
Exchange getOrderIndependentExchange(string pseudoAccount, string orderId)
/*
* Retrieve order's (platform independent) symbol.
*/
string getOrderIndependentSymbol(string pseudoAccount, string orderId)
/*
* Retrieve order's trade type (BUY, SELL).
*/
TradeType getOrderTradeType(string pseudoAccount, string orderId)
/*
* Retrieve order's order type (LIMIT, MARKET, STOP_LOSS, SL_MARKET).
*/
OrderType getOrderOrderType(string pseudoAccount, string orderId)
/*
* Retrieve order's product type (INTRADAY, DELIVERY, NORMAL).
*/
ProductType getOrderProductType(string pseudoAccount, string orderId)
/*
* Retrieve order's quantity.
*/
long getOrderQuantity(string pseudoAccount, string orderId)
/*
* Retrieve order's price.
*/
double getOrderPrice(string pseudoAccount, string orderId)
/*
* Retrieve order's trigger price.
*/
double getOrderTriggerPrice(string pseudoAccount, string orderId)
/*
* Retrieve order's filled quantity.
*/
long getOrderFilledQuantity(string pseudoAccount, string orderId)
/*
* Retrieve order's pending quantity.
*/
long getOrderPendingQuantity(string pseudoAccount, string orderId)
/*
* Retrieve order's (platform independent) status.
* (OPEN, COMPLETE, CANCELLED, REJECTED, TRIGGER_PENDING, UNKNOWN)
*/
string getOrderStatus(string pseudoAccount, string orderId)
/*
* Retrieve order's status message or rejection reason.
*/
string getOrderStatusMessage(string pseudoAccount, string orderId)
/*
* Retrieve order's validity (DAY, IOC).
*/
Validity getOrderValidity(string pseudoAccount, string orderId)
/*
* Retrieve order's average price at which it got traded.
*/
double getOrderAveragePrice(string pseudoAccount, string orderId)
/*
* Retrieve order's parent order id. The id of parent bracket or cover order.
*/
string getOrderParentOrderId(string pseudoAccount, string orderId)
/*
* Retrieve order's disclosed quantity.
*/
long getOrderDisclosedQuantity(string pseudoAccount, string orderId)
/*
* Retrieve order's exchange time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
*/
string getOrderExchangeTime(string pseudoAccount, string orderId)
/*
* Retrieve order's platform time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
*/
string getOrderPlatformTime(string pseudoAccount, string orderId)
/*
* Retrieve order's AMO (after market order) flag. (true/false)
*/
bool getOrderAmo(string pseudoAccount, string orderId)
/*
* Retrieve order's comments.
*/
string getOrderComments(string pseudoAccount, string orderId)
/*
* Retrieve order's raw (platform specific) status.
*/
string getOrderRawStatus(string pseudoAccount, string orderId)
/*
* Retrieve order's (platform specific) exchange.
*/
string getOrderExchange(string pseudoAccount, string orderId)
/*
* Retrieve order's (platform specific) symbol.
*/
string getOrderSymbol(string pseudoAccount, string orderId)
/*
* Retrieve order's date (DD-MM-YYYY).
*/
string getOrderDay(string pseudoAccount, string orderId)
/*
* Retrieve order's trading platform.
*/
string getOrderPlatform(string pseudoAccount, string orderId)
/*
* Retrieve order's client id (as received from trading platform).
*/
string getOrderClientId(string pseudoAccount, string orderId)
/*
* Retrieve order's stock broker.
*/
string getOrderStockBroker(string pseudoAccount, string orderId)
/*
* Checks whether order is open.
* orderId - should be the id returned by placeOrder
* function when you place an order.
*/
bool isOrderOpen(string pseudoAccount, string orderId)
/*
* Checks whether order is complete.
* orderId - should be the id returned by placeOrder
* function when you place an order.
*/
bool isOrderComplete(string pseudoAccount, string orderId)
/*
* Checks whether order is rejected.
* orderId - should be the id returned by placeOrder
* function when you place an order.
*/
bool isOrderRejected(string pseudoAccount, string orderId)
/*
* Checks whether order is cancelled.
* orderId - should be the id returned by placeOrder
* function when you place an order.
*/
bool isOrderCancelled(string pseudoAccount, string orderId)
Examples
orderId = placeOrder("ACC_NAME", "NSE",
"BANKNIFTY_25-JUN-2020_FUT",
"BUY", "MARKET", "INTRADAY", 75,
buyPrice, defaultTriggerPrice(), True);
// You can save the order id in a static variable
/*
* Retrieve order's trading account.
*/
string tradingAccount = getOrderTradingAccount(AT_ACCOUNT, orderId);
/*
* Retrieve order's trading platform id.
*/
string orderId = getOrderId(AT_ACCOUNT, orderId);
/*
* Retrieve order's exchange id.
*/
string exchangeId = getOrderExchangeId(AT_ACCOUNT, orderId);
/*
* Retrieve order's variety (REGULAR, BO, CO).
*/
Variety variety = getOrderVariety(AT_ACCOUNT, orderId);
/*
* Retrieve order's (platform independent) exchange.
*/
Exchange exchange = getOrderIndependentExchange(AT_ACCOUNT, orderId);
/*
* Retrieve order's (platform independent) symbol.
*/
string indSymbol = getOrderIndependentSymbol(AT_ACCOUNT, orderId);
/*
* Retrieve order's trade type (BUY, SELL).
*/
TradeType tradeType = getOrderTradeType(AT_ACCOUNT, orderId);
/*
* Retrieve order's order type (LIMIT, MARKET, STOP_LOSS, SL_MARKET).
*/
OrderType orderType = getOrderOrderType(AT_ACCOUNT, orderId);
/*
* Retrieve order's product type (INTRADAY, DELIVERY, NORMAL).
*/
ProductType productType = getOrderProductType(AT_ACCOUNT, orderId);
/*
* Retrieve order's quantity.
*/
long quantity = getOrderQuantity(AT_ACCOUNT, orderId);
/*
* Retrieve order's price.
*/
double price = getOrderPrice(AT_ACCOUNT, orderId);
/*
* Retrieve order's trigger price.
*/
double triggerPrice = getOrderTriggerPrice(AT_ACCOUNT, orderId);
/*
* Retrieve order's filled quantity.
*/
long filledQuantity = getOrderFilledQuantity(AT_ACCOUNT, orderId);
/*
* Retrieve order's pending quantity.
*/
long pendingQuantity = getOrderPendingQuantity(AT_ACCOUNT, orderId);
/*
* Retrieve order's (platform independent) status.
* (OPEN, COMPLETE, CANCELLED, REJECTED, TRIGGER_PENDING, UNKNOWN)
*/
string status = getOrderStatus(AT_ACCOUNT, orderId);
/*
* Retrieve order's status message or rejection reason.
*/
string statusMessage = getOrderStatusMessage(AT_ACCOUNT, orderId);
/*
* Retrieve order's validity (DAY, IOC).
*/
Validity validity = getOrderValidity(AT_ACCOUNT, orderId);
/*
* Retrieve order's average price at which it got traded.
*/
double averagePrice = getOrderAveragePrice(AT_ACCOUNT, orderId);
/*
* Retrieve order's parent order id. The id of parent bracket or cover order.
*/
string parentOrderId = getOrderParentOrderId(AT_ACCOUNT, orderId);
/*
* Retrieve order's disclosed quantity.
*/
long disclosedQuantity = getOrderDisclosedQuantity(AT_ACCOUNT, orderId);
/*
* Retrieve order's exchange time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
*/
string exchangeTime = getOrderExchangeTime(AT_ACCOUNT, orderId);
/*
* Retrieve order's platform time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
*/
string platformTime = getOrderPlatformTime(AT_ACCOUNT, orderId);
/*
* Retrieve order's AMO (after market order) flag. (true/false)
*/
bool amo = getOrderAmo(AT_ACCOUNT, orderId);
/*
* Retrieve order's comments.
*/
string comments = getOrderComments(AT_ACCOUNT, orderId);
/*
* Retrieve order's raw (platform specific) status.
*/
string rawStatus = getOrderRawStatus(AT_ACCOUNT, orderId);
/*
* Retrieve order's (platform specific) exchange.
*/
string exchange = getOrderExchange(AT_ACCOUNT, orderId);
/*
* Retrieve order's (platform specific) symbol.
*/
string symbol = getOrderSymbol(AT_ACCOUNT, orderId);
/*
* Retrieve order's date (DD-MM-YYYY).
*/
string day = getOrderDay(AT_ACCOUNT, orderId);
/*
* Retrieve order's trading platform.
*/
string platform = getOrderPlatform(AT_ACCOUNT, orderId);
/*
* Retrieve order's client id (as received from trading platform).
*/
string clientId = getOrderClientId(AT_ACCOUNT, orderId);
/*
* Retrieve order's stock broker.
*/
string stockBroker = getOrderStockBroker(AT_ACCOUNT, orderId);
Signature
/**
* Read trading platform orders from the
* trading account mapped to the given
* pseudo account.
*
* @param pseudoAccount pseudo account id
* @return orders trading platform orders
*/
IOperationResponse<Set<PlatformOrder>>
readPlatformOrders(final String pseudoAccount);
Example
IOperationResponse<Set<PlatformOrder>> response =
this.autotrader.readPlatformOrders("ACC_NAME");
Set<PlatformOrder> orders = null;
if(response.success()) {
// Extract the result
orders = response.getResult();
}
This will retrieve orders 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 orders.
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.
PlatformOrder
Here is a look at the public methods of the PlatformOrder class.
/**
* Pseudo account id
*/
String getPseudoAccount();
/**
* Trading account id
*/
String getTradingAccount();
/**
* Stock broker
*/
String getStockBroker();
/**
* Order id given by your trading platform
*/
String getId();
/**
* Broker specific exchange
*/
String getExchange();
/**
* Broker specific symbol
*/
String getSymbol();
/**
* Broker independent exchange
*/
String getIndependentExchange();
/**
* Broker independent symbol
*/
String getIndependentSymbol();
/**
* Trade type {@link com.dakshata.constants.trading.TradeType}
*/
TradeType getTradeType();
/**
* Order type {@link com.dakshata.constants.trading.OrderType}
*/
OrderType getOrderType();
/**
* Product type {@link com.dakshata.constants.trading.ProductType}
*/
ProductType getProductType();
/**
* Variety {@link com.dakshata.constants.trading.Variety}
*/
Variety getVariety();
/**
* Validity {@link com.dakshata.constants.trading.Validity}
*/
Validity getValidity();
/**
* Quantity
*/
Integer getQuantity();
/**
* Disclosed quantity
*/
Integer getDisclosedQuantity();
/**
* Order price (the one which is entered while placing an order)
*/
Float getPrice();
/**
* Trigger price
*/
Float getTriggerPrice();
/**
* Comments
*/
String getComments();
/**
* A flag that indicates whether the order is an After Market Order
*/
Boolean getAmo();
/**
* Status message or rejection reason
*/
String getStatusMessage();
/**
* Modified time
*/
Timestamp getModifiedTime();
/**
* Created time
*/
Timestamp getCreatedTime();
/**
* Day
*/
LocalDate getDay();
/**
* Publisher id (id given by amibroker, metatrader, excel etc.
*
* @see <a href=
* "https://stocksdeveloper.in/documentation/api/api-parameters#order-id">Publisher
* Id</a>
*/
String getPublisherId();
/**
* Parent order id. This is only present for child orders, which are placed by
* stock broker when a bracket order executes.
*/
String getParentOrderId();
/**
* Exchange order id
*/
String getExchangeOrderId();
/**
* Order status (broker independent)
*/
OrderStatus getStatus();
/**
* Order status (as returned by stock broker)
*/
String getRawStatus();
/**
* Order timestamp given by trading platform
*/
Timestamp getPlatformTime();
/**
* Order timestamp given by exchange
*/
Timestamp getExchangeTime();
/**
* Pending quantity
*/
Integer getPendingQuantity();
/**
* Filled quantity
*/
Integer getFilledQuantity();
/**
* Order average price (the average price at which order was traded)
*/
Float getAveragePrice();
/**
* Trading platform
*/
TradingPlatform getPlatform();
/**
* Account (client) id (as returned by broker)
*/
String getClientId();
/**
* Returns true if order is open
*/
boolean isOpen();
/**
* Returns true if order is trigger pending
*/
boolean isTriggerPending();
/**
* Returns true if order is cancelled
*/
boolean isCancelled();
/**
* Returns true if order is rejected
*/
boolean isRejected();
Signature
/// <summary>
/// Read trading platform orders from the trading account mapped to the given
/// pseudo account.
/// </summary>
/// <param name="pseudoAccount"> pseudo account id </param>
/// <returns> orders trading platform orders </returns>
IOperationResponse<ISet<PlatformOrder>> ReadPlatformOrders(
string pseudoAccount);
Example
IOperationResponse<ISet<PlatformOrder>> response =
autoTrader.ReadPlatformOrders("XX1234");
foreach (PlatformOrder p in response.Result)
Console.WriteLine("{0}", p);
This will retrieve orders 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 orders.
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.
PlatformOrder
Here is a look at the public methods of PlatformOrder model class:
string PseudoAccount { get; }
string TradingAccount { get; }
string StockBroker { get; }
/// <summary>
/// For platform orders, it is the order id given by your trading platform.<br>
/// For system orders, it is a unique GUID given by AutoTrader Web.
/// </summary>
string Id { get; }
/// <summary>
/// Broker specific exchange
/// </summary>
string Exchange { get; }
/// <summary>
/// Broker specific symbol
/// </summary>
string Symbol { get; }
/// <summary>
/// Broker independent exchange
/// </summary>
string IndependentExchange { get; }
/// <summary>
/// Broker independent symbol
/// </summary>
string IndependentSymbol { get; }
/// <summary>
/// Trade type <seealso cref="com.dakshata.constants.trading.TradeType"/>
/// </summary>
TradeType TradeType { get; }
/// <summary>
/// Order type <seealso cref="com.dakshata.constants.trading.OrderType"/>
/// </summary>
OrderType OrderType { get; }
/// <summary>
/// Product type <seealso cref="com.dakshata.constants.trading.ProductType"/>
/// </summary>
ProductType ProductType { get; }
/// <summary>
/// Variety <seealso cref="com.dakshata.constants.trading.Variety"/>
/// </summary>
Variety Variety { get; }
/// <summary>
/// Validity <seealso cref="com.dakshata.constants.trading.Validity"/>
/// </summary>
Validity Validity { get; }
/// <summary>
/// Quantity
/// </summary>
int? Quantity { get; }
/// <summary>
/// Disclosed quantity
/// </summary>
int? DisclosedQuantity { get; }
/// <summary>
/// Order price (the one which is entered while placing an order)
/// </summary>
float? Price { get; }
/// <summary>
/// Trigger price
/// </summary>
float? TriggerPrice { get; }
/// <summary>
/// Comments
/// </summary>
string Comments { get; }
/// <summary>
/// A flag that indicates whether the order is an After Market Order
/// </summary>
bool? Amo { get; }
/// <summary>
/// Status message or rejection reason
/// </summary>
string StatusMessage { get; }
/// <summary>
/// Modified time
/// </summary>
long? ModifiedTime { get; }
/// <summary>
/// Created time
/// </summary>
long? CreatedTime { get; }
string ParentOrderId { get; }
string ExchangeOrderId { get; }
string RawStatus { get; }
long? PlatformTime { get; }
long? ExchangeTime { get; }
int? PendingQuantity { get; }
int? FilledQuantity { get; }
float? AveragePrice { get; }
TradingPlatform Platform { get; }
string ClientId { get; }
OrderStatus Status { get; }
string NestRequestId { get; }
bool IsOpen();
bool IsTriggerPending();
bool IsCancelled();
bool IsRejected();
bool IsOpenOrTriggerPending();
Signature
def read_platform_orders(self, pseudo_account):
Example
response = autotrader.read_platform_orders('XX1234')
if response.success():
# Result will be a list of objects of type
# com.dakshata.trading.model.platform.PlatformOrder
for o in response.result:
pretty = "[Pseudo acc.: {}, Trading acc.: {}, Ind. exch: {}, Ind. symbol: {}, " + \
"Id: {}, Variety: {}, Trade type: {}, Order type: {}, Product type: {}, " + \
"Quantity: {}, Price: {}, Trigger price: {}, Status: {}, Pending qty.: {}, " + \
"Filled qty.: {}, Broker: {}, Platform: {}]"
print(pretty.format(o.pseudo_account, o.trading_account, o.independent_exchange,
o.independent_symbol, o.id, o.variety, o.trade_type, o.order_type, o.product_type,
o.quantity, o.price, o.trigger_price, o.status, o.pending_quantity, o.filled_quantity,
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 PlatformOrder
. 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 PlatformOrder.py which is a derived from CoreOrder.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/readPlatformOrders \
-H "api-key: <your_api_key>" \
-d "pseudoAccount=ACC_NAME"
Response
{
"result":[
{
"id":"200702202385337",
"instrument":null,
"independentInstrument":null,
"tradeType":"SELL",
"orderType":"MARKET",
"productType":"INTRADAY",
"variety":"REGULAR",
"validity":"DAY",
"quantity":1,
"disclosedQuantity":0,
"price":0.0,
"triggerPrice":0.0,
"comments":"01XbtQwPsUSTYGA",
"modifiedTime":1593710627248,
"createdTime":1593710627248,
"account":null,
"amo":false,
"version":null,
"statusMessage":null,
"publisherId":null,
"pseudoAccount":"XX9999",
"tradingAccount":"XX9999",
"stockBroker":"Zerodha",
"exchange":"NSE",
"symbol":"SBIN",
"independentExchange":"NSE",
"independentSymbol":"SBIN",
"day":[
2020,
7,
2
],
"parentOrderId":null,
"exchangeOrderId":"1300000009330856",
"averagePrice":185.35,
"clientId":"XX9999",
"rawStatus":"COMPLETE",
"platformTime":1593682696000,
"exchangeTime":1593682696000,
"pendingQuantity":0,
"filledQuantity":1,
"platform":"KITE",
"status":"COMPLETE",
"cancelled":false
},
{
"id":"200702202385430",
"instrument":null,
"independentInstrument":null,
"tradeType":"SELL",
"orderType":"MARKET",
"productType":"INTRADAY",
"variety":"REGULAR",
"validity":"DAY",
"quantity":1,
"disclosedQuantity":0,
"price":0.0,
"triggerPrice":0.0,
"comments":"01X7vJBo3uBL084",
"modifiedTime":1593710627248,
"createdTime":1593710627248,
"account":null,
"amo":false,
"version":null,
"statusMessage":null,
"publisherId":null,
"pseudoAccount":"XX9999",
"tradingAccount":"XX9999",
"stockBroker":"Zerodha",
"exchange":"NSE",
"symbol":"WIPRO",
"independentExchange":"NSE",
"independentSymbol":"WIPRO",
"day":[
2020,
7,
2
],
"parentOrderId":null,
"exchangeOrderId":"1300000009331170",
"averagePrice":225.0,
"clientId":"XX9999",
"rawStatus":"COMPLETE",
"platformTime":1593682697000,
"exchangeTime":1593682697000,
"pendingQuantity":0,
"filledQuantity":1,
"platform":"KITE",
"status":"COMPLETE",
"cancelled":false
},
{
"id":"200702202383567",
"instrument":null,
"independentInstrument":null,
"tradeType":"BUY",
"orderType":"MARKET",
"productType":"INTRADAY",
"variety":"REGULAR",
"validity":"DAY",
"quantity":1,
"disclosedQuantity":0,
"price":0.0,
"triggerPrice":0.0,
"comments":"01X0x4rCdbvG3ie",
"modifiedTime":1593710627248,
"createdTime":1593710627248,
"account":null,
"amo":false,
"version":null,
"statusMessage":null,
"publisherId":null,
"pseudoAccount":"XX9999",
"tradingAccount":"XX9999",
"stockBroker":"Zerodha",
"exchange":"NSE",
"symbol":"WIPRO",
"independentExchange":"NSE",
"independentSymbol":"WIPRO",
"day":[
2020,
7,
2
],
"parentOrderId":null,
"exchangeOrderId":"1300000009323650",
"averagePrice":225.05,
"clientId":"XX9999",
"rawStatus":"COMPLETE",
"platformTime":1593682680000,
"exchangeTime":1593682680000,
"pendingQuantity":0,
"filledQuantity":1,
"platform":"KITE",
"status":"COMPLETE",
"cancelled":false
},
{
"id":"200702202384269",
"instrument":null,
"independentInstrument":null,
"tradeType":"BUY",
"orderType":"MARKET",
"productType":"INTRADAY",
"variety":"REGULAR",
"validity":"DAY",
"quantity":1,
"disclosedQuantity":0,
"price":0.0,
"triggerPrice":0.0,
"comments":"01XVp8zwdq30wo3",
"modifiedTime":1593710627248,
"createdTime":1593710627248,
"account":null,
"amo":false,
"version":null,
"statusMessage":null,
"publisherId":null,
"pseudoAccount":"XX9999",
"tradingAccount":"XX9999",
"stockBroker":"Zerodha",
"exchange":"NSE",
"symbol":"SBIN",
"independentExchange":"NSE",
"independentSymbol":"SBIN",
"day":[
2020,
7,
2
],
"parentOrderId":null,
"exchangeOrderId":"1300000009326854",
"averagePrice":185.35,
"clientId":"XX9999",
"rawStatus":"COMPLETE",
"platformTime":1593682687000,
"exchangeTime":1593682687000,
"pendingQuantity":0,
"filledQuantity":1,
"platform":"KITE",
"status":"COMPLETE",
"cancelled":false
}
],
"message":null,
"status":true,
"commandId":"e5a02067-278b-4c5e-bcae-660252c13df3"
}
The response contains result (which is an array of orders 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 orders to avoid hitting the api limit.
Signatures
' Retrieve order's trading account.
Public Function GetOrderTradingAccount(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's trading platform id.
Public Function GetOrderId(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's exchange id.
Public Function GetOrderExchangeId(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's variety (REGULAR, BO, CO).
Public Function GetOrderVariety(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's (platform independent) exchange.
Public Function GetOrderIndependentExchange(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's (platform independent) symbol.
Public Function GetOrderIndependentSymbol(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's trade type (BUY, SELL).
Public Function GetOrderTradeType(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's order type (LIMIT, MARKET, STOP_LOSS, SL_MARKET).
Public Function GetOrderOrderType(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's product type (INTRADAY, DELIVERY, NORMAL).
Public Function GetOrderProductType(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's quantity.
Public Function GetOrderQuantity(pseudoAccount As String, _
orderId As String) As Long
' Retrieve order's price.
Public Function GetOrderPrice(pseudoAccount As String, _
orderId As String) As Double
' Retrieve order's trigger price.
Public Function GetOrderTriggerPrice(pseudoAccount As String, _
orderId As String) As Double
' Retrieve order's filled quantity.
Public Function GetOrderFilledQuantity(pseudoAccount As String, _
orderId As String) As Long
' Retrieve order's pending quantity.
Public Function GetOrderPendingQuantity(pseudoAccount As String, _
orderId As String) As Long
' Retrieve order's (platform independent) status.
' (OPEN, COMPLETE, CANCELLED, REJECTED, TRIGGER_PENDING, UNKNOWN)
Public Function GetOrderStatus(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's status message or rejection reason.
Public Function GetOrderStatusMessage(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's validity (DAY, IOC).
Public Function GetOrderValidity(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's average price at which it got traded.
Public Function GetOrderAveragePrice(pseudoAccount As String, _
orderId As String) As Double
' Retrieve order's parent order id. The id of parent bracket or cover order.
Public Function GetOrderParentOrderId(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's disclosed quantity.
Public Function GetOrderDisclosedQuantity(pseudoAccount As String, _
orderId As String) As Long
' Retrieve order's exchange time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
Public Function GetOrderExchangeTime(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's platform time as a string (YYYY-MM-DD HH:MM:SS.MILLIS).
Public Function GetOrderPlatformTime(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's AMO (after market order) flag. (true/false)
Public Function GetOrderAmo(pseudoAccount As String, _
orderId As String) As Boolean
' Retrieve order's comments.
Public Function GetOrderComments(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's raw (platform specific) status.
Public Function GetOrderRawStatus(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's (platform specific) exchange.
Public Function GetOrderExchange(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's (platform specific) symbol.
Public Function GetOrderSymbol(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's date (DD-MM-YYYY).
Public Function GetOrderDay(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's trading platform.
Public Function GetOrderPlatform(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's client id (as received from trading platform).
Public Function GetOrderClientId(pseudoAccount As String, _
orderId As String) As String
' Retrieve order's stock broker.
Public Function GetOrderStockBroker(pseudoAccount As String, _
orderId As String) As String
' Checks whether order is open.
Public Function IsOrderOpen(pseudoAccount As String, _
orderId As String) As Boolean
' Checks whether order is complete.
Public Function IsOrderComplete(pseudoAccount As String, _
orderId As String) As Boolean
' Checks whether order is rejected.
Public Function IsOrderRejected(pseudoAccount As String, _
orderId As String) As Boolean
' Checks whether order is cancelled.
Public Function IsOrderCancelled(pseudoAccount As String, _
orderId As String) As Boolean
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.