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: 3023
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: 6188
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: 215
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: 6188
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: 215
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: 6188
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: 1743
Joined: Mon Jul 02, 2012 10:45 pm
Contact:

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
Post Reply

Return to “Betfair Exchange API”