Dust flux, Vostok ice core

Dust flux, Vostok ice core
Two dimensional phase space reconstruction of dust flux from the Vostok core over the period 186-4 ka using the time derivative method. Dust flux on the x-axis, rate of change is on the y-axis. From Gipp (2001).
Showing posts with label HFT. Show all posts
Showing posts with label HFT. Show all posts

Wednesday, April 2, 2014

From the small to the big: earthquakes, avalanches, and high-frequency trading

I've been talking about scale invariance a lot lately. I became interested in the topic quite a few years ago in the context of geological phenomena like earthquakes and avalanches. The Gutenberg-Richter law describing the size-frequency relationship for earthquakes was one of the first natural laws based on scale invariance, but interest in the topic really picked up with the Bak et al. paper in 1987 (pdf - may only be a temporary link).

The cause for this relationship is still foggy, as is the physical mechanism between the small and large earthquakes. The best proposed explanation is that the scale-invariant distibution of events allows for the most efficient flow of energy (and information) through the system (but it isn't clear why that should be so).

So back in the early '90s I was estimating recurrence intervals estimates for certain hazardous events and I started trying to work out a methodology for detecting scale invariance in the geologic record. Using the Gutenberg-Richter Law, you can estimate the likelihood of a large earthquake in an area based on the number of small earthquakes. There were interesting implications for areas where the recurrence interval of large earthquakes is longer than the local recorded history (as in much of Canada). At the time, there were seismic hazard maps produced by the USGS which showed significant earthquake risk in zones which mysteriously ended right at the Canadian border.

One of my classmates in my undergrad days (we're back in the 80s, now) studied the correlation between microquakes and fluid injection at oil extraction operations in southwestern Ontario. The oil companies were surprisingly cooperative until they understood the point of the research, after which they started to withhold data.

And here is the mystery. The principle of scale invariance in earthquakes would suggest that increasing the number of small earthquakes should increase the number of large earthquakes at least in the short term. Yet our understanding of the dynamics of earthquakes tells us that lubricating the fault should allow stresses to be relieved through the small earthquakes, which in the long-run should reduce the chance of a large quake in the longer term. (This idea has been proposed at various times over the past fifty years, but for various obvious reasons, it has never been deliberately pursued).

By the early 2000s, other geophysicists (notably Didier Sornette, but there were others) had moved a portion of their data processing expertise into studying econometric time series. I made this move later as I gradually came to appreciate the key problem with developing quantitative techniques when the data were suspect. First of all, the measurements themselves are inaccurate. More importantly, our estimate of the timing of each observation was just that--an estimate. Most quantitative methods assume that the observations are evenly spaced in time. Failing that, they assume you know the timing of your observations. The consequences of errors in the timing are terrible, and frequently underestimated. The point is that it is difficult to develop excellent quantitative methods when the data are terrible.

The big advantage of working with economic time series--pricing data, in particular, is the elimination of the observational errors. When a transaction occurs, there is no doubt about either the price of the time--right down to the millisecond scale.

I started looking at market macrostructure--because (several years ago) nothing interesting ever happened on a scale of less than about an hour. Until just the past few years. Suddenly, strange, rich, unusual behaviours began to occur in individual stock prices, and even indices, on the millisecond scale. I didn't know what was causing it--but it sure was interesting.


Three seconds on the tilt-a-whirl.

This was the signature of onset of HFT. I was initially interested in it for entirely different reasons than most of you. After Crutchfield's (1994) paper (pdf) on emergence, I had been pondering the idea of how to recognize a fundamental change in a complex system. Again, my interest was in the earth system as a whole, and how to recognize whether or not new observations were pointing to a fundamental change in its mode of operation.

Given our understanding that the number of large avalanches is positively correlated to the number of small avalanches, it seems pretty clear that (as Nanex and Zerohedge has been saying) the damaged market microstructure is mirrored in the increasing number of flash crashes since Reg NMS. Unfortunately, our murky understanding of how the microstructure causes the macrostructural changes can be used by the regulatory authorities to avoid investigation. They can't see a smoking gun.

We would normally expect the micro-crashes to eventually relieve imbalances in the system, improving its long-run stability. (Perhaps this is how the SEC justifies the practice). But unlike earthquakes and avalanches, these uncountably many small crashes are not reducing the imbalances. One reason is that the cause of the imbalances is separate from HFT--the dollars keep being shoveled to the top of the mountain as fast as, if not faster, than HFT brings them cascading down. Another reason is that the trades (mostly) get unwound--so the exchanges push most of the snow back to the mountaintop after the avalanche.

HFT certainly benefits unfairly from the system, but isn't responsible for it. If anything, it is a symptom of corruption--but the cause of the corruption is elsewhere.

Accordingly, my modest proposal for dealing with HFT is this--nothing. Don't bust trades--let them stand. I'd be curious to see the response of the various Ivy-League endowment funds and pension funds when they suffer brutal, near-instantaneous, multi-billion-dollar losses. At a guess, I would probably hear the screaming up here. How would real companies, producing real products, react to a sudden monkey-hammering of their stock price, especially if it triggered debt covenants? Maybe they would all exit the market en masse. It might even force a real change.

Wednesday, November 13, 2013

Complexity, bifurcations, catastrophe

What makes a system complex?

It is a perplexing problem--both its description and its quantification. One might think that the description of a system as complex would suggest it has many subsystems each acting in accordance with its own rules, and interacting with each of the other subsystems in ways that we find difficult to describe. But there are systems involving very few "parts" which exhibit the kind of behaviour we call complex.

Another possible definition may stem from the notion of the compressibility of the system's information. Is it difficult to describe the sequential outputs in a manner that is simpler than merely listing all of our observations? A good random number generator would exhibit such behaviour, but we would not describe that as complex.

John Casti has proposed that the complexity of a system is at least partially dependent on the observer. He uses an example of a rock lying on the ground. To the layperson, there are only a limited number of ways to interact with the rock (kicking it, breaking it, throwing it, etc.) . To a trained geologist, there are more (as before, as well as mass-spectral geochem, x-radiography, electron probe, etc.). So the rock seems more complex to the geologist, but that additional complexity actually stems from the observer.

Another example can be share prices, where the complexity depends on the timing of your observations. If you look at the price of, say, Anadarko Petroleum over the past year, using closing prices only. (for disclosure--no position).


Then we can look at one-minute increments on a daily chart (Nov. 6, 2013).


Note that the variability within the two charts doesn't seem all that different despite the changes of scale. Lastly we could look at how trading in Anadarko looks over one second. One particular second, that is, between 3:59:59 and 4:00:00 on May 17 of this year.



You probably wouldn't expect a lot of change over 1 s, but in this case you would be wrong: the price fell from about $90 to $0.01 in less than 50 ms. That's a loss of $1 billion in market capitalization per millisecond--keep losing money at that rate and before long you're talking real money!

This all seems to trigger a philosophical debate--is the complexity present when none of the observers are capable of seeing it? In the case of Anadarko, if you were a pension fund, your losses would have been real (although the trades were all cancelled and reversed after market close).

If the complexity of a system arises from within, then what characteristics do we ascribe to complexity. One characteristic is discontinuous behaviour, particularly when the inputs to the system are continuous. For instance, tectonic processes gradually cause stresses to accumulate in an area in a fairly uniform fashion, until a critical threshold is reached and the earthquake occurs.

The branch of mathematics that investigates the sudden onset of convulsions wrought by a slow change is called catastrophe theory. Catastrophe theory is generally considered to be a branch of bifurcation theory. By bifurcation we normally mean some change in the operations of a complex system. It could represent a transition from one stable state to another. It could also represent the development of new areas of stability in phase space (or their disappearance) or simply a change in the nature of a chaotic attractor.

In particular, sometimes the sudden appearance of a new mode of stability is brought about by the changing value of a slowly migrating parameter past a critical threshold. Such behaviour is called a catastrophe, in the mathematical sense.

In the past few years we have seen a major change in the mode of operations in the markets. In particular, the rapid growth of high-frequency trading has added complexity at timescales where such behaviour did not previously exist. This is another example of a catastrophe.

Tuesday, November 5, 2013

Happy anniversary chaos!

Fifty years ago, Edward Lorenz published the first paper (pdf) generally recognized to discuss chaos.

Lorenz didn't call what he had discovered 'chaos'. It's not clear that he really understood the importance of what he had discovered. He knew it was interesting, and when scientists find something interesting they publish it, and worry about the ramifications later.

What Lorenz had discovered is that a deterministic system could have unpredictability. It is difficult to convey how unexpected this discovery was at the time, because the idea of what is now called chaos has disseminated (although imperfectly) through our common culture. A deterministic system is one in which the rules are well described (via equations) which operate on data to produce results. Since the time of Laplace's Dr. Manhattan quote, it had always been assumed that nothing unexpected could arise from such a system when an initial position and the rules of motion were defined to arbitrary precision. Unexpected behaviour should only result from randomness.

So when Lorenz put together a simple model for atmospheric convection in the presence of heating, he used three simple differential equations, simple boundary conditions, and an arbitrary starting point, there would have been no reason to suspect that anything unexpected might occur. After all, all the parameters in the equations were known.

In essence, what he discovered was that minute variances in starting conditions led to extremely large variations in outcome. This again was unexpected, because our knowledge was largely built on assumptions of linear behaviour, in which small variations only grow larger slowly. Lorenz's interpretation of what he had discovered was to correctly point out that long-term weather forecasting was impossible, because it was impossible to measure the present state of the system with perfect accuracy--and the range of possible differing outcomes from the measurement accuracy was essentially the range of all possible weather.

The discovery and formalization of chaos theory led to entirely new fields of study encompassing different aspects of nonlinear dynamics and complex systems. Among them is one field of endeavour which has been a point of interest on this blog--complexity.

What do we mean by complexity? Actually, I'll write about this in a future posting. For now, let's just note the relative unpredictability of complex systems and get into the whys of it all later.

- - - - - - -

This post is a bit belated, because Lorenz's publication was actually in March. But something as momentous as chaos should celebrate over the course of an entire year.

Sometimes we go all out and celebrate something over a couple of years. International Geophysical Year (1957-58) and International Heliophysical Year (2007-08) come to mind.

There have already been numerous celebratory events so far this year. But first, a word about the enablers of this year's celebrations on the markets.

High-frequency trading spams the exchanges with empty quotes destined to be cancelled--so much that it appears that many legitimate offers do not get filled at optimum pricing, as the system becomes overwhelmed with meaningless numbers.

According to the exchanges, HFT is a good thing. It increases liquidity, or at least that is the axiom that guides their acceptance. Unfortunately, observation tells us that the opposite may be the case--that HFT causes liquidity to vanish precisely at the time it is most needed.

In the last 50 years, we entered the nonlinear world. But our thinking--especially institutional thinking--is still trapped in the linear world.

In the linear world, if something is a benefit, then more of it is a greater a benefit. But in the nonlinear world, where one may be a benefit, and two may be better; three could turn out to be horrifying.

So in celebrating 50 years of chaos, the exchanges (with their sponsors, the algos) have brought you the following celebratory events.

Flash crash on the German market. Twitter feed flash crash. (Appropriately enough, both of these were in April). Thee Anadarko flash crash. Information travels faster than the speed of light! Closing of the Nasdaq options bourse. Not to mention hundreds of strange trade executions across all the exchanges.


How to lose lots of money in 45 ms by Nanex.

Most of these problems are the (un)predictable result of the interaction of numerous algorithms. Some may have been errors, or the so-called 'fat finger' trades; others may have been other form of human or algo error.

Algo error. Was that supposed to happen?

The markets are not what they used to be. The overall superstate has changed over the last ten years from one dominated by humans to one dominated by machines. The result has a been a series of entirely new phenomena, which we have earlier termed 'innovation'.

The year isn't over yet. I look forward to the next special event. I don't think I have long to wait.

- - - - - - - - - - - - - -

And then there's this. I was going to put in something by King Crimson here, but this seemed more appropriate.

Friday, October 4, 2013

One more time--the distinction between human- and algo-trading

The markets do not act like they once did. The trading in certain stocks is operating on time-scales so small that they cannot be in response to human thought. Not only are certain individuals able to access key information before others and so respond to news releases faster than the speed of light, but certain entities have free range to post and cancel orders on a microsecond basis, and queue-jump by shaving off (or adding on) tiny fractions of a penny from their orders.

Stocks traded by humans tend to make significant moves on a timescale of minutes to days. Even when there is a news event that radically changes the apparent value of a company, if there are only humans in the market, the move takes time to occur. Below we a couple of charts for Detour Gold (I currently have no position in this stock)


Normally, when looked at on a ms timescale, the graph is not really distinguishable from a straight line.


The little squares occur because all the price-changes I saw in the course of the day were a penny. On this scale it scarcely matters which axis is the current price and which is the lagged-price.

Once the algos get involved, the millisecond phase space plots get a lot more interesting. Some of them are works of art! Below, some plots for Century Casinos (I have no position in this one, either). Data here.



Algos playing tug-o-war.

Nice to look at, but maybe not so nice to trade against.

Remember the adage about playing poker: If you don't know who the sucker is . . .

Sunday, September 22, 2013

Why do Ma and Pa play in a rigged market?

They have been able to pay off politicians with political campaign funds and have been granted informal and unspoken yet complete immunity from prosecution, setting the scene for even bigger confiscations of investor capital. With the risk of legal repercussions so small and the temptation to steal so large, why would any of them not take advantage? What do they have to do to stop people from entrusting them with their savings? Put up neon signs that say, “We steal your money”?”
                                        – Dimitri Orlov – The Five Stages of Collapse

Sometimes even that doesn't help.


"Darn it, Pa! I told ya not ta buy AAPL on margin!"
"But Ma, I thought you wuz talkin' 'bout apples."

The problem is that Ma and Pa believe they are above average--in intellect, in wisdom, in luck, in investing acumen. When they see that sign that says their money will be stolen, they all have faith that it will happen to somebody else.

When I was a kid, I wanted to be a pool shark. Never mind that I wasn't much good at it. I researched the concept at the local magazine stand and discovered that the secret was not to beat the other guy with great shooting, but to beat him in a way that he would think he had beat himself, through mistakes. The reason it works is because when your victim makes a good shot, he believes that is his normal capability, but a mistake is not--and tends to be discounted. That discounting is essential, because if your victim believes he only lost because of his own mistakes, he will be confident he will win the next time. On the other hand, if you simply run the table, chances are he won't play again.

This only works because people are usually not as clever as they think they are.

Consequently, Ma and Pa can read about what is being done to them--and they will think it is only a problem for other people. Their orders will get filled in a timely fashion. The stocks they buy have true liquidity--not the phantom liquidity of offers that are never to be filled. And when they file for bankruptcy, it will merely have been bad luck.

Saturday, January 5, 2013

Invasive behaviour and extinction in the retail market

The term "invasive species" has been used to describe new types of plants or animals that have been introduced to a new area, whereupon they change the local biosystem.

The sudden appearance of new lifeforms in an environment can cause rapid losses in some of the species present prior to this appearance. Biosystems are dynamic systems with considerable stability, and often the arrival of new species simply cause a slight change in the dynamics of the system, which continues on with only small cosmetic changes.

On occasion, however, the new players cause overwhelm the stabilizing factors in the system, which undergoes dramatic changes, eventually stabilizing in a new configuration that is highly detrimental to many of the original players in the system.

Which brings me to today's invasive species.

Although high-frequency trading has been around for nearly a decade, it didn't hit public consciousness until the "flash crash" of May 2010. In the past two years, the incidence of HFT flash crashes has expanded (see archive here) to the point where they are causing significant pain to the retail investors.

Much has been written about the impact of HFT, and a broad survey of the literature is so contradictory that I have to feel that some authors are not writing honestly. For every article about manipulation and increased volatility and reduced liquidity, there are academic papers like this one claiming that HFT "improves liquidity and enhances the informativeness of quotes".

Many of the characteristics of successful invasive species are shared by HFT algorithms: 1) fast growth; 2) rapid reproduction; 3) the ability to alter form (mutate) to suit current conditions; 4) tolerance of a wide range of conditions (except perhaps transparency); and 5) ability to live off a wide variety of food types. As a bonus, living in contact with humans also helps invasive species.

