by korkenzieher » Mon Mar 16, 2009 3:54 pm
Hi. I registered just to answer this mail, so I might not be around for any responses. But in trying to find out how to do it, I had the same basic problem-How? What do I need to know? So I thought I would weigh in and tell you how I went about it.
You don't give any indication of your starting level, so I have kept assumptions to a bare minimum. Unfortunately, this also means I have to keep detail to a bare minimum.
I have a crude, but functioning BOT. It has taken some time, coming from a position where I could already program (though rustily) and had made certain choices of how to go about it. I had already developed the strategy I wished to program too. The only stuff I could find really, was a (quite poorly) written ebook by a chap called Richard Wildman. He has since succumbed to cancer, and I think the book is no longer available. Even with it, it was more or less learning from the beginning, as far as writing for the API was concerned.
Where to start - if you can program already, then that is where to start.
If not, you are on a steep learning curve! I use C#. Coming from a background in TCL, C, SQL and so on, it ought to have been easier than it was, though it came back quite quickly once I started. C# is a good choice because you need to know less about web protocols than coming from, say, Java (specifically XML and SOAP); plus there is a lot of help available for Visual Studio, C# and .Net etc. Get or download some books on writing C#. VBA could be considered too, since it is also supported in Visual Studio, and you would have more option to write stuff in VBA say on Excel and port it, than just writing C# will give you. But I chose C#.
Download and install visual studio express from the microsoft website. It is free. I have the fully featured 2008 version, but you don't need all that. If you don't know where to start, then again on the MS developers website, there are several tutorials. The video tutorials from Mark Tabor of LearnVisualStudio.NET (on the MS site) are as good a way to go as any (about 400MB of download!). Unless you are very familiar with object orientation, and general programming constructs, you will need to watch them 2 or 3 times. Each run through is a good 7 hours. Also, look for online guides like csharpcorner and bookmark them. You will be looking at examples on a regular basis, and not knowing which overloaded method to use will be confusing, until you see examples that basically do what you want and you can modify them. You don't need to write beautiful code - build a dinghy and learn how to sail, before crafting a battlecruiser! Learning how to use VisualStudio itself, and write C# will take some time. If you are starting from this level, the whole thing could take 3-6 months of quite hard work.
Download the API documentation from Betfair developers site. This basically tells you how to call specific functionality (like logging in, or placing a bet), and what the response from them will look like. The documentation is a 200 page document with a load of tables documenting data types and structures. You will become very familiar with it!
In essence, what you are aiming to do is make a call to the API in which an object (bunch of data) is sent with an appropriately formatted header, and a return object received back, with (you hope) the correct response inside the data it carries.
Download their sample code (I think it is for the API 5, which is older). You won't learn much from it, until you basically know how to do everything, but once you do, it will make everything more obvious on how to go forward.
One thing which there is very little help for, is how to configure your visual studio application for use with the web services. You will need to add the service references before you can use any of the API functionality. It is a menu item (add web reference), and you will need to do it for the UK and AUS servers, and for the WDSL. You can find references on the betfair developer sites, as to the URL's you need to link to. It is not particularly obvious, and you will probably learn quite a bit just by solving that problem.
Once you have a basic VS application, and it is connected to the API service, then design (from the video tutorials) a simple form, just to log on to the betfair server. You don't need anything more than that as a proof of concept / connection. Then you will need to scour the API documentation and work out how to send the calls and process the returns you want. It isn't possible to help you here too much, without writing a course, but once you get to that point, you can start figuring out which calls you need to add (getEvents, GetPrices, PlaceBet etc.). Learning to use the debug facilities to look at what is being returned will speed things up; and from that you will soon see which bits of the return objects you need, and where they are. Intellisense, in visual studio helps quite a lot here.
Once you can get the market data, you have to parse it, find the bit you want and then (and only then!) plug into your custom strategy, return a bet, test if necessary etc etc. This is all evident from the API documentation - once you have learned how to read and use it!
After that, you may want to start looking at things like threads, spiders and so on, to start monitoring the site and perhaps building more complicated interfaces and so on. But at that point, you will have a basic, simple bot which you can click on, and it will go get information and do stuff according to what you have written.
I should say, that for anyone who can write C# and understands .NET, they would be up and running in an afternoon. I should also say, that you can pay people to do this for you, but there really isn't too much alternative to putting in the hard work. There is a lot to it, and then really not so much depending on your start point.