Get next race horse racing for win market using python.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sandy
    Junior Member
    • Mar 2019
    • 26

    #1

    Get next race horse racing for win market using python.

    I have been live testing my application and I would like to place an order just before the start of the race. The next event is found using the function supplied by Betfair. This can be seen below this text.

    def getMarketCatalogueForNextGBWin(eventTypeID):

    global now, market_catalouge_results, market_catalogue_req

    if (eventTypeID is not None):
    #print('Calling listMarketCatalouge Operation to get MarketID and selectionId')
    now = datetime.datetime.now(pytz.timezone('GMT')).strfti me('%Y-%m-%dT%H:%M:%SZ')
    #now = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
    market_catalogue_req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketCatalogue", "params": {"filter":{"eventTypeIds":["' + eventTypeID + '"],"marketCountries":["GB"],"marketTypeCodes":["WIN"],'\
    '"marketStartTime":{"from":"' + now + '"}},"sort":"FIRST_TO_START","maxResults":"1","mar ketProjection":["RUNNER_METADATA"]}, "id": 1}'
    """
    print market_catalogue_req
    """
    market_catalogue_response = callAping(market_catalogue_req)
    """
    print market_catalogue_response
    """
    market_catalouge_loads = json.loads(market_catalogue_response)
    try:
    market_catalouge_results = market_catalouge_loads['result']
    return market_catalouge_results
    except:
    print('Exception from API-NG' + str(market_catalouge_results['error']))
    exit()

    To do this I use a scheduler to run my function 1 minute before the start of the race. This sometimes gets market for the next race but often gets the market that follows the next one.

    To resolve this issue I have considered running the function every second and append the market ID to a list. Then if the market ID changes to run my place order function. This should catch all the markets. The problem though with this is that I want to place my order just before the race starts and this method will not do this.

    Is there any way to place an order just before a race starts?

    Cheers,
    Sandy
  • Sandy
    Junior Member
    • Mar 2019
    • 26

    #2
    Furthermore, I have been babysitting my app today and the schedule has not been drifting.

    Comment

    • Sandy
      Junior Member
      • Mar 2019
      • 26

      #3
      I've now had a think about it and I think I have thought of a solution if it is not possible to get the to get the price directly before the race starts.

      I will get the market ID for all races before the days racing starts. I will then use a schedular to pass the market ID just before the race starts and that will run my app with the correct marketID at the correct time. This will require a bit more input from myself to the app but should work.

      Comment

      • jabe
        Senior Member
        • Dec 2014
        • 705

        #4
        You can get all the races in one go at the beginning of your program. There are start times for each race, although it's not unusual for them to start late. It's normal to use timers.

        There is a MarketCatalogue for each race meeting, as well as MarketCatalogues for each race. The Market Catalogue should contain information that does not change. The available odds and available amounts are in the MarketBook. The MarketBook should contain data that might change or will change.

        Comment

        • newbie99
          Junior Member
          • Dec 2018
          • 62

          #5
          Originally posted by Sandy View Post
          I've now had a think about it and I think I have thought of a solution if it is not possible to get the to get the price directly before the race starts.

          I will get the market ID for all races before the days racing starts. I will then use a schedular to pass the market ID just before the race starts and that will run my app with the correct marketID at the correct time. This will require a bit more input from myself to the app but should work.
          I believe it is possible to submit an order, to be placed as the race turns in-play, is that essentially what you're trying to do, or would that not quite work?

          Comment

          • Sandy
            Junior Member
            • Mar 2019
            • 26

            #6
            Ok cheers jabe. This ended up a pretty expensive mistake for me.

            Comment

            • tradernz
              Junior Member
              • Feb 2016
              • 19

              #7
              Hey Sandy Just wondering if you are using the betfairlightweight with python, sounds like your trying to do the same thing that im keen on doing and just wondering if you were able to get this working?

              Cheers
              Rob

              Comment

              Working...
              X