3.2 Framework Implementation
4.1.1 Portfolio Generation Strategies
There are two fundamentally different ways to generate portfolios, each lending its support to one of the two main paradigms in financial theory. The first hinges on modern portfolio theory and its efficient market hypothesis. The approach ac-cepts the unpredictable stochasticity of markets, and suggests using diversification methods, like mean-variance optimization, to create efficient portfolios. In prac-tice this result in a set of trading systems called efficient frontier traders . The alternative hinges on the behavioral finance paradigm, where an attempt at un-covering market inefficiencies give rise to price prediction traders. These make price movement predictions based on market developments. Both approaches yield
88 Trading System Implementation
Market
Evaluator
Trading System
applied portfolio
data
Portfolio Generator
Rebalancer
suggested portfolio
Figure 4.1: The most basic trader has a portfolio generator that produces portfolios based on market data and a rebalancer that figures out if it is a good idea to use this portfolio.
very different trader designs. A third more exotic type of trading system termed portfolio selection traders also exist. They try to select or combine portfolios generated by several basic portfolio generators, i.e., miniature trading systems.
The following sections go into detail on these main portfolio generation strategies.
Price Prediction Traders
As illustrated in figure 4.2, there are three main architectures used to perform price movement prediction. The simplest one-to-one predictors employ meth-ods that try to predict price movements individually based on only historical price development. The second many-to-one predictors uses methods that try to predict individual price movements using all available market data. The final many-to-many predictors apply the most general methods; these can, in one go, make multiple price predictions based on all available market data. As figure 4.3 illustrates, the more general prediction methods can perform the task of the simpler ones.
One-to-one Architecture. The most basic price predictors apply simple oper-ations on the data it receives. The one-to-one price prediction architecture looks solely on the price development of an asset and tries to predict its next movement.
Admittedly this is a highly trivial ordeal. The traders that employ this architec-ture are mainly technical analysis traders. These are the most basic traders
PP PP PP PD
PP PP PP
PD PD
MD MD MD MD MD MD
Price Predictor one-to-one
price prediction
many-to-one price prediction
many-to-many price prediction
Market
Market Market
prediction
prediction
price
data
prediction
Trader
Trader Trader data
Figure 4.2: There are three main methods for price prediction. The first sends price data (PD) to individual price predictors (PP) that do not use any other information to predict data. The second employs multiple price predictors using all available market data (MD). The final method uses a single pre-dictor that tries to simultaneously predict all price movements given all available market data.
and apply only the most rudimentary filters in an effort to predict future price development. The indicators these use are described in section 2.2. A glaring problem is that these indicators are all lagging, and have no learning.
Many-to-one Architecture. A more ambitious approach is the many-to-one price prediction architecture. It looks at all available data of the market and tries to predict individual price changes. All traders that do this are learning traders, i.e., they use learning nodes capable of making generalizations and find patterns.
This architecture requires many of these learning nodes, one for each asset. The collection of these learning nodes forwards their predictions to a mechanism for
90 Trading System Implementation
many-to-many predictors one-to-one
predictors many-to-one
predictors
architecture problem domains
Figure 4.3: The more general prediction architectures can perform the task of the simpler once.
creating portfolios. An example of a trader using the many-to-one architecture is the SVM trader. It is able to output only two classes, i.e., values, either 0 or 1. It is applied as a price movement indicator.
Many-to-many Architecture. There are few price prediction methods that handle multiple inputs and multiple outputs. In this thesis, only the neural net-work methods are capable of doing this, and actually be able to make use of the inherent properties of considering all data at once. The traders that apply the many-to-many price prediction architecture are able to process any data and output predictions. The most notable explicit example of such a method is the MLPNN. By presenting price development together with the preceding input it is able to make a prediction of which way the market might move.
An important concept to understand about the price predictors is that the many-to-one and many-to-many architectures can use any data as a basis for price pre-diction, not only the price itself.
Converting Price Predictions to Portfolios. Since price predictions can’t be used directly as a portfolio, a conversion process must be performed. Some output a binary vector of 0s and 1s or a decimal in between, either indicating to what degree the price predictor believes the price will move. There are many ways to transform such predictions into true portfolios.
The main method for converting price indicators v to a portfolio w is by normal-izing it. In essence what is done is to convert the price indicator vector v ∈ [0, 1]n into a simplex where the 1Tw = 1 and w ≥ 0. In this context normalization
simply applies the transformation of 4.1.
w = v
1Tv (4.1)
A special case is when 1Tv = 0. This can happen when the price predictor does not believe in any asset. This is solved by setting the portfolio to a fail-safe portfolio. Typically this is the uniform portfolio w = 1/n or the risk-free asset explicitly. Because of rounding errors all trading systems are required to perform normalization at the end to ensure compliance to the portfolio constraints.
Price movement indication is most often within the interval [0, 1] where 0 is a full commitment to the belief in a downward movement and 1 is the opposite belief in an upward movement. However this is not always the case. Sometimes, as with the MACD histogram, it might be a real number oscillating around zero. Often it might be useful to either force the indicator to be in the mentioned interval, e.g., by using a sigmoid function. It can even be useful to force the indicator to be {0, 1} exactly, i.e., force it to be either 0 or 1. A way to do this is by applying a tuneable threshold parameter γ using a indicator function I(p > γ), where p can be any indicator. It can even be beneficial to do this to already conforming indicators that are within the [0, 1] interval. It can make portfolio creation through normalization less variable thus reducing transaction cost.
After normalization many finalization steps might be performed. Insignificant positions might be removed, or even just the top positions kept. More on this in section 4.1.2.
Efficient Frontier Traders
The efficient frontier traders use modern portfolio theory as a foundation. It con-sists of a node that calculates the mean-variance optimal portfolio given expected return and the covariance matrix. These data are created from the historical data.
The length of the history is set by a meta-parameter. As described in 2.2, a target return, variance, or risk aversion is supplied as a parameter.
Finding an efficient portfolio with the minimum transaction lot is a NP-complete problem[99]. To find an efficient portfolio given either a variance, return or risk aversion factor is a convex problem, easily solved by many pre-existing packages.
This system uses ojAlgo[3], an open source java framework for mathematics and optimization; it is especially suited for the financial domain.
92 Trading System Implementation
Portfolio Selection Traders
The final portfolio generation approach applies ideas from prediction with ex-pert advice[40]. The idea is to let different exex-perts make advice, i.e., let portfolio generators make portfolios, and then, to various degrees, listen to one or more of them. The classical interpretation is that the portfolio selector allots a portion of its available investment capital to each expert based on how much it believes in them.
In mathematical terms. Let expert k, of a total of K experts, output the portfolio wk, then a portfolio matrix W, consisting of K column vectors wk ∈ [0, 1]n, can represent all the advice given for a period. The portfolio selector, then allocates commitment, or funds, zk ∈ [0, 1] to each expert k. The collective allotment z = [z1 · · · zK]T, constrained by 1Tz = 1, can thus be applied to the portfolio advice matrix W to yield a trading system output portfolio w ∈ [0, 1]n, as shown in (4.2). In essence, the outputted portfolio is a convex combination of the expert advice. That is, the constraints on z and wk guarantees that portfolio w is in the convex hull of all wk and that it fulfills the portfolio simplex requirements.
w = Wz = w1z1+ · · · + wKzK (4.2) A problem with this approach is that it does not explicitly take into consideration the expert advice portfolio’s internal risk-return characteristics. What might have been a good portfolio due to its inherent traits might be lost when combined.