Published in

Fintech with Todd

Modeling Markets as Stream Networks

The interaction of water and land as runoff moves towards larger river systems creates a dendritic drainage pattern. Full of branches of streams connecting into points, this system emulates the vascular system of leaves.

A stream network is a stream with all the streams that flow into it. These are made up of a set of links joined so that at each junction only two links flow together to form a third. Each time moving from smaller to larger movements of water and ultimately concluding into the sea.

These stream networks can be represented as a series of line segments joined together at nodes to form a branched network that eventually ends in a single outlet. Mathematically this is referred to as plain binary trees. It is plain because it is in two-dimensions. It is binary since each node can only have a maximum of two nodes.

The diagram above represents a stream network. Here there are links that combine two sources into one. As it moves downward, the size of the body becomes larger.

Markets as Stream Networks

Coming across stream networks in a mathematical modeling book, it became clear that these structures share many properties with markets. To illustrate, below is a diagram of a similar binary tree. However, this one represents a market instead of a stream network. Each node is marked with an A or B for ask and bid. In addition, the flow is bi-directional.

The links represent a transaction from a buyer and seller. As the transaction occurs, it sends a signal to the market — either long or short. Obviously, stream networks can only run in one direction. However, market information runs in two direction. An input from and an output back to the nodes.

Present stream network models utilize moving average constructions. Incidentally, technical analysis of markets use the same thing. This is the arithmetic mean over n time for an asset’s price or movement of water. However, it treats all occurrences the same regardless of where they fall in the series.

Information

An alternative to moving averages is exponential moving averages. These give more weight to recent activity than to past occurrences. The idea being that the most recent information is more important that the past. It is calculated as follows:

One of the unanswered questions of modeling markets is the importance of information. Does past activity have less impact on the current market than recent activity? Intuitively, one may say that recent prices are more relevant than past ones. If this is true, why even bother with prices after the selected relevant time?

The point is that markets only show the past. How much of that past is relevant to the future is something that is very difficult to answer. For example, each stream network has a drainage density. That is the amount of total water it is capable of transporting before being overloaded and flooding occurs.

Drainage density is ultimately a measure of flood risk. Based on the expected rainfall, a stream networks draining density can be a good indicator of future catastrophe for the region. It is calculated as:

drainage density = total stream length / total drainage area

To relate this to markets, it can be thought of as a markets volume density. That is the total volume a market can handle before it becomes overloaded with volatility— calculated as follows:

volume density = total number of assets / total number of trades

Before determining what a good volume density would be for a given asset, one would have to use the past activity of that asset as an benchmark. For some, a large volume of trades may have little impact on current prices. In contrast, it may only take a relatively few number of trades to move the market.

Tipping Point

Using the tree diagram of a market from earlier with the notion of each buy and sell sending a signal to the market, it could be possible to calculate potential moments for trend creation and reversal.

Each trade made contributes to that market in some way. A large number of sells will reduce the overall market price while a greater number of buys will increase the market price. The question is, what number of buys does it take for a market to trend upward? In contrast, how many sells need to occur until the market trends downward?

Looking at the past trends, one may be able to realize the tipping point. Learning once a specific number of transaction occurs in the same direction, a trend is highly probability. It is similar to learning how much rainfall must occur before a stream network is overwhelmed and floods.

Using the volume density calculation, one can determine how much trading needs to occur for it to effect the market in question. Afterwards, taking the majority of direction to determine if the trend is long or short.

Conclusion

This was an exercise in applying a model from one discipline to finance. Perhaps it will help to spot trends. However, it is not likely to fully cover the complexities involved — just another example of how finance loves to borrow models from other disciplines in a desperate attempt to find a working model.

Trying to take scientific models made for nature and bending them to measure human emotion will probably never work. People have proven themselves irrational. This is why there has been big changes from the classical view of economics — with a focus more on human behavior than physics. After all, no one has illustrated a true understanding of how markets work. As an engineer, that means no one understands the problem.

Is it hopeless? Should everyone stop trying to solve a problem no one fully understands? No, while the old methods failed, modeling markets just needs a new approach. Will this come in the form of psychology or is it a problem that only machine learning will solve? The answer remains to be seen.