About Kyriakos Anastasakis

I was born on the beautiful island of Chios, Greece, where I received my primary school and high school education. At the age of 18 (in 1997), I moved to Athens to attend the Department of Informatics at the T.E.I. of Athens. In 2001 as part of a six month industrial placement, I joined Ulysses Systems, Piraeus as a junior Software Developer. In 2002 I received the degree of Informatics Engineer (Mihanikos Pliroforikis) from the T.E.I. of Athens. I continued to work for Ulysses Systems until the end of July of 2003. In 2003 I moved to Birmingham to study for the MSc in Advanced Computer Science at the School of Computer Science, at the University of Birmingham. In 2004, after I finished the MSc studies, I decided to stay in Birmingham and pursue a PhD degree in Computer Science. Since then I have been working towards the PhD in Birmingham under the supervision of Dr. Behzad Bordbar. Since 2005 I have been a part time self-employed software consultant. An interesting project I was involved in, was the development of a small scale CRM software for the Birmingham branch of MLP Private Finance. Since 2004 I have also been responsible for development and maintainance of the website of the Hellenic Society of the University of Birmingham.

Today is the day of the British EU referendum and I decided to express some random thoughts while waiting for the outcome. Polls and the bookmaker odds / market pricing (of the sterling, the FTSE 100) show mixed messages. Polls reveal a very close call (50/50), while the bookmaker odds and the pricing of the market reveal a strong belief that the remain vote will prevail (75% for remain/25% for exit).

These two mixed messages remind me of the famous line from Naked Gun. Nordberg (O. J. Simson) is severely injured in hospital and his colleagues discuss:

Doctors say that Nordberg has a 50/50 chance of living, though there’s only a 10 percent chance of that.

So the Brexit referendum is all about the polls, or should I say the Poles? It’s primarily about internal EU immigration. The Brexit supporters claim that currently people from poorer member states can easily move to richer states and work or claim benefits, essentially moving money out Great Britain. Talking about going into a country, taking its wealth and moving it back to your home country, I can’t help but think those Brexit supporters have never visited the British Museum.

The Brexit supporters also claim that EU is increasing the bureaucracy in Great Britain. Having lived in the UK for 5 years, I am a bit puzzled. I remember we had to fill in a risk assessment form every time we wanted to play basketball at Uni. I also remember lecturers at Uni. complaining they had to spend hours preparing and attending useless committees and doing less research. In  Greece which is notoriously bureaucratic I when it comes to your dealings with the public sector things are much more straight forward in everyday life. So I don’t for the everyday bureaucracy in the UK, the  EU is to blame.

Experts say if Great Britain decides to exit it will have to worry more about the Scots and Irish the next day, than for its future relations with the EU.

The EU is definitively broken and it needs fixing before it falls apart. All member states face similar issues and Brussels doesn’t react (at least effectively). If history has tough us anything though, leaving Germany as the only primary ruling power in Europe has never had a happy ending. The EU needs Britain to help shape its future.

Is there really a 25% chance of Brexit?

Going back to the fact the polls give 50% for Brexit, while the bookies only 25%. Either the polls, or the bookies (or both for that matter) have to be wrong. One argument is that the polls can’t be trusted because there is no history on such a referendum. But what about the bookies? In addition to the “fair odds” (what a bookie decides to be an objective probability for a result) they also adjust the odds based on their exposure to the outcomes, to minimize risk.

Assume that you are a bookie and at the start of two events A and B you think there are 50/50 chances. So (assuming you gain nothing for yourself) you give odds of 2 for A and odds of 2 for B. During the course of the event you have  asymmetric wagering  (e.g. $1M is wagered on A and $250K is wagered on B). Assume your view as a bookie is still 50/50 for A and B, but if the outcome is A, you owe: $2M (net loss of $750K) while if the outcome is B you owe $500K (net profit of $750K). So as more money is wagered on A, the bookie will naturally lower the odds on A and increase the odds on B, purely to minimize the risk and attract more money on event B. So for example the bookie may adjust odds for A to 1.5 and odds for B to 3.  It doesn’t mean the bookie thinks there is a 66.6% change for A and 33.3% chance for B. The bookie merely lowers the odds of A for risk management purposes.

