james 0 Report post Posted August 19, 2019 I realize my follow up question on a previous thread was confusing, so I'm moving it here. As always, I really appreciate all of your help and patience! I'm having trouble getting a stop and limit set when I open a new position using the /newtradeorder api endpoint. The request gets accepted, the response looks okay other than IfDone being empty, and I can see the open position when logging in via the platform with no stop or limit set. What am I doing wrong? I'm spinning my wheels, and need the insights of some smarter eyes. Here is the request I am sending: { "BidPrice": "1511.21", "Direction": "buy", "MarketId": "401153870", "OfferPrice": "1511.66", "PositionMethodId": 1, "Quantity": 1, "TradingAccountId": "401589313", "IfDone": { "Stop": { "Applicability": "gtc", "Direction": "sell", "ExpiryDateTimeUTC": null, "Guaranteed": false, "IfDone": [], "OcoOrder": null, "OrderId": null, "Quantity": 1, "TriggerPrice": 1510.94 }, "Limit": { "Applicability": "gtc", "Direction": "sell", "ExpiryDateTimeUTC": null, "IfDone": [], "OcoOrder": null, "OrderId": null, "Quantity": 1, "TriggerPrice": 1511.94 } } } and here is the response: { "Status": 1, "StatusReason": 1, "OrderId": 693438627, "Orders": [ { "OrderId": 693438627, "StatusReason": 1, "Status": 3, "OrderTypeId": 1, "Price": 1511.58, "Quantity": 1, "TriggerPrice": 0, "CommissionCharge": 0, "IfDone": [], "GuaranteedPremium": 0, "OCO": null, "AssociatedOrders": { "Stop": null, "Limit": null }, "Associated": false } ], "Quote": null, "Actions": [ { "ActionedOrderId": 0, "ActioningOrderId": 0, "Quantity": 1, "ProfitAndLoss": 0, "ProfitAndLossCurrency": null, "OrderActionTypeId": 1 } ], "ErrorMessage": null } Thank you! - James Share this post Link to post
Physicsman 26 Report post Posted August 19, 2019 Hi, I'll take a look in more detail and send you a reply as soon as possible. Thank you for your patience! Kind Regards, PM Share this post Link to post
Physicsman 26 Report post Posted August 20, 2019 Hi @james, It looks as though it is a syntax error in your request - a simple case of missing square brackets [ ] around the Stop and Limit orders. I sent a successful call to place a trade with attached stop/limit orders and then did a line by line examination of my request with yours. I spotted the missing square brackets in your pasted code and have highlighted with green arrows in my screenshot below. I think if you add the square brackets to your call then it should work fine. Kind Regards, PM Share this post Link to post
james 0 Report post Posted August 20, 2019 That did it. I cannot believe I overlooked such a simple problem so many times. Thank you! Share this post Link to post