Yes, I did. The code is in the 4th post, there in all it's glory.
It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
library(ggplot2)
library(gridExtra)
####plot functions
####plot strategy based results
strategy.plot.func <- function(r, bets, max, p){
m <- 1 / (1 - 1 / r)
n <- round(-log (bets * p + 1)/log(1 - p))
init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
rg <- bets + 1
while(round(sum(rg)/10,digits =1) != round(bets/10,digits=1)) {
if(bets*p < 3){stop("increase number of bets or change to higher payout game"); break}
rg <- rgeom(bets*p, p) + 1}
cost.func <- function(x){sum(init/(1-p)^(0:rg[x]))}
win.func <- function(x){init/(1-p)^rg[x] * r}
cost <- sapply(1:(length(rg)), cost.func)
win <- sapply(1:(length(rg)), win.func)
x <- cbind(seq(1,length(cost)*2,2),cost*-1)
y <- cbind(seq(2,length(win)*2,2),win)
z <- rbind(x,y)
z <- z[order(z[,1]),]
a <- cbind(seq(1,length(rg)*2,2),rg-1)
b <- cbind(seq(2,length(rg)*2,2),1)
c <- rbind(a,b)
c <- c[order(c[,1]),]
plot.df <- data.frame(bets = cumsum(c[,2]), btc = cumsum(z[,2]))
plot <- ggplot(plot.df) + geom_line(aes(bets, btc)) +
opts(title=paste(bets,"bets, max loss =",max,"btc, p =", p*65536,"/ 65536"))
return(plot)
}
####plot naive martingale results
naive.plot.func <- function(r, bets, p){
m <- 2
init <- 1
rg <- bets + 1
while(round(sum(rg)/10,digits =1) != round(bets/10,digits=1)) {
if(bets*p < 3){stop("increase number of bets or change to higher payout game"); break}
rg <- rgeom(bets*p, p) + 1}
cost.func <- function(x){sum(init/(1-p)^(0:rg[x]))}
win.func <- function(x){init/(1-p)^rg[x] * r}
cost <- sapply(1:(length(rg)), cost.func)
win <- sapply(1:(length(rg)), win.func)
x <- cbind(seq(1,length(cost)*2,2),cost*-1)
y <- cbind(seq(2,length(win)*2,2),win)
z <- rbind(x,y)
z <- z[order(z[,1]),]
a <- cbind(seq(1,length(rg)*2,2),rg-1)
b <- cbind(seq(2,length(rg)*2,2),1)
c <- rbind(a,b)
c <- c[order(c[,1]),]
plot.df <- data.frame(bets = cumsum(c[,2]), btc = cumsum(z[,2]))
plot <- ggplot(plot.df) + geom_line(aes(bets, btc)) +
opts(title=paste("Naive martingale,",bets,"bets, p =", p*65536,"/ 65536"))
return(plot)
}
#change these variables to suit
r <- 8
p <- 8000/65536
bets <- 100
max <- 1
png(paste("sd", rounds,max,p*65536,".png", sep='.'), height = 500*2, width = 500*16/9)
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrow = 4, ncol = 2,
heights = unit(c(1,1), "null"),
default.units = "null", respect = FALSE,
just="centre")))
vplayout <- function(x, y)
viewport(layout.pos.row = x, layout.pos.col = y)
print(strategy.plot.func(r, bets, max, p), vp = vplayout(1,1))
print(strategy.plot.func(r, bets, max, p), vp = vplayout(2,1))
print(strategy.plot.func(r, bets, max, p), vp = vplayout(3,1))
print(strategy.plot.func(r, bets, max, p), vp = vplayout(4,1))
print(naive.plot.func(r, bets, p), vp = vplayout(1,2))
print(naive.plot.func(r, bets, p), vp = vplayout(2,2))
print(naive.plot.func(r, bets, p), vp = vplayout(3,2))
print(naive.plot.func(r, bets, p), vp = vplayout(4,2))
dev.off()
#reports strategy parameters
strategy.func <- function(r, bets, max, p){
m <- 1 / (1 - 1 / r)
n <- round(-log (bets * p + 1)/log(1 - p))
init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
pc.loss <- (1 - (init*m^n*r - 0.0005)/(init*m^n*r)) * 100
return(noquote(paste("m =",m," | init =",init," | percentage loss to fees =",pc.loss,"%.")))
}
#reports order of martingale betting
allbets.func <- function(r, bets, max, p){
m <- 1 / (1 - 1 / r)
n <- round(-log (bets * p + 1)/log(1 - p))
init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
mat <- matrix(c(1:bets,round(init*m^(1:bets), 6)),bets,2)
colnames(mat)<-c("bet number", "bet amount" )
return(mat)
}
#change these variables to suit
r <- 8
p <- 8000/65536
bets <- 100
max <- 1
strategy.func(r, bets, max, p)
allbets.func(r, bets, max, p)
> strategy.func(r, bets, max, p)
[1] m = 1.14285714285714 | init = 0.10186450536666 | percentage loss to fees = 0.027536291774799 %.
>
> allbets.func(r, bets, max, p)
bet number bet amount
[1,] 1 0.116417
[2,] 2 0.133048
[3,] 3 0.152054
[4,] 4 0.173776
[5,] 5 0.198602
[6,] 6 0.226973
[7,] 7 0.259398
[8,] 8 0.296455
[9,] 9 0.338805
[10,] 10 0.387206