Quantitative finance collector
C++ Matlab VBA/Excel Java Mathematica R/Splus Net Code Site Other
R/Splus in Finance. Having more to say, please consider to be our guest blogger.
Mar 10
Han, Y.F., and Zhou, G.F. have an interesting working paper on the performance of a trend factor they proposed:
In this paper, we propose a trend factor to capture cross-section stock price trends. In contrast to the popular momentum factor constructed by sorting stocks based on a single criterion of past year performance, we form our trend factor with a cross-section regression approach that makes use of multiple trend indicators containing daily, weekly, monthly and yearly information. We find that the average return on the trend factor is 1.61% per month, more than twice of the momentum factor. The Sharpe ratio is more than twice too. Moreover, during the recent financial crisis, the trend factor earns 1.65% per month while the momentum factor loses 1.33% per month. The trend factor return is robust to a variety of control variables including size, prior month return, book-to-market, idiosyncratic volatility, liquidity, etc., and is greater under greater information uncertainty. In addition, the trend factor explains well the cross-section decile portfolio returns sorted by short-term reversal, momentum, and long-term reversal as well as various price ratios (e.g. E/P), and performs much better than the momentum factor.


The basic idea is to first calculate the month-end price moving average time series of different lags, then regress cross-sectionally monthly returns at date t on all moving average series at date t-1, finally predict monthly returns at date t+1 using the regression estimates and the moving average series at date t. This procedure guarantees we forecast stock returns at t+1 with information set only up to t. We then rank all stocks based on the forecasts into five quintiles, long the quintile with highest forecast returns and short the quintile with lowest, and rebalance once per month. This strategy generates, on average, 1.61% monthly return and 0.29 sharpe ratio using all US stocks, performs especially good during recession, and outperforms several existing factors. Moreover, the good performance of this strategy cannot be explained by firm fundamentals.

