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 stock charting patterns. Show all posts
Showing posts with label stock charting patterns. Show all posts

Thursday, December 23, 2010

Reconstructed phase space portraits and charting

It's been awhile since we last checked in on Detour Gold Corp. (disclosure: long).

Over the past seven months, we have seen some nice price action, with a major rise in the early summer.

The two-d reconstructed phase portrait using the time-delay method with a lag of three days (as last time).


In our last installment on this stock the price was rising more or less monotonically. Now we see that what happened was a distinctive shift from one range (at lower left) to a higher price area, where the price has been bouncing around for awhile.

Looking at the two LSAs above, one represents a price range in the $21-25 range, and the second is $27-33. Should it fall out of this range, we would presume it could fall back into the other.

We can see a connection between the price chart and the reconstructed phase space portrait. It is clear that what we call confinement to a Lyapunov-stable area (and use as an indicator of at least temporary stability) . . .


 . . . may be perceived by the chartists as "trading within a range".


(Those diagonal lines aren't intended to be there--they magically appeared during the conversion of the above chart from excel to corel to jpg). 

If we look at the higher of the two Lyapunov-stable areas (LSA30), we see that different parts of it are occupied at different times.

Detail of LSA30 by month.

In particular, the regions of phase space centered at about $30 and at about $31.50 are visited at least three times, and several of those visits are characterized by small loops in the phase space portrait, suggesting quasi-stability. On the price chart above, those regions correspond with what chartists would call support and resistance. 

The phase space portraits of complex systems are often characterized by areas of high probability density, which are sometimes (if they have the correct characteristics) called attractors, but may more commonly be referred to as Lyapunov-stable areas (LSA). An LSA is an area in phase space where the state of the system tends to remain assuming there are no dramatic changes in the dynamics of the system. We would normally interpret such an area as evidence for a metastable state in that region of phase space.

If the state space of the system normally occupies an area below the range of values represented within the LSA, then the upper and outer limit of values will appear (on a one-dimensional chart) to be resistance--and chartists frequently describe such phenomena as the price "bouncing" off resistance.

If the state space of the system is occupying the region above the LSA, the chartists will term the lower boundary of the LSA to be "support".

If support is broken, it means the system has left the LSA, and is moving towards another one, presumably at a lower price. The chartist will say that support has failed, and will look back along the chart for the next region of support, which will have been the lowest value of the next lower LSA. If the price has broken down through an all-time low, then there is no telling how low the price will go.

If resistance is broken, the price may move towards the next higher LSA if one is present. If so, the highest value within the LSA will be seen by the chartist as "the next area of resistance". If the price has broken to a new all time high, then we are probably all in the dark.

Saturday, September 25, 2010

Decline of variability when approaching bifurcation point: an alternative view of charting

One of the significant problems facing climate scientists is how to predict when the system is about to undergo a major change in organization. This point is important because a precise prediction of what is going to happen in response to continued alteration of the atmosphere is unlikely. What we may be able to do is look for signals of an impending global reorganization in the hopes that we will recognize same before the change suddenly occurs.

The basis of this discussion is that the climate system acts to resist external forcings, but if the forcing is strong enough, the system then evolves very rapidly towards some new equilibrium. We may or may not be able to predict what the new equilibrium will be.

It is generally viewed that a change in climate equilibrium would be bad for us as our entire system of global agriculture is geared towards our present equilibrium, which has lasted for about ten thousand years (which, come to think of it, is about as long as we have been practicing agriculture). We haven't put much effort into planning for agriculture in a new equilibrium state.

Once again, understanding the past is the key to predicting the future.

A number of papers have been presented recently, in which the authors have looked at climate signals prior to major climate shifts in the paleoclimate record. And they have noticed that prior to a major change in climatic regime, the short-term variability declines dramatically.



Carbonate content of marine sediments during a "climate tipping" event from greenhouse conditions to icehouse conditions ca. 34 million years ago. From Thompson and Sieber (in press). The lower figure tracks the rise of an autoregressive parameter--essentially an inverse measurement of variability.

The reason for this decline in variability is unclear, however it appears in both models and in observed time series. Given the detailed observations made of present-day climate, it is theoretically possible to anticipate when a sudden climate change is about to occur.

There are counter-arguments, however. Climate measurements are normally easier to make than ecological measurements.

What does this mean for the stock market?

Some well-known charting patterns show the same behaviour; most notably the triangle pattern.


This does seem to be at odds with some conclusions I've drawn earlier. I may have to reconsider.

Consider it evidence that dynamic systems are hard.






Reference

Thompson, J. M. T. and Sieber, J., in press. Predicting climate tipping as a noisy bifurcation: A review. International Journal of Bifurcation and Chaos.

Saturday, August 14, 2010

How life imitates the stock market, part 3

This is the third part of a series about applying analytical methods developed for dynamic systems (like climate) to the stock market.

In our last installment, we were looking at the recent price history of the stock of a company called Nautilus Minerals Inc. and I presented a phase space portrait in two dimensions of the price action over the last four months (note that phase space and state space are often used interchangeably).


2-dimensional phase space portrait of the share price of Nautilus Minerals Inc. from April to August 2010. Look at those rabbit ears! That's what you get from a singular spike in the data. It would be worse in three dimensions. There would be a third spike coming right out of the screen.

The plot above begins in April (the curve starts at the little tail sticking out beside the "April" label above. It actually remains in the grey area (a Lyapunov-stable area, or LSA) near the middle of the plot through most of April making small straight side-to-side and up-and-down motions with a magnitude of about 10 p.

At the end of April, the price state drops out of the upper LSA and meanders its way through phase space towards the lower LSA, in the 100 p range, which is reached in late-May. The price state remains within this lower LSA until about mid-June, then abruptly rises, and by the beginning of July, it appears to be headed back to the upper LSA.

Then comes the sudden price spike. The price state veers up, down, then sharply right, and back left, veers around the upper LSA before plunging into it at the end of July and it has remained until the end of the analysis, which ended early in August.

The price spike seems to have simply resulted in a short-term (one month) detour around the higher price state areas of phase space, but probably did not have any effect on the ultimate destination. Of course, for those who were unfortunate enough to buy at the top of the spike, well . . . sorry about that.

It is extremely rare to see the rabbit-ear formation in these charts, in natural functions. I have seen it only once in some marine core data. Spikes like that are rare in nature, which is hard--so far as we know  ;) -- to manipulate.

What actually is interesting is the drop from the upper LSA to the lower LSA and the subsequent return. What happened in that interval? Was there really a change in the perceived value of the company between April and June (and then again between June and August)? Was this a seasonal junior gold fluctuation?

Let's compare NUS against HUI. It isn't entirely a fair comparison, as NUS is not in commercial production. But we may be able to use HUI to get an idea of the mentality of the gold stock market. It might be better to use gold, or possibly BMO's new junior ETF, but I have numbers for HUI.



HUI chart for six months prior to the writing of this blog entry. There's no link through because I don't want the chart to update. An updated chart is available here.





The reconstructed phase space portrait for the HUI index is presented below. The graph isn't perfect, because I digitized the plot from the above graph, but I believe it will prove to be a reasonable construct.

The HUI reconstructed phase portrait from February until early August looks a little complicated. I have coloured different segments of the curve in different colours so it is a little easier to interpret.

There are two obvious areas of concentration--the area in phase space bounded by about 440 and 460 on both axes, and the area bounded by about 400 and 420 on both axes. Both of these might be considered to be LSAs. There may be a third above 480 on both axes but would need to see more time spent there first.

The system occupies the lower-priced LSA in the early part of the graph, and moves up to the higher-priced LSA at the end of April and remains there except for a few excursions to still higher prices in mid-May and late June.

So where Nautilus showed a steady decline through May, HUI was confined to the higher-priced LSA. When NUS began to rise in late June, this was in tandem with a similar rise in HUI. The spike in NUS was unique to itself.

The behaviour of NUS in May and June may be related to company news. In May, NUS announced that it had demobilized one drilling vessel and was seeking bids on another. Shareholders may have interpreted that this would be some time before there were to be any new results, leading to a drop in share price. The announcement in mid June that a drilling contract was signed suggested that activity would be renewed, which led to the rise in price towards the higher LSA.

One other note about phase space portraits, which I have not previously emphasized. There is no mathematical magic. The phase space is just a different presentation of the data. What appears as a cluster of scribbles in a LSA appears as a discontinuous series of price fluctuations in the original data series--what analysts might call a resistance level (which later becomes support after the price rises through it). Compare the higher-priced LSA in the HUI phase space to the original HUI plot. There are a lot fluctuations between 440 and 460, and these are manifested as that tangle of curves in the area between 440 and 460 in phase space. Later on we will see how the dynamics of a complex system manifests itself in similar areas of "resistance" and "support" even in natural time series.

Wednesday, August 11, 2010

How Life Imitates the Stock Market, part 2

I am modifying much of this discussion from a paper which is currently under consideration for publication.

In the last installment we saw that certain complex systems are characterized by multiple modes of operation. Assuming that our system can be defined as a continuous system of differential equations, then it will evolve deterministically from each uniquely defined initial point to a unique sequence of successor states, implying that two states which lie on different trajectories will remain so—hence, no line crossings occur [Hirsh and Smale, 1974].

Any two different trajectories may evolve toward successor states which are arbitrarily close to one another. Thus they may converge toward a single state which does not change in time. This unchanging state is called an attractor, and the behavior is described as asymptotic stability, as the system tends to evolve asymptotically towards some immovable point. Alternatively, they may not converge onto a particular point, but the successor states from any state within a small region of phase space may stay within a small (but possibly larger) region of phase space. Such behavior is described as Lyapunov stability.

The conditions by which asymptotic stability occurs are extremely specific, and it is difficult on the basis of field observations of the climate system or of the stock market to be certain that our observed system demonstrates such behaviour.

A qualitative approach to interpreting dynamic systems includes describing the phase space in terms of the type, order, and number of attractors (or areas of stability) that are traced out as the system evolves through time. The ice volume phase space portrait of last time is an example of a system with a number of disjoint Lyapunov-stable areas (LSA), each separated in phase space by a separatrix. At any given time, the state of the system occupies only one such LSA, so that their number therefore constitutes the total number of alternative long-term behaviors, or equilibrium states, of the system.

Since an LSA is likely to be smaller than the total allowable range of states, the system tends to become boxed into an LSA unless it is subjected to external forcing. When the state approaches a separatrix, small perturbations can trigger a change to a nearby state, which can result in chaotic changes in the evolution of the system [Parker and Chua, 1989]. Thus very complex behavior can arise in multistable systems.


Probability density plot of reconstructed phase space portrait of the ice volume system compiled from the past 750 thousand years (filled solids) superimposed on the phase space plot of the last 120 thousand years (dashed curve). Regions of high probability (darker) represent LSAs and result from multiple visits to the same region of phase space, or by a drop the rate of evolution of the system. From Gipp (2001).

The typical approach is to label the LSAs and characterize the system as a series of steps from one LSA to another. If the LSAs in the figure are labelled (from lower left to upper right) A2, A3, A4, and A5, then the curve above might be characterized as evolving from A2 to A4 to A5, and is currently heading in the general direction of A2 once again.

The evolution from one LSA to another would not occur except in the presence of external forcing, which successively drives the system across a separatrix after which it evolves quickly towards some other LSA. Now let us consider application of this approach to the stock market.

Over long periods of time, a stock will typically trade within a range. Provided there is to be no change in the fortunes of the company, we would normally expect that small perturbations in the price will be countered. In this way, the stock price exhibits Lyapunov or even asymptotic stability. The market has a "perception" of the value of the stock, and any deviation from that value is arbitraged away. Arbitrageurs will therefore act as the negative feedback cycles that we infer for a complex system.




Reconstructed phase space portrait (price vs. lagged price) showing the trajectory traced out by one stock near a Lyapunov-stable area (LSA). Small arrows show the evolution of the system through time.











Nevertheless, the external forcing (information in the form of money) may be sufficient to perturb the stock price over a separatrix at which point it suddenly accelerates toward some new area of phase space. We would probably say that the stock has become a "momentum play", dominated by the momentum players who continue to push the stock rapidly in whatever direction it happens to be moving.


Price chart for the stock in the above phase space. The momentum players have carried it out of a trading range. How high can it go?





All momentum plays eventually come to an end, and if there have actually been no changes in the fortunes of the company, the reasonable expectation is for the price of the stock to return to its previous trading range. But there is no guarantee that it will do so by the most direct path.




Possible scenarios by which stock price may return back to a trading range after breaking out and momentum later fails. In scenario 1 the stock falls back to the LSA. In scenario 2 the stock goes on an excursion through phase space before returning to the trading range. In this example we are assuming that there has been no change in the perceived value of the stock.
We see two possible scenarios after the breakout. Infinite variety is possible, especially in terms of the excursion through phase space. For an example of a wild one, let's look at one stock. Should I name it? In the interests of full disclosure, the stock in question is Nautilus Minerals Inc. (NUS-V), which was possibly the object of a recent price manipulation. (Kudos also to IKN for this story). I have no position in Nautilus, but am on management of a company that might be perceived as a competitor (but isn't really).


