Friday, September 23, 2016

Anybody can be a quantitative trader!

In part 5 of my blog, I talk about a crowd sourced online quantitative investment firm called Quantopian. The website provides a platform to write investment algorithms in the Python language by providing minute by minute stock data and a development platform for both backtesting and implementation. It then uses an API with the brokerage firm Interactive Brokers to help traders on the website receive real-time quotes and implement their trading algorithms. The best part is that the website is mostly free to use.

A basic quant algorithm essentially has the following structure. A data structure used to store data passed to it (data such as stock price information), a function written that performs technical analysis (our trading ideas) on the stock data, and an output that shows what stocks the analysis says we should trade. Since the development platform can be hooked up to an API, it can also automatically be told to make certain trades that the function has told us to make. These systems are used on a wide variety of information ranging from basic stock prices, earnings, sentiment indexes, dividend announcements and even regulatory filings.


Above is a sample of a simple trading algorithm. As shown, there are many more variables to keep in mind when creating an algorithm. These things include dynamically selecting stocks based on information that is continually being passed to it through the API or creating multi-factor models that assess stocks on a wide variety of variables as I talked about in my last post.

The world of investing is becoming more and more quantitatively driven every day and as information is becoming more widely available with the advent of the internet, speed is as valuable as ever. By creating a stock trading algorithm, it allows investors to analyse a huge database of stocks based on certain criteria in seconds instead of days.

Writing & Image References:
https://www.quantopian.com/home

Friday, September 16, 2016

Predictive Analytics

Predictive analytics is the process of using statistics and modelling to determine future performance based on current and past historical data. What if I told you that you could program a computer to read thousands of gigabytes of data about stock market information and find correlations between asset prices. It would then trade based on this information and make you money. Seems a little bit too good to be true doesn't it? Well...Thats because it is, and its more complicated than that. A lot of these execution systems deal with computing complex bayesian probability (that continually update themselves) at breakneck speed.

One distinction to make is that these predictive analytics systems are slightly different from what algorithms do. A key difference is in its ability to learn to evolve from its experience, a form of artificial intelligence. They take in what are called factors, essentially data types that vary over time and can be correlated to execution, like volatility, size of orders, spread, time of day, news etc... There are hundreds of these types of factors and past analysis yields which ones of them offer the greatest predictive power of stock prices. Those particular factors are tracked by the predictive analytics system and determine likely price movements in the form of buy/sell recommendations.

Rumours among the professional finance community claim that these systems are already forming a new paradigm of trading for both professional traders and retail traders alike. More and more specialised firms are offering these services to the community for increasingly cheap costs (some even for as cheap as a few hundred bucks a month). Only time will tell whether or not these analytics are here to stay. I, for one, say adapt or die.

Friday, September 9, 2016

High Speed Pinging

High frequency traders have received a lot of criticism in the past few years for what many call 'predatory' trading practices. One of the most widely used of these practices is called pinging. What these traders do is send out lightning fast orders (ping orders) in order to detect/learn about larger orders in the market, much like sonar looking for enemy vessels in the ocean i.e. prey.

Large institutional investors (those who buy shares in the millions) aren't able to go into the market with such a large order, so they resort to a tactic called 'iceberging'. This iceberg algorithm takes a stock order (lets say 20 million shares) and breaks it up into smaller components so as to try and reduce market impact (avoiding large price swings). The issue here is that when we have one algorithm trying to make money, there is another trying to compete with it. 

These algorithms, known as predatory algorithms, wait and send out ping orders (small 100 share orders to gauge where potential large orders may be sitting for certain price levels). Once a HFT firm gets a ping or a series of pings in quick succession, they can discern a likely presence of a large order at that price level. They subsequently attack by buying large amounts of stock at that particular price and resell it to the larger buyer for a 1-2 cent premium (since they have the hardware speed advantage). This may not sound like a lot but 1-2 cents for a 20 million stock order amounts to $200,000 dollars in profit. If we think about the daily volume of the US stock market, close to the hundreds of millions, these profits add up quickly. 






Pinging algorithms essentially reverse engineer the iceberg algorithm that's used to hide large order sizes from the market. This activity almost guarantees risk-free profits at the expense of the large institutional investors who receive unfavourable prices. Many professionals have likened this predatory strategy to baiting, luring large investors with large orders to essentially reveal their hand. 

Writing & Image References:
https://www.youtube.com/watch?v=V43a-KxLFcg


Friday, September 2, 2016

A Brief Summary of High Frequency Traders


The human brain is a wonderful thing, but it does have limitations in the speed in which it can process information. It is estimated humans can process simple external stimuli in a space of 250 milliseconds. Lets take this to be the outer boundary for humans to participate in responsive thinking. This 250ms window is where algorithmic trading dominates and creates its edge over the rest of the market.

In the last post, we saw that over 70% of traded securities in US markets are traded by algorithms. A subset of algorithmic trading is high frequency trading. High Frequency Trading companies have spent millions of dollars to store these algorithms in interconnected servers as close to the stock exchanges as possible for the sole purpose of receiving information before anyone else (about prices). It is a world where the speed of light is something one must factor when making calculations.

One of the fastest hardware trade execution algorithms takes about 740 nanoseconds to make a trade. It is difficult to picture this since it's on a time scale humans can't really conceive. A nanosecond is a billionth of a second and to put into context, it takes about 740 nanoseconds for light to travel 11.8 inches. High frequency traders operate on these timescales.

BUT these algorithms aren't very smart. On May 6th, 2010 at 2:45 PM: The algorithms in the US market decided to make some controversial decisions. While the markets were having a slow day, the algorithms  decided they were going to take almost a trillion dollars of capitalisation out of the global financial markets. They traded Accenture stock for 1 cent a share and decided Sotheby's would trade for over $100,000 dollars a share. Then 15 minutes later, they decided that everything was going to go back to normal. Whats most frightening about this is the fact that we still do not know what fundamentally happened in those 15 minutes even today.

Although these algorithms have created a wealth of opportunity in a field of study known for its profitableness, they pose some alarming concerns. There are millions of algorithms in the market we do not understand, operating on time scales inconceivable to humans, influencing prices of not only stocks but commodities like oil. The same oil we use as gasoline in our cars everyday. It begs the question whether or not we are living in a world controlled by these machines.

Writing References:
https://en.wikipedia.org/wiki/2010_Flash_Crash
https://www.capgemini.com/resource-file-access/resource/pdf/High_Frequency_Trading__Evolution_and_the_Future.pdf

Image References: 
http://i2.cdn.turner.com/money/2010/10/01/markets/SEC_CFTC_flash_crash/chart_dow_dip2.top.gif
http://www.transworldfutures.com/images/ex_hosting.png