Scared money

When I used to play poker in one of London's casinos you would often hear the phrase "scared money". The phrase refers to the cautious players, beginners etc. who didn't want to risk too much money.

These players would play with a very small stack of chips in front of them and when it was gone they would walk away. They would do all they could to protect their little stack of chips and that meant dropping hand after hand until they had a monster. All I had to do was drop my hand whenever they kept theirs.

My bankroll for such games was always a lot larger than my opponents. They would buy in for £50 or so. I would buy in for £500 or more. There was never any intention of using the full £500. I just wanted everyone to know that I had them covered. The value of my stack was immediately forgotten as I tried to bully people out of a hand.

Poker is more about finding the right players to play against than anything else. Whenever I went to the casino I would say, "Hello" to my acquaintances, as I passed them by, heading for the easiest table I could find. Usually, a table with tourists or people I knew that had just started coming to the cardroom and were still learning the game. But what has this to do with sports trading?

A common question from beginner traders on the forums is, "What size should my bankroll be?" Alternatively, they will say, "I am going to start with £50 and see how it goes." Immediately, I know their money to be scared money.

A common outcome for a beginner's small bankroll is that it will dwindle away because the fear of losing the bankroll doesn't permit them to trade effectively. When they start trading, all they can see is a zero, sometime in the future, at the bottom of their spreadsheet's profit and loss column.

From that moment on, the beginner trader will be more concerned with not losing money rather than winning money. Any small reversal against them and they are out for a loss, only to see the market swing back in their favour.

Before you determine a bankroll size, you need to determine a winning system. That system will have an expectation or expected value, in other words, how much you can expect to win per £1 bet. Of course, you cannot expect to make exactly what is expected. Indeed, a winning system can lose for while and a losing system can appear to win before reverting.

There is no real answer to the question, "How big should my bankroll be?" Your bankroll should be big enough to cover the volatility of your trades. Only experience and a history of previous trades will give you a value for the variance of your returns.

Whatever bankroll you decide upon, its value should be forgotten. Your prime concern now is to trade to win and never not to lose.

High-Frequency Trading on Betfair

BetAngel is now offering co-located servers for trading on Betfair and BetDAQ. This is a new service and not related to the original VPS that they offered.

The servers are not as close to the exchanges as in financial trading (where the distance between exchange and trader servers is measured in metres) but as close as Betfair will allow you to get.

Already, BetAngel have reported denial of service attacks on the servers (see here) to deny or slowdown the service. The chief suspect being those who wish to protect their preeminence on the exchange.

In the past I have reported on Betfair's use of their own traders and bots to increase profits and that Betfair's exchange is probably a dark pool. High-frequency activity by sophisticated bots leads one to believe that the playing field is not level for all participants.

Maybe it is time for tighter regulation of betting exchanges to ensure that the public are getting a fair deal.

I am keen to move my own bots closer to Betfair's data centre. However, after reading of the problems that BetAngel are having, I would locate my bots to servers that are not advertised as being dedicated to giving the fastest access to Betfair.

Still, I wouldn't put it past an exchange to have a team of people logging access times and running a bespoke attack on an IP address, no matter where you are located.

More so than ever, as with the financial markets, making money from sports betting has less to do with sport and more to do with market structure and taking advantage of it.

Further Reading

Betfair bot observations

Betfair, a form of dark pool?

Dark Pools: The rise of A.I. trading machines and the looming threat to Wall Street

Which financial indicators suit sports trading?

You've all seen them. Take any 3rd-party sports trading software and you will find a myriad of indicators. From candelsticks to moving averages, to the odd sounding Bollinger Bands and stochastic oscillator.

The novice with no idea of how to trade sports markets will open up a trading ladder and see the prices jump from one place to another and wonder what to do next.

They will then open up a chart and see the time series snaking up and down. Again, they will wonder what it has to do with profiting from sports trading.

Finally, the novice will open up the indicators list on the chart and wonder which of the many indicators will divine untold riches. Everyday, I see these novices in the online forums. They have heard that some people get rich from sports trading and they want the short-cut route to joining them.

Sports betting is usually done on the day of the event. In that respect it is like financial day trading. Yes, there are sports markets that open before the start date. For example, horse racing markets usually open the night before but volume is thin and volatile. The classic flat races, The Grand National or The Gold Cup markets will open far in advance. However, in the main, the window for trading a sports market is pretty small.

Sports trading in the temporal aspect is very different to financial trading. In financial day trading there is always tomorrow. A stock, a currency pair, option or futures contract will still be around tomorrow even when you stop trading today. In sports trading you get one day in which to profit from the event.

