SOVRN banner

Tuesday, December 17, 2019

Fraud detection in real time

A couple of weeks ago I found this article about Codere, the Spanish gambling house. The article explains how Codere discovered serious inconsistencies in their yearly accounts, adding up to €20m (£17.9m/$22.0m) in losses. A very serious loss that reminded me of another customer I worked for a few years ago.
By chance, that customer I'm referring was also in the gambling sector and also had operations in South America, indeed they operated worldwide, but I was consulting for them because they wanted to address several kinds of fraud they had discovered in their slot machines in certain countries in America. So this article sparked my memories, and, as I think it was an interesting project and there some lessons to learn, here you have a small article describing it.

General View


As I said, the customer I was prospecting at that time -I will not disclose its name-, operated casinos all around the world with a lot of success. However, from time to time they discovered certain kinds of frauds or even bugs in their slots machines or casino systems they wanted to address. The main problem with this kind of issues it is not to find them out, but when do you find them out. If you have a system that alerts you as soon as a fraud -or a bug- is happening, you can stop the loss immediately and remediate it quickly. If, on the contrary, you allow it to run for days, weeks or even months, the loss increases as a snowball running downhill.

Problems to Address


One example of a bug was in relation with one of their slots machines. It was not their more popular machine, it offered a new game that was only used by a marginal group of users. However, at the end of a given month, when the usage data of the machines arrived the headquarters, the team of business analysts found that this specific type of machine had increased in popularity in an amazing 4000%!!
For some weird reason suddenly everybody wanted to use that machine. So they decided to understand why.
The next discovery was that, in spite of the spike in the number of users, the machine was losing huge amounts of money, but the ratio of winning/losing games did not favor the gamblers, so something very funny was going on.
After retiring the machines from the casinos and sending a team of engineers to find it out, they discovered the real reason of the sudden popularity of the slot machine and why it was losing money: the software had a bug, a very subtle one. 
The machine allowed gamblers to pay with cash, including bank notes, returning change of the amounts not used. The bug consisted in the wrong recognition of a very particular kind of bank note when running one single bet in the machine: when a $20 note was inserted in the machine, and just one bet was used -valued in $1-, the machine returned $99 in change instead of $19, as if the note introduced was a $100 one.
It was a very weird bug, as it didn't happen if the gambler used any other number of bets than one, and only with $20 notes. But word spread quickly among gamblers and they quickly exploited this bug on their benefit. Unfortunately for the company, they needed a couple of months to find it out.
[Note: I used $ as the currency to explain it in a simple way, but the real currency was not in dollars]

To try to stop this things to happen again the company opened a tender to invite vendors to provide a solution. At that time I was working for IBM and we had a wonderful product for real-time/streaming data analysis: Streams. Indeed, it is still being sold by IBM, and allegedly is the best product in this category of software -I'll write a comparison about this products in the future, hopefully-.

The Solution


My proposal was relatively simple: Streams would gather all the information from the different systems installed on the casinos and would analyze it in real-time(1). Then, using stored historical information, Streams would decide it the information was normal or if there were any anomalies that an operator should check in detail. Then, the information would also be stored in the historical databae to be part of the knowledge base for future reference in the search of anomalies, with an additional piece of information: once an operator investigated the detected anomalies, it would annotate them to inform the system if they were worthy to investigate or if they were false possitives ths should be ignored, improving the accuracy of the system.
If you think about this, it resembles an Artificial Intelligence system... 

Obviously, this is more easily said than done. The project involved not only the use of the streaming technology, but the processes to gather the information from the slot machines and other casino systems, the design of the data-warehouse to store the historical information, the algorithms to detect the possible frauds in real-time, etc. 
To add value to the project, my proposal also included monitoring the video cameras in real time in search of suspicious behaviours, not only from the players, but from the maintenance personnel: we were told of cases where the maintenance people acted in connivence with malicious gamblers installing the most exotic devices inside the machines to win illegally.

But not only fraud could be addressed. Another interesting feature that could be addressed with this project was preventive maintenance and detection of failure in the systems. As it happens with cars or other kinds of machinery, there are scheduled maintenance intervals, but sometimes failures happen before the maintenance periods are met, so by monitoring the systems in real time you could learn when a system is about to fail, by using historical information and anomaly detection. Then, by approaching a 100% availability of the machine, it means that the system is almost 100% of the time available to produce a benefit.
In sum, we realized that by just decreasing the fraud in the systems by a 2% -a very easy and non-ambitious target-, the project would not just pay for itself but produce additional benefits in a 10 month period. The other added benefits -reducing maintenance periods and other kinds of fraud- were not included in the proposal as we wanted to stay on the safe side, but we estimated that they could add another 12-15% increase in the final results of the systems being monitored. Regarding fraud detection, the 2% estimation was also a very conservative one. Our previous experience showed we could easily achieve a 18-23% of fraud reduction, which is a significant amount of money as they estimated the undetected fraud in more than $100M

Aftermath


What happened after all? The customer decided not to buy our solution. We may have done if for free and claim only a percentage of the fraud detected, and it would have been the project of the year but our internal rules did not allow that, and anyway the customer didn't want us to do it anyway.
As I said, they asked several vendors and consultancy firms to propose solutions, and they trusted the most their own internal auditor, one of the big 4, so there was no room left for a pure technical provider.
Their auditor-consultant recommended to just audit the results as they were doing, and not spend money on anybody else: just in them... And the customer believed them. It happens a lot, once you earn the trust of your client, it is more likely that they will follow you even if it is not the best possible solution.
In any case, that company was later involved in internal fights and the CIO left the company, so the project quite likely would not have been deployed.

Conclusion

 

