**Quantitative thoughts » EN**, and kindly contributed to R-bloggers)

When dealing with transaction cost analysis, a stock’s volume is assumed to be stable or foreseeable. However, there is different picture, then we are dealing with an illiquid stock.

It is relatively easy to forecast the volume of a liquid stock, because trading volume has high autocorrelation – the volumes at* t* and *t+1* are correlated. For example, let’s take a look at BPN Paribas stock autocorrelation figure:

X axis shows the lag between the days and Y axis shows percentage of the correlation. For BNP Paribas stock we have 60 % correlation between t and t+1 and 30 % between t and t+2.

Now, let’s look what is autocorrelation of an illiquid stock:

The figure above shows, that autocorrelation for this emerging market stock is zero. That means, that we can’t forecast tomorrow’s volume, based on today’s volume.

Imagine, that a portfolio manager has to liquidate 100 000 of illiquid stock where the median of daily volume is 4000 and participation rate has to be maximum 20 %. How many days it will take to liquidate the position?

Because the daily volume of the stock is very volatile, we need more randomness in our forecast. To do that, we can use bootstrap – let’s take the last 250 data-points of the volume and generate 10 000 or 100 000 new time series. Once the have a bunch of new time series, let’s check how many days it would take to liquidate 100 000 stock position in each. Finally, we collect the numbers of the days needed for liquidation and form a new vector. The result is following:

The histogram above shows, that it will take maximum 80 days to liquidate 100 000 of illiquid stock with 95% confidence.

^{?}View Code RSPLUS

#volume - vector of the stock's volume #shareNumber - number of the shares to liquidate #loop - number of the time-series to be created #participationRate - what is going to be participation rate simNumberOfDays<-function(volume,shareNumber,loop=10000,participationRate=0.05) { rez=matrix(nrow=loop) for(i in 1:loop) { x=nasa[sample(NROW(volume))] y=cumsum(x*participationRate) rez[i,]=which(y>shareNumber)[1] } return(rez) } rez=simNumberOfDays(illiquidStock,100000,10000,0.2) |

**leave a comment**for the author, please follow the link and comment on their blog:

**Quantitative thoughts » EN**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...