Placing and tracking orders

  1. When placing a limit order through the order/placeOrder endpoint, what exactly is the price parameter? In a market like the MES, is this the value of the price to execute your order in ticks or in points?

  2. I am tracking my account balance through updates from the user/syncrequest endpoint, more specifically the amount field within cashBalances. How often will I receive an updated amount for this field, does it update as the value of an open position changes or only upon closing a position?

  1. The price field will always be the unit price (in points) that you wish to set the limit order.
  2. cashBalances will be updated through the socket for a bunch of reasons, but it will not calculate open PL. Some of the causes for updates:
    • any fees
    • fills
    • realized profit or loss

The best way to calculate open PL is to aggregate data from a few entity types. You’ll need the position and product entities, as well as the current price for the actual contract traded. You can wrap this function in to quote or chart updates where you have the position and product cached.

function calculateOpenPL(netPrice, netPos, valuePerPoint, price) {
  return (((price - netPrice) * valuePerPoint) * netPos).toFixed(2);
}

//usage
const pnl = calculateOpenPL(
  position.netPrice,
  position.netPos,
  product.valuePerPoint,
  lastPrice //you will know this value inside an event handler for the socket
);

Thank you! I should have specified that I am not using cashBalances to track openPL, just realizedPL. I am primarily using it to enforce a maximum daily loss, but I only want this to trigger upon a trade closing so it should work as I intend it to. I know that using it this way I can end up with a balance lower than my daily loss because cashBalances wouldn’t update until a losing trade was exited but I am accounting for that discrepancy through where I place my stops.