Nautilus Minerals Inc. share price for the past four months in pence (sorry about that!)

We see a general downward trend until that rather singular spike corresponding to the punch line of an interesting promotion. Let's look at the two dimensional reconstructed phase space portrait.


Two dimensional phase space portrait of the NUS-V stock price since April. Lag is four trading days. There is a lot of dynamical information going on here, which I will go through in part 3 of this post, but note the two highlighted areas which may represent areas of Lyapunov stability, and that prior to the unusual spike of early July, the price trajectory appeared to be returning to the LSA that the price state held in April. DYODD.




References

Gipp, M. R., 2001. Interpretation of climate dynamics from phase space portraits: Is the climate system strange or just different? Paleoceanography, 16: 335-351.

Hirsh, M. W. and S. Smale, 1974. Differential Equations, Dynamical Systems and Linear Algebra, Academic, San Diego, Calif., 1974.

Parker, T. S., and L. O. Chua, 1989.  Practical Numerical Algorithms for Chaotic Systems, Springer-Verlag, New York.

Sunday, August 1, 2010

Information flow in price selection, part 2: stock charting and insider trading

In our last installment, we looked at creating higher dimensional phase space diagrams from a single time series. This technique is useful for inferring the dynamics of complex systems from individual time series. In the phase space, the system at each instant of time is represented by a single point in a 2- or higher-dimensional graph. A sequence of points describes the evolution of the system through time. Traditionally we draw a smooth curve through the sequential points, which is described as the trajectory of the system.

