Skip to content

Iceloof/IG-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IG.com Trading API

PyPI PyPI - Downloads PyPI - Python Version PyPI - Wheel GitHub contributors GitHub issues GitHub Action GitHub

Install

pip install ig-trading-api

or

pip install --upgrade ig-trading-api

Usage

  • Initializing
import igapi
ig = igapi.IG(apikey, username, password, account, acc_type)
  • Check version
print(ig.getVersion())
  • Login
ig.login()
  • Logout
ig.logout()
  • Get account information
account = ig.account()
  • Get account balance
ig.getBalance()

or

ig.getBalance(account)
  • Get account available balance
ig.getAvailable()

or

ig.getAvailable(account)
  • Get account deposit
ig.getDeposit()

or

ig.getDeposit(account)
  • Get account getProfitLoss
ig.getProfitLoss()

or

ig.getProfitLoss(account)
  • Get watchlists
watchlists = ig.watchlists()
  • Get specific watchlist
watchlist = ig.watchlist(id)
  • Get account transactions
transactions = ig.getAccountTransactions(type='ALL',period=86400)
  • Get account activities
activities = ig.getAccountActivities()
  • Get price
price = ig.getPrice(epic, [resolution], [numPoints])
  • Get prices
prices = ig.getPrices(epic, [resolution], [numPoints],[start],[end])
  • Get open positions
positions = ig.getOpenPosition([dealId])
  • Create position
dealReference = ig.createPosition(currency, direction, epic, expiry, orderType, size, [limitDistance], [stopDistance], [forceOpen], [guaranteedStop])
  • Close position
dealReference = ig.closePosition(dealId, direction, epic, expiry, orderType, size)

Example

order = ig.createPosition('AUD', 'BUY', 'IX.D.NASDAQ.IFA.IP', '-', 'MARKET', 2, 20, 40)

dealReference = ig.closePosition([dealId],'SELL',  '-', 'MARKET', 2)