What in the market is going extinct? The retail investor.

How so? It comes about through the erosion in their margins brought about by HFT. In the presence of HFT, the unsophisticated investor pays a higher price on the buy and receives a lower price on the sell than would be the case otherwise. The professional traders manage to maintain their margins--the losses of the unsophisticated are the profits of the algos.

As our markets have come to resemble casinos, investment is increasingly like gambling. For a typical gambler in a casino, where winning is determined by chance, is eventually ruined. Gambler's ruin is inevitable in a fair game--but comes faster now that the bias is negative because algos are skimming a little off each one of our gambler's bets.

Wednesday, September 19, 2012

The GS Trader

In response to this.

Once there was a GS Trader,
Who ordered o'er the intervader;
No, no, I mean a GS Get
Who tried to use the internet;
(Dear me, now I'm not quite
Sure if even now I've got it right).

Howe'er it was, he got his bid
Emplaced upon the intergrid,
The more he tried to get it filled
The harder crashed the interbuild.
(I think it's time to stop this rhyme,
Of HFT and micro-time).

-- with apologies to Ogden Nash

Tuesday, May 1, 2012

It isn't the speed; it's the illusion of liquidity

At last the Toronto Star has an opinion piece on high-frequency trading deploring the condition of the markets. Unfortunately the piece focuses on the microsecond advantages that some well-heeled entities have created for themselves by laying millions of dollars of fibre-optic cable, and misses the most important problem--the ability of some players to place and remove bids at inhuman timeframes of thousands per second.

Historically, the person with the best access to information has an advantage over the other participants. I don't view this as being unfair--it's the way it has always been. Furthermore, when those who have an information advantage act on it, they add information to the market, so that the time-advantage of advance knowledge dissipates quickly through the mechanism of the market.

The real problem with rapidly creating and cancelling orders is that it strikes at the fundamental trust underlying the market. When you decide to purchase a stock, you normally do at least a cursory check of liquidity. If, for instance, you look at ABC on the exchange, and the best bid price is $8.00 and the best ask is $2.00, you know there is no liquidity, and it is a stock to be avoided. If the bid is $8.00 and the ask is $7.99, and there are reasonable numbers of shares on offer, then there is liquidity and you should be able to get in or out without too much trouble.

What happens when the entities that have made the best offers have no intention of filling their orders? A casual inspection of market depth might convince other market participants that there is a lot of liquidity available for that particular stock, but the liquidity is an illusion which lures market participants into unsuitable investments and traps them there. Inevitably, the entrapped participants will leave the market and never return.

A store might advertise a product at less than half the usual price, along with a disclaimer that the price may change without notice. We recognize that there may be contingencies that may force the store owner to raise the price. The supplier may call and say there is no more supply. But suppose the contingency that caused the store owner to raise prices was a customer entering the store to buy the product. So the article is advertised as being on sale for $1, but if anyone tries to buy it, the store owner declares a contingent increase in price to $2. The article is for sale at $1, unless someone tries to buy it. How long before the customers stop going to the store? The advertisement may not have been a legally binding contract, but it does create an expectation.

The same expectation is created by the illusion of liquidity. This illusion causes great harm to a motivated buyer (or seller) of securities, particularly if they are motivated to buy or sell a large order. Imagine that you are managing a pension fund, and you find yourself with a million shares of a junior mining stock to sell. You look at market depth, and lo and behold, someone is willing to buy a million shares at, say, 12 cents. You decide that that is an acceptable price; but when you try to fill the order, it is immediately cancelled (perhaps 1000 shares are successfully sold at 12 cents) and replaced by an offer to buy a million shares at 11.5 cents.

Now what? You might wait and see if any more of your offered shares are picked up, but if they are not,  you have a problem. Institutions don't have cheap trades. Your shares are in the form of a certificate in a safe--for you to complete the sale of 1000 shares you have to take the certificate from the safe, deliver it to the transfer agent; have the transfer agent split the share certificate, sending one certificate to the new owner and returning the balance to you; then you have to return the certificate to your safe, but this process has to be audited (i.e. witnessed by a lawyer, who verifies that the certificate is for the correct amount, and has been placed in the correct compartment in the correct safe). All of this costs more than $7.99 that a discount brokerage might charge. So chances are that you will be criticized for a $120 trade.

So you try again at 11.5 cents, but once again only 1000 shares are sold before the buy order is cancelled and replaced by one at 11 cents. Well, you can see how this goes. You keep trying to sell and the price keeps falling until there is real market interest; perhaps at 6 cents--or lower. Had you known that you would have to sell at 6 cents you might never have started. You were lured into a bad trade by the illusion of liquidity.

The practitioners of HFT claim they are supplying liquidity to the market, but this is not the case. They are only creating the illusion of liquidity, and this illusion has drawn a lot of money into the market--money which would not have entered the market without the illusions. Unfortunately, drawing this money into the market is politically advantageous for North American governments who can use it as evidence for an improving economy--consequently there is no interest among the political class for a fair solution to the HFT problem. It is not a problem for them. But it is a problem for everyone else in the market, even, ironically enough, for the high-frequency trading firms.

Friday, December 23, 2011

Innovation in complex systems

Innovation has been on my mind a lot lately. Unfortunately, not the kind that results in iPhones and the like.

We normally think of innovation as a good thing. But not all innovations are good ones. As counterexamples, let's consider recent political innovations in the US that allow indefinite detention without trial of anyone accused of terror-related activities; or the use of Predator drones to target American citizens.

My interest has been innovation in the Earth system--particularly in the behaviour of the climate system over the past two million years. The problem with recognizing innovation is that we tend to interpret any activities in light of what we already know--consequently it is difficult to discover anything new. Our first tendency would be to explain our new observations as a special case of what we already know. We resist the idea that something new is occurring.

The Earth system is driven by a few global parameters which interact with myriads of local agents; yet contrary to expectations instead of dissolving into noise, highly ordered global-scale structure arises. We may call such structures emergent properties, and the means by which they arise is termed emergence.

The problem of how these global structures arise from multitudes of interacting local agents is, shall we say, a non-trivial problem. They are in no way predictable from our knowledge of the local interactions; nevertheless we agree that emergence is in accordance with physical laws.

In earth systems, such emergent properties include plate tectonics, glaciations, superplume events, and some mass extinction events.

The emergent properties of a system may change. These changes may or may not be related to specific change(s) on the local level. For the purpose of this essay, I am referring to such changes as innovation.

Possible examples of innovation in Earth systems include the (somewhat controversial) proposed change in mode of tectonics in Archaean time; (very controversial) Neoproterozoic glaciation (i.e., "snowball Earth"); and magnetic pole reversals.

I have been considering change in operation of the climate system during the Mid-Pleistocene (from about 1 million years ago to about 500 thousand years ago).

I present the following probability density plots of the 2-d phase space reconstructions of the ice volume proxy, produced using the time delay method with a delay of 6 thousand years. Each of the figures below is calculated from 150 thousand years of data.

Starting from the Early Pleistocene . . .



Limit cycles (green dashed ellipses) are common in the Early Pleistocene, less so later.

Areas of Lyapunov stability, labelled A1 and A2, represent relatively ice-free conditions. Current global ice volume is comparable to A2, and A1 represents even less ice than at present. Limit cycles in the Early Pleistocene (representing slow, steady growth and decay of ice sheets) start from either the A1 or A2 condition.





The Late Pleistocene is characterized by discrete areas of high probability, suggesting rapid transitions between longer periods of stability. A2 represents an interglacial condition, and A3 to A6 represent separate metastable ice configurations of greater volume respectively. A6 represents a glacial maximum condition, as we experienced about 18,000 years ago.

Climate dynamics as inferred from global ice volume seems to have changed during the Pleistocene epoch. Was it innovation?

Opinions about what happened during the Mid-Pleistocene include changes in atmospheric CO2 leading to greater glaciations, cumulative cooling in the deep ocean changing the nature of the glacial-interglacial transition, erosive uncovering of crystalline bedrock leading to greater thickness of ice sheets, and spontaneous (chaotic) change. There is general agreement that there is no obvious external forcing or any fundamental change in the low-level dynamics leading to the change in climate behaviour, so it is at least possible to argue that the climate system began to act in an "innovative" fashion (provided we state that we do not view this innovation as having been directed in any way).

Let's look at another system instead--one represented by the share price of Century Casinos.


The chart of the daily closing price looks a little like my portfolio--up to a high in April, and all downhill from there.

The two-dimensional reconstructed phase space doesn't look much different from those of other stocks I've looked at in the past.


Actually, this has been smoothed a little, using a 3-point moving average.

There appears to be nothing interesting in the share price activity over the past year--unless we look at daily high prices instead of closing prices.


And here we see something unexpected--a singular spike in share price on June 21, where the share price bounced between about $3 and $8 several times over the day, on first a one-minute timescale, and around mid-day at a one-second timescale.

To investigate dynamics on this timescale, we have to construct our time-delay phase space with a small lag.


In two seconds of trading we have numerous fluctuations between $3 and $7. Lots of money to be made here! (or there would have been had the exchanges not cancelled all the trades).

A few minutes later we get this over one second.


This is orders of magnitude different from what we see in the annual behaviour of the stock, and even considerably different from the bowl of spaghetti above. This figure actually represents a phase space portrait of a random walk. Yes, you can trade randomly if you are quick enough.

So what is the difference between the trading in CNTY on June 21 and every other day this year? Another innovation--high-frequency trading, but in a form which creates the illusion of liquidity by placing lots of orders and then cancelling them as they begin to be filled. The resulting moves in a stock can be dramatic.

Suppose an institutional investor needs to buy a million shares of CNTY (perhaps part of some proprietary arbitrage position). The buyer looks at the depth chart and sees that there are a million shares being offered at $3, so the buyer attempts to fill the order--only to discover that he gets perhaps a thousand shares, the rest of the offer is cancelled, and there are now a million shares offered at $3.05. The tug-of-war may continue, but if the buyer is motivated, the share price may rise considerably in a remarkably short period of time.

Remember that the original intent of having a bid and ask price is that the various offerings were intended to be sold. The idea that these offerings would be used only as bait and not represent real liquidity is indeed innovative, but unhelpful.

Unlike the change in climate dynamics in the mid-Pleistocene, the change in dynamics in share price of CNTY is symptomatic of a fundamental change in the operation of the market, and this change is detrimental to the majority of its participants.

Saturday, October 22, 2011

Inference of dynamics for complex systems part 2

Phase space portraits

As we left our last installment we had the problem of a series of observations from some interesting system, and we were seeking a means of understanding it. First of all, however, we had some doubts as to whether the measurements we have made will tell us anything about the system, or whether there will be other information needed in order to make any useful inferences.


Approaches to studying dynamic systems include both qualitative studies of the general trends of a system and quantitative studies in which invariant properties of the system are evaluated [Abarbanel, 1996]. System dynamics are evaluated by reconstructing the system’s phase space, which is a geometrical representation of the system projected in a “space” created of different variables [Packard et al., 1980; Abarbanel, 1996]. The climate system can be described by a phase space with coordinates x1, x2, x3, . . . xn, and the functions x1(t), x2(t), x3(t), . . ., xn(t) (the outputs of the system). As time (t) varies, the sequential plot of points of coordinate {x1(t), x2(t), x3(t), . . ., xn(t)} describes the time evolution of the system in phase space.

The number of output functions (n) is called the embedding dimension [Sauer et al., 1991]. The evolution of the system is marked by the trajectory traced out by sequential plots of individual states with coordinates defined by the values of the n functions at each observed time. Describing the trajectory of the system as it flows through phase space is a qualitative means of characterizing the dynamics of the system. The system may also be characterized quantitatively in terms of its invariant properties, such as the Lyapunov exponents and the correlation dimension of the system, which can be calculated from the phase space portrait [Abarbanel, 1996].

Phase space from multiple time series

How do we select the coordinates? One method is to create a phase space by plotting scatterplots of several different records which have been sampled at the same time intervals. For instance, Saltzman and Verbitsky [1994] created a phase space using, as variables, ice mass, ocean temperature, and atmospheric CO2. The state of the system is defined by its location in phase space at a particular time. The plot of successive states through time traces out the trajectory of the system. Traditionally the trajectory is constructed by drawing a curved line, rather than straight line segments through the states in sequence.


The drawback with the Saltzman and Verbitsky approach in paleoclimate is that is difficult to find many records that have been sampled at the same intervals. You are restricted to the portion of the geologic record covered by the shortest record. Additionally, there are errors in both magnitude and time.

Let's not worry about interpretation yet. Today is only about basic methodologies.

Economic systems can quite profitably be studied using this approach, mainly because there are so many of them, the errors tend to be small (except see here), and the timing is usually well constrained as well. So we can compare US unemployment rate to interest rates, for instance.


Data from BLS site.

Commonly we might look at observations like the one above, and not draw the trajectory (the curve that runs sequentially through the data). Instead, a traditional approach might have been to draw a line of best fit in the hopes of defining a correlation. In looking at the above figure, we see two clusters of observations. Past experience tells us it is risky to define a line of best fit using the traditional methods in this way, as the result is heavily weighted by the line between the centres of each cluster.

Similarly we can look at the average duration of unemployment vs unemployment rate.


Data from BLS site.

Or unemployment rate (vertical axis) vs monetary measures.


Data from BLS and St. Louis Fed site.

Or house prices vs real interest rates.


Data from Shiller [2005].

Defining a phase space from multiple variables requires multiple records. The state space can only be characterized over the duration of the shortest record. Dating errors will lead to various forms of distortion in the projected phase space. The economic time series tend to lend themselves well to this form of projection, because many of them exist to any arbitrary level of precision. If you choose month-end or year-end prices, there are normally no dating errors.

Phase space from a single time series

It is pretty uncommon to have more than one geological time series of sufficient length with good dating control. So geologists will normally have to work with a single time series. The method below can similarly be used in other types of time series as well.

When you have one time series, you may wonder how much dynamic information it contains. Fortunately, ergodic theory suggests that dynamic information about the entire system is contained in each time series output from the system [Abarbanel, 1996]. Therefore, a phase space portrait reflecting the dynamics of the entire system may be reconstructed from a single time series.

Time-derivative method

Packard et al. [1980] propose a method in which the function is plotted along one axis, and its various time derivatives are plotted on the other axes. If we use the simplest two-dimensional case, the graph would consist of a scatterplot of the function against its first time derivative. (i.e. y vs. dy/dt). An example of such a plot appears on the masthead of the blog.


In the above figure, we see the ice volume proxy plotted on the horizontal axis (ice volume increases towards the right) plotted against its first derivative over an interval of time lasting about 120,000 years. The numbers on the graph represent the time in thousands of years before present (ka BP). The rate of change of ice volume is plotted with +ve on top, so that as global ice volume grows (near A, for example), the system will move towards the right through phase space.

Any equilibria in this type of figure must necessarily occur along the zero rate of change axis.

Note the error bars presented on some of the states. Similar error bars would be found at all other states in the figure as well. The error in estimating the rate of change is a consequence of the error in measurement being similar in size to the difference between successive measurements. The size of the error bars is large compared to the variability of some parts of the trajectory--consequently our confidence in this trajectory is not as great as it otherwise might be.

Time-delay method

We reduce these errors by reconstructing the phase space by the time delay method [Packard et al., 1980], in which the elements of a time series are plotted against n-1 lagged observations from the same series (figure 2B). Identifying the lags and the embedding dimension (n) are key decisions in the reconstruction. To simplify things in the following discussion we shall only use two dimensions. Thus we reconstruct our phase space portrait by a scatterplot of the data against a lagged copy of itself. The optimum lag is defined by the first minimum of the average mutual information function [Fraser and Swinney, 1986]; however for quasiperiodic data we find that this tends to be the first minimum of the autocorrelation function (about ¼ of the period of the dominant waveform).

Thus for ice volume:


Here we are looking at a two-dimensional phase space reconstructed from ice volume proxy data covering about 200,000 years. In this projection, lower glacial ice volume is at the lower left corner of the plot, with greater ice volume towards the upper right corner. We'll interpret these later. Moving on


Case-Shiller index



Official unemployment rate


Detour Gold Corp.


CNTY busted trades (1 s of trading activity each figure)


Gold-silver ratio in phase space

Dynamic systems, like climate, have historically been analyzed using power spectral methods, such as the Fourier transform and wavelet analysis [Hays et al., 1976; Imbrie et al., 1992]. This has been a reflection of the predominantly linear assumptions underlying early analytical methods.

The power spectrum is not an invariant property of a nonlinear time series [Abarbanel, 1996], meaning that significant changes may appear in the power spectrum despite the lack of changes in the dynamics of the system. Therefore, changes in power spectrum are insufficient evidence to infer changes in dynamics.

In our next installment we'll talk a bit about equilibrium and what any of the above plots have to say about it.

References

Abarbanel, H. D. I. (1996), Analysis of Observed Chaotic Data, Springer-Verlag, New York.

Fraser, A. M., and H. L. Swinney (1986), Independent coordinates for strange attractors from mutual information, Phys. Rev. A, 33, 1134-1140.

Hays, J. D., J. Imbrie, and N. J. Shackleton (1976), Variations in the Earth’s orbit: Pacemaker of the ice ages. Science, 194, 1121-1132.

Imbrie, J., et al. (1992), On the structure and origin of major glaciation cycles, 1, Linear responses to Milankovitch forcing, Paleoceanography, 7, 701-738, 1992.

Packard, N. H., J. P. Crutchfield, J. D. Farmer and R. S. Shaw (1980), Geometry from a time series, Phys. Rev. Lett., 45, 712-716.

Saltzman, B., and M. Verbitsky (1994), Late Pleistocene climatic trajectory in the phase space of global ice, ocean state, and CO2: observations and theory, Paleoceanography, 9, 767-779.

Sauer, T., J. A. Yorke and M. Casdagli (1991), Embedology. Journal of Statistical Physics, 65, 579-616.

Shiller, R. J. (2005), Irrational Exuberance, 2nd ed., Princeton University Press.

Friday, September 23, 2011

Market declines

What's it all about?


European markets at least seem to be declining on low volume. Is this all due to major players pulling their bids? Perhaps they are sending a message to the political realm. Certain individuals who may shortly seek re-election may be under pressure to change.

Tuesday, August 23, 2011

Can HFT hold up the market?

Now here's a funny thought. Market volatility has been unpleasant, to say the least just lately. Liquidity has vanished, thanks to HFT. Arguably, the S&P 500 should be a good deal lower than it is.

Suppose you are an institutional holder of shares, and your models are telling you to sell; but every time you try, liquidity vanishes and you end up completing your sale at a much lower price than anticipated. Your boss yells at you. Worse, your year-end bonus suffers. So what do you do?

What can you do? Any attempt to sell in size collapses the price of the security in which you are trading. You have to come up with a strategy to minimize your losses in selling. Either you limit your orders, which means under the HFT regime they never fill (except for a handful of shares), or you don't sell at all. It's possible that some of these institutions are locked into positions they can't get out of (except at desperately lower prices).

There could be a whole country full of institutions that want to sell but dare not for fear to the scalping they'll receive from the algo traders.

Here is another "gift" HFT has given us. Liquidity on the buy side has already vanished; now liquidity on the sell side is going too. The likelihood of a fair price discovery through the market has taken another beating. Although arguably this allows the market to levitate at far above reasonable value, it also means long years of pain for "investors" as every tick up is desperately sold.

Friday, August 12, 2011

Machines without memory

The Masters of the Market stay
In darkened rooms where 'lectrons play
And talking heads cannot convey
The new idea's birth

For they hunger in their secret dreams
For the trading highs of cruel machines
Projected on a million screens
Without a sense of worth.

At last the HFT algo show!
The crash nobody could foresee!
Your neck inside the rope!
Indices wihout hope!
The looters that ignore the SEC!

Perfumed fingers through the till
The asks all grow but never fill
The red ink has begun to spill
The market starts to tank!

The regulators and the traders too
Are uncertain if the plunge is through
And consult their charts to find a clue
But the frozen screens go blank!

At last the HFT algo show!
High VIX grown of a fractal seed!
A bubbilicious time!
A dark and dirty crime!
The bulging eyes of traders strangled by their greed!

(apologies to Alan Moore)

A paper by W. S. Rea and co-authors reminds me of why the methods of analysis I used in this article failed to provide any useful insight despite appearing to work on longer term charts here, here, here, and here.

The time series outputs of some dynamic systems possess long memory--meaning that the present beharviour is influenced by the entire past history of the system. It may be that recent events have a larger statistical impact on the present, but the characteristic of a long memory requires that even events in the distant past are reflected in the present behaviour.

How memory is "stored" in the system varies. For instance, in the days when HFT was a distant dream, the response of a stock's price to a good quarter would depend at least in part to the company's past behaviour. One which disappointed quarter after quarter would not benefit as much from a good quarter as one which had a history of meeting or exceeding expectations--the market might exhibit some skepticism. Where is this memory stored?

In climate systems, the memory may be "stored" in slow-response variables, which may yet influence the reactions of fast-response variables to various forcings. The geological system is extremely complicated, because local climatic factors, which are driven by such things as ocean currents and the distribution of continental land masses are strongly influenced over the long-term by tectonic activity; and over shorter timescales by the distribution of fresh water bodies, themselves being altered in response to isostatic uplift. Slow variations occasionally lead to catastrophic events, meaning sudden irreversible changes can occur in what had been a slowly evolving system.

Many economic systems appear to have long memory. The activities of today are influenced by events of the past. Nixon striking down the last vestige of the gold standard, Volcker raising interest rates, the "strong dollar" policy of Summers, the wars of Bush the Elder and Bush the Younger, Obama's lates raise of the debt ceiling--all of these have had impacts that have rippled through the USD gold price from then until today.

Dynamic systems analysis--at least the type used on this blog--work best on systems that have this kind of memory. The lessons of the past must echo, at least in some form, through the system for analysis to give us some interpretable results, as they do for unemployment and the gold-silver ratio.

HFT algos are different. They have no memory and only dream of a concept of value. Arguably, they estimate a value on the basis of variability in observed parameters; but their means of acquiring or disposing of a stock subverts the normal method of price discovery. Each trade during a flash crash has no identifiable connection with previous trades, but represents that maximizing of an unpredictable opportunity. When the flash is done, normal trading between human resumes as if nothing had happened.

Tuesday, August 9, 2011

Flash crash: business model or indicator?

After the series on deconstructing algos, a few things become clear:

1) HFT, by and large, does not increase liquidity. On the contrary, it works by reducing liquidity at key intervals (during periods of determined buying or selling), resulting in larger price moves than would otherwise be the case.

