NAME
Finance::TWS::Simple::HistoricalData - request historical quotes
VERSION
version 0.000_01
SYNOPSIS
my $contract = $tws->struct(Contract => {
symbol => 'EUR',
secType => 'CASH',
exchange => 'IDEALPRO',
localSymbol => 'EUR.USD',
});
my $data = $tws->call(ContractDetails => {
contract => $contract,
duration => '2 W',
bar_size => '1 day',
bar_type => 'BID_ASK',
outside_rth => 1,
});
printf(
"%-18s | %-7s | %-7s | %-7s | %7s\n",
'date', 'open', 'high', 'low', 'close',
);
print "-------------------|---------|---------|---------|---------\n";
foreach my $bar (@$data) {
printf(
"%-18s | %7.5f | %7.5f | %7.5f | %7.5f\n",
$bar->date,
$bar->open,
$bar->high,
$bar->low,
$bar->close,
);
}
DESCRIPTION
Return historical quotes (for different time periods).
PARAMETER
contract
Protocol::TWS::Simple::Struct::Contract object.
duration
Format: Integer plus space plus S|D|W (seconds, days, weeks).
bar_size
Valid values: "1 sec", "5 secs", "15 secs", "30 secs", "1 min", "2 mins", "3 mins", "5 mins", "15 mins", "30 mins", "1 hour", "1 day".
end_date
DateTime object, or correctly formatted timestamp ("%Y%m%d %H:%M:%S").
Defaults to yesterday 23:59:59.
bar_type
Valid values: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", "HISTORICAL_VOLATILITY", "OPTION_IMPLIED_VOLATILITY".
Defaults to "TRADES".
outside_rth
Boolean to also include quotes outside regular trading hours (RTH).
Defaults to false (meaning only regular trading hours).
RESULT
Arrayref of Protocol::TWS::Simple::Struct::BarData objects.
SEE ALSO
http://www.interactivebrokers.com/php/apiUsersGuide/apiguide.htm#apiguide/c/contract.htm, http://www.interactivebrokers.com/php/apiUsersGuide/apiguide.htm#apiguide/c/reqhistoricaldata.htm, Protocol::TWS::Struct::Contract, Protocol::TWS::Struct::BarData
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.