Journey

I’m one of those people who’s mind drifts off to thinking about things almost on its own (Maybe all people are like this, I have only been inside my own head after all). I’m either thinking about the task in hand or my thoughts drift off to analyse something else. Perhaps the people or situation around me, some event in the recent past, a new idea (new ideas come when washing up). As I write this I am on a train heading between Durham and York. My mind started mulling over how adaptable humans are to new and different situations. Its true that many people do not like change, but it is also true that many people are able to adapt to huge changes in their lives both very successfully and relatively quickly. I see this in myself and many of the people that are around me.

Recently something happened in my life that while it was happening it occupied most of my mental capacity. Almost my every waking thought and some of my dreams were focused on one particular event. Unpicking it, analysing it and the part that I may or may not have played. At the time it was difficult to see how this could ever be different. We have all been there. Not much time needs to pass however and things change. I still think about it a lot but by no means all the time. It might be triggered back into my conscious thought by something specific, but sometimes it just pops back up without a trigger that I am aware of. This is what happened on this train journey, and the trigger is an association of a place that I will pass by. A place I once loved to visit but now I doubt I will ever go back. The closest I will get is skimming its event horizon on my way up and down the East Coast main line.

Silverlight 5 nightmare…

I subscribe to LoveFilm and I have to say was pretty disappointed when they switched from Flash to Silverlight. Mainly because I can no longer stream movies with Linux, but also because I have had problems with Silverlight before. I wasn’t surprised therefore that when they made the switch my media computer stopped streaming films. I tried all the normal stuff, turned off the firewall, added *.lovefilm.com to the trusted website in the control panel. Uninstalled, reinstalled. Tried different browsers, cleared browser cache. Everything. Nothing worked. I even contacted LoveFilm support who asked me to do all that again and then pretty much gave up.

I then noticed that it was only DRM content that wasn’t working! Annoying, as I should have spotted that before. So some more digging and I found that the DRM licenses used by MS software are stored in “C:\ProgramData\Microsoft\PlayReady\mspr.hds”. So I renamed it. Bingo, DRM content including LoveFilm streaming now works! Doing this will mean you loose all existing DRM licenses, for me that wasn’t an issue as I didn’t have any. Frustrating! At least I can stream films now. Well, just need to encourage my ADSL modem to find enough bandwidth, it over heats poor thing and gets all slow and rubbish.

Text Message Alerts

I have long been interested in setting up my computer so that it is possible for it to tell me what is going on via sms messaging. This would be useful for both my day job and also to alert me to interesting things that it might detect. So I finally got round to setting it up.

Using an old Huawie E220 GSM modem and the linux package called gammu-smsd all of my software can now send me texts. I used to use the modem for mobile broadband but I upgraded to MiFi so I got an ordinary pay as you go sim card for the modem and set it up. These modems are perfectly capable of sending texts. I chose the gammu-smsd because it has the option of using a mysql backend. One tip is that the mysql tables are provided in a file which is included in the distributed source code. Also I ran tail on /var/log/messages (Opensuse – do the same for your version of linux) to see which device the modem is attached too. You can force it use the same one if you like. I might end up doing this if it causes a problem.

Using mysql is handy because you can send a message by directly writing the messsage details in the the outbox table in the database. Easy. I wrote a very simple Java interface to the mysql database that all of my programs can connect to. Any program can use the Java library to inject a message into the database and then it is promptly sent. The computer set up to send the sms messages doesn’t even have to be the computer that is running the simulation. One machine with an accessible database can provide a messaging service for any number of computers. There are alternative approaches but this seemed the easiest to set up quickly.

This is helpful because often simulations take a long time to run and it is useful to be able to leave them to it knowing that I will be notified when the task has completed, or if the task failed for some reason (there is nothing more annoying than finding out that a simulation stopped for some reason the minute you turned your back). I can then log back into the machine and either start the next simulation or whatever. I can also set it to alert me to interesting market events.

Data collection is still going…

I am still collecting lots of data. Nearly all day every trading day programs download market data at 5min intervals (for the FTSE100/250/TechMark, the S&P500 and the NASDAQ). At least I am covering a really interesting period of financial history. Even if I haven’t had any time to do anything with the data yet.

