Stream API Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geoffw123
    Senior Member
    • Mar 2014
    • 250

    #1

    Stream API Question

    Hi

    I have just started looking at the new Stream API and playing with the demo code Betfair put on Github.

    The demo is working OK, but I am wondering if there is a protocol design flaw with the order subscription command ?

    If you have already got some matched orders when you start up your App (or the Betfair demo) there seems to be no way to get the BetIds of those already matched orders ?

    You can get any unmatched order BetIds, and you can get the BetIds of any subsequent matches, but I cant see how you can get the initial ones ?
    The demo program from Betfair certainly has this failing but not sure if its a protocol flaw or just something they haven't implemented in their demo App.

    The data structures for the new Stream API are pretty complicated, so I could easily have missed something ?

    Thanks for any assistance.

    Regards Geoff
  • geoffw123
    Senior Member
    • Mar 2014
    • 250

    #2
    Hi

    In case this is of use to anyone in the future, I will update my question. The protocol doesn't allow you to get the already matched betId's as I suggested in my question. Its not too bad to workaround though as you just use listCurrentOrders when the App starts up to get that missing data.


    Another little oddity I tripped over is that the placed and matched dates I had assumed would be DotNet DateTime types (my pdf doc file doesn't mention the data types). It turned out that the dates are in UnixTime form * 1000. Wonder why they changed this from the API-NG ?

    For info, its easy enough to get it back in DateTime form, just divide by 1000 and call this function.
    Code:
    public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
    {
        // Unix timestamp is seconds past epoch
        System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
        dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
        return dtDateTime;
    }

    Comment

    • LiamP
      Junior Member
      • Oct 2015
      • 284

      #3
      The initial image gives you all active bets, matched or unmatched, looks like betfairs demo code is wrong....

      Comment

      • geoffw123
        Senior Member
        • Mar 2014
        • 250

        #4
        Hi liam

        Thanks for the reply, however I have come to the exact opposite conclusion to this. There is no way using the stream API that you can get the initial BetIds for the already matched bets when an App starts up.

        If you look at page 12 of the doc, it states

        This is the ChangeMessage stream of data we send back to you once you subscribe to the order stream.

        Then it shows two nodes

        1: unmatched orders --> Below this there is a betId and other data

        2: Price point / full depth Ladders --> This contains a list of matched prices and stakes but no betIds

        hence my conclusion.

        Regards Geoff

        Comment

        • LiamP
          Junior Member
          • Oct 2015
          • 284

          #5
          Matched bets will show in unmatched orders.

          Comment

          • geoffw123
            Senior Member
            • Mar 2014
            • 250

            #6
            Hi

            Do we agree that the Betfair demo App, doesn't show any existing matched bets when you start it up and you tell it to subscribe to orders ?

            If your answer to that is yes, then you must be saying somehow the demo App is filtering out those matched orders and not printing them to the console when you tell it to list orders.

            Do you have an explanation why the demo App doesn't show them ?

            Geoff

            Comment

            • Escapee
              Junior Member
              • Feb 2009
              • 51

              #7
              I am in the process of upgrading my programs to use the streaming API. My appkey works fine with API-NG.

              When I try the 'Authenticate' call to the streaming API, I get a "NOT-AUTHORISED" response.

              QUESTION:

              Do I need to ask Betfair to enable my appkey for streaming API to be able to use it for both API-NG and streaming API ?


              Thanks in advance

              Comment

              • geoffw123
                Senior Member
                • Mar 2014
                • 250

                #8
                Yep, you need to send Neil an email to ask to be authorised. (Tell him your Appkey in the email)

                Don't ask me why they have added this restriction, as streaming has already been implemented in several of the commercial Apps. It cant really be classed as an experimental feature now.

                Regards Geoff

                PS. I am in the process of adding it now too, maybe we can compare notes if we get stuck. Its gonna take me a while though.

                Comment

                • LiamP
                  Junior Member
                  • Oct 2015
                  • 284

                  #9
                  Sorry Geoff you are correct the streaming API does not provide info for matched bets on an individual basis if matched before you start streaming.

                  My confusion was due to the fact you are given detailed info on matched bets if it is matched after streaming has started as you get an update.

                  Comment

                  • Dodgee
                    Junior Member
                    • Jan 2009
                    • 17

                    #10
                    Originally posted by geoffw123 View Post
                    Its not too bad to workaround though as you just use listCurrentOrders when the App starts up to get that missing data.
                    Out of interest, how are you doing this reliably (i.e. ensuring nothing is missed between calling listCurrentOrders and subscribing to the order stream?

                    I'm subscribing to the stream first, then calling listCurrentOrders and inserting any missing EC orders into my cache, then making sure the total from all the matched bets corresponds with the Matches returned by the stream.

                    I do worry that I'll somehow miss some bets though! Not sure why the order stream isn't consistent with the market stream (i.e. the first image contains all orders in full).

                    Comment

                    • ShootnikD
                      Junior Member
                      • Oct 2012
                      • 11

                      #11
                      Are Betfair planning to close old(not streaming) api in future?

                      Comment

                      • jabe
                        Senior Member
                        • Dec 2014
                        • 705

                        #12
                        Originally posted by ShootnikD View Post
                        Are Betfair planning to close old(not streaming) api in future?
                        No. I think that is extremely unlikely.

                        Comment

                        Working...
                        X