Sunday, 17 April 2016

Proof's in the data scientist pudding

15:25 Posted by The Thalesians (@thalesians) 2 comments

I am defenseless in the face of those titans of confectionery, chocolate and cake: the sweetness of sugar, the butteriness of butter, the milkiness of milk (I was attempting to choose words to make you, the reader, as hungry as possible). The cause I presume, is my sweet tooth. I realise that this is a somewhat circular argument, yet it nevertheless helps to absolve myself of a certain modicum of responsibility.

Whilst I am more of an expert at consuming sweets, I also occasionally dabble in their creation, with varying levels of success. Usually, I stick to the easier to bake items, such as cookies or brownies. Admittedly, I have yet to master the more visual element of baking, a particularly polite of saying whatever I bake does not really look that nice. However, the end result of my baking efforts seem at least to be successful from a taste perspective.

Does that mean, that I could try my hand at baking macarons, with an automatic guarantee of success? I know the answer is no. The complexity of baking macarons is far greater than that of the humble brownie (from personal experience). Whilst, there are common skills in baking, at the same time there are often specific skills that need to be honed for specific bakes. In other words, these skills are very domain specific.

Data science is a fashionable new term for a mixture of several disciplines, including statistics and programming, as well the ability to display results in an innovative manner, using visualisation tools. Very often data scientists can end up working with unstructured datasets, which take time to clean up and process. Data science is precisely like baking (well in some ways, just bear with me for a few sentences). A few days ago, I tweeted what I thought a data scientist was, namely someone who is both excellent at statistics, but is also adept at coding. There can be a misconception that a data scientist, can simply get by with a bit of stats and the ability to cobble up a bit of Python. I strongly disagree with that notion!

However, in response, one my Twitter followers (@macroarb) noted that data scientists also need some domain specific knowledge, a point that I had casually overlooked. Thinking about this a bit more, if anything, domain specific knowledge is perhaps the most important part of a data scientist's toolkit. After all, it is domain specific knowledge which enables you to ask the right questions from your dataset. In my case, my domain specific knowledge is centred towards systematic trading.

Hence, before even indulging the number crunching of a specific dataset, I form a hypothesis of what I am trying to find in it. Of course, sometimes my hypothesis can be totally discounted by some statistical work, which can actually be an important result. It's far better to know that a trading strategy doesn't work, than mistakenly thinking it is profitable and end up losing money on it. On other occasions, I will be able to find results, which can confirm my initial hypothesis.

If you have no hypothesis, where do you even begin to start when analysing data? Of course, you can keep searching through the data, and perhaps you'll eventually find something. However, is that result going to be robust? I suspect not. If you have no domain specific knowledge, it can be difficult to ask the right questions! Just because I can bake brownies, it doesn't imply I can make macarons successfully!

So next time you try your hand at baking, remember, in some ways you're exactly like a data scientist, the proof's in the data scientist pudding!

Like my writing? Have a look at my book Trading Thalesians - What the ancient world can teach us about trading today is on Palgrave Macmillan. You can order the book on Amazon. Drop me a message if you're interested in me writing something for you or creating a systematic trading strategy for you! Please also come to our regular finance talks in London, New York, Budapest, Prague, Frankfurt, Zurich & San Francisco - join our Meetup.com group for more details here (Thalesians calendar below)

20 Apr - London - Jacob Bartram - Can option trading strategies enhance CTA/trend following
12 May - New York - Luis Seco - Are Negative Hedge Fund Fees on the Horizon?
13 May - Budapest - Saeed Amen/Paul Bilokon - Thalesians workshop on algo trading at Global Derivatives
20 May - London - Martin Bridson - Knots and what not

Sunday, 3 April 2016

When learning was history

19:14 Posted by The Thalesians (@thalesians) 1 comment

