Skip to main content

Simple IG trading API for Python

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ig-trading-api-1.0.6.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

ig_trading_api-1.0.6-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page