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
  • image.png

  • Posts

    • The mischievous amphibian who became a meme legend? Well, meet Apu, his wide-eyed, optimistic cousin, taking the internet by storm – and now, perhaps, the world of finance. Apu, also known as Peepo or Helper, is a kinder, gentler Pepe variant. Tired of the often-scammy memecoin scene, Apu (or rather, Apu's devoted community) decided to create something different: $APU, a "fairly launched, fully transparent coin" built by and for "all frens." Here's where things get interesting. $APU's narrative is one of resilience and community power. Fueled by the cryptocurrency community's enthusiasm, $APU was initially launched with the best of intentions. However, the dream took a nasty turn when the original developer pulled the rug – a disheartening scenario for many crypto enthusiasts. Today, $APU stands as a testament to community empowerment. It's a beacon of hope for projects facing similar challenges, a reminder that collaboration and resilience can transform setbacks into stepping stones. It's also worth noting that another community-driven memecoin, $MASSA, recently found a home on the Bitget exchange. Could this be a sign of things to come for $APU? What are your thoughts? Does Apu's story inspire you? Can a memecoin truly become a legitimate force in the volatile world of cryptocurrency? Share your thoughts and predictions in the comments below!
    • The price shown on the graph is the price after the IG's fee taken. That is the reason for discrepancy.
    • I am a relatively newbie. I have seen similar and also have seen automated closed position has a loss though the close price I have set was above the price I have bought. After about 6 months with a lot of mysterious losses though my closing price was above the opening price, I discovered this was because of the amount charged for opening/closing a position. This is right below BUY and SELL boxes on the right in very small font. This amount vary from  0.9 to 33 or more depending on the level of trading at the time you open or close. It also happens (god knows why it is set to be so, except that the trader is not watching) when there is a lot of buying and selling going on, like an important news has suddenly been out and the result was not the market expected. As a result, I delete all my automated BUY/SELL values before I stop trading for the day. Remember, the the software is set up to favor the IG, not the retail seller. That is why 70% or more end up in loss.  
×
×
  • Create New...
us