Lounging about on Saturday afternoon, my mind seems less honed to thinking, and more adept at wondering away the hours, a boat seemingly poised to eventually land at the shores of the asleep. However, rather than surrender to sleep, I thought it best to try my hand at writing this blogpost.
As ever, the main challenge is not so much writing it, but working out the subject! Rather than thinking up a subject myself, I tweeted suggestions for ideas. One of my followers @grodaeu suggested writing about a historical figure (although, I think the suggestion was somewhat tongue in cheek). His reply nevertheless (together with the book I'm reading) gave me an idea, why not write about history in an abstract sense. Why do we write so much about history?

In a sense, understanding our past might well shed light on our future. Whilst, technology might change from age to age, there is often a common thread which binds us with our ancestors. I'm currently reading a book on the French Revolution and Robespierre. I can hardly claim to be an expert on this period of history, or indeed any. However, what struck me was that many of the motivations which drove the revolution, would not be out of place today.

From the point of view of markets, we could argue that motivations for investors has not changed over the years. Investors actively seek to make a profitable return. How this is achieved is obviously a different question!

The notion of high frequency trading has only come about through the widespread adoption of electronic trading for example. However, one thing that hasn't changed is the need to have a well thought out hypothesis behind a trade. We also use our own histories (or perhaps better put our experience) to view the market. Statisticians use historical data to generate more quantitative descriptions of the past.

Indeed why investors should look to history is a subject which I wrote about extensively in my book Trading Thalesians - What the ancient world can teach us about trading today. Your experiences will impact how you see future events. A trader who experienced the Lehman crisis is likely to behave in a different way when stocks fall, compared to a trader who hasn't.

History might not be able to tell us precisely what the future holds (and perhaps lead us to mistakenly believe that the future will be identical to the past), but it can help us to understand in more abstract way to approach problems.

Like my writing? Have a look at my book Trading Thalesians - What the ancient world can teach us about trading today is on Palgrave Macmillan. You can order the book on Amazon. Drop me a message if you're interested in me writing something for you or creating a systematic trading strategy for you! Please also come to our regular finance talks in London, New York, Budapest, Prague, Frankfurt, Zurich & San Francisco - join our Meetup.com group for more details here (Thalesians calendar below)

14 Apr - New York - Lawrence Glosten - Limit Order Book Tail Expectations (Thalesians/IAQF)
20 Apr - London - Jacob Bartram - Can option trading strategies enhance CTA/trend following
12 May - New York - Luis Seco - Are Negative Hedge Fund Fees on the Horizon?
13 May - Budapest - Saeed Amen/Paul Bilokon - Thalesians workshop on algo trading at Global Derivatives
20 May - London - Martin Bridson - Knots and what not

Saturday, 26 March 2016

Music to benchmarked ears

20:00 Posted by The Thalesians (@thalesians) No comments

There are some days, which I never thought would come. An example of one such day arrived years ago. It was the day, when I simply had no idea which artist was at the top of the music charts. This state of affairs has persisted to the current day: today, I have absolutely no idea who is at the top of either the Billboard 100 or the UK Top 40...

It would however, be wrong to equate this is to a lack of interest with music. I love music just as much as I did a decade ago. Browsing my main playlist, which I have unoriginally called the "Thalesians Mix", which I periodically add my favourite tracks, I see the names Taylor Swift and Ed Sheeran, juxtaposed with David Bowie and Bob Dylan, with a modicum of Tom Petty, The Beatles and topped by a hint of Green Day, interspersed with all manner of musical genres. Is this a "right" playlist? Well, it seems right for me, judging by the fact that I seem to gravitate towards listening to this playlist in its entirety at least several times a week. Whether it is right for everyone else, is an entirely different question, I am quite sure there are some tracks on my playlist, which you the reader, would not like. 

I strongly suspect, that my taste in music seems far more eclectic when judged against the "benchmark" of the music charts. I don't feel the "benchmark" of the current music charts is right for me. Of course, I might like one or two current tracks, but I can never see myself listening entirely to purely new songs and dispensing with the old.

The notion of benchmarks in finance is a fraught subject. Whenever you invest, what should be the yardstick for how you judge your performance? Should investors be purely judged by how they beat (or miss) a benchmark which is the "market"? A recent paper, Curse of the benchmarks, by Dimitri Vayanos and Paul Woolley attempts to answer this question (thanks @george_cooper__ and @PolemicTMM for tweeting this paper to my attention). They suggest that trying to use market cap weighted benchmarks (which is often considered as the market) ends up causing

the inversion of the relationship between risk and return so that high volatile securities and asset classes offer lower returns than low volatile ones

A far better way of judging investors, they suggest, is to try to compare them with their peer group adopting a similar trading strategy, rather than the approach of using market cap benchmarks. More broadly, the matter of precisely how to create targets for your investment, will differ between investors. What is an acceptable drawdown is not acceptable for one investor might well be too much for another. The idea of how much risk a trader should take will differ between mandates. I wrote a chapter on both the matter of risks and investment targets in my book, Trading Thalesians, if you'd be interested in reading more.

So whether it's music or investing, if you do have a benchmark, we first need to consider this: is it the right one? Most important does having the wrong benchmark end up changing your strategy for the worse! In the meantime, I keep listening to the music.

Like my writing? Have a look at my book Trading Thalesians - What the ancient world can teach us about trading today is on Palgrave Macmillan. You can order the book on Amazon. Drop me a message if you're interested in me writing something for you or creating a systematic trading strategy for you! Please also come to our regular finance talks in London, New York, Budapest, Prague, Frankfurt, Zurich & San Francisco - join our Meetup.com group for more details here (Thalesians calendar below)

14 Apr - New York - Lawrence Glosten - Limit Order Book Tail Expectations (Thalesians/IAQF)
20 Apr - London - Jacob Bartram - Can option trading strategies enhance CTA/trend following
12 May - New York - Luis Seco - Are Negative Hedge Fund Fees on the Horizon?
13 May - Budapest - Saeed Amen/Paul Bilokon - Thalesians workshop on algo trading at Global Derivatives
20 May - London - Martin Bridson - Knots and what not

Saturday, 19 March 2016

Go-ing with quant trading

15:04 Posted by The Thalesians (@thalesians) 1 comment

When I think of the word "go", I think of its meaning according to the Cambridge Online Dictionary (written below):

go
verb UK ɡəʊ US ɡoʊ (present participle going, past tense went, past participle gone)
      
go verb (MOVE/TRAVEL)
A1 [I usually + adv/prep] to ​travel or ​move to another ​place:

This week, the word "go" was in the headlines for totally different reasons. Lee Se-Dol the best human player in the world at Go (the Chinese Chinese board game) was beaten by Google's AlphaGo artificial intelligence system. Whilst, chess champions have been beaten in the past, it was thought that it would take at least a decade more for them to accomplish the same thing in Go. Indeed, if you are interested in this topic and are based in London, I recommend you come to Robin Hanson's talk at Thalesians London on economics and robots on March 21st (free tickets)

Perhaps unsurprisingly, it has focused peoples' minds on what other things a computer can do, in areas which have been traditionally required humans. One such area is trading. Trading has seen a massive proliferation of technology. Systematic traders have been trading in markets for many years. Obviously, over the years, the increased processing power of computers and the greater availability of data has increased the types of trading strategies, which can be explored by systematic traders.

What is perhaps a fallacy though is thinking that systematic trading is a matter of computers trading in total isolation from humans! People still have to code up the algorithms executed by computers. Indeed, humans have to come in when a computer's trading algorithm goes wrong.

A computer doesn't understand "why" it is executing code, it simply does it. It can of course calculate all the trading signals, work out the P&L and even execute the trades, without a human touching a system. However, a computer cannot tell you whether you should trade a certain strategy or if there is theoretical basis for a strategy. In a sense, whilst systematic trading reduces the need for day to day decision making for every trade being executed, it increases the process of discretion you need to use on a more strategic level. In particular, this strategic "discretion" comes in, when you are developing the trading strategy and coming up with new ideas to add to your system. Your logic when putting together the model has to be very clear. Any mistakes at this level, will unfortunately persist, when the system goes live.

We sometimes think of systematic and discretionary trading as very different concepts, but in a sense they do share so many similarities. The main difference between them is at which points we employ our discretion.

Like my writing? Have a look at my book Trading Thalesians - What the ancient world can teach us about trading today is on Palgrave Macmillan. You can order the book on Amazon. Drop me a message if you're interested in me writing something for you or creating a systematic trading strategy for you! Please also come to our regular finance talks in London, New York, Budapest, Prague, Frankfurt, Zurich & San Francisco - join our Meetup.com group for more details here (Thalesians calendar below)

21 Mar - London - Robin Hanson - Robin Hanson, Economics when robots rule the Earth
23 Mar - Frankfurt - Miguel Vaz -  Finding structure in financial data: from point clouds to graphs
20 Apr - London - Jacob Bartram - Can option trading strategies enhance CTA/trend following
13 May - Budapest - Saeed Amen/Paul Bilokon - Thalesians workshop on algo trading at Global Derivatives
20 May - London - Martin Bridson - Knots and what not

Saturday, 12 March 2016

Excelling with & without Excel

14:18 Posted by The Thalesians (@thalesians) 2 comments

Travel does many things. The cliche tells us that it broadens the mind. Holidays are the tonic for the whispering monotony of the routine. Yet a holiday is never purely a matter of joy. Within the idea of holiday are bound up the logistics of transportation. None of us book a holiday for the experience of being squeezed on to a flight for hours, at the mercy of delays and heavily processed airline food. However, being able to get to our destination, is a necessary part of any holiday to far away places. Of course we could forgo that long airline journey, but then we'd forgo those sandy beaches, beneath the sunny rays of heat, and instead settle for staying at home.

When trying to analyse markets, we are in a way faced with similar conundrum. We want to find some novel and interesting way to look at market data. However, very often this route is laced with an Excel spreadsheet! Sometimes this approach can work very well, in particular given Excel spreadsheets are the preferred way to share ideas with traders.. but as soon as you have just a bit more data there, a spreadsheet can become unbearably slow to recalculate. Furthermore, when the complexity of your analysis rises, a spreadsheet can become increasingly unstable and easy to break. 

In a sense, there are only certainties in life for a quant researcher: having to use Excel and moaning about having to use Excel. I have to say that I have at times, used Excel far more than perhaps I should have done. One reason is that it makes it easy to explore simple ideas. The difficulty is that very often simple ideas, become very complicated very quickly! Whilst it might save time to use Excel initially, it makes it more difficult to reuse analysis and cost you in the longer term. As for using big datasets like news data, Excel is basically unworkable. Hence, it limits the type of analysis you can do.

To try to get past the issues with Excel, I started writing PyThalesians, an open source Python financial library over a year ago. I wanted to streamline the bulk of my analysis. Rather than reinventing the wheel every single time each time I want to do a new sort of analysis, I've tried to write functions of commonly used financial analysis. These can easily be used again and again, with small modifications. I've now written functions to do basic backtesting of trading strategies, plotting, and market data downloading from many sources including Bloomberg. In particular, I've tried to focus on making the various components interchangeable. Want to change the data source you're using? Just a few lines of code need to be changed, not the the details in your trading algorithm. Want to change how you plot your results? Again, just change a keyword in your code. I've designed the code from the perspective of my experience as a quant researcher and someone who enjoys coding, as opposed to purely looking at it as an IT problem to be solved.

Along the way I've utilised many great open source libraries such as pandas (time series), NumPy (mathematical computations), matplotlib, bokeh and plotly (plotting). Since it's open source, I'm hoping over time, that if users find it useful, they can contribute their own improvements to the library too. We can also blend the two solutions using libraries such as xlwings, which allow us to call complicated calculations in Python and display the results in Excel. In this way, traders who love Excel can still create funky models in Python, but fall back in the familiarity of Excel.

So ok, we often moan about having to use Excel (including me!), but sometimes we can excel both with and without it, if we use a bit of Python (and hopefully PyThalesians!)

Like my writing? Have a look at my book Trading Thalesians - What the ancient world can teach us about trading today is on Palgrave Macmillan. You can order the book on Amazon. Drop me a message if you're interested in me writing something for you or creating a systematic trading strategy for you! Please also come to our regular finance talks in London, New York, Budapest, Prague, Frankfurt, Zurich & San Francisco - join our Meetup.com group for more details here (Thalesians calendar below)

14 Mar - San Francisco - Quant Fintech Mixer Event
15 Mar - New York - Thalesians/IAQF - Alex Lipton - Modern Monetary Circuit Theory
21 Mar - London - Robin Hanson - Robin Hanson, Economics when robots rule the Earth
20 Apr - London - Oskar Mencer - FRTB, RWA, XVA, Scenarios, MiFiD II, fast?
13 May - Budapest - Saeed Amen/Paul Bilokon - Thalesians workshop on algo trading at Global Derivatives
20 May - London - Martin Bridson - Knots and what not

Saturday, 27 February 2016

Miami twice as bearish

15:26 Posted by The Thalesians (@thalesians) 1 comment

So why did the title of this article include the words "Miami twice"? I suppose it does sound like the TV show Miami Vice (well, actually that was the main reason). I can't remember much about the show aside from the white suits, sunglasses and the 80s music, perhaps because, I was always much more a fan of the A-Team during that decade of shoulder pads and forgettable music. 

Before I visited Miami over the past week, I already had this vague image in my head of what to expect: the smell of oranges, the sight of the sea and the sound of Spanish, all somehow coalesced into a single snapshot, with the backdrop of whitewashed Art Deco buildings straddling the image. What I had not quite anticipated, was the serenity of the sunrise casting its shifting gaze over the beach. If you ever do go to Miami, I strongly recommend waking up earlier than you might ordinarily do to witness this.

Much of my time, however, was spent inside at the TradeTech USA FX conference, rather than watching the waves roll on beneath the sun. Whilst the sun was shining outside, the mood inside the conference was perhaps less than shining. A bearish mood pervaded most of the conversations during the conference. This was perhaps not unique to conference. In general, within the market, there seems to be a general perception that we've reached a stage where central banks are out of rope, epitomised by the move negative rates, the latest stage of easing. The recent market reaction following the BoJ's move to negative rates seems to tally with this. One interesting point raised by Steven Englander from Citi, during his conference presentation, was that potentially the markets have underestimated the creativity of central banks in coming up with solutions. 

To some extent, I have to agree with Steven's point, particularly when we consider how central banks have reacted following the financial crisis. They have been somewhat more creative than they were during previous crises, notably following the Great Depression. At present, it has become quite fashionable to be outright bearish. The market can often be "right" and it's a reason why trend following is a profitable strategy and why long only strategies have historically been profitable, albeit with some volatility. However, once the cacophony of market bearishness becomes overwhelming, the risks have evolved from being a black swan style event to merely a grey swan type of event and potentially the market will have overpriced the event. If everyone is expecting a disaster, then arguably market positioning will be skewed that way and if anything any "good" news can result in a nasty squeeze the other way. Insurance is most valuable when the market does not really agree about an event, whether it is in the nature of that event or the timing.

One example of this can be seen in Brexit. We of course do not know with certainty the outcome of the event. What we do know, is the timing of the referendum. Hence, knowing the timing means, we can hedge this risk. The likely risk premium which will seep into the market is likely to increase over time, as investors seek to protect themselves from an adverse outcome. Given it is risk that we can hedge, the temptation is for the market to end up overpaying for protection or having an extended exposure in the cash markets. Hence, even if there is a bad result, the risk premium will be so high that it is unlikely to be the case that a hedge would work. It's like buying a Ferrari and having such expensive insurance, that it ends up being the case that the cost of insurance makes up a large proportion of the cost of the car.

Planning for the expected, is perhaps not as important as planning for the unexpected when it comes to hedges. As Hannibal from the A-Team might say "I love it when a plan comes together".

Like my writing? Have a look at my book Trading Thalesians - What the ancient world can teach us about trading today is on Palgrave Macmillan. You can order the book on Amazon. Drop me a message if you're interested in me writing something for you or creating a systematic trading strategy for you! Please also come to our regular finance talks in London, New York, Budapest, Prague, Frankfurt, Zurich & San Francisco - join our Meetup.com group for more details here (Thalesians calendar below)

29 Feb - London - Jessica James - FX option trading
14 Mar - San Francisco - Quant Fintech Mixer Event
15 Mar - New York - Thalesians/IAQF - Alex Lipton - Modern Monetary Circuit Theory
21 Mar - London - Robin Hanson - Robin Hanson, Economics when robots rule the Earth
20 Apr - London - Oskar Mencer - FRTB, RWA, XVA, Scenarios, MiFiD II, fast?
13 May - Budapest - Saeed Amen/Paul Bilokon - Thalesians workshop on algo trading at Global Derivatives

Saturday, 13 February 2016

Fashion, trends and CTA strategies

17:12 Posted by The Thalesians (@thalesians) 3 comments

I'll confess, understanding fashion has never been my strong point. My uniform for much of my career working in investment banks was simply an ill fitting suit. I eventually worked out that a suit, which was the right size, might actually be a good idea. In recent years, since quitting banking, working as a full time quant strategist at the Thalesians, my uniform has been the humble t-shirt and jeans. I shall leave that up to you to decide whether I possess a modicum of dress sense....

Despite that, the little that I do know about fashion is that trends play a big part in it. If some such celebrity, who I probably don't know the identify of, suddenly wears an item of unusual clothing, it becomes "trendy" to wear it. If an item appears on the catwalk, high street brands will scramble to produce similar items, and then suddenly everyone is wearing it. Fashion trends seem infectious. Then after a while people tire of a fashion and the trend is extinguished. Fashions move in cycles, punctuated by the seasons, items of clothing seem to come in and out of fashion decade after decade.

Trends are obviously not purely restricted to fashion. Markets exhibit trends. There's that hot IPO, which has attracted lots of media interest, that market participants are desperate to get hold of. There's that new startup, which no one cared about, until a few big venture capital funds decided to invest. There's that currency that was languishing near the lows, till a smart hedge fund manager decided to buy, precipitating interest in that currency, from the rest of the market. We see an asset trend upwards on a chart, and suddenly, human behaviour gets involved and we want to buy, we don't want to miss that move! I could give countless examples of this type of herd behaviour in markets, which mirrors that we see in fashion. We all claim to be immune from it, yet, the fact that there are trends in the market seems to say otherwise.

Even if we ignore the behavioural argument for trends, the presence of an economic cycle gives rise to market trends. At the beginning of an economic cycle, we might expect materials stocks to outperform, as companies begin to invest in infrastructure. Countries which export commodities also tend to benefit. As the economic cycle wanes, commodities become less bid, and investors shift towards preservation of capital as the recession approaches, shifting from equities towards bonds.

Whilst the old maxim says "buy low, sell high", to be a trend follower in markets, you do precisely the opposite. You buy high, on an expectation of price action going higher. Conversely, you sell low, expecting the price to continue drifting lower. CTA, or commodity trading advisors have been around for around for decades. Typically they use systematic trading models, which are trend following, to make trading decisions. But how precisely do they go about it? At Global Derivatives in May, which will be in Budapest for the very first time, I'll be presenting my paper "How to build a CTA?" to help answer this!

I'll be examining the various technical indicators which can be used to generate trend following signals. I'll also be showing, how trading multiple asset classes from a trend following perspective can improve risk adjusted returns, compared to focusing on a single asset class. I'll be looking at historical results which show how trend following can help diversify the returns of long only equity and bond investors. To round off the discussion, there will be an interactive demo of how to implement a simple FX CTA type strategy in Python using my open source PyThalesians library (download the code from GitHub here).

If you want to know more about what a CTA does, hopefully see you at my talk at Global Derivatives in May! I promise I won't be attempting to tell you about my fashion sense at the same time....

Like my writing? Have a look at my book Trading Thalesians - What the ancient world can teach us about trading today is on Palgrave Macmillan. You can order the book on Amazon. Drop me a message if you're interested in me writing something for you or creating a systematic trading strategy for you! Please also come to our regular finance talks in London, New York, Budapest, Prague, Frankfurt, Zurich & San Francisco - join our Meetup.com group for more details here (Thalesians calendar below)

16 Feb - New York - Thalesians/IAQF - Harry Mamaysky - Does Unusual News Forecast Market Stress?
29 Feb - London - Jessica James - FX option trading
14 Mar - San Francisco - Quant Fintech Mixer Event
15 Mar - New York - Thalesians/IAQF - Alex Lipton - Modern Monetary Circuit Theory
21 Mar - London - Robin Hanson - Robin Hanson, Economics when robots rule the Earth
20 Apr - London - Oskar Mencer - FRTB, RWA, XVA, Scenarios, MiFiD II, fast?
13 May - Budapest - Saeed Amen/Paul Bilokon - Thalesians workshop on algo trading at Global Derivatives