C# a Step by Step Beginners Tutorial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • osa_dev
    Junior Member
    • Jul 2012
    • 3

    #61
    Escapee please take a look at my form:



    I have some issues with correct Market time. As you can see every market besides horse racing has start hour set at 01:00, is that correct?

    Also in box Last Updated only seconds part is changing and only in the range of last 10 seconds. Minutes and hours don't update at all.

    I got some problems with my regional setting on windows as I needed to change decimal sign from ',' to '.' so maybe I should also correct somehow my date/hour settings in windows to fix those minor issues in software.

    I am just fresh newbie in C# and BF Api.

    Kind regards
    Osa_dev

    Edit:

    I would also like to ask if it is possible to place multiples e.g. on soccer match odds via API?
    Last edited by osa_dev; 03-08-2012, 10:56 PM.

    Comment

    • Escapee
      Junior Member
      • Feb 2009
      • 51

      #62
      Originally posted by osa_dev View Post
      I got the same problem. It is because local decimal sign was set to ',' instead of '.'

      Btw great tutorial, thank you for your time spent on us newbies
      Aha.. that would explain it, variations due to 'Locale' setting on the computer.

      I don't know much about coding for for all location variations as I've never needed to.
      The stuff I've read about it seems to make the code very verbose and bloated so I don't bother with it, especially for a tutorial like this where simplicity and clarity is a large requirement.

      Comment

      • Escapee
        Junior Member
        • Feb 2009
        • 51

        #63
        Originally posted by maniw4 View Post
        Hi Escapee,

        following my earlier post, i did a debug of the program to investigate the problem with the AUS/NZ horse racing. All i can see is that your program is displaying the correct values returned from Betfair, which means for some reason Betfair is sending random stuff for the AUS/NZ races.

        I selected one race the 3:13 Canb(AUS) and looked into the marketResp variable in the LoadNewMarket function - all the information was incorrect for the race and there were no runners! When i logged into my normal Betfair account i could see the race information, there were 7 runners.

        Perhaps there is another interface for the AUS/NZ racing. Maybe i need some funds in the AUS wallet to get the correct info back from Betfair.

        Anyway, your program is working correctly as far as i can tell.
        Due to complicated reasons, betfair split off its Austrailian/NZ markets to a seperate Austrailian exchange.
        For reasons of simplicity, This tutorial only access's the NON-AUS ( i.e. rest of world ) exhange so when you try to access an Austrailian market with it, you'll get zero or incorrect information.


        I could look at adding functionality to access to AUS markets. Its probably just a matter of testing for which exchange a market is on and then setting the end point URL.

        Also, for simplicity, "Asian-Line Markets" are not catered for in this tutorial.

        Comment

        • Escapee
          Junior Member
          • Feb 2009
          • 51

          #64
          Originally posted by osa_dev View Post
          Escapee please take a look at my form:



          I have some issues with correct Market time. As you can see every market besides horse racing has start hour set at 01:00, is that correct?

          Also in box Last Updated only seconds part is changing and only in the range of last 10 seconds. Minutes and hours don't update at all.

          I got some problems with my regional setting on windows as I needed to change decimal sign from ',' to '.' so maybe I should also correct somehow my date/hour settings in windows to fix those minor issues in software.

          I am just fresh newbie in C# and BF Api.

          Kind regards
          Osa_dev

          Edit:

          I would also like to ask if it is possible to place multiples e.g. on soccer match odds via API?

          The issue may also be something to do with the 'Locale' setting on the computer ( not using summer time ? ).
          You can either google for hours to try and sort it out or do a quick fix in the MenuTreeNode class:
          change
          Code:
           if( mktSum.startTime.ToLocalTime().ToString( "HH:mm" ) != "00:00" )
          to
          Code:
          if( mktSum.startTime.ToLocalTime().ToString( "HH:mm" ) != "[COLOR="Red"]01:00[/COLOR]" )

          Also I notice in your picture, the ODDS on your market are in the wrong font, have you missed out a step in the tutorial where the oddsFont is set ?

          Comment

          • osa_dev
            Junior Member
            • Jul 2012
            • 3

            #65
            Trick with changing time from 01 to 00 in MenuTreeNode solved my issue.

            But I didn't missed part about fonts. I have them set as you have in your tutorial but they don't show correctly in data grid. It looks as the part:

            fontOdds = new Font(FontFamily.GenericSansSerif, 11.25F, FontStyle.Bold);
            fontStake = new Font(FontFamily.GenericSansSerif, 8.25F, FontStyle.Regular);
            fontName = new Font(FontFamily.GenericSansSerif, 8.25F, FontStyle.Bold);
            is somehow overridden by other system settings. I will investigate it later.

            What I would like to ask again is there a way to access multiple bets via API?

            Comment

            • Escapee
              Junior Member
              • Feb 2009
              • 51

              #66
              Originally posted by osa_dev View Post
              What I would like to ask again is there a way to access multiple bets via API?
              I don't think so, but if anyone knows differently please chime in.

              Comment

              • Escapee
                Junior Member
                • Feb 2009
                • 51

                #67
                Ziggy plays guitar

                Anyone made much progress past the the tutorial ?

                Mine's called "Ziggy".

                Comment

                • lakedman
                  Junior Member
                  • Aug 2012
                  • 1

                  #68
                  Escapee, thank you very much, can you also show how's work with bets? i have done with your instructions, all is work great, and now i want to create an automation for my betting strategy..

                  i tried to write PlaceBets function like another functions in betfairAPI.cs, please look at it, is it right?
                  Code:
                    public bool PlaceBets(ref PlaceBetsReq PlaceBetsReq, PlaceBets[] pb)
                          {
                              bool bRetCode;
                              const string serviceName = "placeBets";
                  
                              var request = new PlaceBetsReq();
                  
                              request.header = _exchReqHdr;
                              request.bets = pb;
                              PlaceBetsResp response = _bfExchange.placeBets(request);
                  
                              bRetCode = CheckResponse(serviceName,
                                                          Convert.ToString(response.header.errorCode),
                                                          Convert.ToString(response.errorCode),
                                                          PlaceBetsReq.header.sessionToken);
                  
                              if (bRetCode == false)
                              {
                                  return false;
                              }
                  
                              return true;
                          }
                  Sorry for bad English skills..

                  Last edited by lakedman; 25-08-2012, 11:48 AM.

                  Comment

                  • Escapee
                    Junior Member
                    • Feb 2009
                    • 51

                    #69
                    Originally posted by lakedman View Post

                    i tried to write PlaceBets function like another functions in betfairAPI.cs, please look at it, is it right?
                    Code:
                      public bool PlaceBets(ref PlaceBetsReq PlaceBetsReq, PlaceBets[] pb)
                            {
                                bool bRetCode;
                                const string serviceName = "placeBets";
                    
                                var request = new PlaceBetsReq();
                    
                                request.header = _exchReqHdr;
                                request.bets = pb;
                                PlaceBetsResp response = _bfExchange.placeBets(request);
                    
                                bRetCode = CheckResponse(serviceName,
                                                            Convert.ToString(response.header.errorCode),
                                                            Convert.ToString(response.errorCode),
                                                            PlaceBetsReq.header.sessionToken);
                    
                                if (bRetCode == false)
                                {
                                    return false;
                                }
                    
                                return true;
                            }
                    Sorry for bad English skills..
                    No, it doesn't look right to me.

                    Here is my code:
                    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;
                    
                                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 );
                    
                    
                                return bRetCode;
                            }

                    In my programs, I generally have a double or triple wrapper over the place, cancel and update bets calls.
                    This is because unless you are just placing a bet and forgetting about it ( I.E. no tracking and actioning ) you will need to associate other data with the bet as well.



                    PlaceTheseBets( ref MyBetClass MyBets )---->Place_Bets( ref PlaceBetsResp resp, ref PlaceBets[] pBets )

                    All I ever pass into and out of CBetfairAPI when placing, updating or cancelling bets is a reference to "MyBets",

                    and I leave all the request and response processing to within the CBetfairAPI class.
                    i.e This is the call made from the program: PlaceTheseBets( ref MyBetClass MyBets )

                    and PlaceTheseBets() function processes MyBets into PlaceBets[],
                    calls Place_Bets( ref PlaceBetsResp resp, ref PlaceBets[] pBets ),
                    and then processes the response back into MyBets"



                    maybe to hard to explain in text.

                    Comment

                    • BBorisovic
                      Junior Member
                      • Jan 2012
                      • 2

                      #70
                      SartTime field value

                      I created CheckedListBox (left bottom part of the enclosed picture) in order to place there tennis match odds sorting them by StartTime. Unfortunately I received only “01-01-0001-12-00AM” values from StartTime field.
                      I changed MenuTreeNode code in order to get StartTime value for all markets.
                      public MenuTreeNode(BetfairAPI.BFGlobal.MarketSummary mktSum)
                      {
                      m_NodeType = "MarketSummary";
                      m_MktSum = mktSum;
                      //if (mktSum.startTime.ToLocalTime().ToString("HH:mm") != "01:00")
                      //{
                      //this.Text = mktSum.startTime.ToLocalTime().ToString("HH:mm ") + mktSum.marketName;
                      this.Text = mktSum.startTime.ToString() + " - " + mktSum.marketName;
                      /*}
                      else
                      {
                      this.Text = mktSum.marketName;
                      }*/
                      this.m_id = mktSum.marketId;

                      Result: Every market besides greyhound and horse racing has startTime “01-01-0001-12-00AM”



                      Using Excel VBA functions through a Betting Assistant COM interface to Betfair, I was able get list of all tennis match odds with correct date and time.
                      Since I am new to C#, I would greatly appreciate advice on how to get correct StartTime value.
                      Best regards
                      Attached Files

                      Comment

                      • ThanksFish
                        Junior Member
                        • Jan 2009
                        • 3

                        #71
                        Late Joiner

                        Escapee, firstly, thanks very much for a sensational intro to coding for Betfair using C# - the previous bots and tutorials I've written have been in Java and following a couple of years away from coding and a change in career, I've come back to start working in C#. This tutorial has been awesome for me so far!

                        At the moment, I'm up to the point of getting ready to create the prices control - I'm a bit late in joining this, but I'll post my progress anyway.

                        Struck a couple of issues with null pointers and so on, but it turned out they were just minor wrinkles, so I'm up and running now.

                        Here is my progress screenshot, I'm off to start section 7 now!

                        Comment

                        • Escapee
                          Junior Member
                          • Feb 2009
                          • 51

                          #72
                          BBorisovic,
                          " I would greatly appreciate advice on how to get correct StartTime value"

                          I'm not sure about tennis, but I do a very similar thing in football using a combination of getEvents() and getAllMarkets() calls to locate all football fixtures for today, and display them with thier (adjusted) start times in a list box.

                          You can extract the start time for a football match from the getAllMarkets() response, but remember it is in UNIX date format not Windows date format and so requires a bit of faffing to get it useful.

                          Comment

                          • Escapee
                            Junior Member
                            • Feb 2009
                            • 51

                            #73
                            ThanksFish
                            thanks very much

                            you're most welcome

                            Struck a couple of issues with null pointers and so on

                            It seems I might have omitted some code
                            Code:
                            using BetfairAPI.BFGlobal;
                            using BetfairAPI.BFExchange;
                            from somewhere in the tutorial but I'm not sure where, and many people like yourself seems to be able to overcome this small issue.

                            If you can remember how/where you overcame this problem then please let me know and I will go back and edit the tutorial....
                            or maybe I should leave it as it helps the pupil if they have to use some gray matter occasionally
                            Last edited by Escapee; 28-08-2012, 02:29 PM.

                            Comment

                            • BBorisovic
                              Junior Member
                              • Jan 2012
                              • 2

                              #74
                              StartTime field value

                              Escapee,

                              Thank you very much.
                              Your advice help me to solve my problem.

                              Comment

                              • kawafan
                                Junior Member
                                • May 2011
                                • 33

                                #75
                                Very informative tutorial Escapee.
                                When the New Part is coming , waiting for "BETS" Related work like , match unmatched bets and Update bets

                                Comment

                                Working...
                                X