Jump to content
Sign in to follow this  

Open a position with a stop

Recommended Posts



I am able to place a trade without setting a stop or limit.


But when I add a stop to the request, error start to appear. I am not sure what is the correct way of setting up a stop.


My request and the response I received are down below:



  "MarketId": 400616114,
  "Currency": "GBP",
  "AutoRollover": false,
  "Direction": "buy",
  "Quantity": 1,
  "QuoteId": null,
  "PositionMethodId": null,
  "BidPrice": 17842,
  "OfferPrice": 17846,
  "AuditId": "sbINXProd_NON_FX25652",
  "TradingAccountId": 400448826,
  "IfDone": [
      "Stop": {
        "Guaranteed": false,
        "TriggerPrice": 17500,
        "ExpiryDateTimeUTC": null,
        "Applicability": null,
        "ParentOrderId": null,
        "OrderId": 0,
        "AutoRollover": false,
        "MarketId": 0,
        "Direction": null,
        "Quantity": 0,
        "Price": null,
        "TradingAccountId": 0,
        "CurrencyId": 0,
        "StatusId": 0,
        "TypeId": 0,
        "IfDone": null,
        "OcoOrder": null
      "Limit": null
  "Close": null




{"HttpStatus":400,"ErrorMessage":"The direction of the request is invalid.","ErrorCode":60107}




Share this post

Link to post

Hello Vincent,


When you add your stop and/or limit orders to an open trade, are you using the UpdateTrade command?

It will be helpful to look at the "Add Stop and/or Limit Order to an Open Trade" Trading Sequence Diagram at

http://docs.labs.cityindex.com/#Seq Diags.htm%3FTocPath%3DGetting%2520Started%7C_____2


When you using the UpdateTrade command, you'll need to supply the Order ID for the open position you are attaching the stop/limit to. 


Additionally, in the code you pasted you haven't set the direction for your stop order. The error message is complaining about invalid direction because in your request you have left it as null. You'll need to supply the direction for the stop and/or limit orders you are attaching.

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
Sign in to follow this