When trading sports markets things happen that much more quickly. Financial indicators are usually used on a day by day basis rather than second by second. Also, financial assets are priced to the penny. Sports betting markets are priced by odds and the jumps between the odds are not continuous.

An indicator such as a moving average is just that, an average, used to smooth out a time series. Such indicators don't work so well when they are working with discrete prices such as the range 2.98, 3.0, 3.05 and 3.10. Range indicators such as Bollinger bands are easily broken through and may offer a false signal.

Sports trading is as different to financial trading as it is the same. The buying and selling, supply and demand is the same in any market. However, the underlying structure of the markets is very different. The similarities between sports and financial markets are only superficial and because of that I have thrown out all financial indicators and developed my own sports trading indicators.

As I have said before, 3rd-party trading software can force the unwary to be trapped into a trading regime dictated by the software they use. I started trading using 3rd-party software but now I code my own trading software. Doing that has freed my mind to appreciate the differences between sports and financial trading markets.

Betfair bot observations

Spend any length of time on Betfair's exchange and you will see bots in action. A lot of bot action is instigated by Betfair itself.

To a large extent Betfair's sports betting exchange is a dark pool. However, I don't believe any of the users are getting preferential treatment as the High-Frequency firms are in the financial markets. More that Betfair itself has bots running on the exchange to hoover up loose change.

Maybe dark pool is a strong term, considering its negative connotations in the financial world but the exchange exists to make Betfair's shareholders wealthy people.

Now, Betfair has its own traders and also its own fixed odds service for those who just want to bet and not get involved with trading. The more profit Betfair makes the happier are its shareholders. Betfair's traders will have their own idea of where prices should be. Coupled with that is demand from the fixed-odds service, which means that Betfair is always dipping into the exchange when it sees a value arb or wants to balance its book.

When there are large gaps on the ladder I like to place minimum £2 bet (sub £2 bets tend to be ignored - hence my view that Betfair is involved) here and there to see how the bots react. If there is a one or two tick gap in the spread I might place £2 within the spread to see if the bots are backing or laying. More often than not your £2 is taken within the blink of an eye.

Again, I don't think anyone is getting preferential treatment but that sort of speed suggests some form of low-latency activity. And, as Betfair does not (to my knowledge) permit co-location then that is probably a bot inside Betfair's data centre snapping up my £2.

Not only that but the bot appears to have a quantity in mind that it wants to take. If you fire in multiple £2 bets quickly enough you will sometimes see the amount that the bot would like to back or lay. There will be a fleeting moment of the amount used to snap up your £2 and then it will disappear.

For example, if I continuously place a lay bet of £2 in rapid succession on an empty price in the grid and do it fast enough then I will first see maybe £50 hit my £2. The next time I place £2 the bot will jump on it with £48. The following £2 bet will be hit by £46 and so on until the bot has attained the £50 position. Obviously there is someone out there desperate to open a £50 position at that price.

I assume that the volume is removed immediately after grabbing the £2 so that it too is not snapped up by another bot. This all gives credence to my view that this is a Betfair bot with, I am sorry to say, an unfair advantage. An advantage that supports my view that the exchange is a kind of dark pool with different rules for different users (the users being Betfair and then us).

Another thing you can do is place your £2 in a large gap that might have developed between backers and layers. Within a split second more volume will be placed on and behind your £2. On thin volume you can place your £2 on an empty price behind the front backs and lays. Again, it will set off a flurry of activity.

After a few bets have been taken on either side of the spread you can see the return legs of the bets being placed on the other side of the spread. More often than not these bets are placed in anticipation of movement and bets to be matched in the future.

Finally, about 20 minutes before the race the ladder will suddenly fill with volume a good 10 to 20 ticks either side of the spread. It's not a gradual ramping up of volume. It just appears in a split second. Maybe it has something to do with Betfair's fixed-odds sports book.

Not only that but the amount of volume (even far away from the spread) is constantly changing. I believe it might have something to do with fixed-odds and/or SP betting but that is not my field of interest so I'll leave that for someone else to work out.

There is a lot of maths going on in Betfair horse race betting exchange and most of it doesn't have anything to do with horses. That is what I find so fascinating about exchange betting; market structure. There is so much more to making money from trading the structure of the market and I enjoy learning about it.

I hope you enjoyed this article. I would be interested to hear your thoughts.

Nice hobby - I wouldn't do it for a living

These days, making money from horse races has little to do with horses. I wonder why many people (I call them 'The Old Boys' hence the photo) still analyse past horse race data.

In finance we call them fundamentalists, people who read reams of data to ascertain a true price value. As with their religious counterparts these fundamentalists are very rigid in their thinking. Nice hobby but I wouldn't want to do it for a living.

