Jump to content
  • 0

Access Account via REST API with Python Code




I have created a demo account so I got the username, password and api_key but I can't the python code to access my account?
I would apreciate a full python code very much.

I have tried this code:

from trading_ig import IGService
#from trading_ig.config import config  - If I use this line it says: ImportError: cannot import name 'config' from 'trading_ig.config' 


ig_service = IGService(username, password, api_key)

account_info = ig_service.switch_account(acc_number, False) # not necessary


But revecies the error  "KeyError: 'LOGGED_IN'


Link to comment

1 answer to this question

Recommended Posts

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

    • This is not an acceptable explanation for me unfortunately, I am fully aware of the need to move spreads and I had accounted for that. Especially at the open of a market, but your spread was totally unreasonable the spread on DEC contracts is already at 130pip standard, to increase it to 400pips and hold it there even after 5 mins of trading. As my execution was a 09:06 the main market volatility had already been accounted for.   So disappointing after 6years being a customer and on a profitable trade as well: 
    • Dear @MB1470, Thank you for your post. Please note that dealing spreads on shares are subject to variation, especially in volatile market conditions or other unusual circumstances.  Market spreads can widen significantly, particularly at the beginning and end of the trading day, and minimum spreads may exist. Thanks, KoketsoIG
    • This morning at the market open on NOVO DEC contracts. On Spread Bet.    the spread moved from 138pips to close to 400 pips? How can this be reasonable the candle is only displayed on a 15-2min time period not on smaller periods. At market open 09:00 ????? How is this even remotely reasonable?     
  • Create New...