Two interesting ideas here: “trading time” price impact of a…
[This article was first published on isomorphismes, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
![](https://i0.wp.com/24.media.tumblr.com/5a4d513e87a97a0823bf82ccaee670fa/tumblr_mvds0gz66R1qc38e9o5_r1_500.png?w=578)
![](https://i2.wp.com/24.media.tumblr.com/c84bf413eed4dc2f43f68215fa3a1c84/tumblr_mvds0gz66R1qc38e9o1_500.png?w=578)
![](https://i1.wp.com/25.media.tumblr.com/8c17d29029d10e976df6579f88ee4ed0/tumblr_mvds0gz66R1qc38e9o2_r1_500.png?w=578)
![](https://i1.wp.com/25.media.tumblr.com/e89f9d4234ce361e46f90cbef8b8c9fc/tumblr_mvds0gz66R1qc38e9o3_r1_500.png?w=578)
![](https://i0.wp.com/25.media.tumblr.com/79b32427c66f4ce94cec3339808d5198/tumblr_mvds0gz66R1qc38e9o4_r1_500.png?w=578)
Two interesting ideas here:
- “trading time”
- price impact of a trade proportional to
exp( √size )
Code follows:
require(quantmod) getSymbols("MER") #Merrill Lynch #Gatheral's model HiLo <- function(symbol) log( Hi(symbol) / Lo(symbol) ) **2 UpDay <- function(symbol) Cl(symbol) > Op(symbol) #munging mer <- merge( MER, UpDay(MER), HiLo(MER) ) mer <- data.frame(mer) names(mer)[7] = "UpDay" names(mer)[8] = "HiLo" mer <- subset(mer, Vo(mer) > 0) #data cleaning #plot layers require(ggplot2) base <- ggplot(data=mer, aes(x=log(MER.Volume), y=HiLo, col=as.factor(UpDay))) points <- geom_point(alpha=.5) #no more I(.5) ! line <- geom_smooth(method='lm', col='red', fill='red') labels <- labs(y="Volatility", x="Volume", colour="Up day?", title="Jim Gatheral's model") #more munging winners <- subset(mer, UpDay>0) losers <- subset(mer, UpDay
(This doesn’t run as is. I think you can fix that by combining the ggplot pieces differently. I just gave the pieces semantic names combing through my history.
To leave a comment for the author, please follow the link and comment on their blog: isomorphismes.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.