Finance::InteractiveBrokers::SWIG - InteractiveBrokers API C++ wrapper and connector
Create an object as a subclass of Finance::InteractiveBrokers::SWIG::EventHandler:
my $handler = MyEventHandler->new();
my $ib = Finance::InteractiveBrokers::SWIG->new(
handler => $handler, # Your subclassed event handler
# Your event loop here
while( $ib->isConnected() );
# And eventually...
See the examples/ directory in this distribution for more complete and well-commented examples.
This module provides Perl connectivity to the InteractiveBrokers market data and program trading service, using the IB-provided C++ code. It is primarily intended to be used with POE::Component::Client::InteractiveBrokers, which provides a better API, but may be used standalone if desired, by referring to the IB documentation itself (under "SEE ALSO").
It is a very complex module with an involved build process, and as such, you should read this documentation thoroughly before building or using this module distribution.
The InteractiveBrokers API is available as either a set of C++ or Java source files. This module builds a library from this, and then runs SWIG (the Simplified Interface Wrapper and Generator) against it to provide Perl connectivity.
The API consists of several methods, callable from this module, as well as several events, containing the asynchronous responses from IB to event handlers you have created.
In order to catch the events, you must subclass Finance::InteractiveBrokers::SWIG::EventHandler, and override all of the events therein with your own code to handle their responses (e.g. save them to a database, or do whatever).
You then pass your $handler into "new()", and you will have complete access to the IB API, delegated via XS through the C++ library.
You must have the following to build and use this module:
Provides a programmatic means of looking up methods and events in the IB API.
A working build environment
Capable of compiling C and C++ files, and running 'make'.
SWIG >= 1.3.28
The "Simplified Wrapper and Interface Generator", capable of building SWIG interfaces. This module has been tested with SWIG versions 1.3.28 - 2.0.1.
And optional, but highly recommended:
Installs (downloading if necessary) the InteractiveBrokers API files, and provides Perl-y mechanisms for locating them.
You can find links to SWIG and the IB API in "SEE ALSO".
my $ib = Finance::InteractiveBrokers::SWIG->new(
handler => $handler, # Subclassed F::IB::SWIG::EventHandler object
handler => $handler [ REQUIRED ]
This must be an instantiated object that is a subclass of Finance::InteractiveBrokers::SWIG::EventHandler. It is delegated to when receiving events from the IB service.
Please see Finance::InteractiveBrokers::SWIG::EventHandler for notes on how to subclass it, and the examples/ directory of this distribution.
RETURNS: blessed $object, or undef on failure.
my %leftover = $self->initialize( %ARGS );
Initialize the object. If you are subclassing, override this, not "new()".
ARGUMENTS: %HASH of arguments passed into "new()"
RETURNS: %HASH of any leftover arguments.
my @api_methods = $ib->api_methods();
my @api_methods = Finance::InteractiveBrokers::SWIG::api_methods();
Get a list of IB API methods you can call from this class. These correspond 1:1 to the IB API methods, but they are dynamically dispatched, so you won't find actual sub definitions for them in the source.
RETURNS: @ARRAY of callable IB API methods.
NOTE: You can also get a list of them from the command line, via:
perl -MFinance::InteractiveBrokers::SWIG -e'print Finance::InteractiveBrokers::SWIG::api_methods'
Small wrapper around the IB API eConnect() call to add DNS resolution. See "INTERACTIVE BROKERS API" for full information on how to use the IB API.
my $version = $ib->api_version();
Get the IB API version this module was compiled against.
RETURNS: $scalar containing the version as a string, something like '9.64'.
The IB API is not described in this documentation. You should refer to their website ("SEE ALSO") for notes on how to use it and what methods and events are available.
http://www.swig.org/ - SWIG, the Simplified Wrapper and Interface Generator
The POE documentation, POE::Kernel, POE::Session
http://poe.perl.org/ - All about the Perl Object Environment (POE)
http://www.interactivebrokers.com/ - The InteractiveBrokers website
https://www.interactivebrokers.com/en/software/api/api.htm - The IB API documentation
The examples/ directory of this module's distribution.
Jason McManus, <infidel at cpan.org>
<infidel at cpan.org>
Please report any bugs or feature requests to bug-finance-interactivebrokers-swig at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Finance-InteractiveBrokers-SWIG. The authors will be notified, and then you'll automatically be notified of progress on your bug as changes are made.
bug-finance-interactivebrokers-swig at rt.cpan.org
If you are sending a bug report, please include:
Your OS type, version, Perl version, and other similar information.
The version of Finance::InteractiveBrokers::SWIG you are using.
The version of the InteractiveBrokers API you are using.
If possible, a minimal test script which demonstrates your problem.
This will be of great assistance in troubleshooting your issue.
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
Copyright (c) 2010-2014 Jason McManus
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
The authors are not associated with InteractiveBrokers, and as such, take no responsibility or provide no warranty for your use of this module or the InteractiveBrokers service. You do so at your own responsibility. No warranty for any purpose is either expressed or implied by your use of this module suite.
The data from InteractiveBrokers are under an entirely separate license that varies according to exchange rules, etc. It is your responsibility to follow the InteractiveBrokers and exchange license agreements with the data.
To install Finance::InteractiveBrokers::SWIG, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.