PrePAN

Sign in to PrePAN

Finance::IG Module gor using IG Markets REST API.

Author
TheDoktar@github
Date
URL
Status
In Review
Good

Synopsis

          use Finance::IG;
          use strict;
          no strict 'refs';
          use warnings;

          my $ig=Finance::IG->new(
                       username=> "myusername",
                       password=> "mypassword",
                       apikey=>   "myapikey",
                       isdemo=>0,
          );
          $ig->login;

          my $p=$ig->positions();    #  Get a list of positions
          $p=$ig->agg($p);            #  Aggregate them, and sort, so one item per instrument.

          my $format="%-41sinstrumentName %+6.2fsize %-9.2flevel ".
                  "%-9.2fbid £%-8.2fprofit %5.1fprofitpc%% £%10.2fatrisk\n",

          $ig->printpos("stdout" , [], $format);

          for my $position (@$p)
          {
              $ig-> printpos("stdout" ,$position,$format);
          }

Description

The sample code lists your positions and prints them out in a 1 line per position format.

Transactions and accounts can be listed in a similar way.

This code is at an early stage and should serve as a framework for further additions.

I invite anyone who has an IG account and uses the REST API with an api key to try it and advise how you get on.

Comments

Please sign up to post a review.