Jump to content
  • 0

Open and Close positions on python trading_ig


GP79

Question

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)
ig_service.create_session()

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

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

print("")

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

epic = 'IX.D.SPTRD.DAILY.IP'
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
×
×
  • Create New...