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
      21,157
    • Total Posts
      90,663
    • Total Members
      41,266
    • Most Online
      7,522
      10/06/21 10:53

    Newest Member
    BMadoff
    Joined 26/01/23 23:07
  • Posts

    • Content: US Bond Yields, Dollar DXY, US Gold, Silver, Copper, Lithium, Uranium, Nickel, Crude Oil, Natural Gas Commodities Market Summary: Bond yields and US DXY lower, commodities higher Trading Strategies: Hold Long Lithium, Uranium, Gold, Nickel. Video Chapters 00:00  US Gov Bonds 10 Yr Yields 01:22 US Dollar Index DXY  03:48 US Spot Gold GDX ABX NCM 17:02 US Spot Silver 18:20 US Copper / Lithium / Uranium / Nickel (China, Emerging Markets, stocks) 37:48 Crude Oil, Sector XLE / XOM   44:52 Natural Gas 54:07 TRIAL Buy 1 Month Get 3 Months Analyst Peter Mathers TradingLounge™ Australian Financial Services Licence - AFSL 317817 Source: tradinglounge com      
    • Tesla reported earnings of $1.19 per share after the US market close yesterday - four cents higher than analyst expectations. While revenue was at a record high it came in just short of the bullish expectations at $24.32 billion.  Jeremy Naylor | Writer, London | Publication date: Thursday 26 January 2023 Tesla shares up on earnings Tesla shares rose 8% yesterday in extended trade on the IG platform, up a further notch higher by a margin of 5% on from what we saw during full trading yesterday. And this is as a result of earnings out late last night. Let's take a look at the figures. The electric carmaker reported earnings of $1.19 per share after the US markets closed. That's $0.04 higher than analysts expected. Revenue was just short of expectations at $24.32 billion. These are record numbers, according to the company. In a call to investors, CEO Elon Musk said he expected a pretty difficult recession this year for the US economy. But demand for Tesla vehicles, he says, will be good, despite a probable contraction in the automotive market as a whole, adding that absent external disruptions, 2023 deliveries could hit two million vehicles. Share price chart Overall, let's take a look at the share price chart. This stock is now up 51% from the lows that we had back in January and I'm talking January this year. So it's just shy of three weeks. That is a whopping increase. But you've got to bear in mind, the stock has fallen substantially from the record highs we saw back on the 4th of November 2021. We've lost 75.6% of overall value in Tesla. So this uptick here when you're looking at this sort of improvement from those lows, it is an incredible move in terms of percentages, but it's risen from $103 up to $152. So that's what we're opening this morning at 9:00 UK time, extended trade after that big gain yesterday on those numbers coming through from Tesla.
×
×
  • Create New...