VBNet Sample (Yes really)

Collapse
This is a sticky topic.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jabe
    Senior Member
    • Dec 2014
    • 705

    #166
    Originally posted by SimonN View Post
    It comes up fine for Match odds ie home team, away team, and draw.

    But for other markets like Both teams to score or over/under goals I can't seem to get the selectionId market name eg yes/no, under/over.
    Hi Simon

    Fairly easy - square brackets in JSON denote an array, so all you need to do it add more comma-separated items, like this:

    someCodes: ["Code1","Code2","Code3","Etc"]

    Some of the values you can use for marketTypeCodes can be obtained via the listMarketTypes (no parameters required). However, if I recall correctly, they only appear if there are only actual current markets of a particular type.

    For the over/under markets, the codes don't have a decimal point in the marketTypeCode. For example, over/under 5.5 goals has marketTypeCode = OVER_UNDER_55. You can get the yes/no or over/under names from the marketCatalogue - they are the "runner" names and will be called "Over 5.5 goals" or "Under 5.5 goals". If you do a listMarketCatalogue call with "BOTH_SIDES_TO_SCORE", the runner names will be available (not sure what they are, or I'd tell you!).

    Something like this will do the job for you for specifying multiple marketTypeCodes (this has doubled-up quotes for VB):

    """filter"":{""eventIds"": [" & matchId & "],""marketTypeCodes"": [""MATCH_ODDS"",""CORRECT_SCORE"",""OVER_UNDER_25"" ,""OVER_UNDER_35""]},""maxResults"": ""10"",""marketProjection"":[""RUNNER_DESCRIPTION"",""MARKET_START_TIME""]")

    Here is the output for a listMarketTypes call run at about 02:16 23/07/2016:

    {"jsonrpc":"2.0",
    "result":[
    {"marketType":"NONSPORT","marketCount":36},{"marke tType":"ASIAN_HANDICAP","marketCount":603},{"marke tType":"BOTH_TEAMS_TO_SCORE","marketCount":649},{" marketType":"OVER_UNDER_65","marketCount":603},{"m arketType":"OVER_UNDER_55","marketCount":603},{"ma rketType":"FIRST_HALF_GOALS_15","marketCount":601} ,{"marketType":"DRAW_NO_BET","marketCount":615},{" marketType":"OVER_UNDER_05","marketCount":646},{"m arketType":"OVER_UNDER_75","marketCount":602},{"ma rketType":"OVER_UNDER_85","marketCount":603},{"mar ketType":"CORRECT_SCORE2","marketCount":13},{"mark etType":"TEAM_B_1","marketCount":603},{"marketType ":"FIRST_HALF_GOALS_05","marketCount":599},{"marke tType":"DOUBLE_CHANCE","marketCount":602},{"market Type":"ODD_OR_EVEN","marketCount":60},{"marketType ":"TEAM_A_1","marketCount":602},{"marketType":"MAT CH_ODDS","marketCount":1151},{"marketType":"OVER_U NDER_25","marketCount":704},{"marketType":"OVER_UN DER_15","marketCount":647},{"marketType":"OVER_UND ER_45","marketCount":650},{"marketType":"OVER_UNDE R_35","marketCount":648},{"marketType":"TOTAL_GOAL S","marketCount":108},{"marketType":"CORRECT_SCORE ","marketCount":652},{"marketType":"HALF_TIME_SCOR E","marketCount":601},{"marketType":"HALF_TIME","m arketCount":605},{"marketType":"NEXT_GOAL","market Count":603},{"marketType":"HALF_TIME_FULL_TIME","m arketCount":605},{"marketType":"STEWARDS","marketC ount":1},{"marketType":"UNUSED","marketCount":19}, {"marketType":"WINNER","marketCount":277},{"market Type":"SPECIALS_NEXT_MGR","marketCount":4},{"marke tType":"UNDIFFERENTIATED","marketCount":39},{"mark etType":"SEASON_SPECIALS","marketCount":17},{"mark etType":"GRAND_SLAM_SPECIALS","marketCount":1},{"m arketType":"TOURNAMENT_WINNER","marketCount":44},{ "marketType":"OUTRIGHT_WINNER","marketCount":55},{ "marketType":"TOP_N_FINISH","marketCount":141},{"m arketType":"SPECIAL","marketCount":34},{"marketTyp e":"OTHER_SPECIALS","marketCount":3},{"marketType" :"HEAD_TO_HEAD","marketCount":22},{"marketType":"W INNER_WITHOUT","marketCount":1},{"marketType":"SER IES_WINNER","marketCount":8},{"marketType":"TOP_WI CKETS_TAKER","marketCount":4},{"marketType":"TOP_B ATSMAN","marketCount":11},{"marketType":"TOURN_MAT CHBET_NOTIE","marketCount":9},{"marketType":"EACH_ WAY","marketCount":50},{"marketType":"WINNING_MARG IN","marketCount":9},{"marketType":"INNINGS_RUNS", "marketCount":11},{"marketType":"5_WICKETS_INNINGS ","marketCount":2},{"marketType":"OPENING_PARTNERS HIP","marketCount":4},{"marketType":"TO_SCORE_100" ,"marketCount":3},{"marketType":"CENTURY_SCORED"," marketCount":4},{"marketType":"TIED_MATCH","market Count":22},{"marketType":"TEST_MATCH_END","marketC ount":4},{"marketType":"TO_SCORE_50","marketCount" :3},{"marketType":"1ST_INNINGS_LEAD","marketCount" :4},{"marketType":"FIRST_HALF_GOALS_25","marketCou nt":600},{"marketType":"GAME_BY_GAME_03_01","marke tCount":43},{"marketType":"GAME_BY_GAME_02_13","ma rketCount":43},{"marketType":"GAME_BY_GAME_02_10", "marketCount":43},{"marketType":"GAME_BY_GAME_02_0 9","marketCount":43},{"marketType":"GAME_BY_GAME_0 2_12","marketCount":43},{"marketType":"GAME_BY_GAM E_02_11","marketCount":43},{"marketType":"SET_WINN ER","marketCount":281},{"marketType":"NUMBER_OF_SE TS","marketCount":43},{"marketType":"TIE_BREAK","m arketCount":43},{"marketType":"6-0_SET","marketCount":43},{"marketType":"PLAYER_A_W IN_A_SET","marketCount":42},{"marketType":"PLAYER_ B_WIN_A_SET","marketCount":43},{"marketType":"GAME _BY_GAME_02_04","marketCount":43},{"marketType":"G AME_BY_GAME_02_03","marketCount":42},{"marketType" :"SET_CORRECT_SCORE","marketCount":42},{"marketTyp e":"GAME_BY_GAME_02_02","marketCount":42},{"market Type":"SET_BETTING","marketCount":141},{"marketTyp e":"GAME_BY_GAME_02_01","marketCount":42},{"market Type":"GAME_BY_GAME_01_13","marketCount":42},{"mar ketType":"GAME_BY_GAME_02_08","marketCount":43},{" marketType":"GAME_BY_GAME_02_07","marketCount":43} ,{"marketType":"GAME_BY_GAME_02_06","marketCount": 43},{"marketType":"GAME_BY_GAME_02_05","marketCoun t":43},{"marketType":"GAME_BY_GAME_01_08","marketC ount":42},{"marketType":"GAME_BY_GAME_01_07","mark etCount":42},{"marketType":"GAME_BY_GAME_01_06","m arketCount":42},{"marketType":"GAME_BY_GAME_01_12" ,"marketCount":42},{"marketType":"TOTAL_GAMES","ma rketCount":3},{"marketType":"GAME_BY_GAME_01_11"," marketCount":42},{"marketType":"GAME_BY_GAME_01_10 ","marketCount":42},{"marketType":"GAME_BY_GAME_01 _09","marketCount":42},{"marketType":"HANDICAP","m arketCount":20},{"marketType":"GAME_BY_GAME_03_10" ,"marketCount":43},{"marketType":"GAME_BY_GAME_03_ 09","marketCount":43},{"marketType":"GAME_BY_GAME_ 03_08","marketCount":43},{"marketType":"GAME_BY_GA ME_03_07","marketCount":43},{"marketType":"GAME_BY _GAME_03_06","marketCount":43},{"marketType":"GAME _BY_GAME_03_05","marketCount":43},{"marketType":"G AME_BY_GAME_03_04","marketCount":43},{"marketType" :"GAME_BY_GAME_03_03","marketCount":43},{"marketTy pe":"GAME_BY_GAME_03_02","marketCount":43},{"marke tType":"GAME_BY_GAME_03_13","marketCount":43},{"ma rketType":"GAME_BY_GAME_03_12","marketCount":43},{ "marketType":"GAME_BY_GAME_03_11","marketCount":43 },{"marketType":"SESSION_RUNS","marketCount":3},{" marketType":"1ST_DISMISSAL_METHOD","marketCount":5 },{"marketType":"FORECAST","marketCount":99},{"mar ketType":"TOTAL_RUNS_LISTED","marketCount":15},{"m arketType":"RUN_LINE_LISTED","marketCount":60},{"m arketType":"TOTAL_POINTS","marketCount":9},{"marke tType":"CLEAN_SHEET","marketCount":117},{"marketTy pe":"WIN_BOTH_HALVES","marketCount":118},{"marketT ype":"TEAM_A_WIN_TO_NIL","marketCount":103},{"mark etType":"OTHER_PLACE","marketCount":308},{"marketT ype":"WIN","marketCount":377},{"marketType":"OVER_ UNDER","marketCount":6},{"marketType":"GAME_BY_GAM E_01_01","marketCount":41},{"marketType":"GAME_BY_ GAME_01_03","marketCount":41},{"marketType":"GAME_ BY_GAME_01_02","marketCount":41},{"marketType":"GA ME_BY_GAME_01_04","marketCount":41},{"marketType": "GAME_BY_GAME_01_05","marketCount":41},{"marketTyp e":"FIRST_GOAL_ODDS","marketCount":102},{"marketTy pe":"TEAM_B_WIN_TO_NIL","marketCount":102},{"marke tType":"HALF_MATCH_ODDS","marketCount":2},{"market Type":"MATCH_ODDS_UNMANAGED","marketCount":14},{"m arketType":"PLACE","marketCount":171},{"marketType ":"TRAP_CHALLENGE","marketCount":4},{"marketType": "TO_QUALIFY","marketCount":14},{"marketType":"TWO_ BALLS","marketCount":20},{"marketType":"PRACTICE_S ESSIONS","marketCount":1},{"marketType":"QUALIFYIN G_WINNER","marketCount":2},{"marketType":"QUALI_WI NNER_DOUBLE","marketCount":1},{"marketType":"QUALI FYING_ROUND_3","marketCount":1},{"marketType":"TO_ BE_CLASSIFIED","marketCount":1},{"marketType":"SAF ETY_CAR","marketCount":1},{"marketType":"TOTAL_CLA SS_DRIVERS","marketCount":3},{"marketType":"FASTES T_LAP","marketCount":1},{"marketType":"WINNING_CAR ","marketCount":1},{"marketType":"POINTS_FINISH"," marketCount":1},{"marketType":"TOTAL_MATCH_POINTS" ,"marketCount":1},{"marketType":"TEAM_A_2","market Count":8},{"marketType":"PENALTY_TAKEN","marketCou nt":12},{"marketType":"ANYTIME_SCORE","marketCount ":8},{"marketType":"TEAM_A_3","marketCount":8},{"m arketType":"TEAM_B_2","marketCount":8},{"marketTyp e":"TEAM_B_3","marketCount":8},{"marketType":"MATC H_ODDS_AND_OU_25","marketCount":7},{"marketType":" OVER_UNDER_105_CORNR","marketCount":7},{"marketTyp e":"CORNER_ODDS","marketCount":7},{"marketType":"T O_SCORE","marketCount":6},{"marketType":"SENDING_O FF","marketCount":7},{"marketType":"BOOKING_ODDS", "marketCount":7},{"marketType":"FIRST_GOAL_SCORER" ,"marketCount":6},{"marketType":"ANTEPOST_WIN","ma rketCount":50},{"marketType":"RACE_WIN_DIST","mark etCount":3},{"marketType":"HIGHEST_OVER_TOTAL","ma rketCount":6},{"marketType":"FIRST_OVER_RUNS","mar ketCount":4},{"marketType":"COMPLETED_MATCH","mark etCount":18},{"marketType":"TOTAL_SIXES","marketCo unt":6},{"marketType":"MATCH_ODDS_LO_TIE","marketC ount":18},{"marketType":"OVER_UNDER_85_CORNR","mar ketCount":3},{"marketType":"SHOWN_A_CARD","marketC ount":2},{"marketType":"TO_SCORE_2_OR_MORE","marke tCount":2},{"marketType":"TEAM_TOTAL_GOALS","marke tCount":6},{"marketType":"HAT_TRICKED_SCORED","mar ketCount":3},{"marketType":"MATCH_ODDS_AND_BTTS"," marketCount":3},{"marketType":"TO_SCORE_HATTRICK", "marketCount":2},{"marketType":"TO_SCORE_BOTH_HALV ES","marketCount":6},{"marketType":"OVER_UNDER_135 _CORNR","marketCount":3},{"marketType":"WINCAST"," marketCount":2},{"marketType":"OVER_UNDER_45_CARDS ","marketCount":3},{"marketType":"CORNER_MATCH_BET ","marketCount":3},{"marketType":"HALF_WITH_MOST_G OALS","marketCount":3},{"marketType":"SCORE_CAST", "marketCount":2},{"marketType":"PLAYER_180S","mark etCount":4},{"marketType":"MOST_180S","marketCount ":2},{"marketType":"TOTAL_180S","marketCount":2},{ "marketType":"RACE_TO_3_LEGS","marketCount":2},{"m arketType":"HIGHEST_CO_PLAYER","marketCount":2},{" marketType":"TOTAL_LEGS","marketCount":2},{"market Type":"HIGHEST_CO_SCORE","marketCount":2},{"market Type":"METHOD_OF_VICTORY","marketCount":26},{"mark etType":"ROUND_BETTING","marketCount":8},{"marketT ype":"GO_THE_DISTANCE","marketCount":8},{"marketTy pe":"SUPER_OVER","marketCount":1},{"marketType":"T OP_GOALSCORER","marketCount":3},{"marketType":"MAT CH_BET","marketCount":21},{"marketType":"ROCK_BOTT OM","marketCount":1},{"marketType":"MAKE_THE_CUT", "marketCount":2}
    ],
    "id":1}
    Last edited by jabe; 23-07-2016, 02:27 AM.

    Comment

    • SimonN
      Junior Member
      • Dec 2014
      • 71

      #167
      BTTS Which is YES? Which is NO?

      Hello Jabe!

      Nice to see you again and nice to see you still enjoying BF coding.

      Yes thank you I can get the marketID's and the respective prices for the constituent runners but where are the labels for these prices coming from (see attched screenshot).

      Of the Runners SelectionID's how do I know what the market is? In BTTS, which is YES and which is NO?

      Thanks mate,

      Si
      Attached Files

      Comment

      • SimonN
        Junior Member
        • Dec 2014
        • 71

        #168
        ...and as usual after spending hours looking around the moment I ask I find.

        It must just be your magical aura, Jabe, simply by turning up!

        RunnerCatalog!!

        selectionId The unique id for the selection.
        runnerName The name of the runner

        Comment

        • jabe
          Senior Member
          • Dec 2014
          • 705

          #169
          Hi Simon

          Enjoying might not quite be the word! Not enough progress - life getting in the way.

          On your question:

          If you query the marketCatalogue with the marketId, it'll tell you the labels - i.e. the runner names - for the two selectionIds.

          So here's the guts of a listMarketCatalogue request for that marketId:

          "filter": {"marketIds": ["1.125620668"],"marketTypeCodes": ["BOTH_TEAMS_TO_SCORE"]},"maxResults": "10","marketProjection":["RUNNER_DESCRIPTION","MARKET_START_TIME", "COMPETITION"]}

          and this is what comes back:

          {"jsonrpc":"2.0","result":[{"marketId":"1.125620668","marketName":"Both teams to Score?","marketStartTime":"2016-07-23T23:30:00.000Z","totalMatched":76.26,"runners":[{"selectionId":30246,"runnerName":"Yes","handicap" :0.0,"sortPriority":1},{"selectionId":110503,"runn erName":"No","handicap":0.0,"sortPriority":2}],"competition":{"id":"141","name":"MLS"}}]}

          The 30246 is Yes and the 110503 is No. It appears that these two outcomes always have the same selectionId and runnerName, but that might not be 100% guaranteed for the future (it might be worth searching the whole forum to see what the BDP people say about that). I'd say it's always worth getting the marketCatalogue for each market that you're interested in and that way you can get the runnerNames and selectionIds for all possible winners in the market.

          Comment

          • SimonN
            Junior Member
            • Dec 2014
            • 71

            #170
            Haha as you can tell life has been getting in the way of my progress and I'm rusty as hell, lol.

            Thank you for shinning the spot light on the Selection ID labels- that's really helpful to see it set out like that and I managed to get it working in the end the way I want it.

            Any ideas why does the available to lay (for example) prices returned not reflect the same prices as when you go to BF site and view the market when the amounts are only small (shows bigger values)?

            How can I reflect the same available prices precisely as I see on Betfair market site?

            GetListMarketBookRequestString = "{""marketIds"":[""" & marketID & """],""priceProjection"":{""priceData"":[""EX_BEST_OFFERS""]}}"

            Cheers.

            Si
            Last edited by SimonN; 24-07-2016, 11:56 PM.

            Comment

            • jabe
              Senior Member
              • Dec 2014
              • 705

              #171
              Sorry, Simon, I missed your 3.50 post where you said you'd found the runnerCatalogue. I must have clicked Reply but only actually posted the reply some time later.

              I don't know why the available amounts don't match what shows on the website. One possibility is the virtualise = true option. It's complicated and the name might not be its most helpful aspect, but it means that there is more available to satisfy bets by cross-matching. There is a description of how it works, and I'll find a link for it. Good luck with understanding it! In the end, we don't need to understand it, but just be aware that it's there and is used.
              http://docs.developer.betfair.com/do...i/Virtual+Bets

              I don't know if it will entirely solve your problem.

              Comment

              • SimonN
                Junior Member
                • Dec 2014
                • 71

                #172
                Thanks Jabe.

                I did actually add the virtualize option and I thought it worked but then upon further cross checking I found examples of odds with smaller amounts on offer not being picked up, so I don't know.

                Will keep digging.

                No worries on the missed post. I always seem to learn something extra from your posts!

                Si

                Comment

                • SimonN
                  Junior Member
                  • Dec 2014
                  • 71

                  #173
                  Background process to update DB with JSON market data

                  I am a complete novice with this but...

                  I have a small MVC C# application reading an SQL database which I would like to be updated by a background process updating the DB with a BF JSON request potentially up to every minute or few seconds.

                  What is the best way to implement the background JSON DB update? In the MVC app on a persistent timer (is that even possible?) or independently in a separate process with an executable with a programmatic timer or using some kind of scheduler?

                  Thank you and appreciated.

                  Comment

                  • Grantay.
                    Junior Member
                    • Jan 2010
                    • 53

                    #174
                    Background BF Updates

                    SimonN,

                    I do something similar in one of my betting apps. (Vb.Net)

                    Simply stated I do this:

                    1) Create a queue of markets I want to bet on (these are linear in time so I am only betting into a market 1 at a time)
                    2) Market is set to update every x seconds
                    3) At n seconds before the scheduled jump, bets are placed according to my rules
                    4) Move to next race in the q.

                    I manage all this with timers, and it works well - there are issues if a race or meeting gets shifted, the q needs to be reset.

                    Other ways to handle it would be multi threading a process to manage multiple markets simultaneously.

                    Grantay

                    Comment

                    • Valeri
                      Junior Member
                      • May 2016
                      • 1

                      #175
                      TreeView

                      Hello !
                      Please help with the TreeView .
                      I would be very grateful for the explanation of the code or sending request logic of filling the Tree markets and all relevant information .
                      Thanks

                      Comment

                      • SimonN
                        Junior Member
                        • Dec 2014
                        • 71

                        #176
                        Thank you, Grantay - good to know you're succeeding with that solution.

                        Thinking about your suggestion and different languages, forgive me, are there any disadvantages using a completely separate technology outside of the MVC/C# front end solution.

                        Could I just as well use Python or VB for example? There's no dependencies between the two processes - as long as the DB is frequently updated on a timer the MVC application doesnt need to know anything about that process since it is only reading the DB.

                        I say this because I have already developed in python and VBA quite a lot of the Betfair JSON request and parsing routines which would be easier to adapt than starting from scratch in MVC/C for this backend update side of the system. (see attached image)

                        https://drive.google.com/file/d/0B-S...ew?usp=sharing
                        Attached Files
                        Last edited by SimonN; 23-08-2016, 09:24 PM.

                        Comment

                        • Grantay.
                          Junior Member
                          • Jan 2010
                          • 53

                          #177
                          Languages

                          Simon

                          Of course it is possible to develop your app in any language. There are worked examples in both c# and Python in the forum. As a senior developer once said to me - Time and Money - anything and everything can be done if you have those, including landing on the moon.

                          Grantay

                          Comment

                          • SimonN
                            Junior Member
                            • Dec 2014
                            • 71

                            #178
                            haha cheers Grantay.

                            I have had a look at the C Sharp examples and got my single stepping entrance in VS debugger to follow the logic so at least I would know where to start.

                            As you say though time and money. I'll make a decision shortly when I reach the right point to switch from working on the client side MVC part.
                            Last edited by SimonN; 24-08-2016, 02:09 AM.

                            Comment

                            • SimonN
                              Junior Member
                              • Dec 2014
                              • 71

                              #179
                              Hello again,

                              I'm having trouble submitting multiple marketID's to ListMarketBook. It works fine when I use one marketID but anymore than one and the return string is empty.

                              Here's my syntax:

                              SINGLE WORKS.
                              marketID = "1.126416833"
                              Code:
                               GetListMarketBookRequestString = "{""marketIds"":[""" & marketID & """],""priceProjection"":{""priceData"":[""EX_BEST_OFFERS""]}}"
                              MULTIPLE DOESNT WORK.
                              marketID = "1.126416833, 1.126507716"
                              Code:
                               GetListMarketBookRequestString = "{""marketIds"":[""" & marketID & """],""priceProjection"":{""priceData"":[""EX_BEST_OFFERS""]}}"
                              MULTIPLE RETURNS:
                              Code:
                              {"jsonrpc":"2.0","result":[],"id":1}
                              Searching forum as we speak but if anyone knows appreciate picking your brains!

                              Cheers, Simon

                              Comment

                              • SimonN
                                Junior Member
                                • Dec 2014
                                • 71

                                #180
                                Got it - sorry - damn double quotes lol.

                                For anyone else for confirmation it should be:

                                marketID = "1.126416833"", ""1.126507716"

                                Comment

                                Working...
                                X