Today I would like to look at reconstructing the phase space of some idealized stock chart patterns.

Let's look at a simple one: the symmetrical triangle. I have digitized an hypothetical stock price series in excel and plotted the series. I made the limbs of the formation approximately linear, but rounded the edges, as the reconstructed phase space plot will look better if the limbs aren't perfectly linear.







Wedge pattern in a hypothetical stock. Breakout is circled.








The figure above represents a wedge--though not a falling one. Like all time series, the data are one-dimensional. We can use excel to create a 2-dimensional phase space portrait by lagging the price data by a time that is roughly half the time taken to move from a short-term low to a short-term high (this may seem vague but it is because I have not presented a time scale on the above graph).



Two-dimensional phase space portrait of the above stock price. The two dimensions are the price, and the lagged price. The flow of the system is in the direction of the arrow. As time advances, the system follows the trajectory around first the outer loop, then the smaller inner loop, and after the breakout, towards the upper right corner of the graph.



In the first part of this essay, we looked at a simple chaotic function to see the relationship between the one-dimensional and two dimensional projections. The Lorenz equations give us a function that exhibits simple chaotic behaviour, which is believed to be characteristic of many natural systems. We saw that complicated looking butterfly function. Now let's look at a smaller portion of it--say 501 points (the ones I have selected are points 100-600) from the excel file generated last time.


