Announcement

Collapse
No announcement yet.

Basic connection for c#, not console

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Basic connection for c#, not console

    Sorry if this is a basic question. I am a relative noob to c# coding (I was a VB programmer many years ago). I'm trying to get a sample or documentation for just connecting to the Exchange API using c# and not as per the console application sample. I've been through the RTFM steps and am just getting nowhere, confused and hitting brick walls. Is there some really basic c# code anywhere that just shows how to connect to the Exchange API?

    Once I've got that I'll be able to hunt through the methods.

    I don't know how to 'translate' from the console application to a Windows Forms approach as the using statements don't appear to work. I just don't know what I don't know and am going around in circles. I'm probably missing the basics but it's the basics that I need and just can't find.

    Any and all guidance very much appreciated.

  • #2
    Use my bot sdk:

    https://github.com/StefanBelo/Bfexplorer-BOT-SDK

    On BOT SDK solution you have got 3 examples for C#, VB and F#:

    https://github.com/StefanBelo/Betfair-Tutorials
    Betfair BOT SDK

    Comment


    • #3
      Did you manage to get the Betfair C# console App up and running OK, that wasnt clear to me in your post ?

      Comment


      • #4
        Thanks Stefan, I'll hunt through those now for a windows or non-console way of connecting. Appreciate the fast response.

        Geoff, I've just managed to get the console app working now. At least, I can save log in details but I'm not sure what to do with the other commands. However, if I can just get the connection from windows then I should be good to step through the properties to work what I need to send from there.

        Many thanks both for your quick replies.

        Comment


        • #5
          Hi
          I hadnt looked at this example code for years, so downloaded it this afternoon for a quick peruse, see if it had changed much. I got it working OK pretty quickly but something about it is puzzling me. I will post as a separate message thread here, so hopefully tech support might notice it and reply.

          P.S how did you get your AppKey and SessionToken for pasting into the Console Demo ? You seem to have already figured out the most tricky part
          Last edited by geoffw123; 15-05-2022, 07:26 PM.

          Comment


          • #6
            BertrumGlut

            Betfair sample code is just rest api wrapper code for communication with api in C#, I do not know why betfair did not make swagger definition of their rest api, so then client code could be generated for any programming language, the code they manually programmed. Yes, they make swagger definition for streaming api, but the problem is that swagger is not able to generate client code for streaming, you can use it to auto generate data transfer objects or models only.

            I am not quite sure if you understand what I have said above so here is example of what I have explained.

            Here there is my code in VB showing how to use streaming api in Visual Basic:

            https://github.com/StefanBelo/Bfexpl...iVB/Program.vb

            Basically what happens is to login to betfair api, on line 46, then subscribing to horse racing markets on line 63. Subscribing of market updates means that you will get automatically populated data of markets and their prices, you will get Market objects and all data available through api. It is done quite a lot of magic here from your point of you. Using just betfair api wrapper code you would have to call a lot of different api calls to get market catalogue data then prices (market book in rest api), just put the break point on the line 24, and browse market data in VS.

            Well yes, you will get api client code working, but what is your goal then? I think to automate your betting or trading on betfair markets, and that requires a lot of coding.

            The difference in my code base is that my bot sdk is not just api client wrapper, it is framework with already built infrastructure.

            In my bot sdk there is winform sample code in C# presenting the use of the framework in the simple app covering all features you need:

            https://github.com/StefanBelo/Bfexpl...UI/MainForm.cs

            The code implements login to betfair, populating market data, in this case app loads all horse racing markets for a day, updating market data automatically, executing preprogrammed strategies, and so on.

            App uses practice mode so no bets are placed on betfair when bot strategy is executed, but if you place real bets then bet data are populated for you automatically as well.

            The same BOT SDK code is used to build my desktop app, this one:

            http://bfexplorer.net/Products/Bfexplorer
            ​​​​​​​
            Last edited by bfexplorer; 17-05-2022, 08:01 AM.
            Betfair BOT SDK

            Comment


            • #7
              Geoff - for the AppKey and Session ID I followed the instructions from BF and the page where you just get one market (I think). For me, it's the API connections that I don't know how to do and am trying to learn. I'm OK with coding generally but APIs are new to me, as is a lot of the C# nomenclature - I'm self taught in C#.

              Stefan - thanks for your further information and you're absolutely right in that I didn't understand your first paragraph! I don't yet know what swagger is and haven't use git hub before but that's all down to me to learn, which I'll do in time.

              Thanks so much as well for your further information - I'll focus on the MainForm.cs and your instructions as above.

              Appreciate I'll have a lot of coding to do for trading but once I get the relevant connections I can plough through that. If and when I get it robust enough I'll also post my code on here so others could potentially benefit - keen to return in some part the help that you've given me.

              Comment


              • #8
                Sorry I just re-read Geoff's comment and I think I was vague in my response. The page I used was here -

                https://developer.betfair.com/en/get.../#exchange-api

                It takes you to a page that (I assume) BF set up and then you get to see just one market but it confirms your AppKey and Session ID.

                Comment


                • #9
                  Hi

                  I started re-jigging the console example as a small Windows demo, I fixed the couple of bugs in the console version and hopefully improved it a little bit, e.g, a login form so you dont have to faff around generating a session token manually. Its taking me a bit longer than I thought to complete and I have run out of time for now, so will finish it and post it in the near future. I will post it as a new thread just to make it easier to find if anyone finds it useful in the future.

                  Geoff

                  Comment


                  • #10
                    Thank you Geoff. I'm looking at Stefan's code but am gettinng bogged down with using statements, references, NuGet, etc. All really good learning for me.

                    Comment


                    • #11
                      hi

                      No problem, yeah can get complicated. Is that solution/path free of charge, I assumed it wasnt ? I have posted a simple Project now to a new message thread anyways.

                      Geoff

                      Comment


                      • #12
                        Is that solution/path free of charge, I assumed it wasnt ?

                        That could be why I'm getting nowhere with it :-)

                        Comment


                        • #13
                          I dont know, I assumed you have to purchase a subscription to BfExplorer first and then you can run the script files on top of that. I could be wrong though, its nothing to do with me.

                          If you go your own route of write everything yourself, that path is painful also as Betfair now charge £300 for a non delayed API key.

                          Comment


                          • #14
                            BertrumGlut, to get betfair api access your account must be granted such api access, if you want to use your own way, then yes you must pay betfair 299 GBP, it is said on their web page:

                            https://developer.betfair.com/

                            Activation fee 299 GBP

                            If you want to use my code, then you can get activation of api access when installing my app and login to betfair, all is done automatically. Then you can use my app, and as well any code in my bot sdk:

                            https://github.com/StefanBelo/Bfexplorer-BOT-SDK

                            You can use my app for free in trial, then you can subscribe to get support.

                            For some people working with me on betfair strategies, or just sharing anything on betfair or machine learning I give free access, but that is what friends do.
                            Last edited by bfexplorer; 22-05-2022, 01:46 PM.
                            Betfair BOT SDK

                            Comment


                            • #15
                              Thanks again for your replies. I was aware of the £299 activation fee which I'm fine with. The strategy will either work or it won't. Stefan I didn't realise you charge a subscription and I don't know what that is but agree that it's a reasonable approach and again, if what I do works then that would be fine.

                              In my case, I'm keen to understand the coding myself and I'm immensely grateful to you both for taking time out and sharing your knowledge. I've downloaded Geoff's win forms application from the other thread and am stepping through that. I'm learning a lot about API calls which wasn't around when I was doing VB6.

                              Neither of you needed to reply, yet you did, and someone you don't know is genuinely grateful for your help and guidance. Many thanks.
                              Last edited by BertrumGlut; 22-05-2022, 08:09 PM.

                              Comment

                              Working...
                              X