Jump to content
  • 0

Open and Close positions on python trading_ig



I am new to trading_ig library.

I have connected to my live IG account.

from trading_ig import IGService
from trading_ig_config import config

ig_service = IGService(config.username, config.password, config.api_key, config.acc_type)

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

open_positions = ig_service.fetch_open_positions()
print("open_positions:\n%s" % open_positions)


I have been able to download the latest 100 days of an index:

resolution = 'D'
num_points = 100
response = ig_service.fetch_historical_prices_by_epic_and_num_points(epic, resolution, num_points)
df_ask = response['prices']['ask']
print("ask prices:\n%s" % df_ask)

Now, based on an algorithm that I have created, I want to be able to open and close a position automatically by letting the python code continuously run?

Do I need to use Lightstreamer?

How I open and close a position in Python?

Again, I am new to this and the IG documentation didn't provide much information.

Thanks for your help.

Link to comment

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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
    • Total Posts
    • Total Members
    • Most Online
      10/06/21 10:53

    Newest Member
    Joined 04/02/23 01:29
  • Posts

    • Hello, Is any interest paid on "available" cash (not "margin") in a spread betting account? For example, if I held £10k in an account and had no open positions. The reason for asking is that I understand that proceeds from short sales in a CFD will receive interest (benchmark-2.5%), so was wondering if that applied to all cash, and couldn't find an answer on the web site.   Thanks.
    • Hi @Mark12 If you are trading shares, you will have the option to place a limit order to sell your existing position. When the market opens, please check if your order level is close to where the market is trading. All the best, OfentseIG
    • We have to wait until Friday to find out if the UK economy skirted a recession.   Richard Snow, foreign exchange analyst at Daily FX, tells IGTV’s Jeremy Naylor that after the third quarter contraction of 0.3%, there is a risk around the incoming data for the fourth quarter. Here he discusses GBP/USD as a trade to go short. But what if GDP comes in slightly higher? Richard says that is likely to be largely academic and that he believes the short trade will prevail. Jeremy Naylor | Writer, London | Publication date: Friday 03 February 2023
  • Create New...