Require Market Position

The flag require_market_position is available to any command with both an account and instrument field. It blocks and prevents the signal from going through unless the NT8 market position is:

  • flat

  • short

  • long

  • flat or long

  • short or long

  • long or short

Require market position is available to any of the following command types:

  • PLACE

  • FLATPLACE

  • CANCELREPLACE

  • CANCELORDERS

  • CLOSEPOSITION

  • REVERSEPOSITION

  • FLATTEN

Checking Multiple Market Positions

In addition to the standard long, short, flat market positions, we've included the ability to check for 2 of the 3 conditions. That is, if any one of 2 conditions are true, the signal won't be blocked.

The use case here is if you want to add to a position in a certain direction, but only if you're already long or flat in that direction. For example, if you are long +3 contracts and you want to add +1 contracts, you want to ensure you are either long or flat in that direction already. Otherwise, if you're short, you would only be making your position "less short" by closing 1 contract.

To check for the "long or flat" conditions, separate the values with a comma. CSV values represent an "or" condition between them: "flat or long", "long or short", etc. They can be in any order: "flat,long", "long,flat", etc.

An example command would be:

key=your-secret-key;
command=PLACE;
account=sim101;
instrument=ZW 12-24;
action=BUY;
qty=1;
order_type=MARKET;
tif=DAY;
require_market_position=long,flat;

which translates to buy +1 ZW 12-24 at market if and only if a position already exists in ZW 12-24 that is flat or long. If a short position is open, block the signal.

Example Payloads

In the simplest case, a PLACE command with require_market_position=flat; for account "sim101" and instrument "ES 12-24" will not be processed unless there's no preexisting position in ES 12-24 under account sim101. The position must be flat for the order to proceed:

key=your-secret-key; command=PLACE; account=sim101; instrument=ES 12-24; action=BUY; qty=1; order_type=MARKET; TIF=DAY; require_market_position=flat;

Let's say you have multiple alert types in play: Long Entry, Long Exit, Short Entry, Short Exit. You don't want to process the "Short Exit" signal to close if there's a long position already in play. In this instance, you could require the alert to be processed if and only if the current market position is short:

key=your-secret-key; command=CLOSEPOSITION; account=sim101; require_market_position=short;

Similar to our example in the Multiple Market Positions section above, if we want to sell short an "ES 12-24" contract if and only if the exist position in the "sim101" account is flat or short:

key=your-secret-key; command=PLACE; account=sim101; instrument=ES 12-24; action=SELL; qty=1; order_type=MARKET; tif=DAY; require_market_position=flat,short;

Last updated