• Home
  • Products
    • Login
    • Product Info
    • User Guide
    • Pricing
  • Services
    • Stock Brokers
    • Freelancers
  • Help
    • Documentation
    • Knowledge Base
    • FAQ
  • Company
    • About Us
    • Contact Us
    • Terms & Conditions
  • Home
  • Products
    • Login
    • Product Info
    • User Guide
    • Pricing
  • Services
    • Stock Brokers
    • Freelancers
  • Help
    • Documentation
    • Knowledge Base
    • FAQ
  • Company
    • About Us
    • Contact Us
    • Terms & Conditions

AutoTrader Web

home/Documentation/AutoTrader Web
Expand All Collapse All
  • Index
  • Getting Started
  • Portfolio Management System (PMS)
  •  Copy Trading (Master-Child Auto-Copy)
    • Master-Child Copy - Performance
  • PMS vs Master-Child
  • Trading View
  •  Supported Brokers
    • Symphony XTS
    • Zerodha
    • Angel Broking
    • Dhan
    • Aliceblue
    • Fyers
    • Nuvama
    • IIFL
    • Zebu
    • Finvasia
    • Motilal Oswal
    • Kotak
    • Mastertrust
    • Five Paisa
    • Choice Broking
    • FlatTrade
    • Tradejini
    • Upstox
    • SAS Online
    • Profitmart
  •  Client Setup
    • Desktop Client
    • AmiBroker Library
    • Excel Library or Tools
    • Java Library
    • MetaTrader Library
    • C# Library
    • Python Library
    • HTTP REST
  •  User Interface
    • User Registration
    •   Settings
      • General
      • Trading Accounts
      • Pseudo Accounts
      • Group Accounts
      • API Key
    •   AutoTrader
      • Activity
      • Instruments
    •   Trading
      • Summary
      • Positions
      • Orders
      • Margins
      • Holdings
      • Trade
    •   User
      • Account
      • Profile
  •  API (Application Programming Interface)
    • Place Regular Order
    • Place Cover Order
    • Place Bracket Order
    • Place Advanced Order
    • Cancel Order
    • Cancel Child Orders
    • Cancel All Orders
    • Modify Order
    • Modify Order Price
    • Modify Order Quantity
    • Square-off Position
    • Square-off Portfolio
    • Read Orders
    • Read Positions
    • Read Margins
    • Read Holdings
    • Read Portfolio Summary
    • Fetch All Trading Accounts
    • Create or Update Trading Account
    • Validate Trading Account Credentials
    • API Parameters
    • API Rate Limits
    • Email Limits
    • Postman
  • Pricing
  • Precautions
  •  Broker Independence
    • API Functions
    • Pseudo Account
    • Instruments (Trading Symbols)
  • Quantity Multiplier
  • Architecture

Place Cover Order

3775 views July 29, 2024 Pritesh 2

API function to place cover order. APIs are available in AmiBroker, MetaTrader, Excel, Java, C#, Python, HTTP REST.

Api function will place a cover order on Supports leading Indian Stock Brokers.

  • AmiBroker
  • MetaTrader
  • Java
  • C#
  • Python
  • HTTP
  • Excel
  • Postman

Signature

function placeCoverOrder(account, exchange, 
	symbol, tradeType, orderType, 
	quantity, price, triggerPrice, validate)

Example 1

// Apply your logic to calculate stoploss trigger price
stoplossTriggerPrice = buyPrice - 5;

// Place cover order
orderId = placeCoverOrder(AT_ACCOUNT, AT_EXCHANGE, 
	AT_SYMBOL, "BUY", "LIMIT", AT_QUANTITY, 
	buyPrice, stoplossTriggerPrice, True);

This example will place a Cover order for Account, Exchange & Symbol chosen in chart parameters.

Some variables used in above code are parameters defined by AutoTrader library.

Example 2

// Apply your logic to calculate stoploss trigger price
stoplossTriggerPrice = buyPrice - 5;

// Place cover order (Limit)
orderId = placeCoverOrder("ACC_NAME", "NSE", 
	"SBIN", "BUY", "LIMIT", 10, 
	buyPrice, stoplossTriggerPrice, True);

This example will place Cover order for Account (ACC_NAME), Exchange (NSE) & Symbol (SBIN) with quantity 10. We have placed a LIMIT order.

Here we did not use chart parameters, instead we passed the values directly.

Example 3

// Apply your logic to calculate stoploss trigger price
stoplossTriggerPrice = buyPrice - 5;

// Place cover order (Market)
orderId = placeCoverOrder("ACC_NAME", "NSE", 
	"SBIN", "BUY", "MARKET", 10, 
	0, stoplossTriggerPrice, True);

This example will place Cover order for Account (ACC_NAME), Exchange (NSE) & Symbol (SBIN) with quantity 10. We have placed a MARKET order; hence the order price is zero.

Signature

string placeCoverOrder(string account, 
	Exchange exchange, string symbol, 
	TradeType tradeType, OrderType orderType, 
	int quantity, double price, 
	double triggerPrice, bool validate)

Example

// Apply your logic to calculate stoploss trigger price
double stoplossTriggerPrice = buyPrice - 5;

// Place cover order
string id = placeCoverOrder(AT_ACCOUNT, 
	AT_EXCHANGE, AT_SYMBOL, BUY, LIMIT, 1, 
	192, stoplossTriggerPrice, true);

This example will place a Cover order for Account, Exchange & Symbol chosen in chart parameters.

Some variables used in above code are parameters defined by AutoTrader library.

Example 2

// Apply your logic to calculate stoploss trigger price
double stoplossTriggerPrice = buyPrice - 5;
 