2) We can distinguish between the brief episodes when an algo clears out those pesky human bids from those when two algos are going toe-to-toe in a stat arb war, as well as those intervals when an algo is taking some hapless mutual or pension fund to the cleaners.

Examples below are accessible through here, except for the first one which was posted here.


Eliminating human bids before the fun begins--2 s.


Scalping the fund by removing liquidity in the face of determined buyingNote the sudden
 rapid rise in stock price while the fund buys, and the price returns to normal afterward.


Two algos slugging it out. Notice a lot of activity in the bid/ask but very few trades actually occur.


Two algos duel. Then, at 10:25, a committed buyer shows up for a scalping.


A committed seller experiences HFT (note the rapid decline in price).

The flash crashes occur because somebody needs to sell a quantity of shares. The algos "perceive" the orders coming to market and choke off liquidity, and the seller gets a poor price.

The flash "rises" occur because somebody needs to buy. In response to demand, the algos again remove liquidity.

In neither case is liquidity being offered when it is needed. In fact, the exact opposite is occurring. By systematically removing liquidity when it is needed most, HFT algos destabilize the system. This destabilization is merely a side effect--the algos increase the profits of the companies that operate them. But this is very much like the Enron method of doing business--shut down plants at a time of soaring electricity demand to line your own pockets while possibly bringing down the electrical network.

