would you be willing to share any of your code? I'm using pycurl but I dont know much about ssl, so the certificate issues are giving me a headache
My code is unfinished so I wouldn't recommend running this as is but it will get you started since it is able to read and make changes to your rigs. You can improve the algorithm. It sends 3 algo request to Betarigs every minute so that if one is rented, price on remaining algo will increase to 1BTC/Mh/day. If rental is finished, all price will be set to hardcoded "marketprice". I have yet to write an algorithm based on few datas to come up with my version of "market price". During rental progress, it continues to send request every minute which is not how it should be. I also have yet to add a condition statement so that it will restart sending request when rental ended.
BTW, I meant I use Jq to work with JSON data. Not Qt.
#!/bin/bash
#my rigs
x11rignum=(your rig #)
x13rignum=(your rig #)
x15rignum=(your rig #)
nist5rignum=(your rig #)
API_KEY=(enter your own API #)
#need marketprice algo, manually hardcode for now
x11marketprice=(enter your price)
x13marketprice=(enter your price)
x15marketprice=(enter your price)
x11highprice=1
x13highprice=1
x15highprice=1
priceincreased=false
while true; do
###################check all rig rent status#####################
#get information from betarigs then store locally to a txt file
curl https://www.betarigs.com/api/v1/rig/$x11rignum > x11info.txt
sleep 1
curl https://www.betarigs.com/api/v1/rig/$x13rignum > x13info.txt
sleep 1
curl https://www.betarigs.com/api/v1/rig/$x15rignum > x15info.txt
sleep 1
#curl https://www.betarigs.com/api/v1/rig/$nist5rignum > nist5info.txt
#sleep 1
#output is true or false
x11statavail=$(cat x11info.txt | jq '.status.available')
x13statavail=$(cat x13info.txt | jq '.status.available')
x15statavail=$(cat x15info.txt | jq '.status.available')
#nist5statavail=$(cat nist5info.txt | jq '.status.available')
#output are: Available, In Progress, Waiting payment, Offline, etc
x11statlabel=$(cat x11info.txt | jq '.status.label')
x13statlabel=$(cat x13info.txt | jq '.status.label')
x15statlabel=$(cat x15info.txt | jq '.status.label')
#nist5statlabel=$(cat nist5info.txt | jq '.status.label')
##remove "" otherwise string comparison won't work
#x11statlabel=${x11statlabel:1:-1}
#x13statlabel=${x13statlabel:1:-1}
#x15statlabel=${x15statlabel:1:-1}
##nist5statlabel=${nist5statlabel:1:-1}
##default not rented
x11rented=false
x13rented=false
x15rented=false
if [ $x11statavail == false ]; then
x11rented=true
fi
if [ $x13statavail == false ]; then
x13rented=true
fi
if [ $x15statavail == false ]; then
x15rented=true
fi
rentinprogress=false
if [ $x11rented == true ] || [ $x13rented == true ] || [ $x15rented == true ]; then
rentinprogress=true
fi
################### change high price to market price if rental has completed #####################
string1='{"price":{"per_speed_unit":{"value":'
string2=',"unit":"BTC/Mh/day"}}}'
#if rig is not rented
if [ $rentinprogress == false ]; then
if [ $priceincreased == false ]; then
##readback and store all rig currentprice, I can manually change price online
x11currprice=$(cat x11info.txt | jq '.price.per_speed_unit.value')
x13currprice=$(cat x13info.txt | jq '.price.per_speed_unit.value')
x15currprice=$(cat x15info.txt | jq '.price.per_speed_unit.value')
#nist5currprice=$(cat nist5info.txt | jq '.price.per_speed_unit.value')
else #if priceincreased=true means rent period just finished
##set all to marketprice for now
x11currprice=$x11marketprice
x13currprice=$x13marketprice
x15currprice=$x15marketprice
#nist5currprice=$nist5marketprice
jsonstring=$string1$x11currprice$string2
curl -X PUT -H "X-Api-Key: "$API_KEY -H "Content-Type: application/json" -d $jsonstring https://www.betarigs.com/api/v1/rig/$x11rignum
sleep 1
jsonstring=$string1$x13currprice$string2
curl -X PUT -H "X-Api-Key: "$API_KEY -H "Content-Type: application/json" -d $jsonstring https://www.betarigs.com/api/v1/rig/$x13rignum
sleep 1
jsonstring=$string1$x15currprice$string2
curl -X PUT -H "X-Api-Key: "$API_KEY -H "Content-Type: application/json" -d $jsonstring https://www.betarigs.com/api/v1/rig/$x15rignum
sleep 1
#jsonstring=$string1$nist5currprice$string2
#curl -X PUT -H "X-Api-Key: "$API_KEY -H "Content-Type: application/json" -d $jsonstring https://www.betarigs.com/api/v1/rig/$nist5rignum
sleep 1
priceincreased=false
fi
else #if rent is in progress or waiting for payment
################### set price to high if rental started #####################
echo "rent in progress"
if [ $priceincreased == false ]; then
echo "increase non rented price now"
#set highprice to rigs not rented
if [ $x11rented == false ]; then
echo "set x11 price"
x11currprice=$x11highprice
jsonstring=$string1$x11currprice$string2
curl -X PUT -H "X-Api-Key: "$API_KEY -H "Content-Type: application/json" -d $jsonstring https://www.betarigs.com/api/v1/rig/$x11rignum
sleep 1
fi
if [ $x13rented == false ]; then
x13currprice=$x13highprice
jsonstring=$string1$x13currprice$string2
curl -X PUT -H "X-Api-Key: "$API_KEY -H "Content-Type: application/json" -d $jsonstring https://www.betarigs.com/api/v1/rig/$x13rignum
sleep 1
fi
if [ $x15rented == false ]; then
x15currprice=$x15highprice
jsonstring=$string1$x15currprice$string2
curl -X PUT -H "X-Api-Key: "$API_KEY -H "Content-Type: application/json" -d $jsonstring https://www.betarigs.com/api/v1/rig/$x15rignum
sleep 1
fi
priceincreased=true
fi
fi
sleep 60
done