A blog post by Landbrokes that in essence the amount of money wagered on remain is responsible for the low odds of remain, validates this claim.

Let’s also have a flashback one year ago at another referendum, the Greek one. If you study both the polls and the bookies, it’s a deja vu. Polls showed it was a close call, while the bookies gave odds that attributed probabilities of around 64% on Yes (around 1.5 decimal odds). Guess what happened? Greeks voted No, bookies were “wrong” (as explained in the previous paragraph there is no right or wrong, it’s all about risk management) and whoever saw the valuebet and bet on No made some good money.

Let’s have another flashback, two years ago at the Scottish referendum. Again the polls gave it a close call, but bookmakers were much more certain that the remain vote would prevail. As explained by this financial times article, there is much resemblance in the betting patterns of the Brexit referendum with the Scottish referendum.

So, for the Brexit referendum will the bookies get it right like the Scottish referendum or will they get it wrong like the Greek one? Difficult to tell until the result is out. Will the pollsters get it right that it’s going to be a close call? A blog post by financial times suggests that (a) pollsters are subject to herding and (b) if you count the tendency of the undecided voters to vote for the status quo and (c) take into account that the leave campaigners are much more “loud”, the remain has more than 50% chances.

Odds of around 4 for the leave vote are certainly a value bet and even if you think that there is as low as 30% probability of leave, the Kelly criterion suggests you should bet 6.6% of your bankroll on leave. You should be betting on the poor 1.3 odds of remain only if you think it has at least 75% chance of happening. Does it? No idea! I personally think remain has more chances and there are decent odds  for the handicap (50-55% or 55-60%) of the remain.

I have recently started using MongoDB for a very demanding task. Storing all Forex pair ticks (e.g. every change in bid/ask prices). I know there are frameworks designed for this task (e.g. kdb+), but since I wanted to avoid the learning curve. Besides I already use Spring Data in my project and it works with a minimal number of changes for Mongo.

In Mongo I have a collection with more than 3.5 billion records (and growing) and I want to find the latest date for each pair. I tried using the aggregation framework of Mongo, but it doesn’t seem to use the indexes and takes ages (didn’t finish after one day).

Relational Structure

In relational DB the table structure  would look something like:

idpairdateTimebidask
1EUR/USD2015-04-03 21:32:31.4561.141411.14142
............

Then you would have to run the following query:

 

MongoDB Aggregation Framework

In MongoDB the document structure is the same. I am a very very novice user of Mongo, but I gather we could use the aggregation framework for this query:

However, this takes ages, even though I have used a composite index on pair and dateTime.

 

Very Fast Result Using MongoShell

I tried using a sort of iterative approach using MongoShell:

This approach seems to use the composite index on pair and dateTime I defined and the results are lightning fast (for 3.5 billion records).

Maybe there are other ways, but after some digging around I couldn’t find any other method that would use indexes.

It’s been ages since I have posted some sample code. It’s mainly because I don’t have time to collect and post sample code anymore. This once was a bit more challenging and googling wasn’t help much, so now that I have some time I though I would post some sample code that achieves batch inserts with spring data.

For example this link:
http://forum.spring.io/forum/spring-projects/data/118203-bulk-insert-with-crudrepository indicated that I had to manually get the session and iterate/flush (which was true when using Spring/Hibernate/JPA). But when using the CRUDRepository it appears it’s much simpler.

FULL CODE

Full code sample (maven project) can be found on github: https://github.com/cyrus13/anastasakis-net-sample-code/tree/master/spring-data-batch

You basically need to have the following elements:

  • Add: ?rewriteBatchedStatements=true to the end of the connectionstring.
  • Make sure you use a generator that supports batching in your entity. E.g.

  • Use the: save(Iterable<S> paramIterable); method of the JpaRepository to save the data.
  • Use the: hibernate.jdbc.batch_size configuration.

