for those of you in need to heat up their room and without the time to search for the next profitable coin, past weekend i've put together a bash script that switches between 3 multipools (trademybit, yaamp and nicehash) and their algos in function of advertised profitability (by pool's api itself).
the script is self explanatory, just adjust hashing rates, pool's user/pass/apikey where applicable and miner's paths.
warning: don't expect huge profits since profitability on multipools is very low lately...
#!/bin/bash
# depends on sys-devel/bc, app-misc/jq, app-misc/screen and sys-process/schedtool
# after starting this script you can execute "screen -r miner" to see miner's output
# algo ids (the first 8 must match with nicehash's api: https://nicehash.com/?p=api)
scrypt=0
sha256=1
nscrypt=2
x11=3
x13=4
keccak=5
x15=6
nist5=7
neoscrypt=8
x14=9
quark=10
fresh=11
# in the following array keys must match with above ids
declare -a ALGO=('scrypt' 'sha256' 'nscrypt' 'x11' 'x13' 'keccak' 'x15' 'nist5' 'neoscrypt' 'x14' 'quark' 'fresh')
# hashing rates in Mhs (GTX-660-oem)
# not minable, leave it at 0!
RATE[$sha256]=0
# cudaminer (https://github.com/cbuchner1/CudaMiner)
RATE[$scrypt]=.21
RATE[$nscrypt]=.105
# ccminer (https://github.com/tpruvot/ccminer or https://github.com/djm34/ccminer)
RATE[$x11]=1.857
RATE[$x13]=1.386
RATE[$x15]=1.217
RATE[$keccak]=66
RATE[$nist5]=5.1
RATE[$x14]=1.3
RATE[$quark]=2.8
RATE[$fresh]=2.5
# neo-gpuminer (https://github.com/vehre/neo-gpuminer)
RATE[$neoscrypt]=.017
# https://pool.trademybit.com/start
TMB_URL=stratum+tcp://am01.eu.trademybit.com
TMB_PASS=Your_pass
TMB_USER=Your_user
TMB_FEE=3
TMB_API_KEY=Your_TMB_API_key
TMB_PORT[$scrypt]=3330
TMB_PORT[$nscrypt]=2220
TMB_PORT[$x11]=4440
TMB_PORT[$x13]=5550
TMB_PORT[$x15]=6660
TMB_PORT[$nist5]=7770
# https://www.nicehash.com/index.jsp?p=gstarted#seller
NH_URL=stratum+tcp://stratum.nicehash.com
NH_USER=Your_BTC_address
NH_PASS=x
NH_FEE=2
NH_PORT[$scrypt]=3333
NH_PORT[$nscrypt]=3335
NH_PORT[$x11]=3336
NH_PORT[$x13]=3337
NH_PORT[$x15]=3339
NH_PORT[$nist5]=3340
NH_PORT[$keccak]=3338
# http://yaamp.com/ (ports numbers and fees are delivered by the api)
YA_URL=stratum+tcp://yaamp.com
YA_USER=Your_BTC_address
YA_PASS=xx
# hysteresis: by which (absolute) increment of price a pool/algo switch should be triggered
HYST=.1
# miner's paths
CCMINER=~/bitcoin/ccminer-tpruvot/ccminer
CUDAMINER=~/bitcoin/CudaMiner/cudaminer
NEOGPUMINER=~/bitcoin/neo-gpuminer/cgminer
# start miner screen session if it doesn't exist
if [ "$(screen -ls|grep miner)" == "" ]
then
screen -dmS miner
fi
MPRICE=0
while [ 1 ]
do
# start execution timer
START=$(date +%s)
# initialize profitability list
LIST=''
# fetch data from pool's api
NH=$(wget -qO - 'https://www.nicehash.com/api?method=stats.global.current')
YA=$(wget -qO - 'http://yaamp.com/api/status')
TMB=$(wget -qO - "https://pool.trademybit.com/api/bestalgo?key=$TMB_API_KEY")
# process yaamp's data
for i in $(echo "$YA"|jq '.[].name'|tr -d '"')
do
eval x='$'$i
price=$(echo "$YA"|jq ".[\"$i\"].estimate_current"|awk '{ print sprintf("%.9f", $1); }')
YA_FEE=$(echo "$YA"|jq ".[\"$i\"].fees")
price=$(echo "$price * 1000 * ${RATE[$x]}"|bc)
price=$(echo "$price - ($price * $YA_FEE / 100)"|bc)
# if port is 0 means this channel is inactive...
YA_PORT[$x]=$(echo "$YA"|jq ".[\"$i\"].port")
if [ ${YA_PORT[$x]} -gt 0 ]
then
LIST+="$price\t${ALGO[$x]}\tYA\n"
fi
done
# process nicehash's data
for i in $(echo "$NH"|jq '.result.stats[].algo')
do
# ignore algo id 100 (multi-algo id)
if [ $i -eq 100 ]
then
continue
fi
price=$(echo "$NH"|jq ".result.stats[$i].price"|tr -d '"')
price=$(echo "$price * ${RATE[$i]}"|bc)
price=$(echo "$price - ($price * $NH_FEE / 100)"|bc)
LIST+="$price\t${ALGO[$i]}\tNH\n"
done
# process trademybit's data
c=0;
for i in $(echo "$TMB"|jq '.[].algo')
do
eval x='$'$i
price=$(echo "$TMB"| jq ".[$c].actual"|tr -d '"')
price=$(echo "$price * 1000 * ${RATE[$x]}"|bc)
price=$(echo "$price - ($price * $TMB_FEE / 100)"|bc)
LIST+="$price\t${ALGO[$x]}\tTMB\n"
((c++))
done
# most profitable channel candidate extraction
LIST=$(echo -e $LIST|sort -rn)
MPRICE_CAND=$(echo "$LIST"|head -n1|cut -f1)
MALGO_CAND=$(echo "$LIST"|head -n1|cut -f2)
MPOOL_CAND=$(echo "$LIST"|head -n1|cut -f3)
# actual channel price extraction
if [ $(echo "$MPRICE > 0"|bc) -eq 1 ]
then
MPRICE=$(echo "$LIST"|grep -P "[0-9.]+\t$MALGO\t$MPOOL"|cut -f1)
if [ -z $MPRICE ]
then
MPRICE=0
fi
fi
# choose candidate pool/algo if candidate's price difference is greater than HYST
if [ $(echo "$MPRICE_CAND > ($MPRICE + $HYST)"|bc) -eq 1 ]
then
MPRICE=$MPRICE_CAND
MPOOL=$MPOOL_CAND
MALGO=$MALGO_CAND
fi
# set miner parameters
eval URL='$'${MPOOL}_URL
eval PORT='$'{${MPOOL}_PORT[$MALGO]}
eval USER='$'${MPOOL}_USER
eval PASS='$'${MPOOL}_PASS
PMALGO="-a $MALGO"
# choose miner and correctly set algo parameter for nscrypt
if [ "$MALGO" == "scrypt" -o "$MALGO" == "nscrypt" ]
then
MINER=$CUDAMINER
if [ "$MALGO" == "nscrypt" ]
then
PMALGO='-a scrypt:2048'
fi
elif [ "$MALGO" == "neoscrypt" ]
then
MINER=$NEOGPUMINER
PMALGO="--neoscrypt -I 13"
else
MINER=$CCMINER
fi
# start miner if not running or restart it with new parameters if they've changed
if [ -z "$(pgrep $(basename $CCMINER))" -a -z "$(pgrep $(basename $CUDAMINER))" -a -z "$(pgrep $(basename $NEOGPUMINER))" ]
then
screen -S miner -X screen schedtool -B -e $MINER $PMALGO -o $URL:$PORT -u $USER -p $PASS
elif [ -z "$(pgrep -f -- "$PMALGO.*$USER")" ]
then
killall -q $(basename $CCMINER) $(basename $CUDAMINER) $(basename $NEOGPUMINER)
screen -S miner -X screen schedtool -B -e $MINER $PMALGO -o $URL:$PORT -u $USER -p $PASS
echo "========================================================"
fi
# current date/tme and status output
DATE=$(date +"%x %R")
echo "$DATE - Mining $MALGO@$MPOOL@$MPRICE (best $MALGO_CAND@$MPOOL_CAND@$MPRICE_CAND)"
# stop execution timer and sleep until next minute
END=$(date +%s)
TOOK=$((END-START))
SLEEP=$((60-TOOK))
if [ $SLEEP -lt 0 ]
then
SLEEP=0
fi
sleep $SLEEP
done