Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ig-trading-api

bennycode257MIT0.13.9TypeScript support: included

IG Trading API for Node.js, written in TypeScript.

API, CFD, finance, fintech, derivatives, IG, trading, TypeScript

readme

IG Trading API

Language Details Code Coverage License Package Version Dependency Updates

Unofficial IG Trading API for Node.js, written in TypeScript and covered by tests.

Features

  • Typed. Source code is 100% TypeScript. No need to install external typings.
  • Tested. Code coverage is 100%. No surprises when using ig-trading-api.
  • Maintained. Automated security updates. No threats from outdated dependencies.
  • Documented. Get started with the generated documentation.

Installation

npm

npm install ig-trading-api

Yarn

yarn add ig-trading-api

Usage

You can set the API gateway, when initializing the API client. Use APIClient.URL_DEMO (demo-api.ig.com) for demo accounts and APIClient.URL_LIVE (api.ig.com) for live account access.

Login

import {APIClient} from 'ig-trading-api';

const client = new APIClient(APIClient.URL_LIVE, {
  apiKey: 'your-api-key',
  username: 'your-username',
  password: 'your-password',
});

Search Trading Symbol

Make sure to use IG's Epic codes to find a trading symbol:

const query = 'BITCOIN';
const response = await client.rest.market.searchMarkets(query);
console.log(response.markets[0].epic);

Show available resolutions

Check the available intervals for retrieving data:

import {APIClient, Resolution} from 'ig-trading-api';
console.log(Resolution);

Retrieve historical data

const epic = 'UC.D.MSFT.CASH.IP';
const prices = await client.rest.market.price.getPrices(epic, Resolution.DAY, 5);

Subscribe to live data

Here is how you can subscribe to live candles and other updates from IG:

More Examples

More code examples can be found in the demo directory.

Resources

IG Instrument Identifier (Epic)

Breakdown for "IX.D.DOW.DAILY.IP":

Symbol Description Example
IX Hours of trading "Index Out of Hours"
D Tradability "D" when tradeable
DOW Underlying market "Dow Jones"
DAILY Indicator for processing method "Daily" funded bet
IP Asset type "Intellectual Property"

Epics for testing:

Epic Name Environment Trading Time
ED.D.DHERGY.CASH.IP Delivery Hero SE Live / Demo Germany: 09:00 - 17:30
UC.D.MSFT.CASH.IP Microsoft Corp Live / Demo Germany: 10:00 - 03:00
UA.D.COINUS.CASH.IP Coinbase Global Inc Live Germany: 15:30 - 22:00

Development Setup

You can get up and running in just a few simple steps:

  1. Run yarn (to install or update third-party dependencies)
  2. Have a look at the .env.defaults file and make a copy (including your own credentials) with the name .env in the root directory of this repository (read more about dotenv files)
  3. Run yarn demo:login to test your credentials

Maintainers

Benny Neugebauer on Stack Exchange

Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

License

This project is MIT licensed.

⭐️ Show your support ⭐️

Please leave a star if you find this project useful.

changelog

0.13.9 (2024-06-17)

0.13.8 (2024-05-09)

