R code for transaction cost algorithms