Python Forum
CryptoCurrency Mining Auto Switch
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CryptoCurrency Mining Auto Switch
#1
Hi Guys
I'm very new to python and need help
I forked this from another project and need your expert help to optimize it.
Scripts works on nvOC mining os by fullzero : https://bitcointalk.org/index.php?topic=1854250
The code main job is to get data from whattomine.com json api and check which coin from selection is the best for mining now.
It is doing it now but what I now need is to not switch if the profit is lower than a given percent

So for examlpe if I set percent to 10 if coin A is making 100 and coin B making 105 it wont switch from A to B and stay on A untill B goes higher 110
So for this to work, I think it should check the last top coin which is logged to a file (I set it as top_coin), check and compare with new result then print to file the new coin so the bash script can read from it and switch if needed

These are the scripts

python script:
#!/usr/bin/env python2.7
#_*_ coding: utf-8 _*_
#### Whattomine auto switch python script written by papampi, forked from smartminer by damNmad

import requests;

data = requests.get("https://whattomine.com/coins.json);

coinsData = data.json()['coins'];
coins = coinsData.keys();
highBTCrev = {};

includeTags = [ 'ZEC', 'ZEN', 'ZCL', 'SIB' , 'LBC'  ]

filterdCoins = {k: v for k, v in coinsData.iteritems() if v['tag']  in includeTags}
coins = filterdCoins.keys()

def findBTCrev(d1):
    return (d1)

for coin in coins:
    coinObj = coinsData[coin]
    coinObj['smartProfitability'] = findBTCrev(coinObj['btc_revenue'])
    highBTCrev[coin] = coinObj

for k in highBTCrev:
    print highBTCrev[k]['tag'], ' - ', highBTCrev[k]['smartProfitability']

BTCrevenueSort = sorted(filterdCoins.values(), key=lambda d: d['smartProfitability'],reverse=True);

if (len(BTCrevenueSort) > 1):
    finalCoin = BTCrevenueSort[0]

log=open("top_coin", "w")
log.write(finalCoin['tag'])
log.close()
bash script:
#!/bin/bash
#### Whattomine auto switch bash script written by papampi

source ~/1bash
BITCOIN="theGROUND"

# Creating a log file to record coin switch 
LOG_FILE="/home/m1/8_wtmautoswitchlog"

if [ -e "$LOG_FILE" ] ; then
  #Limit the logfile, just keep the last 2K
  LASTLOG=$(tail -n 2K $LOG_FILE)
  echo "$LASTLOG"
  echo ""
fi

while [ $BITCOIN == "theGROUND" ]
do

CURRENT_COIN=$(head -n 150 /home/m1/1bash | grep COIN= | sed 's/COIN=//' | sed 's/\"//' | sed 's/\"//')
TOP_COIN=$(cat /home/m1/top_coin)
TIMEIN=$WTM_AUTO_SWITCH_SYNC_INTERVAL
TIMEOUT=$(($TIMEIN * 60))

python2.7 WTM_AUTO_SWITCH.py 
sleep 5
if [ "$CURRENT_COIN" != "$TOP_COIN" ]
then 
sed -i 's/'COIN=\"$CURRENT_COIN\"'/'COIN=\"$TOP_COIN\"/'' /home/m1/1bash
sleep 2
pkill -e screen
pkill -f 3main
echo ""
echo "$(date) Mining switched from $CURRENT_COIN to $TOP_COIN" | tee -a ${LOG_FILE}
echo "Check again in $TIMEOUT seconds"# | tee -a ${LOG_FILE}
sleep $TIMEOUT

else
echo "$(date) Same Coin on Top, Continue mining $CURRENT_COIN" | tee -a ${LOG_FILE}
echo "Check again in $TIMEOUT seconds" #| tee -a ${LOG_FILE}
sleep $TIMEOUT

fi
done
Reply
#2
Any helps ?
Reply
#3
Sounds like you don't want to do any programming yourself, which is OK,
but if that is the case, the post should be moved to jobs, where you should,
(but are not required to) offer some compensation for the work you want done.

Verify, and I or someone else will move your post for you.
Reply
#4
Why you think I dont want to do programming my self ?
I wrote these scripts myself.
Just because the script is for cryptocurrency mining ...then I should pay for getting help?
I'm not charging any one to use my scripts and put them in bitcointalk for free for any one who wants to use them
Now I have no idea how to do the rest and asked for help.

Please point me to the direction.
And I will try my best to ask as little as possible questions...
Reply
#5
Quote:I forked this from another project
You didn't qualify it as being your own, that's why I asked for verification.
Not an accusation.
Reply
#6
(Oct-07-2017, 01:24 PM)Larz60+ Wrote:
Quote:I forked this from another project
You didn't qualify it as being your own, that's why I asked for verification.
Not an accusation.
Forking a python script for a newbee which has never read or written a python script like me should be count as writing it for an expert ;)
Any way, I will try to change it with some help, or just leave it as is.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Create csv file with 4 columns for process mining thomaskissas33 3 745 Nov-06-2023, 09:36 PM
Last Post: deanhystad
  best way to use switch case? korenron 8 2,982 Aug-18-2021, 03:16 PM
Last Post: naughtyCat
  How do I do this? Switch Case? mstichler 4 2,570 Jun-05-2020, 10:27 AM
Last Post: snippsat
  Cryptocurrency Blockchain Error johnnypy76 2 3,108 Nov-10-2019, 12:03 AM
Last Post: johnnypy76
  switch limitations MuntyScruntfundle 3 2,371 Jan-27-2019, 06:11 PM
Last Post: aakashjha001

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020