yuvyuv has asked for the wisdom of the Perl Monks concerning the following question:

Hey,

I'm trying to get the last trade in a specific currency as of a certain time. I'm using BLPGetHistoricalData to look back, but there might not be a trade at the exact time, so I'm trying to get the most recent one. In excel there are certain parameters you need to pass with the call in order to get the most recent trade. I'm trying to pass those parameters using Perl, but I must be doing something wrong. Does anyone know if it is even possible to pass these parameters?

Thanks,

use Data::Dumper; use Win32::OLE; use Win32::OLE::Variant; my $blpData = Win32::OLE->new('Bloomberg.Data.1') or die + "can NOT l +oad the blpData" ; #print $blpData->Timeout . "\n"; my $aSec = Variant(VT_BSTR, "COPUSD CURNCY"); my $aFields = Variant(VT_ARRAY|VT_BSTR, 1 ); $aFields->Put(0, "LAST_PRICE"); my $sDate = Variant(VT_DATE, "2009/09/30 15:00:00"); my $eDate = Variant(VT_DATE, "2009/09/30 15:00:01"); ## These are the parameters I'm trying to pass. my $option = Variant(VT_ARRAY|VT_BSTR, 9 ); $option->Put(0, "BarTp=T"); $option->Put(1, "BarSz=1"); $option->Put(2, "Dir=V"); $option->Put(3, "Dts=S"); $option->Put(4, "Sort=A"); $option->Put(5, "Quote=C"); $option->Put(6, "Fill=P"); $option->Put(7, "UseDPDF=Y"); $option->Put(8, "cols=2;rows=1"); my $bbData = Variant(VT_EMPTY, 1); $bbData = $blpData->BLPGetHistoricalData($aSec, $aFields, + $sDate, $ +eDate, $option); print "Error: " . Win32::OLE->LastError . "\n"; #print "Array Size: " , $bbData->Dim . "\n"; #print "Returned: " . $bbData->Get(0) . "\n"; # print Dumper $bbData; for my $e (@$bbData) { my $d = $e->[0]; print "date: $d->[0] " . " Price: $d->[1] \n" ; } print "end" ;

Replies are listed 'Best First'.
Re: Win32::OLE BLPGetHistoricalData
by Anonymous Monk on May 16, 2011 at 14:19 UTC
    Did you get an answe on this ?I'm stuck on the same thing, albeit a couple of years later ...