I implement this strategy with Chinese stock data, adjust the rebalance frequency to weekly for convenience, and trade in extreme by always long the one stock with the highest forecast return, no short is allowed, stop loss is set at 5%. The result is amazing, it yields an annualized return at 97.15% from March, 2013 to Feb, 2014, with maximum drawdown at 30.01%. The fund curve is as follows (note: I didn't use all Chinese stocks but only 840 stocks in my stock pool with good liquidity, so there is selection bias and please accept the result cautiously...)


Nice shot. It seems to be better than the simple strategy between A-shares and H-shares.
Tags: , ,
Feb 3
A similar article was posted at the sub-personal blog before and I paste it here in case someone is interested.

At the moment there are 84 firms listed at both A (Shanghai and Shenzhen) and H (Hongkong) stock markets, according to the law of one price, the stock prices of these firms should be at similar level. However, there are huge differences, without considering exchange rate (1 RMB = 1.28 HK$), the ratio of the price in A market to the price in H market for a same firm is as low as 52.72% and as high as 617.59% as of 02/03/2014. Is the difference mean reverting? If yes, we would expect the stock traded cheaper in A market to go up, and vice versa. So can we make profit by long the stocks with large differences?

Rigorous statistical method should be undertaken to examine whether the ratio is indeed mean reverting. For simplicity, I construct a trading strategy that each week, I go long at the opening price the stock in A market that has the smallest price ratio  of previous week, hold it one week and sell it at the weekly closing price. Short trading is not allowed for individual investor in A market. Stop loss is set arbitrarily at 5%. Transaction cost is 0.18% per trading.

The results for this simple strategy from 02.2013 to 01.2014 are:
Annualized Return         0.2070
Annualized Std Dev        0.2545
Annualized Sharpe          0.8133
Maximum Drawdown
        From     Trough         To   Depth Length To Trough Recovery
1 2013-09-13 2013-12-13           -0.1275     19        12       NA
2 2013-08-16 2013-08-23 2013-09-06 -0.0566      4         2        2
3 2013-03-22 2013-04-19 2013-05-03 -0.0488      5         3        2
4 2013-07-12 2013-07-12 2013-07-19 -0.0374      2         1        1
5 2013-05-31 2013-05-31 2013-07-05 -0.0229      6         1        5
The fund curve
Open in new window
Lower line is the return for a buy-and-hold strategy of all 84 firms.

Considering the fact that 2013 is a gloomy year for A market and this strategy is long only, the performance is not bad at all. Comments are welcomed
Tags: ,
Jul 23
I have tested several R optimization functions before: nlm, optim(Nelder-Mead), optim(BFGS), optim(SANN), nlminb, optim (L-BFGS-B) for a eight-parameter Vasicek interest rate model, overall I find that for my setting, nlminb is the best and all R functions finish within seconds. For detail please read the old post at R optimization function test



Pat at Portfolio Probe recently had a wonderful test on some heuristic optimization methods, including simulated annealing, traditional genetic algorithm, evolutionary algorithms. By using R packages and functions - Rmalschains, GenSA, genopt, DEoptim, soma, rgenoud, GA, NMOF and SANN method of optim, he finds that the Rmalschains and GenSA packages are standing out. Nice one, original article is at A comparison of some heuristic optimization methods.
Tags: ,
Dec 2
Happy last month of 2011. I will fly to Sydney to present a paper at the 24th Australasian Finance & Banking Conference on next Thursday, so we may not have a review next week. However, feel free to contact me @a_biao for sharing any useful post. This week's review is highly concentrated on R language.

R-code for the algorithm of Ait-Sahalia: the Closed-Form expansion for the transition densities of diffusions by Professor Yacine Aït-Sahalia facilitates the Maximum Likelihood Estimation, the related papers and Matlab package can be downloaded directly at his website at Ait-Sahalia, but in case you are a R user, this is what you need.

R Memory Issue: insights on R memory issue, most of us have met it more or less.

Regression via Gradient Descent in R: detailed simple example demonstrating how to run a regression via Gradient descent in R: principle and codes.

Amelia II: A Program for Missing Data: An excellent R package for multiple imputation of missing data. I had a post introducing its first version at missing data imputation.

The Art of R Programming: A Tour of Statistical Software Design: the book title tells it, you can't miss it as a R user.

R Cheat Sheets: still having trouble remembering the exact commands in R? here is an excellent collection of R cheet sheets.

How to interpret Johansens' test results: simple while detailed examples guiding you through the basic knowledge how to interpret Johansenss test results for cointegration analysis.

Improving Trend-Following Strategies With Counter-Trend Entries: minor adjustments to strategies that can both improve their backtest performance and also reduce the real costs of trading.
Tags: , ,
Jul 7
Examining the determinants of credit default swap (CDS) spreads is a hot topic, CDS spread has displayed siginificant regime switching behaviour since the break of credit crisis, which can be seen from the old graph in the post Credit Default Spread and Historical Volatility
cds spread volatility

There are sound reasons to believe that CDS spreads keep high in the period of turbulence while stay stably low during most of quiet periods. To investigate if there is possible regime switch phenomenon, I run a three year rolling panel regression using CDSs of over 250 reference entities on several widely accepted explanatory variables including: leverage, volatility, treasury yield and the spread of three month Libor and repo rates, where the last variable is used to proxy liquidity risk. The coefficients for each variable is plotted below
cds spread panel regression results
the coefficients of leverage and treasury yields are changing but without clear regime pattern, on the contrary, the volatility, especially the liquidity effects are suggesting there may exist regime switching and the necessity to employ a Markov regime switch model to explain CDS spreads.

PS: a matlab markov regime switching package can be found here; the panel regression is done with the R package PLM at http://cran.r-project.org/web/packages/plm/vignettes/plm.pdf
Tags: ,
Pages: 1/9 First page 1 2 3 4 5 6 7 8 9 Next page Final page [ View by Articles | List ]