Mathematical and Programming Skills for Sports Trading

I received a question in the comments section of my previous article, Change Your Environment to Promote Success, about the level of mathematics knowledge required to be a sports trader. My answer was so long that I decided to write this article with it. The question was a difficult one to answer because sports trading has many entry points, some requiring a lot of mathematical skill and some requiring less mathematical skill but still a lot of common sense. I could talk in terms of academic qualifications but judging by the commenter's use of the term "math" rather than "maths", as we say in the UK, means that the questioner's education system is probably different to the one I went through and so I will answer the question in more general terms.

The commenter asked
But where to start and find reliable learning sources for improving math skills, should I first remind myself with high school basics and gradually go towards more complex math,what do you think how should I organize my learning,having in mind that I only know basic math(maybe little bit better but lets say just basics is with what I am completly proficient),but never had problems with understanding math concepts,or some kind of math fobia,so question is how and where to start in that way that my learning would be really fruitul,applicable?And one more question do you think it is wise first to get decent math knowledge as a foundation prior to learning programming? Thanks in advance.
There is the gambling quote, "I'd rather be lucky than good," which means so long as you are making money then why worry. If you are making money with little academic acheivement and you like what you are doing then it is quite all right to not want to put any extra baggage in your mind. After all, you are unlikely to use it.

Some people can start off in sports trading and make a profit without really knowing what they are doing. Either they have some latent talent that cannot be quanitified or they are extremely lucky and the law of large numbers is waiting around a dark corner with a cosh, to mug them of all their winnings.

If the idea of sitting in a chair all day long, looking at screens and making money appeals to you then I suppose sports trading is as good as any other job but for one difference. In any other office job (with the exception of proprietary financial trading) you are being paid by someone else to do the work. As a trader you are being paid by yourself and if you have no talent then you are going to lose money. That talent might be inate or it might be created through study, of which mathematics will play a part.

Recently, there was a short series of programmes on UK television about Corals, a bookmaker. One episode showed one of Corals' high street betting shops and the people that go there to bet. Betting shops in the UK are now permitted to have gaming machines in them. As if fleecing people with overround sports books wasn't enough these gaming machines offer video roulette and other such casino games with which to demonstrate negative edge games to the public. One visitor to the bookmaker wasted his unemployment benefit on a video roulette machine. His lack of simple mathematical skills probably kept him drawing benefit and heading to the the machine. Unfortunately, many people do not understand the concept of edge and lose heavily (what else are they supposed to do?) to these machines.

However, I am not sure that a basic understanding of maths will help those people who gravitate towards gaming machines. As discussed by myself and Casini in Perpetual Change, for some people the laws of probability do not matter to them. Luck will conquer all. It would appear that Steve Jobs is not the only one who enjoyed a reality distortion field. Seeing as these machines only take £1 bets you would have to have an enormous reality distortion field to give you a winning run long enough to make you seriously wealthy. Even in sports trading it is easy to create a spreadsheet showing you how your winnings are going to ramp up and dump you on a sun drenched island in the Pacific. Reality is never like that. All the blogs I come across (including this one) are written by people plugging away in their spare bedroom under dreary UK skies.

I guess the best kind of maths to learn is the kind that shows you what a bad bet looks like. I can't teach anyone how to become rich but I can stop them from losing money. After that it is up to you to decide what you want to learn, depending on the kind of betting/trading that you want to do. I wrote an article on edge, Edge, Expectation and Kelly Criterion, which should explain, in simple terms, how to determine a good bet from a bad one. You can ignore Kelly Criterion, for the time being, as that is more to do with money management. 

When building and evaluating systems, a useful book to have is Joseph Buchdahl's, How To Find a Black Cat in a Coal Cellar. Ostensibly, the book teaches you how to evaluate other people's systems but the mathematics within can help you to evaluate your systems too. The particular branch of mathematics used by Buchdahl is statistics and probability theory. If you want to read up on maths that is of use to a sports trader then that area of maths is the place to start your reading. 

Any books that take you up to what we would call in the UK an A-Level standard (pre-university level) in statistics and probability would suffice. I don't think that not having a mathematics qualification as a school leaver will stand in your way, if you are really interested in becoming a sports trader. We have all wondered, as school children, what the point was of learning maths that had nothing to do with the world around us. Eventually, though, some of us will want to fill our world with things that have mathematical properties and maths is the tool that helps us to understand those mathematical properties.

The things you need to learn are :-

 - How do markets work? The battle between backers and layers. Each side wanting to make money, tugging prices one way and the other. 

- Price oscillation as the market determines the price through the Wisdom of the Crowd. Trends created when prices relax as the book becomes less overround or as momentum is created through new information entering the market.

- The effect of late breaking and inside information on prices.

- The roundness of the book. Odds can be converted to probabilities - 100% is a round book. >100% is overround and erodes betting profitability.

