IG Trading Library
Typed operations and safe workflows for IG's REST and streaming APIs.
The library removes protocol decisions from trading code. You call IG concepts such as
markets.search, positions.create, and confirmations.get; the library owns authentication,
endpoint paths, IG protocol versions, response normalisation, safe-read retries, mutation
ambiguity, and streaming recovery.
| Direct HTTP | This library |
|---|---|
| Choose a path and protocol version | Call one named operation |
| Build and validate dictionaries | Use typed request and response models |
| Reimplement auth, retry, and redaction | Share one hardened transport |
| Risk retrying an uncertain trade | Receive AmbiguousExecutionError |
| Compose trade confirmation manually | Use a safe workflow |
One mental model
IG(config)
├── operations one faithful typed IG call
└── workflows a journey composed only from operations
- Use
ig.operationswhen the IG reference names the call you need. - Use
ig.workflowswhen you need a complete journey such as open and confirm. - Use
AsyncIGwithawaitin applications built onasyncio. - Treat library v4 as the Python package version; IG protocol versions stay private.
Install
pip install ig-trading-lib==4.0.3
Python 3.11–3.13 is supported.
Discover and inspect
from ig_trading_lib import Environment, IG, IGConfig, SessionCredentials
config = IGConfig(
environment=Environment.DEMO,
credentials=SessionCredentials(
api_key="your-api-key",
identifier="your-identifier",
password="your-password",
),
)
with IG(config) as ig:
matches = ig.operations.markets.search("EUR/USD")
market = ig.operations.markets.get(matches.markets[0].epic)
print(market.instrument.epic, market.snapshot.market_status if market.snapshot else None)
Provider-added response fields remain available while documented fields are typed and
normalised to snake_case.
Trade and confirm
from ig_trading_lib import CreatePositionRequest, IG, TradingPermit
request = CreatePositionRequest(
epic="CS.D.EURUSD.CFD.IP",
direction="BUY",
size=1,
order_type="MARKET",
currency_code="GBP",
)
with IG(config, trading_permit=TradingPermit()) as ig:
confirmation = ig.workflows.positions.open_and_confirm(request)
print(confirmation.deal_status, confirmation.deal_id)
TradingPermit is mandatory for live mutations. Network failures after a mutation may raise
AmbiguousExecutionError; reconcile the deal before deciding whether to issue another request.
If confirmation retrieval fails after IG returns a deal reference, DealConfirmationError
preserves that reference so you can retrieve the existing confirmation without replaying the trade.
Async
from ig_trading_lib import AsyncIG
async with AsyncIG(config) as ig:
matches = await ig.operations.markets.search("EUR/USD")
Documentation
- Documentation
- PyPI
- Getting started
- Operation reference
- Types and exceptions
- Library reference
- Machine-readable API index
- Source
The automated suite uses mocked IG responses. It never submits a real demo or live trade.
Metadata
Release files for ig-trading-lib 4.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ig_trading_lib-4.0.3.tar.gz | 28.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ig_trading_lib-4.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 65.9 kB
Release files / ig_trading_lib-4.0.3.tar.gz
| Download URL | ig_trading_lib-4.0.3.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb8f30a0bc3370f2eab3b2750dbc3874c2fac2d1d98e199a60264a91008ea14c
|
|
BLAKE2b-256 checksum How to use checksums |
23815295b6db2d61103c309867589d60068dd39a61f0262a5b22aab3ec4be56e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / ig_trading_lib-4.0.3-py3-none-any.whl
| Download URL | ig_trading_lib-4.0.3-py3-none-any.whl |
|---|---|
| Size | 37.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70da7ae7c2c9a3dee417f6270877c6164fa216ccdcfc627e898fcccb01680d33
|
|
BLAKE2b-256 checksum How to use checksums |
4478d1e446fb9488f10cee314bae872a7e6643b7de59b9b4157ee9c6e23f4dd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Security for ig-trading-lib 4.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.