Sort priority to identify runner

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • misiek
    Junior Member
    • Oct 2018
    • 20

    #1

    Sort priority to identify runner

    I need to identify home and away in the runner names, so that I can replace them with "home" and "away" strings. It turns to be hectic task. I have already developed complex logic and getting new cases not covered by that logic very quickly. Some examples below:

    "A Sabalenka" in the event name is "Aryna Sabalenka" as a runner name in match odds market
    "Corinthians U20" in the event name, but "Corinth U20/Corinth U20" in the Half-time/Full-Time soccer market

    I am tired changing this every day, so I thought if I can use sort priority here.

    * will sort priority always be showing runners in following order?
    first team/player of the event name
    second team/player of the event name
    (optional)draw
    * for more complex markets like half-time/full-time, will order of runners be always the same?
    Last edited by misiek; 04-01-2024, 09:10 AM.
  • jabe
    Senior Member
    • Dec 2014
    • 705

    #2
    I've been having a think about this. I had wanted to try some test calls to get some data to look at to see if I could find something obvious and simple. Unfortunately I've mislaid my Bf password, so I can't help with the sequence that First Scorer arrays arrive in.

    But I do have a couple of suggestions that might help.


    I'll start with your problem with team name abbreviations. This shouldn't be a huge problem except where team names are similar, such as in local derby games.

    Taking your example, you have two teams. One name in the Event name is Aryna Sabalenka. Suppose there are two abbreviated names in one place. First, does either abbreviation match one of the two team names in the Event name? If one of them does, it makes it easier.

    But suppose neither does? What I suggest is that you take the first name and loop through the name taking each substring of three characters and seeing whether that string is present in the shorter names of both teams. You would need to get some real world examples to try it out with, but I think it's a fair bet that the name with the most matches (or higher percentage of matches) is the one you want. If you did this process for both team names, I'm pretty sure you're going to get the verdict you want. It might even be possible to do it with one or two characters rather than three characters. It might be that a percentage of matches gives better results rather than just the number of matches.

    There might be games where the verdict is not straightforward. I'm thinking of something ilke Chester v Chesterfield. Every string in Chester is also in Chesterfield, so that's five out of five, or 100%. But not every string in Chesterfield is in Chester, so that would be less than100% and less of a match. You 'd get 5 out of 10, or 50%. If there's a game between Bristol Rovers and Bristol City, the obvious abbreviations to Bristol R and Bristol C would be different when testing for the presence of "l R" and "l C". I suggest you write a simple program to try it out, and perhaps put two longer names in along with a couple of abbreviations for each team. What would help is that shorter names are less likely to be abbreviated and longer ones are more likely to have differences.

    As a further thought, I would expect any team that has its name abbreviated on Betfair to always have it abbreviated in the same way. So, to save you having to do this processing every time they play, you could make a file, perhaps keyed on the longest version of the name, and with the shorter ones returned from a query. A database would work, if you're experienced with those.

    For each match you should only need to do this processing once. Let us know how you get on with it.


    The issue with knowing which team any player belongs to is something else. It appears that full names are used for players on the First Scorer lists, which is a plus. At the moment, the best idea I have for this is that you consider sourcing the team names for each match from some other football site or sites. You could get squad lists from sites such as Soccerbase, but here again you are going to run into the problem of team names that are differently abbreviated. I'd suggest that you start by getting hold of the current league table and then you'd be able to do a matching as I outlined above to decide what names the site uses for your two teams before searching for player lists. You could also add the names the site uses to your database or file of team name abreviations that Betfair uses. You'd maylbe only need to do this once a season for each team. Doing it for cup competitions would need making specific some other way.

    Hope this makes sense. Good luck with it, and if something I've written isn't clear enough or doesn't make sense, let me know and I'll attempt to clarify.

    Comment

    • misiek
      Junior Member
      • Oct 2018
      • 20

      #3
      Thanks Jabe for the answer. Above is actually my current solution. If runner names were just names of home/away, then that would not be an issue. However they can be doubled in half-time/full-time market like in my original example or have various suffixes like "+1". In such cases you don't really know which part of runner name should be replaced on the end and you need to build specific logic for each market type.

      Corinthians U20 in the event name
      Corinth U20 +1 as runner name - I can detect by splitting words, excluding short ones or those available in the other runner and then use contains function between different pieces, but that will not tell me on the end I need to keep +1 in the name.

      Anyway, I changed my code to rely on sort priority (still requires market specific logic, but not that complex as above). We'll see how it goes.
      Last edited by misiek; 05-01-2024, 08:24 AM.

      Comment

      • misiek
        Junior Member
        • Oct 2018
        • 20

        #4
        It seems to be working consistently. If someone is interested, here is the C# code. nodeList3 is list of runner nodes.

        Code:
                                                                if (marketType == "MATCH_ODDS" || marketType == "DRAW_NO_BET" || marketType == "HALF_TIME" || marketType == "TO_QUALIFY"
                                                                    || marketType.StartsWith("SET_WINNER") || marketType == "MONEY_LINE" || marketType == "RT_MATCH_ODDS"
                                                                    || marketType == "MATCH_ODDS_UNMANAGED")
                                                                {
                                                                    switch (sortPriority)
                                                                    {
                                                                        case 1:
                                                                            runnerCode = "Home";
        
                                                                            break;
        
                                                                        case 2:
                                                                            runnerCode = "Away";
        
                                                                            break;
        
                                                                        case 3:
                                                                            runnerCode = "Draw";
        
                                                                            break;
        
                                                                        default:
                                                                            break;
                                                                    }
                                                                }
                                                                else if (marketType == "MATCH_ODDS_AND_BTTS")
                                                                {
                                                                    switch (sortPriority)
                                                                    {
                                                                        case 1:
                                                                            runnerCode = "Home/Yes";
        
                                                                            break;
        
                                                                        case 2:
                                                                            runnerCode = "Away/Yes";
        
                                                                            break;
        
                                                                        case 3:
                                                                            runnerCode = "Draw/Yes";
        
                                                                            break;
        
                                                                        case 4:
                                                                            runnerCode = "Home/No";
        
                                                                            break;
        
                                                                        case 5:
                                                                            runnerCode = "Away/No";
        
                                                                            break;
        
                                                                        case 6:
                                                                            runnerCode = "Draw/No";
        
                                                                            break;
        
                                                                        default:
                                                                            break;
                                                                    }
                                                                }
                                                                else if (marketType == "MATCH_ODDS_AND_OU_25")
                                                                {
                                                                    switch (sortPriority)
                                                                    {
                                                                        case 1:
                                                                            runnerCode = "Home/Under 2.5 Goals";
        
                                                                            break;
        
                                                                        case 2:
                                                                            runnerCode = "Home/Over 2.5 Goals";
        
                                                                            break;
        
                                                                        case 3:
                                                                            runnerCode = "Away/Under 2.5 Goals";
        
                                                                            break;
        
                                                                        case 4:
                                                                            runnerCode = "Away/Over 2.5 Goals";
        
                                                                            break;
        
                                                                        case 5:
                                                                            runnerCode = "Draw/Under 2.5 Goals";
        
                                                                            break;
        
                                                                        case 6:
                                                                            runnerCode = "Draw/Over 2.5 Goals";
        
                                                                            break;
        
                                                                        default:
                                                                            break;
                                                                    }
                                                                }
                                                                else if (marketType == "MATCH_ODDS_AND_OU_35")
                                                                {
                                                                    switch (sortPriority)
                                                                    {
                                                                        case 1:
                                                                            runnerCode = "Home/Under 3.5 Goals";
        
                                                                            break;
        
                                                                        case 2:
                                                                            runnerCode = "Home/Over 3.5 Goals";
        
                                                                            break;
        
                                                                        case 3:
                                                                            runnerCode = "Away/Under 3.5 Goals";
        
                                                                            break;
        
                                                                        case 4:
                                                                            runnerCode = "Away/Over 3.5 Goals";
        
                                                                            break;
        
                                                                        case 5:
                                                                            runnerCode = "Draw/Under 3.5 Goals";
        
                                                                            break;
        
                                                                        case 6:
                                                                            runnerCode = "Draw/Over 3.5 Goals";
        
                                                                            break;
        
                                                                        default:
                                                                            break;
                                                                    }
                                                                }
                                                                else if (marketType.Contains("OVER_UNDER") || marketType.Contains("FIRST_HALF_GOALS") || marketType == "DOUBLE_CHANCE"
                                                                    || marketType == "BOTH_TEAMS_TO_SCORE" || marketType == "HALF_TIME_SCORE" || marketType == "ALT_TOTAL_GOALS"
                                                                    || marketType == "CORRECT_SCORE" || marketType == "SENDING_OFF" || marketType == "CORNER_ODDS"
                                                                    || marketType == "ODD_OR_EVEN" || marketType == "BOOKING_ODDS" || marketType == "MATCH_SHOTS"
                                                                    || marketType == "MATCH_SHOTS_TARGET" || marketType == "CORRECT_SCORE2" || marketType == "PENALTY_TAKEN"
                                                                    || marketType == "NUMBER_OF_SETS" || marketType == "SET_CORRECT_SCORE" || marketType == "PLAYER_B_WIN_A_SET"
                                                                    || marketType == "PLAYER_A_WIN_A_SET" || marketType == "TEAM_A_WIN_TO_NIL" || marketType == "TEAM_B_WIN_TO_NIL"
                                                                    || marketType == "TOTAL_POINTS_LINE" || marketType.StartsWith("CLEAN_SHEET") || marketType == "WIN_BOTH_HALVES"
                                                                    || marketType == "TOTAL_GOALS" || (marketType.StartsWith("OVER_UN_") && marketType.EndsWith("_UNMANAGED"))
                                                                    || marketType == "CORR_SCORE_UNMANAGED" || (marketType.StartsWith("FH_GOAL_") && marketType.EndsWith("_UNMANAGED"))
                                                                    || marketType.StartsWith("RECEIVING_YARDS_") || marketType.StartsWith("PASSING_YARDS_")
                                                                    || marketType.StartsWith("RUSHING_YARDS_"))
                                                                {
                                                                    runnerCode = runnerName;
                                                                }
                                                                else if (marketType == "ASIAN_HANDICAP" || marketType == "HANDICAP")
                                                                {
                                                                    if (sortPriority % 2 == 0)
                                                                    {
                                                                        runnerCode = "Away";
                                                                    }
                                                                    else
                                                                    {
                                                                        runnerCode = "Home";
                                                                    }
                                                                }
                                                                else if (marketType == "COMBINED_TOTAL")
                                                                {
                                                                    if (sortPriority % 2 == 0)
                                                                    {
                                                                        runnerCode = "Over";
                                                                    }
                                                                    else
                                                                    {
                                                                        runnerCode = "Under";
                                                                    }
                                                                }
                                                                else if (marketType.StartsWith("TEAM_A"))
                                                                {
                                                                    switch (sortPriority)
                                                                    {
                                                                        case 1:
                                                                            runnerCode = "Home " + runnerName.Substring(runnerName.LastIndexOf(" ") + 1);
        
                                                                            break;
        
                                                                        case 2:
                                                                            runnerCode = "Away " + runnerName.Substring(runnerName.LastIndexOf(" ") + 1);
        
                                                                            break;
        
                                                                        case 3:
                                                                            runnerCode = "Draw";
        
                                                                            break;
        
                                                                        default:
                                                                            break;
                                                                    }
                                                                }
                                                                else if (marketType.StartsWith("TEAM_B"))
                                                                {
                                                                    switch (sortPriority)
                                                                    {
                                                                        case 1:
                                                                            runnerCode = "Away " + runnerName.Substring(runnerName.LastIndexOf(" ") + 1);
        
                                                                            break;
        
                                                                        case 2:
                                                                            runnerCode = "Home " + runnerName.Substring(runnerName.LastIndexOf(" ") + 1);
        
                                                                            break;
        
                                                                        case 3:
                                                                            runnerCode = "Draw";
        
                                                                            break;
        
                                                                        default:
                                                                            break;
                                                                    }
                                                                }
                                                                else if (marketType == "HALF_TIME_FULL_TIME")
                                                                {
                                                                    switch (sortPriority)
                                                                    {
                                                                        case 1:
                                                                            runnerCode = "Home/Home";
        
                                                                            break;
        
                                                                        case 2:
                                                                            runnerCode = "Home/Draw";
        
                                                                            break;
        
                                                                        case 3:
                                                                            runnerCode = "Home/Away";
        
                                                                            break;
        
                                                                        case 4:
                                                                            runnerCode = "Draw/Home";
        
                                                                            break;
        
                                                                        case 5:
                                                                            runnerCode = "Draw/Draw";
        
                                                                            break;
        
                                                                        case 6:
                                                                            runnerCode = "Draw/Away";
        
                                                                            break;
        
                                                                        case 7:
                                                                            runnerCode = "Away/Home";
        
                                                                            break;
        
                                                                        case 8:
                                                                            runnerCode = "Away/Draw";
        
                                                                            break;
        
                                                                        case 9:
                                                                            runnerCode = "Away/Away";
        
                                                                            break;
        
                                                                        default:
                                                                            break;
                                                                    }
                                                                }
                                                                else if (marketType == "WINNING_MARGIN" || marketType == "SET_BETTING")
                                                                {
                                                                    if (sortPriority <= nodeList3.Count / 2)
                                                                    {
                                                                        runnerCode = "Home " + runnerName.Substring(runnerName.LastIndexOf(" ") + 1);
                                                                    }
                                                                    else
                                                                    {
                                                                        runnerCode = "Away " + runnerName.Substring(runnerName.LastIndexOf(" ") + 1);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    runnerCode = runnerName;
                                                                }
        ​

        Comment

        Working...
        X