Find the potential commission before a bet is placed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • monkeymagix
    Junior Member
    • Jul 2010
    • 105

    #1

    Find the potential commission before a bet is placed

    I am re-coding a BOT I had built that auto-traded for me on the exchange, however to do that correctly with an overlay (so I win £ whether the horse wins or loses from a back bet with lower stake and higher odds than a LAY bet with a higher stake than the BACK bet and lower matched odds) - there is obviously a commission to be paid if the bet wins which I need to take into consideration when working out the DESIRED BACK/LAY price before placing the bets.

    A £2 LAY bet winning might only return £1.90 after commission is deducted which obviously means I need to know the amount that will be deducted before working out the other side of the trades price, especially if the gap between the BACK and LAY positions are a few ticks.

    Is there a method to call to get the commission that will be deducted OR when I place a bet and it's matched is there a way of finding out the commission I will have to pay if the bet wins before listing settled bet status which is the only article I have seen for getting it e.g:

    Request:


    Code:
    [SIZE=12px][B][{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listClearedOrders", "params": {"betStatus":"SETTLED","eventTypeIds":["7"],"settledDateRange":{},"groupBy":"MARKET"}, "id": 1}[/B][/SIZE]
    and the response

    Code:
    [SIZE=12px][B][{"jsonrpc ":"2.0","result":{"clearedOrders":[{"eventTypeId":"7","eventId":"28947625","marketId" :"1.149312109","placedDate":"2018-10-10T13:20:25.000Z","persistenceType":"LAPSE","order Type":"MARKET_ON_CLOSE","betOutcome":"LOST","settl edDate":"2018-10-10T13:25:34.000Z","lastMatchedDate":"2018-10-10T13:21:02.000Z","betCount":2,"commission":0.0,"p riceReduced":false,"profit":-0.3},{"eventTypeId":"7","eventId":"28917668","mark etId":"1.148478572","selectionId":12819184,"handic ap":0.0,"betId":"138605913699","placedDate":"201 8-09-24T08:50:44.000Z","persistenceType":"LAPSE","order Type":"LIMIT","side":"BACK","betOutcome":"LOST","p riceRequested":1.78,"settledDate":"2018-09-24T14:54:50.000Z","lastMatchedDate":"2018-09-24T08:50:44.000Z","betCount":1,"commission":0.0,"p riceMatched":1.72,"priceReduced":true,"sizeSettled ":2.0,"profit":-2.0},{"eventTypeId":"7","eventId":"28853743","mark etId":"1.146920662","selectionId":2643412,"handicap":0.0,"betId":"134652560450","placedDate":"201 8-08-21T13:51:26.000Z","persistenceType":"PERSIST","ord erType":"LIMIT","side":"LAY","betOutcome":"WON","p riceRequested":2.78,"settledDate":"2018-08-21T15:52:17.000Z","lastMatchedDate":"2018-08-21T13:51:26.000Z","betCount":1,"commission":0.05," priceMatched":2.78,"priceReduced":false,"sizeSettl ed":1.0,"profit":1.0}],"moreAvailable":false},"id":1}][/B][/SIZE]
    I was doing okay before but I totally forgot about the commission deduction from winning bets as just making 100 small trade bets in the last 5 minutes before a race could be just the difference between the BACk and LAY price of a couple of ticks or two and a very small stake difference (which all adds up in the end if all are matched) - but I obviously need the commission to be included in my calculation code that works out the positions of each side of the trade.

    I am using C# API_ING but the JSON would be alright for me to work out what to code.

    Thanks for any help in advance,

    Rob
  • geoffw123
    Senior Member
    • Mar 2014
    • 250

    #2
    Hi

    As far as I can tell there is no way to get the profit/loss info you require prior to settlement of the market. However I think you have a workaround. If you use the listMarketCatalogue() command, and you ask for the description field, that contains "marketBaseRate" which should be the percent commision that you are paying in your country. I havent proved this, so you would have to check. Once you have that you can calculate yourself the P/L on a market net of commision.

    Of course prior to the event you dont know if the commision will be x % or 0 % applied. Thats quite tricky as you need a crystal ball
    Last edited by geoffw123; 24-07-2020, 09:38 AM.

    Comment

    • monkeymagix
      Junior Member
      • Jul 2010
      • 105

      #3
      Yes, a crystal ball would be nice in this game wouldn't it ....

      I've got all the code, I spent ages writing a BOT for their 1st API in SOAP, much less code, 2 classes was all I had plus a list of courses and abbreviations, then just as I was ready to pump some serious money into it as I had made £1500 in the year just testing it with £2 bets (min stake), and as there was no way to use delayed data like there is now I was using real money for testing. I made many mistakes during that time (probably why people put on prices of 1000 on the exchange to trap BOTS taking any position early in the morning).

      I found lots of safety checks, stop loss, max/min prices, max bets to place and stop at % profit made per day were the key factors in any automated betting bot to prevent major losses. One time I forgot to put a limit on the no of unmatched trade bets the BOT could place when doing LAY then BACK, rather than BACK then LAY, and I put on 80 bets before I could stop it and of course they all won their races so I lost £160 from all those £2 LAY bets that weren't matched.

      Anyway as soon as I was ready Betfair only go and change the API to API_ING JSON, I had to spend a whole year on the sly at work rebuilding it, now I have 30+ classes and 10,000+ lines of code (C#), every object has to have its own class, enums, interfaces for both JSON formats, it was a right pain in the a$$ to rewrite, but if the difference in price between the LAY price and BACK price is only a few ticks then the commission in theory can wipe out any profit at 5%-10% of a win.

      So I am trying to think of a way to calculate the possible commission I would be paying if the LAY or BACK bets won so I can use that % in my calculation to make sure the difference in prices between positions are enough to ensure profit. There's no point winning 100 trades if the commission is just going to wipe out any profit etc...

      I am in the UK, and I guess what you mean is to use:

      Code:
      marketProjections.Add(MarketProjection.MARKET_DESCRIPTION)
      To get the base commission, I can see there are a lot of options but that calling this after listMarketCataglouge and when looping through the markets (single as I pass in a marketID), the MarketBaseRate is available e.g

      Code:
      var marketCatalogues = BetfairAPI.Client.listMarketCatalogue(marketFilter , marketProjections, marketSort, maxResults);
      double commission = marketCatalogue.Description.MarketBaseRate;
      However what else would I need to do to get the potential commission, I obviously don't know if the LAYS or the BACK bets will win but need to calculate the tick spread needed to handle the commission before setting desired prices for each trade.

      I can see there is also a IsDiscountAllowed property in the Description object

      Code:
      marketCatalogue.Description.IsDiscountAllowed
      Also if you look at the AccountFundsResponse class > https://github.com/betfair/API-NG-sa...03403817f73675

      there is a RetainedCommission and PointsBalance property available, wouldn't these also be needed to calculate the real commission as the more bets you place the discount would surely rise.

      I have access with all these classes I wrote to all the objects I just need to know what I need to do to find the % of a "potential profit" from a bet that would be taken off me by Betfair before I set out my positions and prices.

      If I am in GB/UK, so what else would I need to do to take the commission % from marketCatalogue.Description.MarketBaseRate and work out the potential deduction I would be looking at if it's not just as simple as potential win £ - commission ?

      I would have thought the commission you are currently paying on winning bets would be part of the Account object along with your Wallet, Betting Balance and Current Liabilities?

      What I need is some lovely theoretical equation using all these properties, the MarketBaseRate, RetainedCommission, PointsBalance etc..

      commission = (MarketBaseRate - RetainedCommission) + ???

      I thought there would be some simple equation or property on the Account object to obtain it along with you current balance and liabilities, but I searched the KB and can't see anything.

      Thanks for your help!

      Comment

      • WTPooh
        Member
        • May 2012
        • 88

        #4
        Hi,

        Some of your questions are really strange. Read about betfair exchange comission here: https://www.betfair.com/aboutUs/Betfair.Charges/#Excom2

        Comment

        • geoffw123
          Senior Member
          • Mar 2014
          • 250

          #5
          Hiya

          UK here too, my story is the same as yours, wrote some C# code ages ago to get the API working, then about 1 week after i got it working Betfair introduced the API-NG. So I shot that horse and jumped onto Betfair's new horse at the time. Then after I got that working and finished, Betfair introduced the streaming API so that horse got shot too, and I jumped onto the streaming API. Happy Days

          I am no expert on this, it should be Betfair Tech Support explaining how all this works but I will have a stab at it.

          Definition of terms

          Retained commission = Not 100% sure on this one, it is some sort of defferred commision.
          "Retained commission is the maximum amount of commission you could pay on a partly settled market. it is not necessarily a guide to how much you will pay in any way, and it pre-dates the existence of express payout markets."
          For me personally I have never seen this be anything other than 0. I would just simplify the problem and ignore it totally.


          marketBaseRate = This is the important figure when calculating the commision on a winning bet. It is typically 5%. It can be different though, so needs to be read from the API if your App is going to calculate commission.

          disountRate = this is a percent factor that is applied into the commision calculation to reduce the amount of commision you pay on a winning bet. You can get this dscountRate from Betfair via the accounts API. For me this figure is also 0% as my bet amounts are small and I never accumulate enought points for Betfair to give me a discount.

          The formula to calculate commision on a winning bet is

          Comm = Net Winnings * MarketBaseRate * (100 - discountRatePercent)

          so an example would be

          £400 * 5% * (100 - 40%) = £12

          IsDiscountAllowed = this is a boolean available in the description response from the API. It describes whether Betfair like you or not. I cant see any info as to why this flag can toggle between true and false. They dont like me obviously as mine is set to false It might be false for me as I havent accumulated enough bets to qualify, who knows. Anyways this is just a bool and easy to check to see if a discount can be applied.

          So to summarise you have to iterate through every bet you have in the market and work out the net profit on all bets.
          If that result is 0 or negative you pay no commision, however if it is positive then you pay the commision calculated on the net market profit.This would then of course give you a spread of net profits that could occur on the race depending on how many of your selections in that market win. Thats the best you can do without the crystal ball.

          Hope this rambling was of some use
          Last edited by geoffw123; 26-07-2020, 04:32 PM.

          Comment

          • monkeymagix
            Junior Member
            • Jul 2010
            • 105

            #6
            Thanks for your responses.

            Mr WTPooh, what exactly do you mean when you say some of my questions are really strange?

            Which ones exactly and could you explain why, as Geoff seems to understand what I am talking about.

            All I want is the % of commission Betfair would deduct off any winning bets (LAY or BACK) in either an algorithm, or ideally a single property in an existing object.

            Betfair obviously know this % as they always deduct it on any winning bets so I am at a loss to why they can't supply it as a single property within the API for our use?

            Also after spending 10 years working on their API and being a member of this support site, helping to write one one of the first .NET BOTS that used their SOAP API, I always go straight to their KB to look for an answer.

            A KB is always my first port of call and I wouldn't waste writing a post to ask members and many amateur developers for help if Betfair actually had an article explaining the answer. In all my years of using this site I have never seen an article that helped with this issue of calculating commission correctly and If I have missed one and you know of the link could you please send me the URL ??

            However Geoff, your explanation about the properties and your example algorithm was a great response, and much more than I could have hoped to get from a request on here so I really do appreciate it.

            It seems like we have both been coding against the constant API changes for the same amount of time and we have both had a mare and a half doing so. I will try and test it as soon as I can.

            Also whilst your algorithm is great, if you place a lot of bets, and spend lots of money, like the big bookies or big time gamblers and traders, then the amount of commission they deduct from winning bets obviously lowers. So whilst your equation is great and much better than anything I have found online, I am just wondering whether the PointsBalance would have some place within it. I was pretty sure that the amount of points you currently had affected the % of commission they deducted?

            Also I would love to ask a Betfair developer for the answer to this question and in the old days i would have just fired off an email to their development team. They always offered quick programming solutions and general betting help. However it seems now that the email address no longer accepts inbound emails and the only way I know of getting support from them is through their Twitter account @BetfairCS.

            That account has been great for sorting out issues with their mobile apps or website but I don't know if that is the best way of getting development help that doesn't exist online. However I will try, if you don't ask you don't get as the saying goes.

            If anyone knows a better way of asking the Betfair API Development team a question such as this then please let me know.

            Thanks for your help, and if you or anyone else finds anything further about calculating the correct commission that would be deducted from a winning bet pre race then please let me know!

            Comment

            • WTPooh
              Member
              • May 2012
              • 88

              #7
              Hi,

              Betfair charges commission not from the winning bets but on your net winnings on a market.
              If you are from GB you can select your commission rate via 'My Betfair Rewards' in 'My Account' (from 2% in GB).
              If IsDiscountAllowed = FALSE then commissionRate = marketCatalogue.Description.MarketBaseRate
              If IsDiscountAllowed = TRUE then commissionRate = marketCatalogue.Description.MarketBaseRate * (1 - accountDetailsResponse.DiscountRate / 100)
              commission = marketProfit * commissionRate / 100

              Everything else is irrelevant. Hope this helps.

              Comment

              • LetsGo
                Senior Member
                • Oct 2018
                • 112

                #8
                Commission cannot wipe out your profits because you only pay commission when you win.

                Example:-

                3. Balistic George 2.92 10.75 Back 26-Jul-20 10:51 20.64
                3. Balistic George 2.92 8.92 Lay 26-Jul-20 10:51 -17.13

                Back subtotal: 20.64
                Lay subtotal: -17.13
                Market subtotal: 3.51
                Commission @ 1.99%: 0.07
                Net Market Total: 3.44

                Comment

                • geoffw123
                  Senior Member
                  • Mar 2014
                  • 250

                  #9
                  Hi
                  However Geoff, your explanation about the properties and your example algorithm was a great response
                  Thanks for that, but the last bit at the end was incorrect in the way I explained it. As WtPooh of course correctly points out

                  Betfair charges commission not from the winning bets but on your net winnings on a market.
                  So you would have to iterate through all your bets in the market to figure out your net profit, then apply the commission calculation to that resultant figure,
                  Sorry for the error, I have corrected my original post

                  your other point you stated
                  I am just wondering whether the PointsBalance would have some place within it. I was pretty sure that the amount of points you currently had affected the % of commission they deducted?
                  Yes, if you are a "high roller" then you accrue more points, which then means BF give you a bigger accountDetailsResponse.DiscountRate based on that number of points.

                  Last edited by geoffw123; 26-07-2020, 04:46 PM.

                  Comment

                  • monkeymagix
                    Junior Member
                    • Jul 2010
                    • 105

                    #10
                    Thank you WTPooh, that is very helpful to have a list and a meaning for each property.

                    At the moment, I am paying 10% commission however I have only been manually betting on Sportsbook whilst I re-code my BOT, so I haven't made the required amount of bets to qualify for a change of plan. It says:

                    "You must place bets in at least 20 Exchange markets each month" to get one of 3 plans which are still in BETA and are a combo of things not just commission rates. You get to this by selecting "Promotions & Rewards" from the main top menu, then "My Betfair Rewards [BETA]", which is at the bottom of that menu. You can change your plan each month if you have qualified.

                    Despite me currently being on 10% commission this month I have qualified for next months reward plan. However there are 3 plans, I do have an image in both PNG and GIF format, but this editor won't let me upload it for some reason. So a quick list of each of the 3 reward plans are:

                    Rewards+ plan - with an 8% commission, a 10% refund on net losses at the start of the month, and more free bets and bonuses.

                    The standard plan (or most popular) -, which I will be on in August, with 5% commission a £5 free acca every month and some casino free spins which I am definitely not interested in.

                    Or the BASIC plan - 2% commission plan however doesn't give you BOG on SportsBook bets which I definitely want, neither do you get any bonuses or free bets.

                    So it's a choice between 3 plans made up of free bets, casino spins, commission rate and SportsBook BOG, so I'd have to think carefully about which plan to use as I do a lot of Same Game Accumulators and Football bets in Sportsbook an would love to keep BOG.

                    Also due to these new "plans" made up of multiple options, I cannot see how the commission rate would change from the "Reward Plan" you are on in any way, either though points or a discount rate, if it is fixed by the plan you are on.

                    It actually states in the small print that:

                    Any Exchange discount rate you would normally receive due to your Betfair Points will not apply while you are opted in to a package. Betfair points will continue to accrue as normal. Your commission rate on Australasian markets will continue to be calculated using MBR (Market Base Rate) and Betfair Points.
                    So if that is correct and if the commission is based on a rewards plan any points I got would not effect my commission if I became a "high roller" and my points balance was high. However I cannot see any option anywhere to "Opt Out" of a Reward Plan, which would take me back to an equation where points are involved etc. Unless either of you know where this option is?

                    Also when I mentioned about not making any profit, I was actually referring to the "easy" way of trading. Setting a BACK or LAY bet before the race and then cashing it out before the race started.

                    The other night I was just playing around with the cash out button as it just places the opposing bet for you to make a trade and although the big yellow button kept saying "Cash Out £xx Profit", when I did it, up to 10 times for one horse per race and then looked at my Profit/Loss I hadn't actually made any profit at all.

                    I don't normally use the Cash Out button as I am not about to watch the market or race which is why I have made my own BOT.

                    However I just wanted to see trading in effect without doing the work and just pressing the button whenever it said I would be in profit after placing a bet. If I had made some profit from these Cash Out trades then I couldn't see it in my Exchange PL, or Account Statement at all. It seemed that the amount of money I had in my bank was the same 10 mins before the race before I started, and the same when I stopped. I didn't let any bets stay inplay I cashed them all out before the race as the price moved up and down, and only when it said I would be making a profit.

                    All I know is I placed say 10 £2 LAY bets at prices of 2.30 - 2.60 as the market bobbled up and down on the favourite, and whenever the Cash Out button said I could cash out my full stake and make money I hit it, then did another bet straight away and so on and so on. Despite this my bank balance didn't increase at all.

                    I am sure there is an explanation for this but I can't think of one of the top of my head unless cash outs do their trading differently somehow.

                    By the way do either of you actually know the correct way to contact Betfair developers apart from @BetfairCS on Twitter. I used to email bdp@betfair.com and they were always great at helping me work out what had happened with partially matched bets or lapsed bets which didn't show up as lapsed in the early days of the API when they were still fixing bugs.

                    It would be great to know a way of asking a Betfair API developer a question directly.

                    Thanks for both your help though.

                    Comment

                    • monkeymagix
                      Junior Member
                      • Jul 2010
                      • 105

                      #11
                      Just a quick after thought, due to these fixed plans with fixed commission rates, is there a single property or equation made up of property values that would tell me if I was currently ON a plan with a fixed commission OR if I was "opted out" and therefore needed to work out my commission using my points balance etc as you have both shown me?

                      Comment

                      • WTPooh
                        Member
                        • May 2012
                        • 88

                        #12
                        Originally posted by monkeymagix View Post
                        By the way do either of you actually know the correct way to contact Betfair developers apart from @BetfairCS on Twitter.
                        https://support.developer.betfair.co...s/requests/new

                        Comment

                        • bfexplorer
                          Senior Member
                          • Sep 2018
                          • 204

                          #13
                          Originally posted by monkeymagix View Post
                          Just a quick after thought, due to these fixed plans with fixed commission rates, is there a single property or equation made up of property values that would tell me if I was currently ON a plan with a fixed commission OR if I was "opted out" and therefore needed to work out my commission using my points balance etc as you have both shown me?
                          Just a common sense:

                          Whatever commission plan you have got, when bet is settled and won, it is calculated commission and is deducted from your winning. Commission fee amount is saved as your every bet placed on betfair for 90 days, so even when you switched different commission plans during those days the bets are available in your p/l history, you will get always relevant commission fee amount.



                          Comment

                          • monkeymagix
                            Junior Member
                            • Jul 2010
                            • 105

                            #14
                            Hi WTPooh,

                            Yes I would know the commission, from what is deducted AFTER a race but this whole post is about getting the right commission BEFORE a race.

                            In theory you could NOT be on a plan (not that I can see a way to opt out yet), and be using your points to build up a deduction and be on 2% 5% or 10% from a NON PLAN commission rate.

                            So just knowing the commission from a previous race doesn't tell me if I'm on a Reward Plan or my points balance has been taken into considerstion for me to get a similar commission % rate.

                            Therefore a property that would tell me what plan I was on would be a nice feature.

                            Thanks

                            Comment

                            • monkeymagix
                              Junior Member
                              • Jul 2010
                              • 105

                              #15
                              I've sent a message to that link you sent me asking how I would find out from the API whether I was on a reward plan or not (opted out), and not just guessing I am on the basic plan due to having a 2% commission rate as that in theory could be from my default commission - discount rate and using the points balance etc. I'll let you know if I get an answer.

                              Comment

                              Working...
                              X