Who wants to earn money whereby on some days you make a loss and you have no idea why? Is the betting system broken or does it have negative expectation and will fail anyway? If you have what it takes to be a trader then after the intial learning curve there will be very few losing days, if any at all.

If I have a low yielding day from trading then I can usually narrow it down to getting stuck on a horse and over-trading. Either a reversal was missed and I had to trade my way out of it or I tried to noodle around scraping up pennies on narrow margin trades. Either of these two will add turnover for little return thus impacting on yield. Over-trading being my sole concern, trading is a lot easier than betting.

This morning, I awoke at 9:10AM, a little late as I have Seasonal Affective Disorder. I normally sleep with the curtains open so that sunlight awakes me naturally, every morning. In the summer, I leap out of be at 5AM to start the day. In the winter, if the day is as overcast as today then I drag myself out of bed at between 8:30AM and 9:30AM.

As with any morning, the first thing I do is to switch on the PC and start my software running. I am very happy with the code that I created using the new Betfair API. The ability to monitor every runner in every race has increased the amount of trading I do. More trading leads to more turnover and more profit.

The names of race courses, runners, jockeys, owners and trainers are unknown to me. All I am interested in is trends. By 10AM I have started to open some positions and by the start of the first race I have opened all the positions that I am likely to open that day and have profits that give me leeway to speculate when the larger volume starts arriving before the off.

For most of the day its a case of monitoring positions. A position might reverse and it's a case of easing into a new trend or closing out for a minimal loss. Nearer to the race start time I will start selling my position back to the market, a little at a time. Initially, to lock in a profit and then to make the most of it, if the position has done very well.

At no time do I look at a horse race. I know that other trades have a video link to the race but I never do. Any shenanigans in the paddock, leading up to the race start, will make itself known to me in the price but by then I will already have profits with which to cashout or use to trade a new position with.

Whenever I read online forums dedicated to form, I am always amused. By and large the systems they come up with are so specific that I doubt they will be used much. Broadcasting them to the world doesn't help either. The idea of placing a bet on a horse and waiting for the end of the race is anathema to me. I am done and dusted before the race starts.

The late afternoon and evening is for me to do with as I please. No reading form nor watching videos of previous races. The hard work was in understanding how betting markets work. By that I don't mean the simplicities of how backing and laying works and the overround. There is a lot more to betting markets than that; such as structural and psychological factors.

Much of the structure of a betting market is very subtle but easily understood by any finance quant. Whilst most form followers could never understand how to trade, many people who trade profitably do so minus a lot of knowledge that could make their trading even more profitable. Using 3rd party software with which to trade many traders are constrained by the capabilities of their software and do not have the imagination to try new avenues of thought.

I have a simple motto and it goes like this "I like going to sleep every night having learned something new." Even though I am a profitable trader I am not resting on my laurels. I am constantly developing new ideas, coding improvements to my software and researching the effects of little anomalies I notice during the day.

If you want to make money from horse racing then forget the horses. For me the only aspect of horse race betting that involves horses is the fact that without them I wouldn't be able to trade on the races. For that I am grateful.

Betfair API-NG Tutorial #3 - Getting a List of Markets (part 1)

In this tutorial we shall build a simple application using Visual Basic that does no more than gather a list of all races and runners for today's UK horse races.

This tutorial teaches only interaction with Betfair's servers and is not intended as a lesson in Visual Basic programming. Readers who are not experienced in designing GUIs (Graphical User Interfaces) or the intricacies of programming are advised to research such topics elsewhere.

From the previous two tutorials we should now be able to login to Betfair. We shall access the betting server and make a call to get today's races and runners.

After we have started a new project in Visual Studio we create a new module and call it BettingAPI.vb. We then copy the following code into it.

Imports System.Net
Imports System.Text
Imports System.IO
Imports Newtonsoft.Json

