I'm getting around to accepting that I have to lead this conversation. We've spoken in the past in several languages, but R has always been the best algorithm-to-human interface. I started out by picking the market.
"So White Bumblebee, do you want to talk about gold or silver?"
No reply. I felt a little cheap with that taunt so I started again.
"White Bumblebee, let's talk about the gold market, and let's use the GLD gold etf as a point of reference for our little chat."
Still no reply, but I could see an almost imperceptible smile.
I didn't really say "... let's talk about the gold market ...". I said the following:
GLD$fast <- BBands(( GLD[,4] ), n=10, sd=0.5)
GLD$slow <- BBands(( GLD[,4] ), n=30, sd=0.5)
GLD <- na.locf(GLD, na.rm=TRUE)
position <- ifelse (GLD$mavg > GLD$up.1, 1,
ifelse(GLD$mavg < GLD$dn.1, -1, NA))
position <- na.locf(position, na.rm=TRUE)
Here, we continue our conversation. And start building a meaningful relationship.
Me: White Bumblebee, how often have you been long versus short the yellow metal in the last few years?
main="How often have you been long
vs short in the last few years?",
Me: What does your daily distribution of returns look like?:
returns <- ROC(Cl(GLD))*positionWhite Bumblebee:
hist(returns, main="What do your daily returns look like?", col="darkslategray2")
Me: Ahem, without look-ahead bias, please?
returns <- Lag(ROC(Cl(GLD)))*positionWhite Bumblebee:
hist(returns, main="Ahem, without Look-Ahead Bias?", col="darkslategray")
Me: Got anything more intuitive?:
returns <- na.locf(returns, na.rm=TRUE)
vioplot(returns, names="Got anything more intuitive?", col="blue")
Me: Where do you see gold closing tomorrow?:
paste("What is the closing price for gold tomorrow?")White Bumblebee:
trick_question <- Cl(GLD[NROW(GLD)+1, ])
Error in `[.xts`(GLD, NROW(GLD) + 1, ) : subscript out of bounds
That last one was a trick question. I couldn't resist. Good thing for me that White Bumblebee knows how to take a joke.