Lorenz calculations showing x-values only from point 100 (at left) to 600. Looks a little familiar. . .





The above does look rather suspiciously like the wedge pattern in the stock price shown above. Except for one thing--time is flowing from left to right. So the wedge is actually running backwards when compared to the stock price pattern.






The 2-D reconstructed phase space portrait from the above graph, using a lag of 12 points. The abscissa is price (higher to the right), and the ordinate is lagged price (higher towards the top). At first glance, this looks a little familiar. We see what appears to be the same flow starting from the larger loop, spiralling inwards until Pow! Moonshot!








We wish all investing was this easy. But there is something wrong. Unfortunately, this trajectory starts at the upper right and moves to the region of low prices at the bottom left. Not such a good investment after all!

The characteristic feature of stock price charts is the apparent time reversal--the dynamics of stock prices flows through time backwards in comparison to those of natural systems. The dynamics of the natural system is driven by the flow of energy, with consequences following from causes. We see a rapid evolution towards a new area of phase space, and subsequent fluctuations represent instabilities which grow until the system rapidly shoots over to a new region of phase space.

So how do we explain the reversal in time observed in the stock chart patterns?

As my background is science, you will forgive me if I insist that the natural systems are going the "right" way through time and the economic systems are moving backwards.

Stock prices we normally consider to be driven by greed and fear. But what does this really mean? They are driven by flows of money, which represents information in the economic system (it is not the only information in the system). That the dynamics of the stock prices evolve through time in the opposite direction relative to natural systems suggests that players with foreknowledge of some forthcoming announcement (what we call "insider" information) are making good use of their information.

