BASH SCRYPT for ALGO SWITCHING--
This is a rough edit from Skunk's earlier posting. 3 big differences:
1) NiceHash has changed the ID number for some algos, and eliminated x14 and fresh algos.
2) TradeMyBit (TMB) is gone.
3) ALL algos can be mined with just CCminer now. No need for CudaMiner or NeoGpuMiner.
This script is set up to mine at NiceHash and Yaamp. I was getting syntax errors. I execute the script as "sudo ./switch.sh", it runs, it mines, it doesn't switch just ok yet. I hope some other user(s) might want to work the bugs out.
Right now, the script launches cleanly, and reports the best paying algo between NiceHash and Yaamp every minute, and mines! My error was using an abreviation for my home directory. I just corrected it; use the full path from root to your mining directory with "ccminer". I am still looking for bugs...
For what it is worth:
============================= switch.sh ========================================
#!/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 12 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
lyra2re=9
whirlpoolx=10
qubit=11
quark=12
# in the following array keys must match with above ids
declare -a ALGO=('scrypt' 'sha256' 'nscrypt' 'x11' 'x13' 'keccak' 'x15' 'nist5' 'neoscrypt' 'lyra2re' 'whirlpoolx' 'qubit' 'quark')
# hashing rates in Mhs (750ti)
# if not minable, leave it at 0!
RATE[$scrypt]=.28
RATE[$sha256]=0
RATE[$nscrypt]=.105
RATE[$x11]=3.2
RATE[$x13]=2.4
RATE[$keccak]=115
RATE[$x15]=2.11
RATE[$nist5]=8.1
RATE[$neoscrypt]=.180
RATE[$lyra2re]=.076
RATE[$whirlpoolx]=165
RATE[$qubit]=5.6
RATE[$quark]=6.35
#
https://www.nicehash.com/index.jsp?p=gstarted#sellerNH_URL=stratum+tcp://stratum.nicehash.com
NH_USER=BITCOIN-ADDRESS.worker
NH_PASS=x
NH_FEE=2
NH_PORT[$scrypt]=3333
NH_PORT[$sha256]=3334
NH_PORT[$nscrypt]=3335
NH_PORT[$x11]=3336
NH_PORT[$x13]=3337
NH_PORT[$keccak]=3338
NH_PORT[$x15]=3339
NH_PORT[$nist5]=3340
NH_PORT[$neoscrypt]=3341
NH_PORT[$lyra2re]=3342
NH_PORT[$whirlpoolx]=3343
NH_PORT[$qubit]=3344
NH_PORT[$quark]=3345
#
http://yaamp.com/ (ports numbers and fees are delivered by the api)
YA_URL=stratum+tcp://yaamp.com
YA_USER=BITCOIN-ADDRESS
YA_PASS=worker
# hysteresis: by which (absolute) increment of price a pool/algo switch should be triggered
HYST=.1
# miner's paths
CCMINER=/home/yourusername/miningdirectory/ccminer
# 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')
# 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
# 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
# choose miner and correctly set algo parameter for nscrypt
if [ "$MALGO" == "scrypt" -o "$MALGO" == "nscrypt" ]
then
MINER=$CCMINER
if [ "$MALGO" == "nscrypt" ]
then
PMALGO="-a scrypt:2048"
fi
elif [ "$MALGO" == "neoscrypt" ]
then
MINER=$CCMINER
PMALGO="-a neoscrypt -i 15.5"
else
MINER=$CCMINER
fi
# start miner if not running or restart it with new parameters if they've changed
if [ -z "$(pgrep $(basename $CCMINER))" ]
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)
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
==================================END======================================