I modified this to show the number of bitcoins that could have been bought had bitfloor been immediately buying coins at another exchange as fees were received (assuming price was the same at both exchanges).
#Get Data from bitcoincharts
bitfloor<-read.table("http://bitcoincharts.com/t/trades.csv?symbol=bitfloorUSD&start=0",
sep=","
)
##Convert Times from Unix
times=matrix(nrow=nrow(bitfloor), ncol=6)
time.string=NULL
for(i in 1:nrow(bitfloor)){
timeStamp<-ISOdatetime(1970,1,1,0,0,0) + bitfloor[i,1]
date<-strsplit(as.character(timeStamp), " ")[[1]][1]
yr<-as.numeric(strsplit(date, "-")[[1]][1])
mo<-as.numeric(strsplit(date, "-")[[1]][2])
day<-as.numeric(strsplit(date, "-")[[1]][3])
ToD<-strsplit(as.character(timeStamp), " ")[[1]][2]
hr<-as.numeric(strsplit(ToD, ":")[[1]][1])
min<-as.numeric(strsplit(ToD, ":")[[1]][2])
sec<-as.numeric(strsplit(ToD, ":")[[1]][2])
times[i,]<-cbind(yr,mo,day,hr,min,sec)
time.string<-rbind(time.string,as.character(timeStamp))
}
bitfloor<-cbind(times,bitfloor)
colnames(bitfloor)<-c("Yr","Mo","Day","Hr","Min","Sec","UnixT","Price","Vol")
##Set First Timestamp bitfloor was open after hack
post.hack.open.time<-as.numeric(head(
bitfloor[which(bitfloor[,1]==2012 & bitfloor[,2]==9 & bitfloor[,3]==21),],
1)[7])
##Divide into pre and post hack data
pre.hack.bitfloor<-bitfloor[which(bitfloor[,7]<post.hack.open.time),]
post.hack.bitfloor<-bitfloor[which(bitfloor[,7]>(post.hack.open.time-1)),]
#Generate cumulative volume and fees
pre.hack.bitfloor<-cbind(pre.hack.bitfloor,
cumsum(pre.hack.bitfloor[,8]*pre.hack.bitfloor[,9]),
cumsum(pre.hack.bitfloor[,8]*pre.hack.bitfloor[,9])*.005
)
colnames(pre.hack.bitfloor)[10:11]<-c("cumUSD.Vol","cumFee")
post.hack.bitfloor<-cbind(post.hack.bitfloor,
cumsum(post.hack.bitfloor[,8]*post.hack.bitfloor[,9]),
cumsum(post.hack.bitfloor[,8]*post.hack.bitfloor[,9])*.003
)
colnames(post.hack.bitfloor)[10:11]<-c("cumUSD.Vol","cumFee")
#
##Set Timestamp of first payout
payback.time.one<-as.numeric(head(
bitfloor[which(bitfloor[,1]==2012 & bitfloor[,2]==12 & bitfloor[,3]==1),],
1)[7])
##Split into pre and post payout
pre.payout.one<-post.hack.bitfloor[which(post.hack.bitfloor[,7]<payback.time.one),]
post.payout.one<-post.hack.bitfloor[which(post.hack.bitfloor[,7]>(payback.time.one-1)),]
#Generate cumulative volume and fee data
pre.payout.one[,10:11]<-cbind(
cumsum(pre.payout.one[,8]*pre.payout.one[,9]),
cumsum(pre.payout.one[,8]*pre.payout.one[,9])*.003
)
post.payout.one[,10:11]<-cbind(
cumsum(post.payout.one[,8]*post.payout.one[,9]),
cumsum(post.payout.one[,8]*post.payout.one[,9])*.003
)
#
##Get months from unix timestamps
month.labels=data.frame()
for(y in 2012:2013){
for(m in 1:12){
unixT<-bitfloor[which(bitfloor[,1]==y & bitfloor[,2]==m),7][1]
month.labels<-rbind(month.labels,cbind(unixT,month.name[m]))
}
}
month.labels<-month.labels[which(!is.na(month.labels[,1])),]
month.labels<-month.labels[2:nrow(month.labels),]
##Misc
est.payed.back<-.017
Total.Value.Stolen<-25000*tail(bitfloor[,8],1)
Total.Value.Payed<-est.payed.back*Total.Value.Stolen
##Make Plots
png("bitfloor.png", height=800, width=1300, pointsize=15)
layout(matrix(c(1,1,1,3,2,2,2,4), 2, 4, byrow = TRUE))
plot(bitfloor[,7],bitfloor[,8], type="n", xaxt="n",
xlab="Time",
ylab="USD/BTC",ylim=c(0,(max(bitfloor[,8])+5)),
main="Bitfloor Price History"
)
axis(1,at=as.numeric(as.matrix(month.labels[,1])),
labels=as.character(month.labels[,2]))
lines(pre.hack.bitfloor[,7],pre.hack.bitfloor[,8], col="Green")
lines(pre.payout.one[,7],pre.payout.one[,8], col="Red")
lines(post.payout.one[,7],post.payout.one[,8], col="Blue")
abline(v=payback.time.one)
plot(pre.hack.bitfloor[,7],pre.hack.bitfloor[,11], xaxt="n",
xlab="Time",
ylab="Cumulative Fees Generated (USD)",
xlim=c(min(bitfloor[,7]),max(bitfloor[,7])),
ylim=c(0,max(pre.hack.bitfloor[,11],pre.payout.one[,11],post.payout.one[,11])),
type="l", lwd=3, col="Green",
main=c("Bitfloor Cumulative Fee Revenue",
"Before Hack Rate= 0.5%, After Hack= 0.3%")
)
axis(1,at=as.numeric(as.matrix(month.labels[,1])),
labels=as.character(month.labels[,2]))
lines(pre.payout.one[,7],pre.payout.one[,11],
type="l", lwd=3, col="Red"
)
lines(post.payout.one[,7],post.payout.one[,11],
type="l", lwd=3, col="Blue"
)
abline(v=payback.time.one)
barplot(c(
Total.Value.Stolen,
Total.Value.Payed
),
ylab="USD", ylim=c(0,1.1*Total.Value.Stolen),
names.arg=c(paste("Value Stolen=", Total.Value.Stolen),
paste("Value Payed=",Total.Value.Payed)),
col=c("Red","Green"),
main=paste("Estimated Payed Back=",100*est.payed.back,"%")
)
barplot(c(
max(pre.payout.one[,11]),
max(post.payout.one[,11])
),
ylim=c(0,1.1*max(c(max(pre.payout.one[,11]),max(post.payout.one[,11])))),
ylab="Fees Generated (USD)",
names.arg=c(paste("Hack to First Payout=", round(max(pre.payout.one[,11]),1)),
paste("Since=",round(max(post.payout.one[,11]),1))),
col=c("Red","Blue"),
main=c("Fees Generated Since Hack",
paste("Constant Buying:",round(sum(0.003*post.payout.one[,9]),1), "BTC"),
paste("Buy Now:",round(max(post.payout.one[,11])/tail(post.payout.one[,8],1),1),"BTC")
)
)
dev.off()