RESULT

So enabling the query log in MySQL:

we can see the following mysql code is executed:

Note: Don’t forget to stop logging statements into MySQL general log!

SET global general_log = 0;

I have a MacBook Pro (13-inch, Late 2011) with 8GB of RAM. As I need quite a few memory thirsty applications I have reached a point where 8GB is not enough. The official documentation of the Mac says that it supports up to 8GB. So I need to buy a new laptop?

Apparently not! It seems that the laptop supports 16GB of RAM, but not officially (from Apple). Crucial provides a system scanner, which scans your systems and suggests for compatible memory. It suggested a kit of 16GB memory. I have ordered it and I am waiting to install. The link for the scanner: http://eu.crucial.com/eur/en/systemscanner

Today I decided to update to OSX Yosemite. How much time would it take? 1 hour, 2hours? It appeared to get stuck to “one minute to finish” the installation for quite some time. During the upgrade process if you move the cursor to the top of the screen a menu will appear. One of the options is: “Show Log”. This option pops up a window that shows detailed information about the process.

In my case for around half an hour it was logging events like this:

It appears it was taking a lot of time processing the texlive files. I had installed texlive in the past, but i haven’t used it at least in a year. So, before upgrading to Yosemite make sure to delete any unwanted applications for a faster upgrade!

I wanted to add the suffix of the day in Java (i.e. 1st, 2nd, 3rd, etc.). This is a small method that does the Job

I have a Thomson TG585v8 router and I connect to a Cisco VPN using my Macbook running Mavericks. When I connect to the VPN all other devices in the house lose connectivity to the internet! I checked the router logs and I got quite a few errors like the following when connecting to the VPN:

UPnP action ‘AddPortMapping’ from ip (Undocumented UPNP error)

It is clearly and error related to the uPnP. So I disabled UPnp on the Thomson router and now everything works perfectly when I connect to the VPN.

I installed a fresh Ubuntu desktop guest on VirtualBox 4.3.14. Trying to install VBox additions I was getting an error message:

The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.

 

Apparently all I had to do is reinstall the headers using the following two commands:

 

Trying to reinstall Linux Additions for VirtualBox works like a charm!

I wanted to replace my old Logitech laptop speakers. I have recently started listening to Spotify a lot and I got a Netflix subscription, which I use on my Apple TV. So I needed some good 2.1 Speakers. Searching the Internet it looked like Edifier S730 where the best choice. It was a bit expensive around 300 euros.

It arrived in a heavy, solid box. I opened the box and the first items I removed was the controller with the cables and the remote. First thing I noticed: Many scratches on the screen of the device. It’s outrageous that they had a cover on the buttons of the thing, but not the screen! It seems that the cables and the plastic stand for the controller, which were in the same compartment in the box were scratching the screen all the way from China (or wherever they are made in) to Greece.  Apart from the scratches there was also a visible mark .

 

photo

 

I contacted the shop where I bought them from and they were very very helpful. I am expecting a new controller in 10 days, hopefully without any scratches. If you pay 300 Euros for speakers, you expect some quality, at least when they arrive brand new. If they are susceptible to scratches it’s your job to look after them once you start using them, but they first have to arrive in a good condition!

For the sound quality part/review, there are loads of reviews and youtube videos. Speakers come with a 3.5mm to RCA, RCA to RCA and coaxial cables. They do not come with optical audio cable though. What I can say is that I connected my Macbook pro headphones exit to the speakers using the 3.5 mm to RCA. The sound was not what I expected. Certainly better than my old speakers, but still it seemed to be missing something.

Then I thought that maybe the headphones exit of my soundcard is not a good choice. So, I used airplay to send only sound to my Apple TV, which I connected to the speakers using an optical cable. Not sure if it’s just my idea, but I have a feeling the sound is a bit better with this setup.

 

Update: As it turns out, the screen has a plastic protector and the scratches were against this plastic. The plastic cover is attached to the screen and doesn’t protrude. You need to use your fingernails on the edge of the screen to remove it.