Days with a lot of flash crashes, as on Friday (August 5), are days where there is a lot of institutional selling. It is possible that the focussed withdrawal of liquidity by these service providers contributed to the rather steep decline of the indices on that day.

Friday, August 5, 2011

Deconstructing algos part 5: Are there any humans in the market?

In the past few days, some unusual behaviour has been occurring in after-hours trading of Earthlink shares.

Are there any humans in this market? Hello?


After hours pricing on ELNK, August 2, 2011. Lots of action. Image from Nanex.


Details of the above image. Same source.


And here's the trading action. Not much considering all the bidding activity.

I think what we are seeing is the elimination of humans from the market. Two algos, using their own stat-arb approaches have a differing opinion about ELNK. One thinks it is a buy at any price below, say, $8--the other thinks it a sell at any price better than, say, $7.95. It is normal for such differences of opinion to exist--indeed, they have to exist for the market to exist. When two humans meet in the market, with just such a difference in opinion, they would soon come to an agreement, the price being dependent on which participant gives away his opinion first.

The algos each try to maximize its own gain. And they do this by showing only a small offering at the best price that doesn't attract any attention. As soon as some interest is shown in their bid, it is cancelled and moved to a much more favourable price. It would be as if one of the human traders had opined "I might be interested in selling some ELNK at $7.95", and then when anyone expresses an interest, suddenly changes his mind, and say, "actually, I meant $8.15." Then the other trader says, "well, if you came down to $8.10, I might be interested," and just as the first trader goes to agree, the other suddenly says, "actually I mean $7.75." After this goes back and forth for awhile until the inevitable fistfight breaks out. 

