Jump to content

GP79

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by GP79

  1. 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.

×
×
  • Create New...
us