C# a Step by Step Beginners Tutorial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts

  • Fappes
    replied
    Originally posted by kawafan View Post
    SO , No New Updates ?
    Maybe the Thread "Using VB2008 to acccess the Betfair API: A tutorial" can help you.
    I havent seen this C# Tutorial and translated the VB Code for my needs to C#

    Leave a comment:


  • kawafan
    replied
    SO , No New Updates ?

    Leave a comment:


  • ThanksFish
    replied
    Originally posted by Escapee View Post

    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
    Hi Escapee, I have a feeling those two lines were exactly the things I needed to figure out, but for the life of me I can't remember where they were supposed to be - I think it may have been in the RefreshControl, because it was handling the GetMarketPricesCompressedResp object.

    Given that I can't remember where it was and neither can you, I think it's fairly safe to call this an "exercise in problem solving"

    Leave a comment:


  • Escapee
    replied
    Originally posted by kawafan View Post
    Very informative tutorial Escapee.
    When the New Part is coming , waiting for "BETS" Related work like , match unmatched bets and Update bets
    The problem is that this :



    is probably more complex and logically involved than the whole tutorial up to this point.
    Take a moment to think through what happens on the betfair webpage when you place and subsequently match or partially match a bet or five.

    Having said that, almost all knowledge that is required to evolve this bets module is already contained within this tutorial.
    Last edited by Escapee; 06-09-2012, 08:29 AM.

    Leave a comment:


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

    Leave a comment:


  • BBorisovic
    replied
    StartTime field value

    Escapee,

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

    Leave a comment:


  • Escapee
    replied
    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.

    Leave a comment:


  • Escapee
    replied
    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.

    Leave a comment:


  • ThanksFish
    replied
    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!

    Leave a comment:


  • BBorisovic
    replied
    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

    Leave a comment:


  • Escapee
    replied
    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.

    Leave a comment:


  • lakedman
    replied
    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.

    Leave a comment:


  • Escapee
    replied
    Ziggy plays guitar

    Anyone made much progress past the the tutorial ?

    Mine's called "Ziggy".

    Leave a comment:


  • Escapee
    replied
    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.

    Leave a comment:


  • osa_dev
    replied
    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?

    Leave a comment:

Working...
X