A suitable language to build a bot for a complete beginner?

Post Reply
Speculator_3
Posts: 61
Joined: Wed Feb 20, 2019 10:01 pm

I would like to build a bot to automate my football trades. The basic trading strategy is to use a trigger (i.e. certain event in the match) to enter a market, then trade out a part of my stake when another certain event happens, and let the rest of the stake run till the end of the match. There's more to it than that, but building a bot that does this in the first place would be a good start.

I am a programming novice ( I can write simple functions, loop statements and I am learning about object orientation at the moment, using C++). I am thinking of either switching to Java / Python / C# to build the bot since I assume using C++ would be way too complicated for this task.

So, my questions are:

1. Are the above-mentioned languages (Java, Python, C#) suitable languages for Betfair API? What would be the best language to choose?

2. Given that I am a beginner, is my aim feasible? I realise I may be getting ahead of myself, but I want to learn how to write a program that does something practical for myself, rather than going through contrived examples in textbooks.

3. I am thinking of buying "Programming for Betfair: A Guide to Creating Sports Trading Applications with API-NG " book by James Butler. Would this book be useful? Given that the code there is in Visual Basic, would I be able to take it as a starting point and translate it to the language of my choice easily?
spreadbetting
Posts: 3140
Joined: Sun Jan 31, 2010 8:06 pm

1) All are suitable languages so you'd need to choose which one you think would suit you best. One of the forum members has written and provided extensive code for python , I keep meaning to try it myself but never get the time and not sure you can get an extensive graphical interface with python as easily as you can with the other languages especially as I'd like to have input and the MS visual studio developers make that side quite easy.

2) Yes it's perfectly possible to write your own program, I started with php pre all the betting software simply because I saw the opportunities to bot the markets and php was free and lots of snippets. Looking back I wish I'd taken the time to learn a different language because I'm quite lazy and never upgraded my coding to anything other than VBA. Again VBA simply because A lot of the trading software connects to excel


3) Don't waste your time, I bought it and it's pretty much useless and outdated there's even a separate web page for it to cover all the errors/omissions in the book. There's a Betfair developers forum and snippets out there for most languages to get up and running.

At the end of the day you'd be surprised at how little coding you really need to get bots up and running as soon as you've understood the API basics and looping thru data responses.
User avatar
ShaunWhite
Posts: 9731
Joined: Sat Sep 03, 2016 3:42 am

If you're starting with a blank piece of paper then I'd agree with sb about something that's doable in VisualStudio (I use C#). The amount of support and info about VS is truely vast. Other languages have their fans and plenty of stuff on the net but VS really is the daddy.

I recognise your desire to just crack on and get things working, all those exercises making stopwatches etc can feel like a waste of time, but they do teach you some fundamentals so don't just dismiss them.

You biggest enemy wrt time will be diving in and writing 'something' because it will almost certainly need to be re-written later as your system develops. Don't underestimate the value of planning and design, the later changes occur in your project, the more trouble they'll be. When you become proficient you'll find that everyday you spend designing is something like Visio, with be two days saved messing around with code.

Good luck, it's a tough journey, it might take you 6+ months working on it full time and that's before you even start to work on finding edges, but it's worth every minute. And if the trading doesn't work out, you should be able to find a lucrative job using your new skills, so it's a win/win.

If you're going to start somewhere then start with data collection otherwise you'll end up with a fancy new trading system and no data to test anything on. It's also a nice easily definable objective and it will give you exposure to all the things you'll need (ie API interaction and database manipulation). Re: your database, I don't think you need to look much further than SQL.
pythonic
Posts: 65
Joined: Sun Jul 08, 2018 10:20 pm

Maybe it is obvious given my name but I would suggest python.
It is a good beginner language and a very popular general purpose language with a good ecosystem and also a very good API wrapper written by one of the forum members.
What's not to like?
User avatar
johnsheppard
Posts: 283
Joined: Mon Feb 04, 2019 6:00 am
Location: Cairns Australia

This guy here has done the C# work...including stream API stuff...https://github.com/joelpob/betfairng

Depends where you want to go in future...If you want a backup job if things fail...C# is much better to fall back on IMO...

Personally, I think 6 months is optimistic....well...yes the very basics....but realistically, a lot more to work is required to get to something that doesn't already exist out there...

If you want it to scale you'll want to learn about messaged based architectures and all kinds of complicated doodads...
User avatar
ShaunWhite
Posts: 9731
Joined: Sat Sep 03, 2016 3:42 am

johnsheppard wrote:
Thu May 16, 2019 4:11 am
Personally, I think 6 months is optimistic....well...yes the very basics
I was trying not to demoralise the guy...I tried to qualify that as full time so iro 1000hrs if it's well planned (daily or hourly) and structured work rather than just meandering. But I agree that's just to get a framework in place that does 'something' and will need a lot of blanks filling in still. It's certainly heavy on the doodads at the cutting edge and you can't fast track the experience you'll need to untangle the trickier problems.