- Determing when you have an edge. When betting, is the price right? When trading, is the price going to move in the direction you think it will move?

 - Mathematics for system building. Charting, simple statisitcs for building your own metrics. A few select charting techniques used in financial trading - e.g. the moving average and volume analysis.

- Money management. Making the most of an edge. Losing as little as possible when that edge turns negative. Now you can learn about Kelly Criterion.

Your interests will determine what you want to learn. Gathering data, spreadsheeting and charting it will make you ask questions. Those questions might require you to research on the web for a mathematical skill or tool to help you answer the questions. Research plays a large part in sports trading. An enquiring mind and a search engine can go a long way.

As far as programming is concerned, it always annoys me when someone asks, "Which language do you like/usually program in?" It's a silly question. If you can program then you shoud be able to program in any language, after suitable conversion. All pogramming languages are based on logic and so I would recommend a basic understanding of predicate calculus. That's rather old school and probably today's programmers learn Python, have no idea what predicate calculus is and refuse to program in any other language. 

Still, thinking logically is the only way to write a computer program and not a course on a specific language. Programming is an art, more than a science and whatever programming your teacher teaches you then you will find another way. If you have never programmed before then you can't go wrong with Visual Basic and any beginner's book. However, like carpentry, you don't go to college to learn hammers or chisels. You learn how to be a carpenter, develop skills and use the appropriate tools.

i 8 sum pi and it was delicious

Further Reading


Change Your Environment to Promote Success

I ran into an interesting article about the environment affecting behaviour. From the moment we are born our environment acts like a mould, shaping our future self. I remember seeing an episode of Horizon discussing criminality, genetics and the environment. An example from the programme showed that a person may be genetically pre-disposed with psychopathic tendencies that could lead to a life of crime, but if that person was born into a loving and caring family then the worst they might ever be is a bit of an annoying control freak and nothing more.

In recent articles I have detailed my hardware set-up and the difficulty I have been having with my eyesight. Undoubtedly, sitting in front of a monitor all day and night is not a healthy activity. My eyesight has suffered and my general health too. I was a member of a tennis club until I decided to concentrate on completing my book earlier in the year. I haven't played tennis since the autumn of 2014 and so I need to think about joining a club again. As things are I get no exercise other than an occasional walk to the supermarket.

After getting my glasses prescription I realised that the glasses alone would not help my eye strain. The glasses are only good for reading and these days most of my reading is done from a screen with only a little book, tablet or Kindle reading. I decided therefore to change my working environment by setting the monitor further back, altering the monitor's brightness and contrast, changing the font size and trying to spend less time sitting in front of the monitor. It is too early to say if it has made any difference. I have thought about bifocal lenses but for now I won't get them.

The article I read on behaviour and environment, entitled The Most Effective Way to Change Your Behaviour and Improve Your Life goes further. Your environment affects the way you think, which I can vouch for after making bad trading decisions when hungry, angry or pre-occupied with thoughts not relavent to my trading activity and so on. This is what makes us human and why machines struggle to replicate human behaviour. A machine intelligence makes optimal decisions and then acts upon them. Humans are often "satisficing" (sufficing with decisions that satisfy a need) or thinking on the fly. That is why I use bots to trade with now. A bot doesn't get hungry or angry or worry about anything other than what you programmed it do. Just make sure you program the bot when your attention is fully focused on the task.

A quote I liked from the article was

We are often lazy creatures of habit, strongly influenced by the world around us. We don’t even use our leisure time to do what we really enjoy, we do what’s easiest. And without a prod we don’t do the ethical thing, we do what’s convenient.

I know that I can get stuck in a rut very easily. My rut can be very comfortable but if I don't get out of it then I know greater success will elude me. How about you? Do you keep promising yourself to learn to program but end up sticking to some simple half-working manual trading idea that only earns peanuts? Are you fearful of improving your mathematical knowledge because of a fear of failure?

This morning I realised that 20 years have passed since I graduated. There has been some hardship along the way, many bad decisions but also a number of successes. I decided to write down all the good and bad things over the past two decades. I won't share them with you as some of the things are rather personal but amongst them were things that I can be proud of. I need to create an environment that will promote more success and avoid  failure as best as I can. It is better to try and fail than not to have tried at all.

Trading Hardware

Following the publication of my book, Programming for Betfair, I have had a few emails asking about my hardware set-up. My set-up is quite simple due to the fact that I am not an in-play trader. I have just two monitor screens. There is no live feed on a monitor or television screen as I am out of the markets before they go-in-play. The second monitor is only used when the first screen is full and I need the extra space on which to spread my work out. The second screen also permits me to monitor bots trading on one screen and do research and development on the other


An algorithmic trader using bots could easily make do with a single screen. The item hiding under the plastic bag on the right of the picture is a laser printer. The bag keeps the dust off.