Module BettingAPI

    Public ssoid As String 'single sign-on Id
    Private appKey As String = "YOUR APPLICATION KEY HERE" 'application key

    'function to send JSON request to betting server
    Private Function sendBetReq(ByVal jsonString As String)


        Dim request = CType(WebRequest.Create("https://api.betfair.com/exchange/betting/json-rpc/v1"), WebRequest)

        Dim byteArray As Byte() = Encoding.UTF8.GetBytes(jsonString)

        request.Method = "POST"
        request.ContentType = "application/json"
        request.ContentLength = byteArray.Length
        request.Headers.Add("X-Application: " & appKey)
        request.Headers.Add("X-Authentication: " & ssoid)

        Dim dataStream As Stream = request.GetRequestStream()
        dataStream.Write(byteArray, 0, byteArray.Length)

        Dim response As WebResponse = request.GetResponse()
        dataStream = response.GetResponseStream()

        Dim reader As New StreamReader(dataStream)
        Dim responseFromServer As String = reader.ReadToEnd()

        reader.Close()
        dataStream.Close()
        response.Close()

        Return responseFromServer

    End Function

    'Classes for MarketCatalogue request
    Public Class MarketCatalogueRequest
        Public jsonrpc As String = "2.0"
        Public method As String = "SportsAPING/v1.0/listMarketCatalogue" 'the betting operation
        Public params As New Params 'parameters for this operation
        Public id As Integer = 1
    End Class

    Public Class Params
        Public filter As New Filter
        Public sort As String = "FIRST_TO_START"
        Public maxResults As String = "200"
        Public marketProjection As New List(Of String)
    End Class

    Public Class Filter
        Public eventTypeIds As New List(Of String) 'horse racing = 7
        Public marketCountries As New List(Of String) 'UK = GB, Ireland = IRL
        Public marketTypeCodes As New List(Of String) 'WIN, PLACE
        Public marketStartTime As New StartTime
    End Class

    Public Class StartTime
        Public from As String
        Public [to] As String
    End Class

    'Classes for listMarketCatalogue response
    Public Class MarketCatalogueResponse
        Public jsonrpc As String
        Public result As List(Of MarketCatalogue)
        Public id As Integer
    End Class

    Public Class MarketCatalogue
        Public marketId As String
        Public marketName As String
        Public marketStartTime As String
        Public totalMatched As Double
        Public runners As New List(Of Runners)()
        Public [event] As New [Event] ' event in [] as it is a reserved word
    End Class

    Public Class Runners
        Public selectionId As Integer
        Public runnerName As String
        Public handicap As Double
        Public sortPriority As Integer
    End Class

    Public Class [Event]
        Public id As Integer ' meeting ID - not to be confused with marketId
        Public name As String
        Public countryCode As String
        Public timezone As String
        Public venue As String
        Public openDate As String
    End Class

    Function GetMarketCatalogueResponse(ByVal jsonRequest As String)
        Return JsonConvert.DeserializeObject(Of MarketCatalogueResponse())(sendBetReq(jsonRequest)) 'deserialise JSON response to VB MarketCatalogueResponse
    End Function

    Function CreateMarketCatalogueRequest(ByVal requestList As List(Of MarketCatalogueRequest))
        Return JsonConvert.SerializeObject(requestList) 'serialise VB object to JSON request
    End Function


End Module


We will notice that there is an error and that the Newtonsoft.json package is not recognised. This is because the library is a third-party library and is not a standard Microsoft library.

Microsoft has its own library for handling serialization but it is slower than the Newtonsoft library. As time means money then we shall use the faster library. To add the library to our application we must first download it. We do so by visiting https://json.codeplex.com/releases/view/121470 and clicking on the file below RECOMMENDED DOWNLOAD. We then unzip the download to any suitable directory.

From the Visual Studio IDE we click the PROJECT drop down menu at the top of IDE and click Add Reference. On doing so a dialog box will appear with a Browse... button at the bottom. We browse to the folder into which we unzipped the Newtonsoft library, enter the Bin directory and then the NetXX (XX depends on the current iteration) directory under that. We double click the .dll file in that directory and click the OK button on the dialog. The Newtonsoft library should now be recognised.

At the top of the Module we see the various imported libraries to handle the web and JSON functions that we are utilising in this application. The variables ssoid and appKey are stored in the Module as these are specific to the BettingAPI. We will need to replace "YOUR APP KEY" with the one received from Betfair in the previous article.

If the classes for making the listMarketCatalogue request are understood then we can go ahead and build an application to display races and runners. Remember, we will have to use the login from Tutorial #2 to get our ssoid and place that string into the ssoid variable in the BettingAPI module. In the next tutorial we will show how to get a complete application running for those who are struggling.


More tutorials here

Agent-Based Trading Models

Here is an interesting article written by J Doyne Farmer (previously mentioned in my last article as one of the creators of the first digital roulette computer) on agent-based trading models.

Farmer co-founded The Prediction Company, a company that has created trading models since the early nineties. Since then Farmer has returned to academia and now researches complexity economics at Oxford Univesity.

I am beginning to look at agent based models myself. My intention is to create a model horse race betting market containing various agents; naive bettors, arbitrageurs, trend traders to see how they interact with each other.

From there I will probably use genetic algorithms to evolve traders that will enter the market and attempt to maximise their return. The aim will be to see if there are any trading strategies that are superior to others under certain circumstances.

In time I will create a citations page for J Doyne Farmer as complexity is something that I am beginning to move into and his papers have a lot of interesting material (if not extremely readable compared to some papers) in them.

Toward Agent-Based Models for Investment

The Predictors - A book about the setting up of the The Prediction Company.