Coder Social home page Coder Social logo

ashleydavis / ig-cfd-cli Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 3.0 21 KB

CLI tool and API for the IG CFDs API.

License: MIT License

JavaScript 0.98% Batchfile 2.04% TypeScript 96.98%
javascript typescript quantitative-trading algorithmic-trading trading trading-bot

ig-cfd-cli's Introduction

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.

Click here to 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": "<your-ig-username>",
    "password": "<your-ig-password>",
    "apiKey": "<your-ig-apikey>"
}

You can start your config.json with a copy of the template config.json:

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

ig-cfd-cli price-history <epic> <max-bars> [<resolution>]

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).

ig-cfd-cli's People

Contributors

ashleydavis avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.