Jump to content
Sign in to follow this  
jackhopkins

The Market must be of type: CFD

Recommended Posts

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

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

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

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

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

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

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:

  1. Applicability:null
  2. AuditId:"4315293-1-0-0-R"
  3. AutoRollover:false
  4. BidPrice:18240.7
  5. Currency:null
  6. Direction:"sell"
  7. ExpiryDateTimeUTC:null
  8. ExpiryDateTimeUTCDate:null
  9. IfDone:[]
  10. LastChangedDateTimeUTC:null
  11. LastChangedDateTimeUTCDate:null
  12. MarketId:99498
  13. MarketName:"Wall Street CFD"
  14. OcoOrder:null
  15. OfferPrice:18243.5
  16. OrderId:0
  17. PositionMethodId:1
  18. Quantity:1
  19. QuoteId:null
  20. Reference:"origin274"
  21. Status:null
  22. TradingAccountId:400784862
  23. TriggerPrice:null
  24. Type:null
  25. 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

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:

  1. Problem with your account.
  2. 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

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

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  
×