Well, it is you who have to reach your own conclussions, right?
Just kidding. Regarding only the streaming project, real-time (streaming) analysis of information is a very powerful tool that can provide immediate results and mitigate, if not totally avoid, future problems. And if used in combination with AI/ML techniques and the proper use of historical information it is just fantastic.
There has been a lot of advance in several open-source platforms to address those kind of issues and with relatively very small investment a lot can be achieved with these solutions, but its use is not as widespread as I'd like it to be. 
We'll have to work on this.

---------------------------------------------------
(1): When I mention real-time in this context I really mean "streaming", or that the information is analyzed just as it arrives and an answer is provided as soon as possible. For computer scientists, real-time means that the information needs to be received and processed in a fix interval of time, as otherwise it would be lost or would be meaningless. For instance, real-time when operating a rover in Mars is about 9 minutes: approximately 4.5 minutes are needed for a radio signal send by the rover to reach the Earth and another 4.5 minutes for the answer to get back So if the rover finds an obstacle, its real-time to request instructions to avoid it is 9 minutes. If we are controlling an autonomous vehicle, real-time is under a second, as it is the time the vehicle may have to decide the best course of action to avoid an accident (after this second, the accident could be unavoidable).

Monday, September 23, 2019

Brexit and the price of milk in the UK and Spain

Sooner or later I had to talk about the B word. Let's go with it!
It is commonly accepted that prices in the UK, in general, are higher than in Spain. Salaries too, but in general it is assumed that the cost of living is more expensive in the UK.
In general this is so, but there are some products that are way cheaper in the UK than in Spain and the differences are quite noticeable. One of the ones I find more surprising is the milk.

It so happens that milk is cheaper in the UK. Depending on the size of the bottle the price varies, the bigger the bottle the cheaper the litre, but in general lets assume that the average price is 44 pennies. Today, after the pound has plummetted thanks to Boris Johnson, we can assume the price is the same in euros, but, assuming a normal situation when the pound is about 1.10 euros, to round it up, I'll assume 48p per litre.

This very same litre of fresh mik in Spain costs around 1.13 euros per litre. This is the cheapest price I've found in all the supermarkets checked, so I'll use it as a reference price. I insist: 1.13 euros, More than double the price in the UK! And in a country where the cost of living is supposed to be way higher than in Spain!
Even more, in Spain, the pausterized litre of milk, the famous "brick" format, which it is supposed to be of lower quality and hence is cheaper than fresh milk, in Spain costs around €0.58, More expensive than fresh milk in the UK!

How is this possible? This is the big question here. And sadly I have not reached any valid conclussion. My initial thesis when I started this article was that the difference was due to the production quotas or limits imposed by the EU to Spain and so I'd then ellaborate that the UK has no real reason to leave the EU, at least this one would not be a motive for the UK but for Spain.
However, my hypothesis proved to be false as since 2015 there are no limits to the production of milk in Spain and so the sector can produce as much milk as they want, what in theory should benefit the consumers as prices should go down thank to the competence among the producers.

Then, why the price is so high in comparison to other places like the UK? In addition to this, the milk producers are constantly complaining of the low prices they are paid for the milk, as it seems that they should charge a minimum of €0.33/0.34 per litre to make it a profitable business. Keep in mind that in the UK the price is £0.44 per litre, final price, not producer price. Maybe in the UK the margin for the farmers is greater as they don't need to buy grass to feed the cows, but I don't think there is so much difference at the end of the day.

So, I cannot blame the EU. The only ones I may try to blame are the intermediaries and the big corporations that buy the milk to the producers, that would be adding an artificial cost in the whole process for their benefit, keeping low prices for the producers and high prices for the consumers in a typical monopolistic practice, but I have no data to sustain this theory. That, or maybe the one to blame is climate change. I have not a winner!

Thursday, September 19, 2019

Investment strategies: Investing in crude oil

After what just happened in Saudi Arabia, it was quite easy to foresee a spike in the oil price.
 It was something I was expecting after the troubles with oil ships and the Iranian forces in the Strait of Ormuz this summer, so although I hadn't found the time to write this article recommending to purchase futures of oil, the thing is that the past 9th of August I made a "purchase" to test my theory in a more practical way (with fake money in my trial account opened at Oanda, so I'm not risking any money - and not winning any real money either).
Here you have a screenshot with the summary of the positions I have opened at this training account:





As you can see, the only investment currently in green is the Brent Oil investment. The other ones are positions I keep in Sterling Pounds (Does anybody still use the word "Sterling"?), as I'm betting that there will not be a Brexit, at least not a hard one, and thus Pound will spike eventually, as well as Euro and Dollar will reduce its value. We've just seen that the Fed has just reduced the interest rate and in my opinion the Euro will follow suit soon. But this is subject of another entry in this blog.

When I "bought" the oil futures, the price of the barrel of Brent was $58.8. I estimated that in the medum term it would escalate up to $70. This prediction was fulfilled this week, so if this was a real investment I'd had sold all my positions and got the money earned, about €1500 over an initial investment of 10,000, about a 15%, not bad for some more than a month.
But, as it is a fake money account, I am keeping the position, and have programmed the tool to automatically sell the options if they reach more $70. We will see if the situation happens again until the end of the year, which I doubt, sincerely.
In the mid term, I think oil has already reached its peak and this prices will not repeat any soon, so the possibility to repeat this gains is remote, in my opinion, unless a war breaks in the zone or again the oil supplies are affected by a blockade of the strait of Ormuz or any similar situation.
In summary, in my humble opinion, the moment to invest in oil has just passed, as it was this August when prices were already under $60 with possibility to reach $70, which has already happened and thus it is time to wait and see.