Documentation Changes
New Features
  • Add subscriptions for Account, Trade and Ticks (#581) (874586d9)

0.13.7 (2023-10-03)

0.13.6 (2023-08-24)

0.13.5 (2023-08-14)

Documentation Changes
Bug Fixes
  • Git working directory not clean (a131afbf)
  • Git working directory not clean (9006407d)
Other Changes

0.13.5 (2023-08-14)

Documentation Changes
Bug Fixes
  • Git working directory not clean (a131afbf)
  • Git working directory not clean (9006407d)
Other Changes

0.13.5 (2023-08-14)

Documentation Changes
Bug Fixes
  • Git working directory not clean (a131afbf)
  • Git working directory not clean (9006407d)

0.13.5 (2023-08-14)

Documentation Changes
Bug Fixes
  • Git working directory not clean (a131afbf)
  • Git working directory not clean (9006407d)

0.14.0 (2023-08-14)

Chores
Documentation Changes
Bug Fixes
  • Git working directory not clean (a131afbf)
  • Git working directory not clean (9006407d)

0.13.5 (2023-08-14)

Chores
Documentation Changes
Bug Fixes
  • Git working directory not clean (9006407d)

0.13.5 (2023-08-14)

Chores
Documentation Changes

0.13.5 (2023-08-14)

Chores
Documentation Changes

0.13.5 (2023-08-14)

Chores
Documentation Changes

0.13.5 (2023-08-14)

Chores
Documentation Changes

0.13.5 (2023-08-14)

Chores

0.13.4 (2022-07-21)

Chores

0.13.3 (2022-02-19)

Chores
Documentation Changes
Bug Fixes
  • Formatting of timestamps on streamed market prices (#339) (c6388077)

0.13.3 (2022-02-19)

Chores
Bug Fixes
  • Formatting of timestamps on streamed market prices (#339) (c6388077)

0.13.2 (2021-09-21)

Chores
  • Upgrade dependencies (8ecaa940)
  • Run dependency updates once each month (435e155d)
  • deps-dev:
  • deps: bump @types/node from 15.12.4 to 15.14.9 (#281) (6b05b105)
Other Changes
  • deps-dev: bump typedoc from 0.21.9 to 0.22.0 (#283)" (42d7e3d9)

0.13.1 (2021-09-08)

Chores

0.13.0 (2021-05-11)

New Features
  • client: Automatically create trading session with username and password (#169) (2cb80b39)

0.12.0 (2021-05-10)

Chores
  • Update lockfile (a6de4ba7)
  • Add auto-merge for dependency updates (076a553a)
  • deps-dev:
  • deps:
Documentation Changes
New Features
  • login: Support login credentials in constructor (#168) (119b153f)

0.12.0 (2021-05-10)

Chores
  • deps-dev:
  • Add auto-merge for dependency updates (076a553a)
  • deps:
Documentation Changes
New Features
  • login: Support login credentials in constructor (#168) (119b153f)

0.11.1 (2021-04-27)

Chores
  • deps-dev:
    • bump eslint from 7.24.0 to 7.25.0 (#151) (694d4815)
    • bump typedoc from 0.20.35 to 0.20.36 (#153) (1f98e6db)
    • bump eslint-config-prettier from 8.2.0 to 8.3.0 (#152) (5060e40f)
    • bump typedoc-plugin-markdown from 3.7.1 to 3.7.2 (#154) (eac69382)
New Features
Tests

0.11.0 (2021-04-22)

Chores
  • deps-dev:
    • bump @types/luxon from 1.26.3 to 1.26.4 (#146) (bd8ca059)
    • bump @typescript-eslint/parser from 4.21.0 to 4.22.0 (#143) (8b96ffdb)
    • bump eslint-plugin-prettier from 3.3.1 to 3.4.0 (#145) (1490f8a7)
    • bump typedoc-plugin-markdown from 3.6.1 to 3.7.1 (#144) (1b169719)
    • bump eslint-config-prettier from 8.1.0 to 8.2.0 (#147) (e318517b)
    • bump @typescript-eslint/eslint-plugin (#149) (18d9166c)
  • deps: bump @types/node from 14.14.37 to 14.14.41 (#148) (ca2e611c)
  • Update Codecov GitHub Action (fba0f0e6)
Documentation Changes
New Features

0.10.1 (2021-04-14)

Bug Fixes
  • client: Remove request timeouts (b4f3e60e)

0.10.0 (2021-04-14)

Chores
Documentation Changes
  • Add links to limits & commissions (2dd175d5)
New Features

0.9.1 (2021-04-13)

Documentation Changes
New Features
Tests

0.10.0 (2021-04-13)

New Features

0.9.0 (2021-04-12)

Chores
Documentation Changes
  • Add link to Streaming companion (66084e68)
New Features

0.8.1 (2021-03-10)

Chores
  • deps-dev:
    • bump eslint-config-prettier from 8.0.0 to 8.1.0 (#100) (84f2a8c2)
    • bump typedoc from 0.20.28 to 0.20.30 (#104) (01db363b)
    • bump @types/luxon from 1.26.0 to 1.26.2 (#106) (8fd138b9)
    • bump @typescript-eslint/parser from 4.15.2 to 4.17.0 (#110) (75a4b3db)
    • bump @types/jasmine from 3.6.4 to 3.6.6 (#103) (8d6e712c)
    • bump eslint from 7.20.0 to 7.21.0 (#98) (0e6379c4)
    • bump typedoc-plugin-markdown from 3.5.0 to 3.6.0 (#97) (4bd84447)
    • bump @typescript-eslint/eslint-plugin (#107) (117ea3fc)
    • bump nock from 13.0.7 to 13.0.11 (#108) (56c04532)
  • deps: bump @types/node from 14.14.31 to 14.14.32 (#102) (27984f82)
Bug Fixes

0.8.0 (2021-02-25)

Chores
  • deps-dev:
    • bump @typescript-eslint/parser from 4.15.1 to 4.15.2 (#93) (f25d903c)
    • bump @typescript-eslint/eslint-plugin (#92) (e2bb66db)
    • bump @types/jasmine from 3.6.3 to 3.6.4 (#82) (c0998d0c)
    • bump typedoc from 0.20.25 to 0.20.28 (#91) (621916f3)
    • bump @types/luxon from 1.25.2 to 1.26.0 (#83) (eaba7731)
    • bump @typescript-eslint/parser from 4.15.0 to 4.15.1 (#85) (21f78c99)
    • bump typedoc-plugin-markdown from 3.4.5 to 3.5.0 (#89) (c527e1c2)
    • bump eslint-config-prettier from 7.2.0 to 8.0.0 (#90) (1fd759d4)
    • bump @typescript-eslint/eslint-plugin (#76) (3cc00b17)
    • bump @types/luxon from 1.25.1 to 1.25.2 (#74) (67287935)
    • bump @typescript-eslint/parser from 4.14.2 to 4.15.0 (#77) (f8252096)
    • bump eslint from 7.19.0 to 7.20.0 (#78) (24f1119f)
    • bump husky from 4.3.8 to 5.0.9 (#79) (c021454c)
    • bump typedoc from 0.20.23 to 0.20.25 (#80) (07389890)
    • bump typescript from 4.1.3 to 4.1.5 (#81) (c9c85749)
  • Ignore husky v5 (563215a7)
  • deps:
    • bump @types/node from 14.14.28 to 14.14.31 (#87) (2a42a239)
    • bump luxon from 1.25.0 to 1.26.0 (#73) (51fd94b1)
    • bump @types/node from 14.14.25 to 14.14.28 (#75) (3de7c7e6)
New Features
Bug Fixes
Refactors
  • Return Lightstreamer client on candle subscription (#94) (f390c65e)

0.7.0 (2021-02-11)

Documentation Changes
New Features

0.6.0 (2021-02-11)

Chores
  • deps-dev:
    • bump lint-staged from 10.5.3 to 10.5.4 (#70) (e96f8682)
    • bump typedoc from 0.20.20 to 0.20.23 (#69) (84affc83)
  • deps: bump @types/node from 14.14.22 to 14.14.25 (#71) (236c89de)
New Features

0.5.1 (2021-02-07)

Bug Fixes

0.5.0 (2021-02-03)

Chores
  • deps-dev:
    • bump @typescript-eslint/parser from 4.14.0 to 4.14.1 (#62) (ee1fb5a3)
    • bump typedoc from 0.20.18 to 0.20.20 (#65) (8e57c68f)
    • bump eslint from 7.18.0 to 7.19.0 (#61) (fd5e7425)
    • bump @typescript-eslint/eslint-plugin (#63) (dc187d28)
    • bump nock from 13.0.6 to 13.0.7 (#64) (9ee6df6a)
    • bump typedoc-plugin-markdown from 3.4.3 to 3.4.5 (#66) (2fe0a2f9)
New Features
Refactors
  • Share demo client in scripts (4ec64730)
Tests
  • Add 100% code coverage for Lightstreamer API (a72c87aa)

0.4.0 (2021-01-28)

New Features
Refactors
  • Turn candlestick dates into strings (67b957ec)

0.3.0 (2021-01-27)

New Features
  • Export interfaces from Market and Dealing API (#57) (54d4af0c)

0.2.0 (2021-01-27)

New Features
Refactors
  • Submit times in ISO 8601 string format (a955b631)

0.1.0 (2021-01-25)

Chores
  • Update to TypeDoc v0.20 (f2d7acad)
  • deps-dev:
    • bump @typescript-eslint/eslint-plugin (#44) (3c18fae8)
    • bump typedoc from 0.20.16 to 0.20.18 (#49) (df728118)
    • bump jasmine from 3.6.3 to 3.6.4 (#45) (3c59b7d1)
    • bump @typescript-eslint/parser from 4.13.0 to 4.14.0 (#46) (1fc39315)
    • bump @types/jasmine from 3.6.2 to 3.6.3 (#48) (6d87e4d0)
    • bump eslint-config-prettier from 7.1.0 to 7.2.0 (#50) (6c86a641)
    • bump typedoc-plugin-markdown from 3.4.0 to 3.4.3 (#51) (c386fda2)
    • bump nock from 13.0.5 to 13.0.6 (#52) (649f8f14)
    • bump eslint from 7.17.0 to 7.18.0 (#38) (64d06c1a)
    • bump @typescript-eslint/parser from 4.12.0 to 4.13.0 (#39) (23904fa2)
    • bump husky from 4.3.7 to 4.3.8 (#40) (2cbc860b)
    • bump typedoc from 0.20.14 to 0.20.16 (#41) (348ef3ad)
    • bump @typescript-eslint/eslint-plugin (#36) (0291a293)
    • bump husky from 4.3.6 to 4.3.7 (#33) (661de6fd)
    • bump eslint from 7.16.0 to 7.17.0 (#25) (e86892f7)
    • bump typedoc and typedoc-plugin-markdown (#32) (2472579f)
    • bump eslint-plugin-prettier from 3.3.0 to 3.3.1 (#34) (c157b3ac)
    • bump @typescript-eslint/parser from 4.11.0 to 4.12.0 (#35) (c6a8719a)
    • bump typedoc-plugin-markdown from 3.0.11 to 3.1.1 (#9) (e0d9619e)
    • bump eslint-config-prettier from 7.0.0 to 7.1.0 (#20) (1fb37069)
    • bump @typescript-eslint/parser from 4.9.0 to 4.11.0 (#23) (ca1b8654)
    • bump ts-node from 9.1.0 to 9.1.1 (#8) (d4d62ce9)
    • bump husky from 4.3.0 to 4.3.6 (#11) (c4746513)
    • bump typescript from 4.1.2 to 4.1.3 (#15) (c0a97275)
    • bump eslint-plugin-prettier from 3.2.0 to 3.3.0 (#13) (40056b7b)
    • bump eslint from 7.15.0 to 7.16.0 (#19) (923b2781)
    • bump @typescript-eslint/eslint-plugin (#21) (60a5ff90)
  • deps:
    • bump @types/node from 14.14.21 to 14.14.22 (#47) (705afbd4)
    • bump @types/node from 14.14.20 to 14.14.21 (#37) (b44fd5ea)
    • bump @types/node from 14.14.16 to 14.14.20 (#30) (7b156da5)
    • bump axios from 0.21.0 to 0.21.1 (#24) (a356a91f)
    • bump @types/node from 14.14.10 to 14.14.16 (#22) (3373d3ad)
Documentation Changes
New Features

0.0.3 (2020-12-07)

Chores
  • deps-dev: bump eslint-config-prettier from 6.15.0 to 7.0.0 (#5) (de283478)
New Features

0.0.2 (2020-12-05)

Chores
  • Upload coverage reports to Codecov (#4) (ead734bf)
  • Add continuous integration (#2) (20f7a249)
  • deps-dev: bump eslint from 7.14.0 to 7.15.0 (#3) (2a9f632e)
Documentation Changes
New Features

0.0.1 (2020-12-04)

Documentation Changes
New Features

0.0.1 (2020-12-04)

New Features