File
contrarian_trading_strategy.m
Name
contrarian_trading_strategy
Synopsis
contrarian_trading_strategy - calculates the cumulative return of the contrarian trading strategy.
Introduction
Khandani and Lo (2011) present a simple mean-reversion strategy originally proposed by Lo and MacKinlay (1990a) to proxy for market making (i.e. liquidity provisioning) profits. This high-frequency mean-reversion strategy is based on buying losers and selling winners over lagged m-minute returns, where m is varied from 5 to 60 minutes. Specifically, a long and a short portfolio are formed at time t by looking at the returns of all stocks in the sample over the previous m minutes. The stocks are sorted into performance deciles, and the strategy is to form a portfolio that is long those stocks in the lowest return-decile over this previous m-minute interval, and short those stocks in the highest return-decile over the previous m-minute interval. This dollar neutral portfolio is then held for q minutes, i.e., until time t + q, after which the portfolio formation process is repeated by forming deciles over the returns over the previous m minutes, i.e., the interval from time t + q -m to t+q, and then holding these new positions for q minutes, i.e. until time t+2q, and so on.
License
=============================================================================
Copyright 2011, Dimitrios Bisias, Andrew W. Lo, and Stavros Valavanis
COPYRIGHT STATUS: This work was funded in whole or in part by the Office of
Financial Research under U.S. Government contract TOSOFR-11-C-0001, and is,
therefore, subject to the following license: The Government is granted for
itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
worldwide license to reproduce, prepare derivative works,
distribute copies to the public, perform and display the work.
All other rights are reserved by the copyright owner.
THIS SOFTWARE IS PROVIDED "AS IS". YOU ARE USING THIS SOFTWARE AT YOUR OWN RISK. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS, OR THE UNITED STATES GOVERNMENT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================
Inputs
Outputs
Code
% Run warning message
warning('OFRwp0001:UntestedCode', ...
['This version of the source code is very preliminary, ' ...
'and has not been thoroughly tested. Users should not rely on ' ...
'these calculations.']);
num_periods = size(input_returns,1);
num_securities = size(input_returns,2);
ret = 1;
for period = 1:num_periods
% Market Portfolio
Rm = 1/num_securities*ones(num_securities,1)'*input_returns(period,:)';
% Strategy
unnormalized_weights = - 1/num_securities*(input_returns(period,:) - Rm);
size_p = sum(abs(unnormalized_weights))/2;
% Divide by the amount of money to support the position
normalized_weights = unnormalized_weights/size_p;
realized_return = normalized_weights*realized_returns(period,:)';
ret = ret*(1+realized_return);
end
Examples
NOTE: Numbers used in the examples are arbitrary valid values.
They do not necessarily represent a realistic or plausible scenario.:
input_returns = ...
[-.00, .02,-.15;
.02,-.01, .06;
-.17, .28,-.10;
.02,-.07, .20;];
realized_returns = ...
[ .02,-.14, .17;
-.04,-.04,-.26;
.7, -.02, .02;
.41, .87, .65;];
ret = contrarian_trading_strategy(input_returns, realized_returns);
References