NAME

Finance::InteractiveBrokers::SWIG - InteractiveBrokers C++ connector

SYNOPSIS

Create an object as a subclass of Finance::InteractiveBrokers::SWIG::EventHandler:

my $handler = MyEventHandler->new();

Then:

my $ib = Finance::InteractiveBrokers::SWIG->new(
    handler => $handler,    # Your subclassed event handler
);

$ib->eConnect();
$ib->reqCurrentTime();

# This should probably be a better event loop
$ib->processMessags()
    while( $ib->isConnected() );

# Eventually...
$ib->eDisconnect();

DESCRIPTION

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 thus you should read this documentation thoroughly.

HOW IT WORKS

The IB API is available as either a set of C++ or Java source code 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 methods you have called.

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 have complete access to the IB API, delegated through the C++ library.

PREREQUISITES

You must have the following to build and use this module:

  • Finance::InteractiveBrokers::API

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

    The "Simplified Wrapper and Interface Generator", capable of building SWIG interfaces. This module has been tested with versions from 1.3.36-2.0.1.

And optional, but highly recommended:

  • Alien::InteractiveBrokers

    Installs (downloading if necessary) the InteractiveBrokers API files, and provides Perly mechanisms for locating them.

You can find links to SWIG and the IB API in "SEE ALSO".

CONSTRUCTOR

new()

my $ib = Finance::InteractiveBrokers::SWIG->new(
    handler => $handler,    # Subclassed F::IB::SWIG::EventHandler object 
);

ARGUMENTS:

handler = $handler> [ REQUIRED ]

RETURNS: blessed $object, or undef on failure.

initialize()

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.

METHODS

api_methods()

my @api_methods = $ib->api_methods();

or

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.

ARGUMENTS: None.

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'

eConnect()

Small wrapper around the IB API eConnect() call to add DNS resolution. See the "INTERACTIVE BROKERS API" section for full information how to use this.

api_version()

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

INTERACTIVE BROKERS API

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.

SEE ALSO

Finance::InteractiveBrokers::SWIG::EventHandler

Alien::InteractiveBrokers

POE::Component::Client::InteractiveBrokers

Finance::InteractiveBrokers::API

Finance::InteractiveBrokers::Java

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

http://www.interactivebrokers.com/php/apiUsersGuide/apiguide.htm - The IB API documentation

The examples/ directory of this module's distribution.

AUTHORS

Jason McManus, <infidel at cpan.org>

BUGS

Please report any bugs or feature requests to bug-finance-interactivebrokers-swig at rt.cpan.org, or through the web interface athttp://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.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Finance::InteractiveBrokers::SWIG

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright (c) 2010-2011 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.