In the absence of potential profit, that "insider" information would not flow out into the market, but rather the market would learn the information at the time that some announcement is made by the company in question. The profit margin actually causes the information to flow out into the market more rapidly than it would flow otherwise. Furthermore, the very existence of such an opportunity argues against the efficient-market hypothesis.

In conclusion, it appears that stock charting gives us some limited forecasting ability in stock prices because trading on insider information is endemic in the markets.

Saturday, July 31, 2010

Information flow in price selection, part 1

There is an article in the Guardian recently about how humanity should prepare for planetary-scale disasters. The authors offered some suggestions for deciding on the best way for dealing with a disaster, both of which involved setting up panels of experts (government-appointed). The proposals were: 1) setting up a government Office of Risk and Catastrophe; 2) setting up a panel of scientists and experts who would study the problem and advise governments and/or industry the best way to solve it; or 3) setting up two panels of scientists, each of which was to take a contrary position and argue it out--presumably the argument would allow us to see all sides of the problem and thus come up with the best solution.

The one problem that afflicts all of these proposals is the role of government in the funding and in defining the philosophical approach that these panels will take. It appears to be implicit that all of these bodies will be appointed by and accountable to some government, most likely at the national level. The past history of similar panels suggests that politics will play some role in the solutions.

 Just as Noam Chomsky and Edward S. Herman explain in Manufacturing Consent: The Political Economy of the Mass Media, any body dependent on government sources for information (or in this case, for funding) will find itself squeezed if it keeps making recommendations that are at odds with current government policy. Furthermore, any of the above solutions can be used to frame the debate by presenting a limited range of options. Even in the third option, it is likely that only two possible courses of action will be proposed, when in fact it may be useful to debate a wide range of possible actions.

Is there a better way? One method might be a futures market similar to the Pentagon's ill-fated Policy Analysis Market. Although there was popular revulsion to this particular application, the concept of a prediction market is a sound method of allowing information to flow from innovators to the general market.

There are those who would say that a prediction market works on a kind of "hive mind" principle. To me it sounds like superstition. History shows that mobs are not smarter than individuals. I prefer to think that prediction markets work because information is not evenly distributed, however that the profit motive is an efficient means to spread it around (which may foreshadow what I will say below about the efficient-market hypothesis).

As an aside, I once asked an introductory-level statistics class to consider the following problem: you are one of 500 passengers about to board a plane with 500 seats. Each passenger has a boarding card with an assigned seat. As the first passenger boards the plane, he discovers he has lost his boarding card, so he chooses a seat at random and sits in it. All subsequent passengers attempt to take their seats, but if one finds her seat occupied, she will choose an empty seat at random. If you are the last passenger to board the plane, what is the probability that you will be able to sit in your assigned seat (answer below). None of the students in the class had any idea of how to approach this (probably my fault!) so I conducted an experiment. I had everyone guess, tallied up the answers and took the average, which turned out to be surprisingly close to the correct answer.  So maybe all of us are smarter than just one of us. (Admittedly, the result was helped by the two exceptional know-nothings who each guessed a probability higher than 1).

