Jump to content
james

help with 'Price tolerance exceeded.' reason code?

Recommended Posts

Hello. I'm trying to place a trade via https://ciapi.cityindex.com/TradingAPI/order/newtradeorder .

The response I'm getting back contains an Order with a StatusReason of 158. I'm understanding that to be 'Price Tolerance Exceeded'. 

I don't understand what this means - can someone help me understand what needs to be changed to resolve this?

Thank you!

Here's an example of the full parameters for a request, and the related response -

Request:

{
  "MarketId": 401153870,
  "Currency": "USD",
  "AutoRollover": false,
  "Direction": "Buy",
  "Quantity": 1,
  "QuoteId": null,
  "PositionMethodId": 1,
  "BidPrice": 1226.8,
  "OfferPrice": 1226.8,
  "AuditId": "2",
  "TradingAccountId": "401589313",
  "IfDone": {
    "Stop": {
      "Guaranteed": 1,
      "TriggerPrice": 1225.8,
      "ExpiryDateTimeUTC": null,
      "Applicability": "GoodTillCancelled",
      "ParentOrderId": null,
      "TrailingDistance": null,
      "Associated": false
    },
    "Limit": {
      "Guaranteed": 1,
      "TriggerPrice": 1227.8,
      "ExpiryDateTimeUTC": null,
      "Applicability": "GoodTillCancelled",
      "ParentOrderId": null,
      "TrailingDistance": null,
      "Associated": false
    }
  },
  "Close": [],
  "References": "GCAPI",
  "AllocationProfileId": 0,
  "PriceTolerance": 2
}

 

 

Response:

{
  "Status": 2,
  "StatusReason": 75,
  "OrderId": 0,
  "Orders": [
    {
      "OrderId": 0,
      "StatusReason": 158,
      "Status": 10,
      "OrderTypeId": 1,
      "Price": 0,
      "Quantity": 1,
      "TriggerPrice": 0,
      "CommissionCharge": 0,
      "IfDone": [],
      "GuaranteedPremium": 0,
      "OCO": null,
      "AssociatedOrders": {
        "Stop": null,
        "Limit": null
      },
      "Associated": false
    }
  ],
  "Quote": null,
  "Actions": [],
  "ErrorMessage": null
}

Share this post


Link to post

Hi,

The error message means that the price has moved beyond the Price Tolerance parameter in your account for that market. If you haven't changed the default value, then Price Tolerance is 2. It specifies how much slippage of market prices you are willing to accept to execute your trade.

However I think the real culprit is that in the request sent, the Bid Price is equal to the Offer Price. :blink: Unless something has drastically gone wrong, markets are not normally locked.

Are you subscribing to the live streaming prices for that market and then reading in the Bid and Offer prices from the stream to populate the values in your call? I think this might be the step that has been missed. 

Kind Regards, PM

Share this post


Link to post

Aha, I see what you mean about the Bid Price and Offer Price. Thank you!

I am also not subscribing to the streaming prices, but am instead pulling the most recent price from the tickhistory endpoint.  Will this not suffice, or do these sources not report the same data?

 

Thank you for the help!

Share this post


Link to post

Hi, 

I assume you're using GetLatestPriceTicks  to retrieve the Tick history? The issues with using that is price ticks show the last transacted price, so it doesn't show the current Bid/Offer prices. That is why your Bid and Offer prices ended up being equal. Additionally, that endpoint is not live streaming data so it won't update as the market moves.

You do need to subscribe to the live streaming prices for the market you want to trade. This enables you to read in the most current bid and offer prices so that your order can go through without the error message.

Kind Regards, PM

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×