Post
Topic
Board Service Announcements
Re: [ANN] NiceHash.com - innovative professional cryptocurrency cloud mining service
by
torontominer
on 21/08/2014, 20:16:02 UTC
I made a powershell script to do multi-algo switch between nicehash and wafflepool.
this script is tested in windows 7 ,powershell v2. it will run in the folder where sgminer.exe is .
it will switch between niceshash x11 x13 x15 kecaack nist5 , wafflepool x11
$switchcontrol is 1.1 which means when the highest normalized profit is at least 1.1times of current profit , the switch will be triggered.
$delay is 30 now , it should be 300 which means after 300 seconds , the script will process again for the most profitable algo.
1.conf to 6.conf  each match the conf file for x11 ,x13 ,kecaack , x15, nist5 ,wafflex11

Quote
get-process | where-object {$_.name -like "*sgminer*"} | stop-process;"Program Start @"+ $(get-date) + "Nicehash x11 is loaded by default"  ;$current =3; start-process powershell "cmd.exe /C sgminer.exe --config 1.conf";$current = 3
[decimal]$switchcontrol = 1.1
[int]$delay = 300
do{
$aaa = new-object system.net.webclient
$bbb = $aaa.downloadstring("https://www.nicehash.com/api?method=stats.global.current")
[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") >null
$ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer
$obj = $ser.DeserializeObject($bbb)
$nicehashprofit =@()
for ($i = 0;$i -le 7;$i++){
$nicehashprofit  += $obj.result.stats[$i].price
}
$nicehashbest = @()
$nicehashbest += [decimal]$nicehashprofit[0]*0
$nicehashbest += [decimal]$nicehashprofit[1]*0
$nicehashbest += [decimal]$nicehashprofit[2]*0
$nicehashbest += [decimal]$nicehashprofit[3]*5.5
$nicehashbest += [decimal]$nicehashprofit[4]*4
$nicehashbest += [decimal]$nicehashprofit[5]*500
$nicehashbest += [decimal]$nicehashprofit[6]*3.5
$nicehashbest += [decimal]$nicehashprofit[7]*16
#------------------waffle---------------------
$ccc = new-object system.net.webclient
$ddd = $ccc.downloadstring("http://wafflepool.com/api/stats")
[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") >null
$waf = New-Object System.Web.Script.Serialization.JavaScriptSerializer
$waf1 = $waf.DeserializeObject($ddd)
$waffleprofit7=($waf1."values") | foreach-object {$_."earnings"} | foreach-object {$_."permhs"}
#------------------add waffle x11 to comparasion ---------------------
$nicehashbest += [decimal]$waffleprofit7[14]*5500
$nicehashnormalized = ($nicehashbest | measure -maximum).maximum
#------------------make the switch based on price and variance ---------------------
if($nicehashbest[0] -eq $nicehashnormalized -and $nicehashbest[0] -gt $switchcontrol*$nicehashbest[$current]) {"switch to scrypt,$nicehashnormalized";$current = 0}
elseif($nicehashbest[1] -eq $nicehashnormalized -and $nicehashbest[1] -gt $switchcontrol*$nicehashbest[$current]) {"switch to sha256,$nicehashnormalized";$current = 1}
elseif($nicehashbest[2] -eq $nicehashnormalized -and $nicehashbest[2] -gt $switchcontrol*$nicehashbest[$current]) {"switch to scrypt-n,$nicehashnormalized";$current = 2}
elseif($nicehashbest[3] -eq $nicehashnormalized -and $nicehashbest[3] -gt $switchcontrol*$nicehashbest[$current]) {if ($current -eq 3  -and (get-process | Where-Object {$_.name -eq "sgminer" } ).responding){"remain in X11 @"+$(get-date)} else { get-process | where-object {$_.name -like "*sgminer*"} | stop-process;"Switching to X11 @"+ $(get-date);$current =3; start-process powershell "cmd.exe /C sgminer.exe --config 1.conf";$current = 3}}
elseif($nicehashbest[4] -eq $nicehashnormalized -and $nicehashbest[4] -gt $switchcontrol*$nicehashbest[$current]) {if ($current -eq 4  -and (get-process | Where-Object {$_.name -eq "sgminer" } ).responding){"remain in X13 @"+$(get-date)} else { get-process | where-object {$_.name -like "*sgminer*"} | stop-process;"Switching to X13 @"+ $(get-date);$current =4; start-process powershell "cmd.exe /C sgminer.exe --config 2.conf";$current = 4}}
elseif($nicehashbest[5] -eq $nicehashnormalized -and $nicehashbest[5] -gt $switchcontrol*$nicehashbest[$current]) {if ($current -eq 5  -and (get-process | Where-Object {$_.name -eq "sgminer" } ).responding){"remain in Keccak @"+$(get-date)} else { get-process | where-object {$_.name -like "*sgminer*"} | stop-process;"Switching to Keccak @"+ $(get-date);$current =5; start-process powershell "cmd.exe /C sgminer.exe --config 3.conf";$current = 5}}
elseif($nicehashbest[6] -eq $nicehashnormalized -and $nicehashbest[6] -gt $switchcontrol*$nicehashbest[$current]) {if ($current -eq 6  -and (get-process | Where-Object {$_.name -eq "sgminer" } ).responding){"remain in X15 @"+$(get-date)} else { get-process | where-object {$_.name -like "*sgminer*"} | stop-process;"Switching to X15 @"+ $(get-date);$current =6; start-process powershell "cmd.exe /C sgminer.exe --config 4.conf";$current = 6}}
elseif ($nicehashbest[7] -eq $nicehashnormalized -and $nicehashbest[7] -gt $switchcontrol*$nicehashbest[$current]) {if ($current -eq 7  -and (get-process | Where-Object {$_.name -eq "sgminer" } ).responding){"remain in Nist5 @"+$(get-date)} else { get-process | where-object {$_.name -like "*sgminer*"} | stop-process;"Switching to Nist5 @"+ $(get-date);$current =7; start-process powershell "cmd.exe /C sgminer.exe --config 5.conf";$current = 7}}
elseif($nicehashbest[8] -eq $nicehashnormalized -and $nicehashbest[8] -gt $switchcontrol*$nicehashbest[$current]){if ($current -eq 8  -and (get-process | Where-Object {$_.name -eq "sgminer" } ).responding){"remain in waffle X11 @"+$(get-date)} else { get-process | where-object {$_.name -like "*sgminer*"} | stop-process;"Switching to waffle X11 @"+ $(get-date);$current =8; start-process powershell "cmd.exe /C sgminer.exe --config 6.conf";$current = 8}}
elseif((get-process | Where-Object {$_.name -eq "sgminer" } ).responding -eq $true) {"remian in last algo @ price:$($nicehashbest[$current])"}
else{"for some reason sgminer stopped, please check the hardware";start-process powershell "cmd.exe /C sgminer.exe --config 1.conf";$current = 3}
sleep $delay
}while($true -eq $true)