How about a month on trainer wheels using vba in excel first (perhaps using sql) to see if he has an aptitude and to grasp essentials, then move on before it gets too ingrained. That way he'll have learned something useful even if the bigger project has to go on hold.
User avatar
johnsheppard
Posts: 283
Joined: Mon Feb 04, 2019 6:00 am
Location: Cairns Australia

johnsheppard wrote:
Thu May 16, 2019 4:11 am
How about a month on trainer wheels using vba in excel first (perhaps using sql) to see if he has an aptitude and to grasp essentials, then move on before it gets too ingrained. That way he'll have learned something useful even if the bigger project has to go on hold.
I suppose the main thing is that its fun :) If its fun well, who cares if you make any money...but I agree, a month is a good estimate for getting something up and going with something throw away...

Myself personally, I started out having zero interest in gambling and zero knowledge of trading. Somewhere along the line I came to thinking that writing a bot to automate online casino roulette's using a martingale technique was a fantastic idea...(didn't realise it was called that at the time, lol)....If I remember right, I think I came to that after learning about matched betting...and abusing bonuses, etc...

Somewhere along the line in the process of doing that I found out about betfair and their API...and figured it was easier to martingale that using an API rather than messing with screen/pixel based automation....

So I spent lots of time having fun with staking plans....and putting in random bets on random events trying to make profit purely from staking plans.....and lets just say I haven't made it rich :) Don't laugh :) haha... and I currently work in retail lol...

THEN I started to learn about trading...but haven't got very far yet :) My apps architecture has to change AGAIN lol... hence why I've started using BetAngel :)

I started doing it all in Access/VBA, then moved to C#, then it becomes a rabbit warren of different technologies with pitfalls at every corner... I chose those technologies not on capabilities, but because I have in the past been paid to maintain and develop access databases, and also some VB.Net stuff and figured I knew something...so use what ya know I guess... but from where I stand, I would still chose C# for a lot of reasons...

And on the other hand I haven't used python, but there is a certain wisdom in restricting yourself from getting into the warren...although...maybe it's the same... its hard to know... cause there's not enough time to try it all
Speculator_3
Posts: 61
Joined: Wed Feb 20, 2019 10:01 pm

spreadbetting, Shaun, pythonic et al: thanks for all your replies.

Shaun: you mentioned SQL / database connectivity. I would only need this if I wanted to test historical data, right?

Another thing. Untill now, I was under the impression that Betfair API readily provides the live scoreline info. Then I saw this thread: viewtopic.php?f=50&t=12490.

