1
$\begingroup$

I'm working on stock price prediction and automatic or semi-automatic control of trading. The price trends of these stocks exhibit recurring patterns that may be exploited. My dataset is currently small, only in the thousands of points. There are no images or very high dimensional inputs at all. The system must select from among the usual trading actions.

  • Buy $n$ shares at the current bid price
  • Hold at the current position
  • Sell $n$ shares at what the current market will bear

I'm not sure if reinforcement learning is the best choice, deep learning is the best choice, something else, or some combination of AI components.

It doesn't seem to me to be a classification problem, with hard to discern features. It seems to be an action-space problem, where the current state is a main input. Because of the recurring patterns, the history that demonstrates the observable patterns is definitely pertinent.

I've tried some code examples, most of which employ some form of artificial nets, but I've been wondering if I even need deep learning for this, having seen the question, When is deep-learning overkill? on this site.

Since I have very limited training data, I'm not sure what AI design makes most sense to develop and test first.

$\endgroup$
2
$\begingroup$

This is an interesting problem, the answer of which is highly coveted for obvious reasons. The production of an answer in this public space is appropriate, provided one believes in a more level distribution of assets across those alive and is comfortable with rewarding technical people for the abilities they developed while others might have been engaging in less technical pursuits. I only ask that those who may successfully employ it consider using at least some of any windfall generated in a philanthropic manner, to benefit the less fortunate.

Here we go.

Abstract Algebra

One of the fundamental principles presented in Morgenstern and von Neumann's Theory of Games and Economic Behavior is the idea that the value of a monetary unit may vary based on actions of those that control the monetary system, but the underlying value itself has abstract algebraic properties favorable to prediction. These properties, the book proposes in early chapters, permit additive modelling.

Explained another way, imagine a pile of paper bills of a particular denomination. The selection of any one of the bills from anywhere in the deque is identical in value to the selector as any other selection of one bill. The selection of which particular bill is also not a factor in the value remaining in the deque after the selection.

This is also true of shares, which is why serial numbers are not a trading parameter at the investor-trade interface.

For more theory behind this, the interested parties can study group theory and rings.

Critique of M&VN

This convenient additive view of value beneath monetary systems has been critiqued. The value of assets, products, and services may be demonstrated to vary with life expectancy and philosophic divergence. While some people fall into an investment mode, others may be divesting.

Fortunately, similar to Isaac Asimov's fictional presentation of psycho-history, the predictive mechanisms that may be developed are, in fact, not fettered by this investment versus divestment mode variance. The volume of trading and number of traders typically hide the variance through cancellations across either side of mean behavior.

Those with considerable assets can exploit this caveat and a large number of other caveats in the additive nature, but most traders cannot.

Patterns in Stock Values

The phrase that may have started a number of investment firms down the path toward the use of machine learning in high speed training, leading to a conspicuous growth in the number of billionaires in the world, is a simple phrase from Darren Aronofsky's Pi, a 1998 movie in black and white. The protagonist, Maximillian Cohen, looks at the scrolling LED version of a ticker tape and says, "I know these numbers," and then begins to verbally state each price just before it appears.

The patterns in stock prices have intrigued those who watch trends since the emergence of the New York Stock Exchange. But they are not cyclic, in spite of the naive belief that they run in cycles. They only appear to run in cycles, just as one might find a pattern they think they understand in a graphic representation of the Mendelbrot Set, but when the renderer of the set zooms in or out, the greater detail or the generality respectively reveal that the understanding was an illusion.

Attempts to use Fourier Analysis as part of a predictive strategy for anything but extremely narrowly timed speculation have been of limited value. The reliability of the prediction of advantageous trading choice, expressed as a probability $P(C)$, dwindles to pure entropy (zero bits of actual predictive information) as the clock time of the prediction increases relative to that of the last time in the complete vector of state historic states $\vec{S}$ used for prediction.

$$\lim_{(t - t_\emptyset) \rightarrow \inf} P(A|\vec{S}) \rightarrow 0$$

In plain terms, the risk of trading based on a predictive model from past price trend increases with the staleness of trend information.

