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" ;

In reply to Win32::OLE BLPGetHistoricalData by yuvyuv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.