Announcement

Collapse
No announcement yet.

Synchronous Retrieval

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

  • Synchronous Retrieval

    I am responding to your request to create a new thread to readdress issues previously.

    As far as basic quote retrieval [GetBasicQuote], it seems there is no easy way to synchronously request a quote, i.e., block the procedure until the quote has been retrieved. The object fills quickly, but not immediately. Initially I thought it was too much overhead to wait for an out-of-procedure event to fire in order to collect the quote, but now I'm actually wondering about the soundness of applying an identical methodology to both the RequestSymbol(, "true") and "false" cases.

    Here's what I'm saying. When you retrieve a quote with "true", indicating you wish to receive realtime updates for it, events begin to fire and you can process them using event logic to manage a stream of symbol updates. (Like if I were to create some sort of ticker.)

    However, let's say I need just one quote, and my application cannot proceed until I have it. In that case, I should issue the same request with "false", catch the event, and then that's that. But that's really no different than issuing the request with "true", and simply releasing the handle when the event I'm looking for is caught. What "false" should do is provide me with an IsQuoteReady function, where I can just wait for the object to be filled and process. It doesn't seem like the ActiveX API provides, at this point, a true "on-demand" functionality for quote retrieval. I can simulate on-demand, but without guessing as to how long it will take, it's very difficult to procedurally retrieve a quote.

    Worse yet, assuming I can recognize when the event I've semantically designated as "on-demand" fires, if a user passes an invalid symbol, this event never fires. It doesn't time out or issue data indicating my symbol is invalid, it just sits there forever. So unless I program a timeout -- which is hard to set, because it's not up to me, and given CPU load can cause this object fill to be arbitrarily long -- there's no way to count on a simulated procedural quote retrieval ever finishing.

    Certainly there are satisfactory, if not stellar, workarounds, but it seems easy enough to even just fill a quote object directly from a request, with the understanding that it might be a few seconds. But the API is in the position to tell me when it's ready, and it's imperfect for me to guess or busy-wait on it. I don't know if other users have critical blocking points like the one I'm describing, but this issue revolves around the situation when regardless of an event queue, an immediate and highest-priority quote check is required.

  • #2
    FYI

    pxctmarkm,

    I received this from one of our developers:


    I did fix that, but it is also possible that the event would fire after the call completed, but before the user could make another call.

    Like this (in pseudocode):

    myHandle = GetSomeHistory(mySymbol)
    <*** EVENT for myHandle fires ***>
    myListOfHandles[myHandle] = mySymbol

    This could happen, though it's a tough thing to test.

    Comment


    • #3
      Hi Robi,

      By synchronous retrieval, I believe he is asking for a non-event based mechanism for quote retrieval. I agree that if you just want the last bid/ask/trade price for a symbol and don't want to receive updates for that symbol, that having to use an event-based (aka callback-ish) system seems a bit complex/overkill. That being said, I have never needed such synchronous calls in my trading app as everything I do expects streaming updates and the asynchronous event style works best for me.

      As far as the bug fix mentioned:

      I did fix that, but it is also possible that the event would fire after the call completed, but before the user could make another call.

      Like this (in pseudocode):

      myHandle = GetSomeHistory(mySymbol)
      <*** EVENT for myHandle fires ***>
      myListOfHandles[myHandle] = mySymbol
      If it has been fixed so that an event won't get fired until GetSomeHistory() has returned a handle, then, assuming these lines of pseudo-code are contained within the same function body, this seems impossible to me in a single-threaded application. Well, an event could be ready for firing, but the app wouldn't be able to process it until the Windows message pump resumes and that wouldn't happen until the function has completed and the callstack unwinds back up to the message pump. So I can't see anyway for the storing of the handle into the array to not have completed before an OnHistoryWhatever() event function is called (in a single-threaded app, which is what I assume pretty much everyone here is doing at this point).

      BTW, I'm not saying that I have noticed the bug in 7.6 as I haven't looked for it. Just trying to understand what was fixed exactly. I assume it is that an event won't fire until after GetSomeHistory() has returned.

      Cheers... George

      Comment


      • #4
        Our developer made the following comment:

        Following up to genspoo's comment, he is exactly right.

        The bug was fixed precisely by deferring the event to the message queue, so it won't fire until sometime after the javascript loses it's scope.

        Comment


        • #5
          Our developer made the following comment:

          Following up to genspoo's comment, he is exactly right.

          The bug was fixed precisely by deferring the event to the message queue, so it won't fire until sometime after the javascript loses it's scope.

          Comment

          Working...
          X