Announcement

Collapse
No announcement yet.

C++ RequestTimeSales returns NULL handle

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • C++ RequestTimeSales returns NULL handle

    In the following example, a request for timesales returns a null handle, but the request for daily history returns a valid handle.

    TimeSalesFilter f;
    f.sSymbol =S2B(ax_symbol);
    f.lNumDays=1;
    f.bQuotes=1;
    f.bTrades=1;
    f.bFilterPrice=0;
    f.bFilterVolume=0;
    f.bFilterTradeExchanges=0;
    f.bFilterQuoteExchanges=0;
    f.dMinPrice=0;
    f.dMaxPrice=0;
    f.lVolume=0;
    f.sQuoteExchangesList=S2B("");
    f.sTradeExchangesList=S2B("");
    m_hHistory2 = (*m_piHooks)->GetRequestTimeSales(&f);

    m_hHistory = (*m_piHooks)->GetRequestHistory(S2B(ax_symbol), "D", btBARS,2,-1,-1);

  • #2
    COM Interface Requires CString/BSTR Initialization

    Hi Giaru,

    I looked into your code and the C++ sample. C++ and the COM interface require a little more work than VB.

    You must initialize each field that has a BSTR value. It's safest to supply a value for each field. Try the following code:

    #1: Modify S2B in EventSink.h as follows:

    inline BSTR S2B(CString s) {
    return s.AllocSysString();
    }


    #2: Ensure each field is assigned a proper value

    TimeSalesFilter f;

    f.sSymbol = S2B(ax_symbol);
    f.bQuotes = TRUE;
    f.bTrades = TRUE;
    f.lNumDays = 1;
    f.bFilterPrice = FALSE;
    f.bFilterVolume = FALSE;
    f.bFilterQuoteExchanges = FALSE;
    f.bFilterTradeExchanges = FALSE;
    f.dMaxPrice = 0;
    f.dMinPrice = 0;
    f.lVolume = 0;
    f.sQuoteExchangesList = S2B("");
    f.sTradeExchangesList = S2B("");

    // I think the S2B function may not have worked
    // properly before. I think S2B("") didn't operate as
    // expected.

    m_hHistory2 = (*m_piHooks)->GetRequestTimeSales(&f);




    I will look at the documentation to detemine if it also needs to be updated.

    I hope this helps,

    - Todd -
    Last edited by TGafford; 09-16-2003, 02:48 PM.
    Todd Gafford | Developer Support and API Product Manager | Interactive Data Desktop Solutions
    3955 Point Eden Way, Hayward, CA 94545

    Comment


    • #3
      Your code improvements did seem to help. I am now getting about 5 OnTimeSalesChanged events. Each time I am running the following code and being told that I have zero bars to read.

      It is also not clear to me how to know when I have gotten all the data I requested, so I can release the handle.


      void CMainDlg::ES_OnTimeSalesChanged(long l) {
      long lNumBars;
      long lNumRtBars;
      TimeSalesData baritem;

      lNumBars = 0;
      lNumRtBars = (*m_piHooks)->GetGetNumTimeSalesRtBars(m_hHistory2);
      lNumBars = (*m_piHooks)->GetGetNumTimeSalesBars(m_hHistory2);
      for (long i = -(lNumBars-1); i <= 0; i++) {
      baritem = (TimeSalesData)((*m_piHooks)->GetGetTimeSalesBar(m_hHistory2, i));
      }



      }

      Comment


      • #4
        My mistake. I missed the following change, and it fixed the problem:

        inline BSTR S2B(CString s) {
        return s.AllocSysString();
        }

        Comment

        Working...
        X