Jump to content
  • 0

API and Spread Betting


david_blumkey

Question

Hello,

I have two questions about interacting with the API in conjunction with a spread betting account. There are two things that I don't understand:

- After POSTing to `/session`, I have two accounts that are returned in the response (CFD and Spread Bet), however I don't understand how I can select that account to be used when (for example) creating and viewing trades. In the response object I can see my preferred account is selected as the CFD account, but I'm not sure how I can update this "preferred account" or even programmatically select the Spread Bet account for further use. How can I ensure the spread bet account is used for subsequent API interactions?

- When querying for market epics via `/markets`. How can I tell if a market is a spread betting market or a CFD (or other) market? There doesn't appear to be a clear way of knowing.

Thanks in advance for you time! Please let me know if I can provide any further information.

Link to comment

5 answers to this question

Recommended Posts

  • 0
21 hours ago, david_blumkey said:

Hello,

I have two questions about interacting with the API in conjunction with a spread betting account. There are two things that I don't understand:

- After POSTing to `/session`, I have two accounts that are returned in the response (CFD and Spread Bet), however I don't understand how I can select that account to be used when (for example) creating and viewing trades. In the response object I can see my preferred account is selected as the CFD account, but I'm not sure how I can update this "preferred account" or even programmatically select the Spread Bet account for further use. How can I ensure the spread bet account is used for subsequent API interactions?

- When querying for market epics via `/markets`. How can I tell if a market is a spread betting market or a CFD (or other) market? There doesn't appear to be a clear way of knowing.

Thanks in advance for you time! Please let me know if I can provide any further information.

Hi @david_blumkey,

Welcome to the IG community and thank you for your post. Please see the below answers to your questions:

1. The API will always use the account that has been set as the 'default' account as the preferred account, once logged in to the API there is a 'Switch account' function that can be used to switch between Spread Bet and CFD accounts but preferred account will always be the default account on login.

2. Most Spread Bet market EPICs will have 'Daily' or 'Cash' and CFD market EPICs will normally have 'Today' in the EPIC. The best option is to get the EPIC from the market for the specific account (Spread Bet/CFD) to ensure the right EPIC is used for the correct account and for the correct market EPIC.

All the best,

KoketsoIG
 

Please rate us on Trustpilot: IG Trustpilot 

Link to comment
  • 0
On 13/11/2023 at 09:17, KoketsoIG said:

Hi @david_blumkey,

Welcome to the IG community and thank you for your post. Please see the below answers to your questions:

1. The API will always use the account that has been set as the 'default' account as the preferred account, once logged in to the API there is a 'Switch account' function that can be used to switch between Spread Bet and CFD accounts but preferred account will always be the default account on login.

2. Most Spread Bet market EPICs will have 'Daily' or 'Cash' and CFD market EPICs will normally have 'Today' in the EPIC. The best option is to get the EPIC from the market for the specific account (Spread Bet/CFD) to ensure the right EPIC is used for the correct account and for the correct market EPIC.

All the best,

KoketsoIG
 

Thank you for getting back to me, and thank you for the information. Would you have a link to the endpoint that you were referring to in regards to the switching accounts function?

I thought it might the PUT /accounts/preferences endpoint, but accoring to the documentation that only allows you to enable / disable trailing stop losses:
https://labs.ig.com/rest-trading-api-reference/service-detail?id=654

Would it be possible to set in the UI? I can't seem to find the setting if so. I tried changing the "Default View", but that doesn't appear to set affect the API account

Screenshot2023-11-25at11_36_05.thumb.png.96160e6261191e73c083a34750e36ef7.png

Link to comment
  • 0
On 25/11/2023 at 13:37, david_blumkey said:

Thank you for getting back to me, and thank you for the information. Would you have a link to the endpoint that you were referring to in regards to the switching accounts function?

I thought it might the PUT /accounts/preferences endpoint, but accoring to the documentation that only allows you to enable / disable trailing stop losses:
https://labs.ig.com/rest-trading-api-reference/service-detail?id=654

Would it be possible to set in the UI? I can't seem to find the setting if so. I tried changing the "Default View", but that doesn't appear to set affect the API account

Screenshot2023-11-25at11_36_05.thumb.png.96160e6261191e73c083a34750e36ef7.png

Hi @david_blumkey,

Thank you for your post.

Please note that you can find the details in the following: /session | IG Labs it's under Login and Session

This can be done in the UI, changing 'Default view' in the web platform only changes the default account for Live accounts. You might have changed the default account for live and logged in with your demo API which is why you might have not noticed a change.

Changing the default account for the demo can only be done on the IG mobile app (Account > Manage accounts).

image.png

Please rate us on Trustpilot: IG Trustpilot 

Link to comment
  • 0

Understanding how to select the desired account for your API requests is crucial for seamless integration. If the response object indicates your preferred account as the CFD account, you might need to explore the API documentation further to find methods for updating this preference or programmatically selecting the Spread Bet account.

Link to comment
  • 0
On 21/03/2024 at 17:11, capitulinagarage said:

Understanding how to select the desired account for your API requests is crucial for seamless integration. If the response object indicates your preferred account as the CFD account, you might need to explore the API documentation further to find methods for updating this preference or programmatically selecting the Spread Bet account.

Remember, troubleshooting API integrations can be complex, but with patience and persistence, you'll likely find a solution that works for you. And if you're interested in expanding your knowledge of spread betting or exploring related topics, you might discover valuable insights and resources at https://www.nettcasino.com/omtaler/. Keep up the great work, and don't hesitate to reach out if you have further questions or need assistance along the way!

Edited by capitulinagarage
Link to comment

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
×
×
  • Create New...
us