©2006 All content on site protected by copyright
Comparators and the Markets, from Victor Niederhoffer
It is amazing how often the way something works in one area of life is similar to the way something else works in a different area. We often find ourselves thinking that the computer works exactly like the brain, or that the techniques used to win board games are similar to those that are appropriate for winning in markets. Music is one of the fields where the techniques and procedures often seem directly transferable to another field like art or games. Perhaps this is because it is a universal language of its own, and as such is subject to the same general physical and biological regularities as other 'languages.' The similarities between different fields are often so great that I find myself working in one field, then I find that just by changing the nouns, or substituting a market for a physical device such as a machine or magnet or resistor, the meaning is entirely transferable.
Perhaps this is due to the general applicability of physical principles, like the conservation or gravitation laws, or perhaps the similarities occur because of the common principles of life contained in Hoagland's The Way Life Works, which can never be repeated too often.
I have felt for a long time that everything that happens in the world of electronics specifically, how the components and all the circuits work, is an exact analogy to how the markets works. I am going to focus on just one aspect of this today which is the uses of comparators based on op-amps. I am going to use Michael Merchant's chapter on op-amp applications from the book Exploring Electronics, a highly recommended non-mathematical text for trouble shooting in the field, filled with diagrams and simple examples. As a second source, Try here.
I will focus on applications of the op-amp that deal mainly with comparators and skip some of the more involved applications that relate to filters, oscillators ,summers, integrators and differentiators. An op amp is a integrated circuit consisting of a differential amplifier with two inputs ,and a following output. The inverting input sends out a voltage completely opposite in phase to the input, (turns positive to negative, or negative to positive). Depending on whether the net sum of the voltage at the source is positive or negative, the output is magnified about 100,000 times up to the total voltage supplied by the power supplies -- usually 16 volts. a good diagrammatic description of it can be found here.
The whole idea of an op-amp is based on negative feedback. The output gets connected back with a wire to the inverting input thru a component like a resistor , a capacitor , or a diode, in order to stabilize the output and reduce the gain from 100,000 to a moderate level. Amazing things can happen with negative feedback in electronics or the markets.
Let us start by looking at the most basic application of an op-amp ,one that does not involve feedback: the comparator. The idea here is to compare the level of the input to a certain specified value, and then take action based on whether it is above or below that value. The procedure is to establish that basic level on the inverting input and then let the positive input vary above and below the basic level to detect the threshold. Such a circuit is often used in real life to sense temperature or wind, light, sound or pressure. Actions are then taken to control a device such as a motor or machine. Indeed, in the my home, such a procedure is used to automatically open and shut a toilet cover.
In the market, such a circuit would be used first to compare the moves in price to zero, or perhaps to the previous high or low. When the signal moves to above the level, action is take to buy or sell.
The next set of applications involves a Schmitt Trigger. The idea here is to let the input swing to two certain levels, called the upper and lower threshold, which trigger a new reference level in the op-amp, which then takes action only when the input goes above or below the new reference level by a certain amount. This is an example of hysteresis, a delay between changed action. The idea here is to reduce the frequency of false detections in the signal due to noise or randomness.
Such a situation arises in markets often. The prices moves near a high or low. But action must be delayed to see if it is a true move, or whether it is caused by merely running or stops, an ephemeral factor relating to news, or perhaps just some random buying or selling by a big player (where the market moves completely out of bounds to accommodate and give bad fills to such a player.)
The next set of comparators is based on bounded comparators, i.e. window comparators, where the configuration is set up to detect whether the signal is within a window -- between the upper threshold and the lower threshold. Such a configuration requires feedback in the circuit through diodes. The idea here is to see if the input is within a normal range.
The market situation here is, for example, whether to continue a buy and hold strategy. Such would depend on the stability of another signal that you were watching, say the moves in interest rates or foreign exchange. Or perhaps you have a position in a stock, and you wish to measure its strength relative to the market, triggering investigation or action when it goes outside of the window. All quality control actions where no-action is taken as long as the output is within control bands would seem to be of this nature.
The next set of op-amp applications seeks to find the peak or minimum voltage of the input. Such a circuit usually requires two components , a diode and a capacitor in a negative feedback configuration. and allows for constantly changing levels of the high and low. The usual application would be to see if you are nearing the breakdown level of the input or output you are controlling. Is the noise too loud, or the pressure being applied to the output above the breaking strength of the material?
Applications where the market is constantly monitored require more effort in markets also. When you are going to buy or sell would often be effected by whether the highs or lows keep going in the same direction. or whether a previous level has been broken by the current high or low. Indeed, the entire basis of pivot or swing trading would seem to be subsumed by peak detectors.
Other applications of op-amps relate to the creation of oscillators where an output is created that stays within a cyclical pattern, as long as the input signal is within certain bands. That would lead to the whole subject of cyclical moves in the markets, how individual cumulative changes in the input should be amplified, what frequency of individual time intervals would be considered, and the levels from peak to low that would be allowed to happen?
Another set of op-amp applications is based on the instrumentation amplified, which is used to detect signals that are very attenuated or subjected to noise. This is used to detect and amplify the true signal and eliminate the random component. Such configurations are a bit more involved in electronics, often requiring three or more op-amps before actions would be taken.
The market applications would involve more complicated procedures such as to consider the moves in markets that are not based on ephemeral factors such as economic announcements, or hyping by brokerages. Or perhaps the idea would be to eliminate all moves in an average that are caused by a individual component that goes above or beyond a peak level of 10% or so? The applications here are move involved and sophisticated, limited only by one's imagination, and as in the case of the instrumentation amplifier, require the monitoring of several different inputs.
The extent of op-amp applications is endless. Indeed, many programs have been developed to show the output that can be developed if various components of varying magnitudes, are connected to the input and output. A random simulation of what might happen by starting with some of the usual electronic components such as resistors, inductors, capacitors, diodes, transistors, switches, lasers, etc. might be of interest to the electronics engineer. In turn, the study of the uses of op-amp circuits that have been used by engineers in practice and that cover almost all digital and analogue configuration would be inspiring and fruitful to the market engineer.
These are just preliminary thoughts, but the subject seemed rich enough to put up in order to gain feedback both positive and negative, so that our knowledge can be improved upon.
Jeff Sasmor comments:
The history of op-amps stretches back to the time of vacuum tubes and analog computers. Today's digital computers use the binary number system to represent quantized, discrete-time values; analog computers used voltages and current to represent continuous voltage and time along with math operations (hence 'operational') like addition, subtraction, integration, etc. When I first started in electronics (around the time when Fred Flintstone was still listening to his avian record-player) op-amps were just transitioning from modules a few square inches in size (containing discrete components such as transistors and resistors 'potted' in epoxy) to inexpensive integrated circuits like the infamous uA741 from Fairchild Semi-conductor. It was cheap in price and lousy in performance. Audio ciruits created with 741's were disdained by audio folks as Pieces of $%*&.
It is no stretch for any googler to find interesting and informative articles on analog computers or op-amps.
One informative statement that I found was:
The similarity between linear mechanical components, such as springs and dashpots, and electrical components, such as capacitors, inductors, and resistors is striking in terms of mathematics, or even as it were direct mapping as in simulation. They can be modeled using equations that are of in essence the same form. Other methods include direct observation without the aid of mathematical operations. For example, water pressure can be simulated by voltage and water flow in terms of gallons per minute can be simulated by amperes. [read more]
I agree with what the Chair has said regarding similarities between electrical circuits and markets; I recall this subject has come up before. In June '06 there was a thread about Hysteresis - part of my comment is appended to the end of this post.
One of the interesting differences between op-amps was a parameter called slew-rate. It is the speed at which an op-amp circuit can move from one voltage level to another. Audio designers (such as myself at one point) usually went for the higher slew rate op-amps (when we could convince my boss Richard at Eventide Clockworks to spend the extra pennies) due to their reduction in distortion -- they could follow the high-frequency waveforms with greater accuracy.
I have been playing around with the notion of price-change slew rates -- how to quantify them and how to interpret them. I have been writing some Tradestation code in this vein, for example, there seems (to me) to be a big difference in how to react to a slow-moving intraday change in price as opposed to a fast-moving one.
Fast-moving price changes tend to overshoot major price points like whole-dollar amounts (also .5 and .25), anecdotally I see more overshoot (or undershoot) for faster-moving price than slower. It seems to create larger retracements (or bounces). Apologies for hand-waving here ... but the analogy to electrical circuits is very apt and fits my intuition. Fast slew-rate in op-amps allows the output to more closely follow the input but also adds overshoot and undershoot (distortion) effects that the designer needs to control.
I suppose you could somehow model the universe of all markets as a very complicated electrical circuit. Certainly the money flow into and out of various securities can be considered to be an alternating current (of money).
There is probably a relation between futures and their underlying; they could probably be modeled as capacitors and inductors. Futures as capacitors because the current (money) leads the voltage (price) in phase (time) and stocks (commodities, etc) as inductors because the price (voltage) leads the current (money) in phase. That may sound weird, just think about it a bit.
The reactance of the overall market is thence a complex function; actually, a time-varying complex function (even worse). Push/pull a lot of current (money) in/out of it and the voltage (price) reacts accordingly. I think that this applies to an individual component of the overall market, like the stock market. Overshoot and undershoot from step functions in price (gaps) help a lot of people make money every day.
Jim Sogi mentions:
Speaking of amplifiers, an electric guitar sounds best through vacuum tube amplifiers. One of the best amps is a 1972 Fender Pro Reverb which is known as a "vintage amp" based on technology that was popular during the 2nd World War. In fact it is hard to get vacuum tubes now except in places like Russia, China and Slovakia where they must still use them for other purposes as well as playing rock and roll music. Another great amp is a new version of the old amps.
Tube amps are an endless topic of discussion among guitarists seeking the perfect tone. What goes on in the amps is not well understood and has a degree of mysticism involved. It is not well understood what is going on inside the vacuum tubes as they glow and hum with an eerie glow as power surges through the ether. Some time in the early 1970s CBS bought out Fender and in an attempt to improve the circuits made modifications which made them sound worse. Now the older pre-modification amps are prized for their tone and amps are routinely returned to the older specs before the "improvements" . I sent my 34 year old amp to Kendrick in Texas who completely rebuilt my amp to the old specs and now its sounds better than ever.
The tone of the amp when playing a guitar is based on the fact that the amps have a clean sound, a distortion/overdrive mode, and a feedback mode. The clean sound is the country sound, Chet Atkins. Distortion over drive is used by Blues guitarists like BB King, Stevie Ray Vaughn to give a warmer tone. Feedback is the sounds of Jimi Hendrix. This article has a good discussion and some quantitative specs on the balance of inputs and tone which might apply well to market input and volatility and tone. The excerpt below discusses the effect of increasing supply on the market dynamics. The vintage tube amps had a balance of dampening and power transformers dual stage amplification that allowed versatile tone, clean sounds, overdrive and feedback all in one amp.
As applied to markets in line with Chair's idea, the Fed model is a power supply idea basically. Other sources of power input might be the bond market, money supply, foreign buying, internal buying, insider buying, payrolls, buybacks, productivity gains, crude price increases, real estate increases, interest declines. The dampening provided by resistors are the market mechanisms and rules, and the market makers themselves. When the resistance is overcome by input a feedback loop generates.
Markets have tones. The clean tone is the average daily range with partial oscillations within the day. The overdrive distortion tone are the days with expanding intraday ranges or swing within the day that are as great as the daily range and rougher sine wave oscillations comparable to those of distorted guitar sounds. Feedback days are the days like last week where the tone outputting circled back to the input and buying began more buying driving the market up into new highs. From a quantitative view point, the market tone set early in the day seems to set the rhythm and tone for the day and the market player seem to play along like a band in a jam session.
Feed back in guitars, when controlled can sound good, but for vocal microphones it is bad. Often the acoustics of the room affect feedback loops and you only hear feedback in certain frequencies, usually the higher frequencies. The same seems to be true in the markets. The acoustics of the market tend to encourage feedback at the high price ranges. A noticeable number of the large traders seek confirmation and momentum, and pile in on new highs in strength. While these are descriptive, prediction is difficult, but as with guitar playing after hours and weeks and years of practice these ephemeral conditions can be harnessed through feel to create good tones and music. There are some digital signal processing algorithms that have been applied to markets in various ways and may provide a good basis for testing.
Kashi Vishwanath comments:
Victor mentions "...the same general ...regularities" between seemingly disparate fields. I couldn't resist bringing up Christopher Alexander's wonderful A Pattern Language and Danny Hillis's The Pattern on the Stone. The former is about universal architecture principles followed (at some level of the (un)conscious) by people of disparate cultures around the world and over the eons. The latter is on principles of software and computer engineering by one that has been at the cutting edge of that field. Written well after the former and obviously very influenced by it, Danny comments with fluency and erudition on how patterns and themes in software engineering are alike to those mentioned in Chris Alexander's treatises. Fascinating reads, both.
Gary Rogan adds:
One of the most interesting things about how op-amps are used is that a powerful, yet extremely variable component is converted by relatively simple means into a much less powerful, but much more precise one. Op-amps by their very nature have very high amplification, but the absolute magnitude of it is not well controlled: for a particular type it could vary from, say, 20,000 to 70,000 (and I am not even going to get into their "frequency response" problems). However, if you surround them by two resistors which are easy to make precise, but are obviously not "powerful" in any meaningful sense, you can get a circuit that amplifies by a relatively small factor, like 10, with a degree of precision limited pretty much only by the precision of those resistors, thus .2% is fairly easily achievable given .1% resistors, and with a frequency response so high and relatively more predictable that you often do not have to worry about it. There has got to be a general lesson about taming powerful forces in there.
Interestingly, the triumph of digital technologies over analog techniques (as in digital computers replacing analog ones that used to use op amps) is more of the same. We give up even more of the raw capabilities of the underlying circuits to switch fast to have them switch precisely and between only two levels, 0 and 1.
What is the unifying theme? Predictability. It's worth a very high price.
On another note, the non-intuitive idea that I should magnify my response and gain precision by adding dampening is a key feature of the nervous system. Our brains are full of inhibitory feed-back circuits, and cases of parallel inhibitory circuits to stimulatory ones.
The retina, for example, performs a huge amount of edge-detection by itself before the information even enters the brain. The photo receptors are stimulatory, and synapse on several inter-neurons, one type of which are horizontal cells, which are inhibitory, passing an inhibitory signal to regions nearby. These inter-neuron layers propagate forward to the final output of the retina, the retinal ganglion cell. The response of a cell is a classic center-surround field. where light in the center of a cell's receptive field stimulates the cell, and light off-center inhibits it. If you record from these cells, and throw the stimulus response patterns across the retina up on a screen, you see gross representations of the edges of the image.
Parkinson's in the motor system is a classic case of the inhibitory system being impaired, and throwing off precision.
The implications for trading systems are clear. One can sharpen one's responses to a trading stimulus by looking for ways you should inhibit the response, perhaps using orthogonal information, or looking for cases of negative correlation. I've long thought that that would be a great way to hone a trading system. We spend so much time looking for ways things are correlated with each other, but perhaps we can build a more precise system by adding in non-correlated or negatively correlated information. I'm sure there are very smart people, probably on this list, who are already doing this and are telling me to keep it down.