// Place cover order (Market)
orderId = placeCoverOrder("XX2030", 
    NSE, "SBIN", BUY, MARKET, 10, 
    0, stoplossTriggerPrice, true);

This example will place Cover order for Account (XX2030), Exchange (NSE) & Symbol (SBIN) with quantity 10. We have placed a MARKET order; hence the order price is zero.

Signature

/**
 * Places a cover order.
 *
 * @param pseudoAccount pseudo account
 * @param exchange      exchange
 * @param symbol        symbol
 * @param tradeType     trade type
 * @param orderType     order type
 * @param quantity      quantity
 * @param price         price
 * @param triggerPrice  trigger price
 * @return the order id given by your stock broker
 */
IOperationResponse<String> placeCoverOrder(
	String pseudoAccount, String exchange, 
	String symbol, TradeType tradeType, 
	OrderType orderType, int quantity, 
	float price, float triggerPrice);

Example

// Place a cover order
final IOperationResponse<String> response = 
	autotrader.placeCoverOrder("ACC_NAME", 
	"NSE", "SBIN", TradeType.BUY, OrderType.LIMIT, 
	10, 180.5f, 180f);
	
// Read order id
String orderId = null;
if (response.success()) {
	orderId = response.getResult();
} else {
	final String errorMessage = response.getMessage();
}

This will place a cover order into 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 access order_id given by your trading platform.

Signature

/// <summary>
/// Places a cover order. For more information, please see <a href=
/// "https://stocksdeveloper.in/documentation/api/place-cover-order/">api
/// docs</a>.
/// </summary>
/// <param name="pseudoAccount"> pseudo account </param>
/// <param name="exchange">      exchange </param>
/// <param name="symbol">        symbol </param>
/// <param name="tradeType">     trade type </param>
/// <param name="orderType">     order type </param>
/// <param name="quantity">      quantity </param>
/// <param name="price">         price </param>
/// <param name="triggerPrice">  trigger price </param>
/// <returns> the order id given by your stock broker </returns>
IOperationResponse<String> PlaceCoverOrder(
	string pseudoAccount, string exchange, 
	string symbol, TradeType tradeType, 
	OrderType orderType, int quantity, 
	float price, float triggerPrice);

Example

IOperationResponse<string> response = 
	autoTrader.PlaceCoverOrder("XX1234", 
	"NSE", "SBIN", TradeType.SELL,
	OrderType.MARKET, 3, 0, 218.4f);
	
if(response.Success()) {
    Console.WriteLine("Result: {0}", response.Result);
}
else {
    Console.WriteLine("Message: {0}", response.Message);
}

This will place an order into 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 Result property to access order_id given by your trading platform.

Signature

def place_cover_order(self, pseudo_account, \
	exchange, symbol, tradeType, orderType, \
	quantity, price, triggerPrice):

Example

response = autotrader.place_cover_order( \
	'XX1234', 'NSE', 'SBIN', 'SELL', 'LIMIT', \
	1, 188.15, 190.0)
	
if response.success():
    print("Result: {0}".format(response.result))
else:
    print("Message: {0}".format(response.message))

Example

curl https://api.stocksdeveloper.in/trading/placeCoverOrder \
   -H "api-key: <your_api_key>" \
   -d "pseudoAccount=ACC_NAME" \
   -d "exchange=NSE" \
   -d "symbol=SBIN" \
   -d "tradeType=BUY" \
   -d "orderType=LIMIT" \
   -d "quantity=10" \
   -d "price=180.5" \
   -d "triggerPrice=180"

Response

{
	"result":"200622000333410",
	"error":null,
	"message":null,
	"status":true,
	"commandId":"6d4b5738-c1aa-4623-b0c5-8df779e0f44d"
}

The response contains result (which is order_id given by your trading platform).

If there is any error, then you will get status as false & message will have error text.

The commandId cab be used to trace the activity on AutoTrader Web.

Signature

Public Function PlaceCoverOrder( _
    PseudoAccount As String, _
    Exchange As String, _
    Symbol As String, _
    TradeType As String, _
    OrderType As String, _
    Quantity As Integer, _
    Price As Double, _
    TriggerPrice As Double) As String

Example

Dim OrderId As String

OrderId = PlaceCoverOrder("ACC_NAME", _
	"NSE", "SBIN", "BUY", "LIMIT", 100, 200.55, 0)

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.


Parameters

  • account – pseudo account
  • exchange – instrument (stock/derivative) exchange
  • symbol – instrument (stock/derivative) symbol
  • tradeType – trade type
  • orderType – order type
  • quantity – quantity
    • Note: For NSE/BSE derivatives, quantity should be multiple of lot size. Example, BANKNIFTY lot size is 15. So to buy/sell 1 lot, you need to enter 15 quantity.
  • price – order price
  • triggerPrice – trigger price
  • validate – validate order (check for duplicate signals). Only applicable for AmiBroker & MetaTrader.

Return value

AmiBroker, MetaTrader, Excel

This function sends place order request to AutoTrader Desktop Client. On successful submission, it will return a unique publisherId (orderId given by AutoTrader library).

Java, HTTP, C#, Python

The function returns a platformId (orderId given by your trading platform).

The type of the return value is String or Text.

Important

  • Your broker must support Cover order on our platform. Please try placing a cover order from our platform’s trading terminal first to confirm whether it is supported or not.
Place Regular Order
Place Bracket Order

Was this helpful?

2 Yes  No
Related Articles
  • Master-Child Copy – Performance
  • Tradejini
  • Dhan
  • FlatTrade
  • Supported Brokers
  • Symphony XTS

© 2025 Stocks Developer. All Rights Reserved.