Am I correct in understanding that in fact, it is not possible to obtain a scoreline update from the API (in the first post in that thread it's mentioned "Without an actual score feed to trigger bets following a goal...") ? Is this lack of a score feed due to Betfair API itself, and as such would be universal, or is that thread only relevant for BetAngel software users?
User avatar
ShaunWhite
Posts: 9731
Joined: Sat Sep 03, 2016 3:42 am

Speculator_3 wrote:
Thu May 30, 2019 12:25 am
Shaun: you mentioned SQL / database connectivity. I would only need this if I wanted to test historical data, right?
If you're going to the trouble of interacting with the API you might as well store what you can, but it builds up fast. My UK/IE horse data alone is iro 1Gb a day. And if you want to store any significant amount of data then Excel really doesn't cut it. But just go one step at a time, and start by using Excel as both the database and the application. All that said, if you're just writing a bot then technically you wouldn't needn't store any of it, but looking forward you'll almost certainly wish you had.
Speculator_3 wrote:
Thu May 30, 2019 12:25 am
Untill now, I was under the impression that Betfair API readily provides the live scoreline info.
This will tell you what's in the API -> https://docs.developer.betfair.com/disp ... I+Overview
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

Speculator_3 wrote:
Thu May 30, 2019 12:25 am
spreadbetting, Shaun, pythonic et al: thanks for all your replies.

Shaun: you mentioned SQL / database connectivity. I would only need this if I wanted to test historical data, right?

Another thing. Untill now, I was under the impression that Betfair API readily provides the live scoreline info. Then I saw this thread: viewtopic.php?f=50&t=12490.

Am I correct in understanding that in fact, it is not possible to obtain a scoreline update from the API (in the first post in that thread it's mentioned "Without an actual score feed to trigger bets following a goal...") ? Is this lack of a score feed due to Betfair API itself, and as such would be universal, or is that thread only relevant for BetAngel software users?
If you go down the python route, I have added the inplayservice endpoint which is what the Betfair website uses for scores.

https://github.com/liampauling/betfair

https://github.com/liampauling/betfair/ ... service.py
Speculator_3
Posts: 61
Joined: Wed Feb 20, 2019 10:01 pm

LinusP wrote:
Thu May 30, 2019 7:51 am
Speculator_3 wrote:
Thu May 30, 2019 12:25 am
spreadbetting, Shaun, pythonic et al: thanks for all your replies.

Shaun: you mentioned SQL / database connectivity. I would only need this if I wanted to test historical data, right?

Another thing. Untill now, I was under the impression that Betfair API readily provides the live scoreline info. Then I saw this thread: viewtopic.php?f=50&t=12490.

Am I correct in understanding that in fact, it is not possible to obtain a scoreline update from the API (in the first post in that thread it's mentioned "Without an actual score feed to trigger bets following a goal...") ? Is this lack of a score feed due to Betfair API itself, and as such would be universal, or is that thread only relevant for BetAngel software users?
If you go down the python route, I have added the inplayservice endpoint which is what the Betfair website uses for scores.

https://github.com/liampauling/betfair

https://github.com/liampauling/betfair/ ... service.py
Thanks Linus - will have a look.

I had a look at some commercial bots available for purchase - looks like they can't do apriori exactly what I want (maybe they can, but it's not straightforward to set them up like this).

So indeed, I will have to head down the route of trying to build this bot myself.
User avatar
firlandsfarm
Posts: 2688
Joined: Sat May 03, 2014 8:20 am

ShaunWhite wrote:
Wed May 15, 2019 2:55 pm
... it might take you 6+ months working on it full time and that's before you even start to work on finding edges …
johnsheppard wrote:
Thu May 16, 2019 4:11 am
Personally, I think 6 months is optimistic....well...yes the very basics....but realistically, a lot more to work is required to get to something that doesn't already exist out there...
Shaun/John, are you suggesting it would take one person at least 6 months, full time, to design, write and debug the code for a bot? I find that amazing. I'm not saying I disagree, I have no idea what would be involved but … wow!

I have used BA off and on over the years (currently on :) ) and have tried to compare it within a group of available bots. That is at least 6 months work and at the end you still don't know if you are going to get what you want. yes you can draw up a "does and does not" list but it's not until you use a bot and really get into it that you realise just how important those little seemingly insignificant do's are. Public bots evolve 'democratically'. They start in their originator's eye and then embark down the evolution road. The journey is largely influenced by the originator's developing needs but as the originator slowly exhausts their list of needs this gives way to what the users want tempered by commercial reality so it may never do what some users want.

To discover what you can do with a bot takes an extraordinary length of time. First you learn what it does (that's the comparatively easy part, you read a manual) but then you have to link those exclusive facilities together to find out what it can do. But at that stage you are not sufficiently familiar with what it does to immediately think "if I do A then B and lastly C it will do what I want" so you spend a lot of time thinking how to do it and you ask and beg for help on a forum and maybe, if you are lucky you work your way through it. To learn each bot is no different to learning each programming language. So for some it may be quicker to learn and build their own bot than compare off the shelf products and at the end of it not only do they (hopefully) have something that does exactly what they want (within the capabilities of the market) but maybe they have something they can sell. Of course another alternative is to find a guy beavering away in his bedroom to write the code but that has it's downsides.

BA is a very good product and I would put it in the top 2 of the ones I have looked at but I think the market is wanting a bot builder along the lines of the various web builders (e.g. Wix) and financial market builders (e.g. MetaTrader).
PeterLe
Posts: 3715
Joined: Wed Apr 15, 2009 3:19 pm

Re the Book..
3) Don't waste your time, I bought it and it's pretty much useless and outdated there's even a separate web page for it to cover all the errors/omissions in the book. There's a Betfair developers forum and snippets out there for most languages to get up and running.

[/quote]

Id agree with this; i hit some problems and the author wouldn't help (nor were the errors covered in his separate web pages) Its out of date now anyway

i already had my own bots up and running anyway which were built with C++
If you are new to coding, there are some great courses on UDEMY, for around £15 - £20
regards
Peter
User avatar
firlandsfarm
Posts: 2688
Joined: Sat May 03, 2014 8:20 am

PeterLe wrote:
Sun Jun 02, 2019 10:33 am
If you are new to coding, there are some great courses on UDEMY, for around £15 - £20
Thanks for mentioning that Peter, never come across that website before, it looks to be a huge depository of information
PeterLe
Posts: 3715
Joined: Wed Apr 15, 2009 3:19 pm

firlandsfarm wrote:
Sun Jun 02, 2019 12:04 pm
PeterLe wrote:
Sun Jun 02, 2019 10:33 am
If you are new to coding, there are some great courses on UDEMY, for around £15 - £20
Thanks for mentioning that Peter, never come across that website before, it looks to be a huge depository of information
No probs; glad it was of use
By the way; DONT pay the full price, there are loads of codes around for discounts on Udemy, you shouldn't pay more than say £20...
Thanks
Peter
Post Reply

Return to “Betfair Exchange API”