C# a Step by Step Beginners Tutorial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Escapee
    Junior Member
    • Feb 2009
    • 51

    #91

    Comment

    • cikatomo
      Junior Member
      • Feb 2012
      • 1

      #92
      thanks for the tutorial!
      What about https://api.betfair.com/global/v4/BFGlobalService.wsdl?
      Is that same as v3?

      Comment

      • Escapee
        Junior Member
        • Feb 2009
        • 51

        #93
        Originally posted by cikatomo View Post
        thanks for the tutorial!
        What about https://api.betfair.com/global/v4/BFGlobalService.wsdl?
        Is that same as v3?
        Probably an upgrade that didn't go public.

        I found a few undocumented fields/calls in V3 and having a quick look at V4 I can see others.

        Comment

        • husvar
          Junior Member
          • Dec 2012
          • 1

          #94
          Last Update Time + Lag

          Hi

          First of all, thanks for the nice detailed tutorial

          I have two questions:
          1 - Is it normal that the last updated time is constantly increasing? Mine is going up and down and not necessarily obeying to the value in the form.
          2 - Is it normal to have different values (lag) between betfair http and betfair api? I noticed it a couple of times...

          Comment

          • Escapee
            Junior Member
            • Feb 2009
            • 51

            #95
            1 - Is it normal that the last updated time is constantly increasing? Mine is going up and down and not necessarily obeying to the value in the form.

            As far as I know, the 'Last Updated' timestamp represents the latest time that the market was updated on the server that serviced the getMarketPricesCompressed() call.
            So if data is returned marked with a timestamp earlier than a previous call then the data can can be ignored.
            You will find this happens most often in slow markets where no bets are being placed. But it can also happen occasionally during peak activity such as an in-play horse race.
            I check the timestamp, ignore the data and flash the visual timestamp RED when this happens.

            2 - Is it normal to have different values (lag) between betfair http and betfair api? I noticed it a couple of times...
            I'm not sure about lag, I think that shouldn't happen.
            But what you may be seeing on the web site which you won't see via the API
            is betfair synthetic prices generated by their 'X-Matching bot' ( There is a discussion thread on it somewhere on this forum )
            So this makes the prices on the Web differ from the API

            Comment

            • thegrad
              Junior Member
              • Dec 2012
              • 2

              #96
              Thumbs Up Escapee !

              Thank you very much for this tutorial Escapee! It certainly has given me an appetite for C#. I would post my version, but I started to mess around with and guess what....! It will probably take me a week or 2 to sort out and then I`ll post it to this thread
              In the meantime do you mind please giving some pointers as to how to achieve extra functionality? I`m not asking for a tutorial as I appreciate that that would take up more of your time, but maybe a lead as to how to achieve;
              1/ Graphing of volume,prices
              2/ Market depth, etc.,

              Any help would be appreciated and thank you again for your efforts and postings thus far!

              Toby

              Comment

              • Escapee
                Junior Member
                • Feb 2009
                • 51

                #97
                Your most welcome thegrad, I appreciate the feedback.

                As you've already guessed, I am very short of spare time at the moment, so no tutorials in the pipe.

                1/ Graphing of volume,prices
                I did a graph many moons ago in C++ and a basic one is fairly easy
                using fairly standard OnPaint over-ride stuff. Things to look out for are
                NOT updating the whole chart on every refresh, i.e. redrawing enough room
                every 60 seconds to allow another 60 refreshes with just drawing a single point each time. Makes it very fast updates.
                I found the user flexability stuff alot more fiddly, auto scaling zooms, scrolls etc
                whilst maintaining updates, guessing if the user wants to see a scale of 1 to 10, 20 to 50 or 1 to 1,000, and also accounting for the dersired autosroll on 2 axis etc in the context of the current view and the new view....
                maybe i did it wrong but it ended up a bit messy.

                Alternatively there are lots of free 'push charts' out there I'm sure you'd find a suitable one to adapt.


                2/ Market depth, etc.,
                Are you talking about Ladders ? I'm not sure what kind of pointers you want here.
                I had one planned that would have fitted nicely on this project, but never got arround to building. Here's a basic outline of how it would work in the context of this tutorials design if that would help.
                • add a List of priceStruct to the CRunnerData class.
                • Add a new thread to the Refresh control which usesGetCompleteMarketPricesCompressed() to retrieve all market depth
                • parse it in a similar manner to the current compressed prices, putting the data into a new List ( discard old ) each refresh for each runner.
                • the Actual display should probably be made up of a dynamicaly created array of a ladder objects ( probably a datagridview ) One for each runner on a user control object.
                • ladder object for each runner should contain the List of its previous update
                • the user control subscribes to the standard evMarketUpdated message.
                • OnMArketUpdated, the user control iterates through each runner, comparing its own list with the new list in CRUNNERDATA and updates the display only where the data is different. thus hopefully making it reasonably efficient and not having to update every one of the 350+ possible prices and ammounts for every runner on every refresh



                Not sure if I explained it well but I know what I mean

                hope this helps

                P.S.
                Post a pic your program when you get it working again, always nice to see the different results and tweaks
                Last edited by Escapee; 22-01-2013, 03:11 AM.

                Comment

                • thegrad
                  Junior Member
                  • Dec 2012
                  • 2

                  #98
                  Thanks for the tips mate, i`ll try and put them to good use ! My take on your tutorial is the file attached.
                  Attached Files

                  Comment

                  • gectolympus
                    Junior Member
                    • Jan 2013
                    • 1

                    #99
                    Can someone please provide a clean finished example from this manual?

                    Looks like I'm missing something... went through all the steps several times however I keep on recieving errors in various parts...

                    The authors skills are strong and we have to be very very gratefull for such an effort... For me the code looks too enthusiastic with classes, customised elements and etc. ))

                    The author went "the hard way" ))

                    Comment

                    • maxxim
                      Junior Member
                      • Jan 2010
                      • 7

                      #100
                      Sorry for my english! Help me! How to make In one request PlaceBets to send two bets from one market? Please, show the example. Thank you.

                      Comment

                      • Drifter
                        Junior Member
                        • Mar 2009
                        • 30

                        #101
                        Rejects - though no idea why

                        I have just had to do a machine re-install thanks to a .Net4 update corrupting my entire development platform (thanks, Microsoft!). The tutorial, which was working fine before, now returns:

                        Login - FAILED: Response.Header.ErrorCode = PRODUCT_REQUIRES_FUNDED_ACCOUNT

                        when I try to run it. It compiles OK, and I have logged in to check my account, which is more than adequately funded. I can't see why I would get this back? There have been no code changes - just simply copied the directory from the old iinstallation to the new one.

                        Comment

                        • vossie
                          BDP Team
                          • Sep 2008
                          • 40

                          #102
                          Transfer money from your UK wallet to your Aus wallet and back again to get rid of the funded error.
                          "Why don't you just fix your little problem and light this candle?" - Alan B. Shepard, Jr

                          Comment

                          • bfusr
                            Junior Member
                            • Jan 2013
                            • 2

                            #103
                            I finished 3rd part of this very helpful tutorial and before I go to next parts I want to add a few features to the application and better understand the code. I've got couple questions.

                            1. How to make controls from main Form visible for BFControl? I want to make "My countries" feature, so I need to check
                            Items from CheckedListBox in MenuTree.cs.
                            2. When the TreeMenu is initialised, I would like to make Nodes directly for countries in "Soccer" event type. In other words, there should be "English Soccer", "Spanish Soccer" at start, not event types.
                            3. Also, I would like to make Nodes only for contests with matches on a given day.

                            I know I have to better understand how the API works, but I got stucked a bit. Any advice will be helpful. Thx in advance.

                            Comment

                            • Escapee
                              Junior Member
                              • Feb 2009
                              • 51

                              #104
                              gectolympus
                              Looks like I'm missing something... went through all the steps several times however I keep on recieving errors in various parts...

                              There is one small error where 2 lines of code might be missing ( see posts 71,73 & 77 ).
                              But many people have completed this and posted pictures of thier result so it might be that you are overlooking something in one of the steps

                              Best of luck with it and post a picture if and when you get it breathing.



                              maxxim
                              Sorry for my english! Help me! How to make In one request PlaceBets to send two bets from one market? Please, show the example. Thank you.

                              Create a Placebets[] array and a PlaceBetsResp, fill the PlaceBets[] with the bets you want to place
                              Code:
                                          PlaceBets[] pBets = new PlaceBets[2];;
                              
                                          PlaceBetsResp pbResp = new PlaceBetsResp();;
                              
                              
                                          pBets[0] = new PlaceBets();
                              
                                          pBets[0].selectionId = "A Valid selectionId";
                              
                                          pBets[0].marketId = "A Valid Market Id;
                              
                                         // Fill in the rest of the bet stuff for bet 1
                                         // and repeat for bet 2 etc etc
                              
                                         // Then place the bets like this
                              
                                         bRetCode = Place_Bets( ref pbResp, ref pBets );
                              Put this Place_Bets( ref pbResp, ref pBets ) in your CBetfairAPI.cs class
                              Code:
                                      private bool Place_Bets( ref PlaceBetsResp resp, ref PlaceBets[] pBets )
                                      {
                                          bool bRetCode;
                                          const string serviceName = "placeBets";
                              
                                          //TraceMsg("placeBets");
                              
                                          var request = new PlaceBetsReq();
                              
                                          request.header = _exchReqHdr;
                                          request.bets = pBets;
                              
                                          try
                                          {
                              
                                              resp = _bfExchange.placeBets( request );
                              
                                              pbErrorCode = resp.errorCode.ToString() + "," + resp.header.errorCode.ToString();
                              
                                              bRetCode = CheckResponse( serviceName,
                                                                          Convert.ToString( resp.header.errorCode ),
                                                                          Convert.ToString( resp.errorCode ),
                                                                          resp.header.sessionToken );
                              
                                          }
                                          catch( Exception exc )
                                          {
                                              bRetCode = false;
                                              TTraceMsg( "ERROR: {0}, Exception: {1}", serviceName, exc.Message );
                                          }
                              
                                          return bRetCode;
                                      }
                              That should be enough to get you betting like a coder.
                              Good Luck



                              Drifter

                              That sound very painful. I've just bought a Windows 8 laptop omfg^%$^%$%$*^%0-6, great if you want bookface and twatter effluence but removing the start button is a real painful leap if you use a pc to actually work on, I'm definitely cutting bill gates out of my will now

                              I Hope Vossie's suggestion has cured your 'Go away you're skint !' error code


                              vossie
                              Hi there, nice swift response to Drifter there, top potato
                              p.s. are you not reading your PM's these days or did I not make the grade


                              bfusr
                              1. How to make controls from main Form visible for BFControl? I want to make "My countries" feature, so I need to check
                              Items from CheckedListBox in MenuTree.cs.
                              2. When the TreeMenu is initialised, I would like to make Nodes directly for countries in "Soccer" event type. In other words, there should be "English Soccer", "Spanish Soccer" at start, not event types.
                              3. Also, I would like to make Nodes only for contests with matches on a given day.


                              Q1) Not sure I understand the question, But custom nodes are the way, you can do all sorts with user drawn nodes if you want to get fancy.
                              Q2) and Q3 )
                              I've customised my menu for "Todays Soccer" Tennis etc. its a bit to involved to explain in a nugget and would require another chapter in this tutorial.

                              Here's an outline

                              Just add something to handle Custom Nodes in menuTreeNode.cs
                              Code:
                                      public MenuTreeNode( string NodeName, string CustomNodeType )
                                      {
                                          m_Name = NodeName;
                                          this.Text = NodeName;
                                          m_NodeType = CustomNodeType;
                              
                                      }
                              load them onto the menu in Initialise()
                              Code:
                                          tNode = new MenuTreeNode( "Todays GB Horse Races", "TodaysGBRaces" );
                                          this.Nodes.Add( tNode );
                                          tNode = new MenuTreeNode( "Todays Soccer Fixtures", "TodaysSoccer" );
                                          this.Nodes.Add( tNode );
                                          tNode = new MenuTreeNode( "Todays Tennis Matches", "TodaysTennis" );
                                          this.Nodes.Add( tNode );
                              
                                          tNode = new MenuTreeNode( "", "" );
                                          this.Nodes.Add( tNode );
                              and then handle the custom nodeType in OnAfterSelect()
                              Code:
                                                  case "TodaysSoccer":
                              
                                                      BuildTodaysSoccerFixtures( tNode );
                              
                                                      break;
                              and then you get custom nodes like this:



                              In your "BuildTodaysXXXX()" functions you can use getAllMarkets() api call to get and filter the markets you want, as you can see I show the country on the Tennis markets so you should be able to filter exactly what countries you want.

                              Get coding

                              Comment

                              • Drifter
                                Junior Member
                                • Mar 2009
                                • 30

                                #105
                                But why?

                                Thanks for the quick response Vossie - it worked!
                                But why?

                                Comment

                                Working...
                                X