The increase in entropy is likely to be a feature of the prediction of any system as complex as the stock market even as prediction tools mature. It is a consequence of initial input sensitivity combined with measurement inaccuracy and the inevitable unsatisfactory distributed model of decisioning. These constraints may not be inescapable, but they are certainly resistant to brute force attacks, such as adding artificial network layers.

There are tools that can be predictive in ways better than trying to identify a spectrum using Fourier Analysis. But let's first consider a spectrum, which is how music listeners identify the pitch, loudness, timbre, and envelope of notes. Unlike the playing and listening to music, the distribution of pitches in the spectrum from moment to moment are not purely a representation of the spectral distribution in which value fluctuations reside.

The spectral analysis of stock prices reflects artificial bounds. The spectrum is bounded by the market sampling rate and Nyquest's criteria on the high frequency side. It is bound by the accumulation of additive effects that tends price fluctuation toward a Gaussian distribution on the low frequency end of the spectrum.

Three-fold Challenge of Freshness, Accuracy, and Complexity

Some may note that the intention of the question, to control (with or without human moderation) a stock portfolio to maximize profit is a planning problem that appears to have the Markov Property, provided the trader is not wealthy or trading in penny stocks, since the impact of previous trades seems unlikely to have significantly impacted market trends. As we shall see, this appearance may not be objectively true.

Initial input sensitivity is a nearly universal quality of complex systems. In the case of the stock market, the complexity is high. Consider a cursory examination of the magnitude of market complexity, understanding that a single price is affected by neighboring prices in that sector and business and in the major market indicators that people watch. A stock is almost completely isolated in terms of trading actions but inherently tied to all traders and other stocks through an interconnected network of IT pipelines, trading interfaces, news events, and brains, each containing a few billion neurons with complexities much greater than artificial cells.

A popular name for initial input sensitivity is the Buterfly Effect, which, properly explained is this.

Whether a butterfly flaps its wings in Brazil may determine the path of a major storm in Peking a month later.

Sometimes the initial word, "Whether," is not included, which renders the explanation incorrect. It is a statement of the effect of whether or not the perturbation occurs. Once cannot say that the air movement from the wing flap causes the storm but rather the presence of a small perturbation may be grossly amplified over time in a complex system. Or it may not.

Studies of chaotic systems have proven this potential of amplified effect as a characteristic of many if not most complex systems of differential equations with sufficient curvature in their behavioral surface to cause a system phenomena that could most descriptively be called, "Radically increasing bifurcations."

For those seeking greater depth of understanding, the work of Fourier, Nyquist, Cantor; G. Julia and P. Fatou; and Aleksandr Lyapunov may be of interest.

Because of initial input sensitivity, the Markov Property cannot be guaranteed for stock trading, even at low levels of investment. Even though, technically, the Markov Property is not guaranteed, its assumption at low trading levels and in the leveraging of fresh data for short term gains, it may lead to reasonable approximations with sufficient reliability to win at the negative sum game of trading.

Trading as a Below Zero Sum Game

In a zero sum game, those trading with stale information and trying to apply ineffective predictive strategies will, over any longer period lose. Their monetary assets will pass to those with fresher information using effective predictive strategies. With trading fees, the condition is more challenging, because the sum of all interactions is below zero by the sum of the fees.

Gaining Advantage

To gain advantage in any practical way above those who may have already employed machine learning in their trading operations or hired a funds manager that already did, there will have to be some clever application of more advanced principles in a way that drives effectiveness even higher than those already in game play.

