jackhopkins 0 Report post Posted September 26, 2016 I am attempting to open a spreadbetting position via the API with the following request: { "MarketId": 400616113, "MarketName": "UK 100", "Direction": "sell", "Quantity": 1, "BidPrice": 6831, "OfferPrice": 6832, "TradingAccountId": "<TRADING ID>", "isTrade": true, "IfDone": [ ], "Reference": "CIAPI", "PriceTolerance": 0, "AutoRollover": false, "OrderId": 0, "ExpiryDateTimeUTCDate": null, "LastChangedDateTimeUTCDate": null, "OcoOrder": null, "Type": null, "ExpiryDateTimeUTC": null, "Applicability": null, "Currency": "USD", "QuoteId": null, "LastChangedDateTimeUTC": null, "Status": null, "AuditId": "45435468-3-0-0-R", "PositionMethodId": 1, "AllocationProfileId": 0 } Unfortunately I get the following response: { "Status": 2, "StatusReason": 75, "OrderId": 0, "Orders": [ { "OrderId": 0, "StatusReason": 43, "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 } The status message reads: "The Market must be of type: CFD" and the request fails. Is my request incorrect? Share this post Link to post
Physicsman 25 Report post Posted September 26, 2016 Hi Jack, Looking at the OrderStatusReason response codes in the lookup page (http://docs.labs.cityindex.com/#APICodesList.htm%3FTocPath%3DGetting%2520Started%7CLookup%2520Values%7C_____1), you have a code 43. This corresponds to: The order currency must match the currency of the underlying. In the order request that you sent, you have put currency as USD, however the market you are trying to trade is the GB 100, which has a base currency of GBP. If you change USD to GBP in your order request that should fix this particular error. Kind Regards, PM! Share this post Link to post
jackhopkins 0 Report post Posted September 26, 2016 Thanks for replying so quickly. I must apologise, the request/response I posted was incorrect. The following is the correct request/response which corresponds to the CFD error: Request: { "MarketId": 400616113, "MarketName": "UK 100", "Direction": "sell", "Quantity": 1, "BidPrice": 6819, "OfferPrice": 6820, "TradingAccountId": "<TRADING ID>", "isTrade": true, "IfDone": [ ], "Reference": "CIAPI", "PriceTolerance": 0, "AutoRollover": false, "OrderId": 0, "ExpiryDateTimeUTCDate": null, "LastChangedDateTimeUTCDate": null, "OcoOrder": null, "Type": null, "ExpiryDateTimeUTC": null, "Applicability": null, "Currency": "GBP", "QuoteId": null, "LastChangedDateTimeUTC": null, "Status": null, "AuditId": "45490714-3-0-0-R", "PositionMethodId": 1, "AllocationProfileId": 0 } Response: { "Status": 2, "StatusReason": 75, "OrderId": 0, "Orders": [ { "OrderId": 0, "StatusReason": 65, "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
Physicsman 25 Report post Posted September 26, 2016 Hello, I've checked your request body and it is correct for when you are placing a trade at market. The error message you are receiving leads me to think that maybe you are using a CFD only account? Please check by logging into your account using anyone of our trading platforms. Do you see only CFD markets are can you see Spreadbet markets? Please let us know. Kind Regards, PM! Share this post Link to post
jackhopkins 0 Report post Posted September 26, 2016 Hi again, I was able to login to the CI Advantageweb platform and open/close a position on DFT Wall St. Thanks, Jack Share this post Link to post
Physicsman 25 Report post Posted September 26, 2016 Hi, Thanks for the update - your account has access to spreadbet markets so that isn't the problem. I've asked our API lead to look into this for you and they or someone on their team should be able to get a solution to the issue your encountering. Look out for an update on this thread. Kind Regards, PM! Share this post Link to post
Physicsman 25 Report post Posted September 27, 2016 Hi Jack, Our API development team has taken a look at your request body and can confirm that it is correct - there is nothing wrong in the way you have formatted it. Like myself, when we tested the call in our internal systems it works and we cannot reproduce your error. The Devs have suggested the following diagnostic steps: 1. A quick sanity check, using for example our CI Advantage Web platform are you able to place a trade on the exact same (UK100) market? We want to eliminate there being a market specific problem, since we know you can trade the Wall Street DFT market on the Web platform. 2. Using the API and your program code, send the trade request and note the time in UTC when you send it then let us know what time it was. We can track / trace your call that arrives at our servers using our internal systems and can try to diagnose what is going on from our backend. 3. Are you familiar with using web development tools in browsers such as the Google Developer Tools in the Chrome browser, or Mozilla Firebug for the Firefox browser? If you are, when using our Web platform can you use one of these tools to send us the request and response that you see when placing a trade in your account on the UK 100 market. 4. Finally, to check whether it is a problem in your account or possibly in your API code, I will send you a private message on this forum with the credentials for a Test account. Please try sending your API trade requests using the Demo account and see if that is successful or if it results in the same error. Kind Regards, PM! Share this post Link to post
jackhopkins 0 Report post Posted September 28, 2016 Hi PM, Thanks for the response. 1. I've successfully managed to place trades on multiple indices on the trading platform. 2. The time from a failed request is as follows: 28 Sep 2016 11:54:54 GMT 3. Request: Applicability:null AuditId:"4315293-1-0-0-R" AutoRollover:false BidPrice:18240.7 Currency:null Direction:"sell" ExpiryDateTimeUTC:null ExpiryDateTimeUTCDate:null IfDone:[] LastChangedDateTimeUTC:null LastChangedDateTimeUTCDate:null MarketId:99498 MarketName:"Wall Street CFD" OcoOrder:null OfferPrice:18243.5 OrderId:0 PositionMethodId:1 Quantity:1 QuoteId:null Reference:"origin274" Status:null TradingAccountId:400784862 TriggerPrice:null Type:null isTrade:true Response: {"Status": 1,"StatusReason": 1,"OrderId": 578423496,"Orders": [{"OrderId": 578423496,"StatusReason": 1,"Status": 3,"OrderTypeId": 1,"Price": 18240.7,"Quantity": 1,"TriggerPrice": 0,"CommissionCharge": 0,"IfDone": [],"GuaranteedPremium": 0,"OCO": null,"AssociatedOrders": {"Stop": null,"Limit": null},"Associated": false}],"Quote": null,"Actions": [{"ActionedOrderId": 578423496,"ActioningOrderId": 578423496,"Quantity": 1,"ProfitAndLoss": 0,"ProfitAndLossCurrency": null,"OrderActionTypeId": 1}],"ErrorMessage": null} 4. The new credentials result in the same issue. I suppose its something wrong with my implementation? Share this post Link to post
Physicsman 25 Report post Posted September 28, 2016 Much obliged for the trouble shooting information - I'll pass it to our API development team and will reply when they have a response. We're making progress though - eliminating the following from consideration: Problem with your account. Problem specific to the UK 100 market. It's looking like it may be something in how the call is being formulated but we'll see after investigation. Kind Regards, PM! Share this post Link to post
Physicsman 25 Report post Posted September 29, 2016 Hi, We have a possible lead on this issue from the information you've given us. Please send me a private message (PM) with a cut and paste of the full request you are sending that results in the 65 error response. Please leave in the TradingAccountID in your request. Thanks a lot, PM! Share this post Link to post
jackhopkins 0 Report post Posted October 1, 2016 Hi PM, Thanks a lot for your help. The issue was indeed the type of account I was using. A stupid mistake! Its all working now. Cheers, Jack Share this post Link to post
Physicsman 25 Report post Posted October 3, 2016 Glad we could help! Cordially, PM! Share this post Link to post