API Json syntax

Planning to test API in demo. While browsing the API document, no JSON syntax provided for closing a specific symbol position when there are multiple symbol position open and modify Stop Loss/Take Profit.

Appreciate your help on the required JSON syntax for Closing a position and placing/modifying stoploss & Take Profit.


Hi there,
Could you please help me to get the details of the required JSON syntax to be passed for closing an open position for a particular symbol, Modifying Stop Loss/ Take Profit for an order ?


Hello @kaygee,

One way that you can liquidate your position is through the /order/liquidatePosition endpoint, you can view the JSON syntax details here on our documentation site. Calling this endpoint will attempt to close any open positions you hold and pending orders placed for a given contract. Hope this helps!

Thanks but i’m looking for a syntax to close a particular symbol position if i have two open positions in different symbol and would like to close only one.
Example: 1 contract buy in NQ , 1 contract Sell in ES but close is only for 1 control Sell in ES ?


just looking the syntax in liquidate position. Is that contract id is same as symbol id: example: if Micros ES sep - MESU21 ?
If yes then i should be able to close the particular contract ?

Sorry, i’m new to this forum/tradovate API.

Thanks for your help.

Not a problem, we are glad to see new users!

The liquidatePosition endpoint is for exactly this situation. You provide it a contract id (not the “symbol”) and it closes your positions for just that contract. If you liquidate on NQ, NQ positions will be closed (attempted to be closed, no guarantees in web work!) but ES positions will remain. It takes the id field of the contract in question.

If you don’t have the id field of the contract, you need to first acquire it using the /contract/find endpoint. This is easy though, simply send a GET request to /contract/find?name=MNQU1 or whatever symbol you’re searching, and you’ll get a JSON response containing an id field for that contract. This id field is the one you are looking for to parameterize your liquidatePosition request.

Best of luck to you!

Thanks so much for the details.
One more follow up on placing the order:
If I’m placing the market order - i do see a field for stop price. Is this the filed for Stop Loss price ? How about Take Profit value if i want to put along with the market order ?
Will start testing the access and order from next week in Demo.


There are many options when it comes to making orders with the API. You can place orders using the /order/placeOrder endpoint. You can view the docs here. You’ll notice many parameters are optional - this is because the parameters you use are determined by the type of order you’re placing. For example, a Stop would have a stopPrice field, where a Limit would have a price field. A Market order would simply require the naturally required parameters (you’ll see these marked required in red text).

Now you also mentioned specifying take-profits. Rather than trying to work out your own way to place brackets algorithmically, you can piggyback off of Tradovate’s built-in Brackets trading algorithm. In order to do so, you can use the /orderStrategy/startOrderStrategy endpoint. You can read those docs here. This allows you to create quite complex strategies for taking profit, stopping loss, and adding trailing stops without having to specify unique orders for each window you’d like to trade in - the Brackets algo does a lot of the work for you.

We also have endpoints for OSOs (order-sends-order) and OCOs (order-cancels-order) for alternative order strategies, from which you could build your own bracket-like strategies if you wanted.

thanks so much. This helps and let me read all these and get back to you for any help or issues while testing.

1 Like

No problem, happy to help out!

Some follow up questions - sorry for the basic questions as I’m learning this API…
username - account login name
account id: respective account ID of Demo and Live as i appear in the account- if Demo DEMOXXXXX and LIVE VXXXXXX

Is my understanding correct ?


The accountId field must be your account’s entity ID - this is just an integer value, not a string. To acquire the entity ID, use a call to /account/list. This will return all the accounts assoc. with your user. This data will be an array of account objects. To choose an account, you’d need to simply use one of those object’s id fields as the accountId field in your request.

THanks. Let me get all this fixed once I activate my API keys by this week.