These are some key elements.

  • Since the windowing over the price sequence of any LTS (liquid tradable security) to derive a spectrum will produce spectra with no particularly improved predictive power than the price sequence in the time domain, the goal must be to discover the nature of the patterns beyond spectral features.
  • For very short duration investments, spectral features may provide some advantage but perhaps not enough to overcome others using similar predictive strategies.
  • Some stocks are predictors of others in that there is a strong unidirectional or bidirectional causal relationship. For instance, the cost of a barrel of oil impacts the future cost of toys, since plastic is a refinery product. The development of a semantic net with causal relationships modeled and tuned with each epoch of training can produce predictive power that may exceed the market norm. In this context, something like convolution may be advantageous, but not in the frame-horizontal-vertical-pixel-layer sense, since semantic networks have a non-cartesian topology. The edges and vertices in a semantic net of LTSs don't make nice 90 degree angles that lend themselves to trivial applications of loops and arrays.
  • Attractors, another analytical concept from the world of chaos, are an analytical tool that lend themselves to trends in stock groups and possibly individual stocks, however diversification principles of investment also apply well to attractors. The thing to study is auto-correlation in $\mathbb{R}^{(m n)}$, where $m$ is the number of features in the stock statistics for which there is a fresh historical record and $n$ is the number of LTSs in the group. The group is not a trench, with varying risk pooled together to provide a favorable curve of return versus stability. The group is a set of LTSs that correlated positively or negatively and with or without relative temporal shift (delay).
  • Leverage factors outside the exchange. For instance, the result of a close election is a key event that impacts markets. Terrorism is. Experts who may know nothing about where the market is going but sound good can vastly sway trends. Some billionaire somewhere may have rode a wave in a temporary correlation between the price of oranges and the price of gold, floating down the eastern seaboard in a yacht, not having the faintest idea why oranges correlated to gold, but analysis showed too many correlative effects to deny the tie, and they rode it until the model broke.

Project Strategy

It is recommended NOT to test with actual trades. Build a system and create a simulated portfolio. Do not use retirement funds and college funds to test a system pitted against some of the best trading automation in the world funded by a few hundred billionaires. You will end up in Gamblers Anonymous that way. Also understand that, as time passes, the bar will rise, and more people will be trading using predictive systems so that what is a profitable system today may consume all your time and energy and eventually lose everything you gained as other systems gain advantage over yours.

Also remember that asset management, in the final summary, is a zero sum game. Trading gains are inescapably stuck inside the larger game where the pieces are placed back in the box and the box back in the closet. This is true even if you have children or grandchildren. Eventually, chaos has its sway. Our great, great, great, great grandchildren, who probably won't care to know our name, might end up poorer because we were wealthy or wealthier because we were poor. It's the Butterfly Effect again.

There are infinitely more important things than asset accumulation. Ask any honest billionaire with an advanced terminal condition.

Layer Depth?

Yes depth. There is no way to meaningfully model even the most banal aspects of the complexity of markets with a few layers of perceptrons.

Real Time Learning?

Reinforcement, yes, because the Q-learning algorithm class and variants are a powerful tool for re-entrant, real time learning system design. However, be careful to not necessarily assuming the Markov Property. Whether you can use an algorithm, right out of the box, wired directly to inputs from market data with no normalization and prevail in a sub-zero sum game is unlikely.

Innovation will be a requirement to any earned and even short term sustainable success. Always, with the application of these powerful AI components, thoughtfully apply what is known to the design, initialization, and further development of the system into which the component fits.

Another network type worthy of consideration with time series is the LSTM network design. This is where layer depth makes sense, however systems with multiple AI components are really the work horses of the industry today. Very few problems give way easily to the deployment of some code generated from one algorithm specified in one paper and nothing added.

System Topology

There is likely to be multiple pipelines containing information in a system that sustainably provides growth-positive automated or semi-automated portfolio management, even among groupings of LTSs that seem to display patterned and more easily predictable trends.

If one wishes to get a general sense of the complexity of system design that may be required to beat those at the forefront of the investment community, visit a nuclear power plant or disassemble the control system of the jet engine of a passenger jet. Still, someone seems to be getting it right. A suspiciously large number of new billionaires have emerged since 1998 with investing given as the industry in their Forbes entry.

Additional technical information is provided in this answer.

$\endgroup$
1
$\begingroup$

Unclear from your description how RL is useful. RL is a technique that allows your model learn interactive by trial and error. Where is your "trial and error" in your problem?

Stock price prediction sounds more like a regression problem to me. It can be done by DL or many other methods. Probably a shallow neural network would work well for you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.