The rest of my hardware is kept in a rackmount system. I like rackmount as I can hide everything in a cabinet and keep it reasonably dust free. I am rather prone to dust; pollen in the summer and dust in the winter has me reaching for the antihistamines. The cabinet is a short style 19-inch rackmount cabinet, the type used for telecomms equipment rather than servers, which tend to be in much deeper cabinets that take up too much floor space.

The shorter telecomms cabinets are ideal for installing short ITX cases. The particular rack case that I use is a 1.5U case. I did have a 1U case but that required a blower to keep the CPU cool rather than a fan. Blowers are very noisy and I don't recommend them for home offices. They are better suited to data centres. The 1.5U case will only take one 3.5 inch or two 2.5 inch hard drives so I use external drives on a shelf above for additional storage.

I will probably put another machine in the rack in the near future. I am not keen on upgrading to Windows 10 although it looks as though Microsoft will soon change Windows 10 from an optional upgrade to a required upgrade. If I don't like what I see then I will probably go back to Linux. Now that Betfair uses JSON rather than SOAP through which to provide data I shouldn't have any problems with coding a price server and bot platform for Linux. When I last used Betfair's old API-6 on Linux the task was not a pleasant one. I like things that work out of the box. With Linux there is so much gluing to do.

The processor on my ITX motherboard is an Intel i7-3770K with four cores running at 3.5 Ghz and is still quite high up on the CPU benchmark website. There are some six core Intels now on the market, which are only a little more expensive than the price I paid for my processor two years ago that are a little more capable than my machine. Still, I am happy with my system as it can grab data for all the day's races and process it in under a second, which is good enough for the trading algorithms that I use.

As mentioned, I have used the Linux operating system in the past but I ended up dumping it. I don't like bolting things on and then tweaking them to get them running perfectly, which was what I always seem to be doing on Linux. For all its faults Windows is very much plug and play. That goes for Microsoft's Visual Studio programming environment too where I can create applications without having to worry about incompatibilities. And so I am caught in a quandry, preferring Microsoft for programming but not wanting to get caught up in whatever Microsoft has planned for the future.

I use the the 64-bit version of Windows 7. The Windows 10 upgrade icon sits on my taskbar but I have not been tempted to click it. It would appear that Microsoft is following other operating system vendors in monetising all aspects of an operating system with micro-payments here and there for everything. I regard micro-payments as another tax on stupidity, along with the lottery and mobile phone contracts. I am not a youngster who has been brainwashed into accepting micro-payments for everything. I believe in applying money management principles to all aspects of my daily life. I have a pay as you go phone but never call out with it. Email and free VoIP (voice over IP) are my preferred methods of communication. I have no television, no satellite receiver and no license fee compelling me to be brainwashed with BBC propaganda.

Currently, I program with Visual Studio Community Edition 2015, which allows me to code applications in BASIC, C++, C#, Python and F#. If I move over to Linux again then I will port my code to the Mono environment. As I have already said, that shouldn't be too problematic with API-NG's JSON based system. I will probably build another machine to run alongside the Windows 7 (assuming it has not been shutdown by Microsoft) machine rather than dual booting. There is plenty of room in the rack for more cases. I use PlusNet as my ISP and then only the slowest broadband option. This is fine for my needs as there is no other activity during trading. No downloads or media consumption to slow things down or risk being throttled by my ISP.

On my desk you can see lots of scrap paper, pens and pencils. This is for writing down ideas, which I can then research, test and implement. Whilst monitoring markets I watch for anomalies to exploit, novice bots being tested and more professional concerns to see what they are up to. The markets are constantly in flux and you have to be alert to new openings as once profitable areas dry up in liquidity.

My glasses are useless

The glasses are fine for reading so the prescription is correct. It's just that they are useless for computer work, of which excessive amounts of time in front of a monitor caused my layoff. I was recommended to sit closer to the monitor but at the range at which the glasses begin to work I am too close to the screen and cannot see all of it at once. If I continue in that manner then I could well end up like the actor in the picture, left (Ben Turpin for those of you under 100 years of age.)

I have resorted to moving the screen further away so that my eyes don't get tired from working too hard at focussing. The glasses I just use for reading things in my hands; books, fiddling with electronics and so on. I am having to take rest breaks, which I never like to do once I get into the flow of things. There is the 20-20-20 rule; every 20 minutes take a 20 second break to look at something 20 feet away. By the time I notice the time, an hour or more might have passed. I am just too used to pushing myself past the pain and continuing to look through squinted eyes.

My work output has decreased a lot in the past month but I will gradually increase it again. However, I am not sure that I can work at the level I once did before the eyestrain. It's a case of quality over quantity, concentrating on the next book more than anything else. Some coding and research when I am up to it. Thanks to all those who wished me well.