Tennis?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Burdett
    Junior Member
    • Sep 2012
    • 29

    #1

    Tennis?

    Although my code is pinned below, I can't seem to filter to a tennis match (to differentiate from a horse example) and effectively find tennis players(or runners?). Can anyone point out something obvious? Thank you.


    I'm not understanding yet, why the following call made, becomes an index out of range:
    Calling: SportsAPING/v1.0/listMarketCatalogue With args: {"filter":{"eventTypeIds":["2"],"marketCountries":["AU","US","GB"],"marketTypeCodes":["WIN"],"marketStartTime":{"from":"2016-01-26T17:36:39.1951801+00:00","to":"2016-01-29T17:36:39.1951801+00:00"}},"marketProjection":["RUNNER_METADATA"],"sort":"FIRST_TO_START","maxResults":"2","locale" :null}




    My Code Used:


    Console.WriteLine("\nBeginning sample run!\n");

    try
    {
    var marketFilter = new MarketFilter();


    //if you want a population of eventypes....
    var eventTypes = client.listEventTypes(marketFilter);
    // forming an eventype id set for the eventype id extracted from the result
    ISet<string> eventypeIds = new HashSet<string>();
    foreach (EventTypeResult eventType in eventTypes)
    {
    if (eventType.EventType.Name.Equals("Tennis"))
    {
    Console.WriteLine("\nFound event type for Tennis: " + JsonConvert.SerializeObject(eventType));


    //extracting eventype id, dab basically gets the eventtypeID from the text you supply i.e. tennis
    eventypeIds.Add(eventType.EventType.Id);
    }
    }


    //ListMarketCatalogue: Get next available event, parameters:
    var time = new TimeRange();
    time.From = DateTime.Now;
    time.To = DateTime.Now.AddDays(3);

    marketFilter = new MarketFilter();
    marketFilter.EventTypeIds = eventypeIds;
    marketFilter.MarketStartTime = time;

    //market countries appears to be the location of the events (not legal betting territories)
    marketFilter.MarketCountries = new HashSet<string>() { "AU", "US", "GB" };
    marketFilter.MarketTypeCodes = new HashSet<String>() { "WIN" };

    var marketSort = MarketSort.FIRST_TO_START;
    var maxResults = "2";

    //as an example we requested runner metadata
    ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
    marketProjections.Add(MarketProjection.RUNNER_META DATA);
    //marketProjections.Add(MarketProjection.EVENT_TYPE) ;



    Console.WriteLine("\nGetting the next available event selected markets");

    var marketCatalogues = client.listMarketCatalogue(marketFilter, marketProjections, marketSort, maxResults);


    //Test we can identify certain criteria
    var description = new RunnerDescription();
    description = marketCatalogues[0].Runners[0];

    string myName = description.RunnerName;
    string mySelectionID = "MySelectionID = " + description.SelectionId.ToString();
    string markets = marketCatalogues.Count.ToString();

    Console.WriteLine("The name of the selection is: " + myName + " " + mySelectionID + " " + " Number of Races in Pool = " + markets);

    //extract the marketId of the next event
    String marketId = marketCatalogues[0].MarketId;

    // Console.WriteLine(marketCatalogues[0].Description.ToString());

    IList<string> marketIds = new List<string>();
    marketIds.Add(marketId);


    ISet<PriceData> priceData = new HashSet<PriceData>();
    //get all prices from the exchange
    priceData.Add(PriceData.EX_BEST_OFFERS);



    var priceProjection = new PriceProjection();
    priceProjection.PriceData = priceData;

    Console.WriteLine("\nGetting prices for market: " + marketId);

    var marketBook = client.listMarketBook(marketIds, priceProjection);


    // try to get the total participants selected book (tennis = 2)

    string runners = marketBook[0].NumberOfActiveRunners.ToString();

    if (marketBook.Count != 0)
    {

    Console.WriteLine("Total number of active runners in the race: " + runners);



    Console.WriteLine("\nDONE!");

    }
    else
    {
    Console.Write("\nSorry the market has no runner to place a bet on, try again later");
    }

    }
    catch (APINGException apiExcepion)
    {
    Console.WriteLine("Got an exception from Api-NG: " + apiExcepion.ErrorCode);
    Environment.Exit(0);
    }
    catch (System.Exception e)
    {
    Console.WriteLine("Unknown exception from application: " + e.Message);
    Environment.Exit(0);

    }



    }




    }
    }
  • betdynamics
    Junior Member
    • Sep 2010
    • 534

    #2
    Probably because there is no "WIN" market for Tennis matches.

    For Tennis events, you have:

    MATCH_ODDS
    SET_WINNER
    SET_BETTING
    TOURNAMENT_WINNER

    and a few other markets.

    Try using the Visualiser to look more at the types of events you are interested in and you will find things a lot easier.

    Comment

    • Burdett
      Junior Member
      • Sep 2012
      • 29

      #3
      Tennis. Done.

      Thankyou so much for your help. I now understand; tennis rather than being simpler, is more detailed. In horse racing you just win the race, but tennis players can win set, matches and tournaments and what you say, has now cleared that area of detail for me. It has to be this way. I switched in the below, and managed to place a bet on a tennis market.

      marketFilter.MarketTypeCodes = new HashSet<String>() {"MATCH_ODDS"};

      I will take on-board your advice and take a closer look at the visualiser:
      https://developers.betfair.com/visua...ts-operations/

      Cheers

      Burdett.

      Comment

      Working...
      X