No trading would occur. This approach provides no liquidity.

It is a contest, like the game where you try to step on your opponents foot. One favoured tactic is to dangle your foot in front, luring your opponent into an attack, pulling it out of the way as he does so, and then quickly counterattacking your opponent's extended foot. Every so often one of the opponents manages to touch the other and a trade goes through. Otherwise, the bids and offers just go up and down furiously.

*  *  *  *  *  *  *  *  *  *  *

In the last "Deconstructing algos" article we looked at two-dimensional reconstructed phase space portraits of busted trade data for CNTY; original data acquired from the Nanex site here.

As described earlier, one approach to creating a geometric representation of a phase space from a time series is to generate a time-delay plot, in which the values of our time series are plotted against lagged values of the same series. We use a constant lag for reasons described here.

Now, in the CNTY data (and in the data series in today's articles) the time control isn't as fine as we would like. In particular, even though the trades are presented in order, the time stamps only extend to the second. We may have 250 transactions in order in that second, but we don't actually know the length of time between any of them. How do we come up with a constant lag?

We can't. What I did in the last episode was assume that all trades were evenly spaced. In reality, this was unlikely. The result is that my phase space portraits were distorted somewhat from reality. How much distortion depends on how far from evenly spaced the samples are. In practice, with lots of points, the distortion isn't really going to be bad unless you have more than 80% of the trades compressed into an interval comprising less than 20% of the time investigated. This seems unlikely, but it would be nice to be able to check. Intuitively, it seems likely that the many trades at similar values occur close together in time.

A geological time series may be a representation of midsummer temperature, captured at thousand-year intervals. We don't know what the temperature does in between each of our observations, but it would be reasonable to assume that it varies, probably in quasiperiodic fashion. Worse, our control over the timing of our samples is nowhere near as nice as we like to pretend. Ask a geologist if his samples really are separated by thousand-year intervals and he will smile and have a distant look in his eye. In reality, the samples are at uncertain intervals, and the time series is fitted to some sort of time scale, and the geological parameters of interest have been interpolated (usually in a linear fashion).

Pricing series are different. Each of our observations is one sale. There is no doubt what the price is between sales. By convention the price between sales is that price of the last sale. So there is no need to interpolate data.

Let's look at a simple example. Brown-Forman Corp. (BF.A) had some interesting gyrations on July 12, 2011, as detailed on the Nanex strange days page.


We observe 46 trades time-stamped 09:30:01. Notice the stock trades from $68 down to $23 during this second. The trades are not quite evenly spaced, but I have created the time-delay pseudo phase space plot by assuming they are, and plotting the price of one of the trades with this time stamp against the fifth trade prior (with the same time stamp). Hence we have 42 paired trades to put on a scatter plot. By convention we draw a trajectory through them in sequence. Here is what the resulting pseudo phase space plot looks like.


A masterpiece of flash impressionism! Look at the elegant lines. It looks ready to take flight, free at last from human meddling with the stock price! The initial trades are near the upper right, the final trades took place at the left lower tip.

Now we can add some trading density to the graph. We know the location of each of the paired trades. We choose select the volume--either that of the original trade or that of the lagged trade--it doesn't matter which, but be consistent! I have chosen the lagged volume and contoured using various bin sizes. In these graphs, the bins are 2x2 squares, centred in the midpoint of the four squares.


The above plot used fairly large bins. Each bin has a $20 trading range. I had to use such large bins because there weren't very many trades. The contours are at 10% intervals, meaning that all bins (2x2 boxes) centred within the first shaded contour contain at least 10% of all trades during the one second interval represented in the plot. Most trades occur in the $60-$70 range. The trading density thins out at the lower price intervals.

Here is the same plot with smaller bins.


Smaller binning gives a better image of what's going on. Here we see the greatest trading density was actually in the $50 range. There are five disjoint basins (six disjoint areas, maybe). Other than that I don't know how to interpret this. I'm not sure whether there is any point in trying to tease out any more information from it.

Let us look at trades for ASIA on July 14, 2011.


The stock began trading near $16 and within 1 s had retreated to $14.

Trading density plot.


Here I've used an absolute trading density (i.e. number of shares traded). The most shares traded in one bin was in excess of 50,000 (labelled on diagram). Instead of contouring, I shaded the bins in accordance with the legend. The labelled dot is the first state at 9:30:01.

This exercise is really about displaying the data in a different form in the hopes that we can make some kind of interpretation of it. It is always possible that no interpretation is possible. This has made me dizzy. I am posting these (and will post a few more shortly) in the hopes that someone sees something of note.

Or perhaps this is the correct interpretation.