The flip side to that is that this is such an unusual period that techniques learn’t using this data might not be generally applicable. A friend that works for a systematic hedge fund told me that their models have changed completely since the crash of 2008. No way of knowing unless I actually get round to doing something with the data.

Making R Load libraries at startup

There are sometimes things that I want to do, and have to spend a while figuring out. So I am going to store that knowledge on here.

Loading R libraries at start… (works in Opensuse linux)

Easy, create a file in /usr/lib64/R/etc called ‘Rprofile.site’. Put in that file the libraries you want to load.

library(ggplot2)

When you load R those libraries with be loaded.

Right, next time I reinstall my system I will know where to look if I have forgotten…

Full Trading Platform Built

I have finished building a virtual trading platform. The idea is that this can be used to learn trading algorithms for shares on UK and US markets, and then later be coupled to a real trading platform using an API provided by a company such as Interactive Brokers. For now it just takes virtual positions, so no real money at risk.

The algorithm currently in use is pretty naive and needs to be replace. The question is with what. In many ways I would like the system to learn its own method for trading, and in true complex systems style, perhaps I don’t even have to be able to understand what it is doing. I intend to take an agent based approach by having a population of agents running different algorithms or the same algorithms with different learnt parameters. Successful agents will be allowed to duplicate and persist, unsuccessful with be removed from the population. Essentially a evolutionary approach not a million miles away from a genetic algorithm.

Multiple sources of information will be able to the agents to inform their trading. From sentiment analysis (twitter etc), to a large database of historical share prices  and realtime market data. The intention is that the learning part of the system will learn what subset of the available information is useful for trading share. The system only needs to be able to be slightly better than random chance.

Too busy working to make any money…

Recently I have been working hard at my day job and not really felt like doing much out of work. This is partly due to the work I’m doing being really interesting. So its by no means a bad thing. Its not helping me on the quest to making enough money to buy a house without a mortgage. Which I think is the basic general plan. I haven’t really put a time scale on my adventure but I theory I would like to achieve this goal in about 4 years. I better get going I suppose.

Finally sorted my data…

So I have had programs saving data in a raw form for months. Almost years in some cases. I have finally got my act together and written the programs to actually turn this raw data into nicely formatted data that is stored in mysql tables. I will of course keep the old data, just in case.

I now have enough to try a number of different things. Sentiment analysis, clustering analysis of price movement, and perhaps enough to try to built some networks. Things are finally taking shape.

Sentiment Analysis

So, I have been thinking of dipping my toe into the pool of sentiment analysis for a while now. I made the first positive steps the other day. I found a list of positive and negative words on the internet. I have a Java library that works as a basic dictionary and I have created mini dictionaries of these words. The idea is that I can make some assessment of the sentiment of what people are saying about a share for example and then use this as part of a trading algorithm. People have been doing this for years, but I would like to try it myself. I want to see what the problems, pitfalls, limitations are firsthand. I suspect the key will be making the connection between share price movements and certain key individual’s or group’s sentiment. This is similar to that throw away line in the film The Social Network. Something like, “..he made $300,000 trading oil based on the weather…”. If weather is a key indicator of oil price changes I need to find the equivalent key persons for shares that I am interested in trading. Classic old problem of finding the signal in the noise, and there is a lot of noise.

America doesn’t default this time…

So after leaving it to the very last second (well maybe hours) America avoids a voluntary default. Most people didn’t seem to think it was going to happen. Although I suspect that it was more hope than insight. Not only has a default been avoided, it looks that for now at least there will be no downgrade of US treasures. Odd that I think; the US looks in a bad way. The economy is slowing. Growth slowed for the last quarter and the previous quarter was revised down. Manufacturing is down too. However this new data might serve to support a watered down deficit reduction plan. The new debt deal will cut spending by about $2.5T, about half what the rating agencies were calling for. if the economy is slowing then perhaps this isn’t the time for tax increases and spending cuts. In some ways the US and UK are following different paths. Who will fair better? On the face of it the UK is getting support from the markets. With interest rates on it borrowing dropping to an all time low, 2.75%. I can’t thinking that perhaps the world is just looking the other way at the minute. Problems in the US, and further crises brewing in Europe (Spain and Italy have seen there borrowing costs increase sharply) mean that no-one is paying close attention to the UK right now. How long will that last I wonder.