NAME
Finance::TWS::Simple - simple InteractiveBrokers API (blocking abstraction over AnyEvent::TWS)
VERSION
version 0.000_01
SYNOPSIS
use Data::Dumper;
use Finance::TWS::Simple;
my $tws = Finance::TWS::Simple->new;
my $contract = $tws->struct(Contract => {
symbol => 'EUR',
secType => 'CASH',
exchange => 'IDEALPRO',
localSymbol => 'EUR.USD',
});
my $details = $tws->call(ContractDetails => {contract => $contract});
warn Dumper $details;
DESCRIPTION
A simple, blocking layer above AnyEvent::TWS and Protocol::TWS to access InteractiveBrokers Traders Workstation (TWS) API.
Use it in simple scripts, e. g. to retrieve historical data.
CONSTRUCTOR
new
Constructor, connects to InteractiveBrokers API. Accepts the same parameters as AnyEvent::TWS->new (host, port and client_id - all have useful defaults).
METHODS
call
Calls an (abstracted) API function. First parameter name (equals class name of subclass), second parameter (hashref) arguments.
Have a look at the other classes in this distribution to know which function calls are available:
At the moment the abstractions are quite limited, email me your suggestions.
struct
Shortcut for instanciating Protocol::TWS::Struct subclasses. First parameter name (equals class name), second parameter (hashref) arguments to the constructor.
INTERNAL METHODS
Not really internal, you may use them. But normally you don't have to. These are used from the subclasses.
next_id
Returns the next (unused) request ID (see AnyEvent::TWS->next_valid_id).
ae_call
Shortcut to AnyEvent::TWS->call. First parameter is an object (which implements cb
method), second parameter is Protocol::TWS::Request object. The response is handed to the cb
method.
request
Shortcut for instanciating Protocol::TWS::Request subclasses. First parameter name (equals class name), second parameter (hashref) arguments to the constructor.
BUGS AND SUPPORT
Bugs are quite likely, as I did not try all requests/responses. If you find a bug, please email me a code example together with a description what you expect as result.
If you have any questions or suggestions feel free to email me as well. There are a lot of abstractions missing.
Also, if you have any examples that I can include, I would appreciate it.
SEE ALSO
http://www.interactivebrokers.com/en/p.php?f=programInterface, http://www.interactivebrokers.com/php/apiUsersGuide/apiguide.htm#apiguide/c/c.htm, Protocol::TWS, AnyEvent::TWS
AUTHOR
Uwe Voelker <uwe@uwevoelker.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Uwe Voelker.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.