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

3 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
 

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

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
  • General Statistics

    • Total Topics
      23,612
    • Total Posts
      96,990
    • Total Members
      44,177
    • Most Online
      7,522
      10/06/21 10:53

    Newest Member
    Herb1e43
    Joined 04/12/23 11:30
  • Posts

    • Going by what i see on the weekly TF, BTC is heading to $46-48k major price zone level. If it breaks and holds above this zone, then $51-52k is the next minor zone, since its a minor zone, BTC might rally at this zone before deciding to go all the way up or coming back down. Though, I am still mindful of the bearish flag pattern, so there is tendency that BTC could start dumping from any of this zones yah. Lets see how it plays out yah.
    • Interesting update. I also withdrew my funds from Binance and deposited it on Bitget and Bybit exchange just to be safe. Though, personally, I believe Binance will bounce back from this set back. It is no news that both CZ and Binance has contributed immense to the growth of the crypto space and continues to do so.. More so, their case is a different from FTX as you clearly stated. I am optimistic Binance is going no where, not any time soon yah.
    • Gold price hits new peak, and silver price makes headway, but Brent crude oil falls again Precious metals are on the up once more following Jerome Powell’s speech on Friday, but the fallout from the OPEC meeting continues to weigh on oil prices. Source:Bloomberg  Chris Beauchamp | Chief Market Analyst, London | Publication date: Monday 04 December 2023 13:08 Gold surges to new peak Gold prices shot to a new record high overnight, continuing the surge from Friday’s session. Chairman Jerome Powell’s speech on Friday left markets continuing to expect that no more Fed rate hikes are on their way. This sent gold flying and pushed the dollar lower. The move puts the price firmly above the highs seen in 2022 and 2023, but the price does look overextended in the short-term. Some consolidation around current levels, or even a short-term drop back towards $2050 might not be entirely surprising. Source: ProRealTime Brent falls further OPEC’s decision to go for voluntary cuts to production last week failed to support oil prices, and now the next move appears to be a test of the November low. The past month has seen the price try and fail to hold above the 200-day SMA, and now the November low around $77.30 comes into view. Below this would see the price head back in the direction of the late Spring/early Summer lows around $72. Buyers will need a close back above $80 to suggest another attempt to challenge the 200-day SMA could develop. Source: ProRealTime Silver hits six-month plus high Silver’s move on Friday was not quite as exuberant as gold’s, but it still managed to hit its highest level in over six months. The rally of the past three weeks has barely halted. From a higher low in early November, when the price lagged behind its more expensive cousin, silver then surged through the 50- and 200-day SMAs. It has now cleared the August and July highs, and now the May peak around $26.20 comes into view. A move back below $25 would be needed to signal that some short-term consolidation had begun. Source: ProRealTime
×
×
  • Create New...
us