An open API service indexing awesome lists of open source software.

https://github.com/ashleydavis/ig-cfd-cli

CLI tool and API for the IG CFDs API.
https://github.com/ashleydavis/ig-cfd-cli

algorithmic-trading javascript quantitative-trading trading trading-bot typescript

Last synced: 5 months ago
JSON representation

CLI tool and API for the IG CFDs API.

Awesome Lists containing this project

README

          

# ig-cfd-cli

CLI tool and API for the IG CFDs API.

WORK IN PROGRESS:

- Currently allows price history of a CFD to be downloaded.

To learn more about working with data in JavaScript please read my book [Data Wrangling with JavaScript](http://bit.ly/2t2cJu2).

[Click here to support my work](https://www.codecapers.com.au/about#support-my-work)

## WARNING

Please be aware that if you run this multiple times you can quickly exhaust your data limits with IG.

Use sparingly!

## CLI usage

You must have Node.js installed to use this tool.

Install it globally:

npm install -g ig-cfd-cli

Create config.json in your working directory and fill out your IG account details:

{
"baseUrl": "https://demo-api.ig.com/gateway/deal",
"userName": "",
"password": "",
"apiKey": ""
}

You can start your config.json with a copy of the [template config.json](https://github.com/ashleydavis/ig-cfd-cli/blob/master/example-config.json):

Now run the command line tool to download the price history for a CFD:

ig-cfd-cli price-history []

Options:

- epic - The name of the CFD to download price history.
- max-bars - Max number of bars to download (keep it as small as possible to avoid exhausting your data allowance).
- resolution - Optional resolution of bars, defaults to DAY.

For example to download the price history for the Bitcoin CFD:

ig-cfd-cli price-history CS.D.BITCOIN.CFD.IP 10

This downloads the price history for the requested CFD to a CSV file in the working directory.
It will be named after the epic that was requested.

For example downloading CS.D.BITCOIN.CFD.IP will create the file CS-D-BITCOIN-CFD-IP.csv.

Resolution defaults to DAY, but you can set it to other values such as HOUR:

ig-cfd-cli price-history CS.D.BITCOIN.CFD.IP 10 HOUR

The resolution parameter is passed directly to the IG API, available options are:

MINUTE
MINUTE_2
MINUTE_3
MINUTE_5
MINUTE_10
MINUTE_15
MINUTE_30
HOUR
HOUR_2
HOUR_3
HOUR_4
DAY
WEEK
MONTH

## Missing features

- Document API usage.
- Other commands: Get accounts, get positions, open position, close position, etc.
- Better error checking (eg missing config file).