Github API-NG C# Sample Code Issues

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geoffw123
    Senior Member
    • Mar 2014
    • 250

    #1

    Github API-NG C# Sample Code Issues

    Yesterday I downloaded the Github API-NG C# Sample Code to get the latest changes.

    I noticed a few issues that Betfair might want to look into. (they are quick and easy to resolve)

    Issue 1) Using Visual Studio 2022 the C# solution source doesnt build for me.
    Code:
    In JsonRPCclient.cs
    if (response.ContentEncoding.ToLower() == "gzip") // ContentEncoding is not known
    
    Presumably this is now deprecated in Net 4.8 version. I fixed it with
    
    string contentEncoding = response.Headers["Content-Encoding"];
    if(contentEncoding?.ToLower() == "gzip")​
    Issue 2) A Bet is placed that according to example code shouldnt work.

    The code tries to place a bet of £ 0.10 at odds of 1000.

    It prints out to console "Below minimum betsize and expecting a INVALID_BET_SIZE response"

    I was expecting that error as 10 pence is less than the minimum bet size of £1.00, however it works and the bet does actually get placed.
    So the code is not behaving as the console priint out says it should. i havent figured out the exact reason why that works, but I am guessing it has to do with the changes that were made some time back to prevent some rounding error exploit on small bet stakes. Cant remember details now, but would be interested to know if anyone understands this one ?

    Issue 3)
    I noticed that the version of Newtonsoft.json.dll in the repo is version 4.5.10 which is ancient. Apparently this dll had security vulnerabilties all the way up to versions 13.0.1
    In the repo version Betfair havent used the nuget package for this dll Betfair should probably consider updating this dll for security reasons. I tried deleting the old one in the lib folder and adding version 13.3 via nuget package. As far as I can see it is now using the latest dll and didnt introduce any build problems.


    While I am writing this up, a cople of simple suggestions that I think would be an improvement to the code.

    Suggestion 1)
    Before I got this working, program.cs was exiting with various errors, I couldnt quickly see what the error was as the console window closes before you can read the output. In all the error exit points consider changing to
    Code:
    Console.ReadKey();
    Environment.Exit(0);

    Suggestion 2)
    ​When I was testing this if I ran code more than once quickly I got an error referring to duplicate bets. This was initially puzzling but was down to this line
    Code:
    var customerRef = "123456";​
    So that makes sense, but to stop this error popping up it maybe better to change it to this.
    Code:
    // mS to randomise a bit, as duplicates will make Betfair return a duplicate bet error
    var customerRef = "123456" + DateTime.Now.Millisecond;

    Suggestion 3)
    ​​As the code can handle zipped responses from Betfair, why not enable that in the example ? Consider adding to jsonRpcClient.cs
    Code:
    request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip");

    Sorry for long post, hope it was of some use
    Last edited by geoffw123; 14-01-2025, 12:33 PM.
  • BetfairDeveloperProgram
    Administrator
    • Oct 2008
    • 680

    #2
    Hi geoffw123

    Thanks for the feedback.

    I've asked our dev team to take a look.

    Kind Regards

    Neil

    Comment

    • Sansa
      Member
      • Jan 2019
      • 35

      #3
      Regarding issue 2: Changes were implemented to allow smaller bets which reached the minimum payout, see below.

      Sansa

      Ability to place lower minimum stakes at larger prices

      In order to allow customers to bet to smaller stakes on longer-priced selections, an extra property has been added to our Currency Parameters – “Min Bet Payout”.

      As currently LIMIT bets where the backer’s stake is at and above the ‘Min Bet Size’ for the currency concerned (£1 for GBP) are valid. In addition, bets below this value are valid if the payout of the bet would be equal to or greater than the value of ‘Min Bet Payout’ - £10 for GBP. For example, a bet of £1 @ 10, or 10p @ 100 or 1p @ 1000 are all valid as they all target a payout of £10 or more.

      This functionality is available to "orderType: LIMIT" bets only.

      Comment

      • geoffw123
        Senior Member
        • Mar 2014
        • 250

        #4
        Thanks for the clarification, I remembered it was something like that. Betfair need to update their example code to not say that the bet placement should fail.

        The Github C# repo was updated last week with some changes, I wonder why they didnt spot this error and the failure to compile problem ? Strange.


        Comment

        Working...
        X