Jump to content
  • 0

Separate program threads fail setting account after session creation (REST API)


JulianG

Question

I have a program that uses the REST API. It has a main routine and two threads (written in Python). The main routine and each of the two threads establish their own session using the API (POST /session), then set the account (PUT /session).

This has worked fine for months, but for the last few weeks there has been a problem. The first creation of a session and setting the account works as before. However, when the threads come to set their accounts, I get error 401 and message 'error.security.account-token-invalid'. This program goes straight from creating the session to setting the account and it uses the CST and X-SECURITY-TOKEN returned by the session creation when it sets the account. Creating the session itself returns code 200, which indicates success.

Nothing has changed in my program to cause this. The problem is intermittent and I can improve things by retrying after a few seconds, when it will sometimes work.

Does anyone know of any changes at the IG end that might be causing this? Are there any obvious workarounds. One reason for having the separate sessions for the threads was to avoid any possibility of interference between them. I don't know how necessary this is. However, the program worked before and, even if I have to change it, I'd like to know what is happening.

Thanks for any help or suggestions.

Julian

 

Link to comment

1 answer to this question

Recommended Posts

  • 0

I've had similar problems using the rest api on a demo account. I've been using it for around 18 months now. My experience is this: it all works fine for months, then something happens (maybe they update the software or something) then it all goes flakey, struggling to create a session, errors downloading historic data. This can continue for weeks until finally everything goes back to normal again. Based on my time with IG I would describe what you have experienced as normal behaviour for their rest API. It's a shame and is putting me off from going live to be honest.

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
      22,096
    • Total Posts
      92,951
    • Total Members
      42,474
    • Most Online
      7,522
      10/06/21 10:53

    Newest Member
    scobes2
    Joined 17/05/23 10:51
  • Posts

    • What's the next move following the bank run that led to a rally in US stocks? The markets have been giving us hints on its coming trend, which markets are they? Deploying market psychology not only helps us to connect the dots in today’s complexity, it also gives us the simplicity to chart into the future. In this session, we have invited market veteran, Wong Kon How, to help you improve your trading literacy and successfully navigate the financial markets. Kon How will demonstrate how he understands today’s market complexity and seizes the coming opportunity with behavioral science.  
    • Charting the Markets: 1 June Dow and CAC40 stabilise while Nasdaq 100 edges down. EUR/USD, EUR/GBP and USD/CAD stabilise as US debt ceiling bill goes to Senate. And Brent, orange juice stabilise while copper advances as US debt ceiling bill gets signed. Shaun Murison | Senior Market Analyst, Johannesburg | Publication date: Thursday 01 June 2023               This is here for you to catch up but if you have any ideas on markets or events you want us to relay to the TV team we’re more than happy to.
    • Hi all. I have a chunk of cash sitting around and don't really want to allocate it to equities or anything too risky so I was hoping to pick up some regular coupons from something like non-junk bond. I've tried to find bonds on my ISA or Share Dealing account but they don't really seem to exist. I can't find bonds nor ETFs of bonds...  Also can someone help me to understand - like I don't want to bet on the value of bonds or rates going up. I only care about dumping cash in bonds and receiving regular coupons. I understand that the prices of bonds go up and down and therefore you may make a gain/loss on your principal if you sell before maturity, but I kinda want a low-risk bond and want to hold it to maturity. Or at least something that has that kind of risk-reward profile.
×
×
  • Create New...