What is the basis of my assertion that some participants in, say, the stock market have more information than others? One is the long history of investigations into allegations of insider trading. The other is that an analysis of market dynamics shows that stock price movements have the distinctive fingerprints of this flow of information all over them.

A common problem faced by scientists studying natural systems is that the systems are complex: frequently they are dynamic, driven, and dissipative (meaning that they move, are influenced by energy or matter inputs, and some energy is lost through friction or its equivalent). Such a system may be described by any number of differential equations, and modified by any number of time-varying inputs and boundary conditions. Additionally, the system may have many different outputs, only some of which (commonly only one of which) we actually observe. Naturally we don't know any of the actual equations, nor do we know what the inputs are, nor do we know if the particular observations we have made actually reflect what is happening within the system. Such is the life of a geologist, for instance. Despite these difficulties, we are full of optimism that somehow we can infer the dynamics of the system using our observations, and there are even well-defined mathematical approaches to this general problem.

There are many places to track down the information in the following discussion, but a good place to start is
Analysis of Observed Chaotic Data by H.D.I. Abarbanel (referred hereafter as Abarbanel, 1996). Ergodic theory suggests that dynamic information about the entire system is contained within any time-varying output of the system, so we don't need to worry about whether the particular observations we have chosen to make are important or not--everything we are looking for (simplistically speaking) is in there somewhere. But how do we reveal what may possibly be a multi-dimensional structure when we have a single time series (i.e., one dimensional data)?

One approach is to construct a phase space in multiple dimensions from our single time series. To give credit where credit is due, this concept was first discussed in a classic paper by Packard et al. (1980). The simplest approach is to reconstruct the phase space by plotting the time series against a lagged copy of itself. I will carry out a simple demonstration below.

Using the equations for the famous Lorenz "butterfly"--I will perform this work in Excel to show how easily this can be done, although it can be done better in a proper mathematical plotting package (especially one with 3-D rendering).

We will use the following equations:

xn+1=xn+0.005*10*(yn-xn)
yn+1=yn+0.005*(xn*(28-zn)-yn)
zn+1=zn+0.005*(xn*yn-8/3*zn)
Initial coordinates were (1, 0.5, 0). So in this case, I was using 0.005 as a "time-step". Your mileage may vary. You may use a different value, but then you will have either a more or a less dense looking graph than the one depicted below (which demonstrates x vs y over 4000 values). 




Lorenz "butterfly" curve rendered in Excel (as a scatterplot) based on x vs y over 4000 points using the equations and initial condition stipulated above.








If I were studying the above system, it is possible that the only observations I might have were the x column, which would look like this:









Sequential plot of the first 4000 x-values from the equations and boundary conditions listed above.

They don't look much alike. The first graph is a two-dimensional projection of a three-dimensional object. The graph above is really one-dimensional, and at first glance it does not seem possible to reconstruct the first graph from the second. But if we plot our x-values against a lagged copy (i.e. plot xn vs xn+12), we get:



Reconstructed two-dimensional phase space obtained by the time-delay method, rendered in Excel.










The trick above is to take the data in the x-column, and copy the values (not the formulae) into the next column, starting in the 13th row. You will then have 3988 points defined in two dimensions, which can be plotted on a scatter plot. You may be wondering why I chose the particular lag (why not xn vs xn+100?)--for now consider it to have been an arbitrary decision. There is an information theoretic prescription for deciding on the optimum lag, just as there is a prescription for choosing the correct embedding dimension (I have chosen to use two dimensions because of the limitations of excel, but it would be better to use three).

We see that the reconstructed phase space in two dimensions is topologically very similar to the two-dimensional projection of the actual system. Next time we'll start using this tool to analyze stock charting techniques.

---------

Update - June 19 - did I really forget the answer? Probability of you sitting in your proper seat is 0.5. The easiest way to consider this is to realize that of all the possible random seats that could be selected by the passenger with the missing boarding card, it is only whether he selects his properly assigned seat or yours that matters (as far as our problem is concerned). If he chooses his own seat, you will get to sit in yours; if he chooses yours, then obviously you won't. Any other choice simply defers the critical choice to a later passenger, who will have a smaller selection of seats from which to choose, but will again only have the two meaningful choices.