Gunthy
GUNBOT: The automatic profit generator => Beginners & Help => Topic started by: shacky on April 21, 2017, 07:13:58 AM
-
Hi everyone,
Today I did a bash script to help me start all the pairs in Linux (one in each screen) with a time delay of 5 seg for each pair. The script check if the screen exist to reduce the risk to start a duplicate pair.
The script will search for all config files in the gunbot folder and will try to start each one.
How to setup:
1) create a file in the gunbot folder with whatever name you want but the extension should be .sh, for example:
nano start_gunbot.sh
2) Copy the code to the file
#!/bin/bash
########### EDIT PLEASE ###############
# exact folder where gunbot and config files are
botfolder="/root/bot/gunbotv2.0.4"
########## NO MORE EDIT ###############
############## DONT EDIT ##############
_dfiles="*-config.js"
red=`tput bold setaf 1`
green=`tput bold setaf 2`
blue=`tput bold setaf 4`
reset=`tput sgr0`
for f in $_dfiles
do
_name="${f##*/}"
_namef="${f%-*}"
echo "Checking if pair $_namef is running..."
if ! screen -list | grep -q "$_namef"; then
echo "${red}Pair not running.... ${green}Starting $_namef pair... ${reset}"
screen -dmS $_namef
screen -S $_namef -p 0 -X exec $botfolder/gunbot $_namef
echo "Waiting 5S"
sleep 1
echo -n "...1"
sleep 1
echo -n "...2"
sleep 1
echo -n "...3"
sleep 1
echo -n "...4"
sleep 1
echo "${blue}...5!${reset}"
echo "${green}Next PAIR${reset}"
else
echo "${green}Pair $_namef RUNNING${reset}"
sleep 0.2
fi
done
3)Make sure you edit the botfolder variable to the exact folder your bot is installed.
4) control + o to save and control + x to exit
5) make in executable:
chmod u+x start_gunbot.sh
6) execute the script
./start_gunbot.sh
The script will search for all files with the name XXX_XXX-config.js and will execute the bot with that configuration in a screen called with the name of the pair.
Remember that:
- You should have only the config files you want to run in the gunbot folder, because the script will start ALL the pairs with config files in that directory. If you don't want to run a individual pair, move the config file.
- This only works with gunbot strategy, not 1000 strategy. It's easy to modify for that strategy.
- Dont call this script if you already running the bot. To run this script please stop all your robot sessions.
- Works with all Linux distributions.
If you want to see the output of each pair, you should execute:
screen -ls
and when you find the pair you want to see the output, only call the screen:
screen -r PAIR_NAME
To exit of the screen without closing it, press:
control a + d
I have another script to stop all trading, here is the code:
#!/bin/bash
############## DONT EDIT ##############
_dfiles="*-config.js"
red=`tput bold setaf 1`
green=`tput bold setaf 2`
blue=`tput bold setaf 4`
reset=`tput sgr0`
for f in $_dfiles
do
_name="${f##*/}"
_namef="${f%-*}"
echo "Checking if pair $_namef is running..."
if ! screen -list | grep -q "$_namef"; then
echo "${blue}Pair not running.... ${reset}"
else
echo "${red}Pair $_namef RUNNING${reset}"
screen -S $_namef -X quit
echo "${blue}EXITING...${reset}"
sleep 0.2
fi
done
This code will close all the screen running with the name of the pairs listed in the gunbot folder.
If anyone want help, let me know,
If this helps you, give me a beer:
1Hoy4BgkHQg8wGzskwcVbxhcEcRscMFRnW
Thanks.
-
That sir, is some sexy bash. Mine is just a line of commands. Yours is smart. I'm gonna go drink some Brawndo now. It's got electrolytes.
-
hi
little improvement and compatibility with 3.x release :
change the grep command line to grep -qw (because pair like STR won't launch if pair STRAT is already running so the -w flag force a whole word match)
#!/bin/bash
########### EDIT PLEASE ###############
# exact folder where gunbot and config files are
botfolder="/home/user/gunbot"
########## NO MORE EDIT ###############
############## DONT EDIT ##############
_dfiles="*-config.js"
red=`tput bold setaf 1`
green=`tput bold setaf 2`
blue=`tput bold setaf 4`
reset=`tput sgr0`
for f in $_dfiles
do
_name="${f##*/}"
_namef="${f%-*}"
echo "Checking if pair $_namef is running..."
if ! screen -list | grep -qw "$_namef"; then
echo "${red}Pair not running.... ${green}Starting $_namef pair... ${reset}"
screen -dmS $_namef
screen -S $_namef -p 0 -X exec node $botfolder/index $_namef poloniex
echo "Waiting 5S"
sleep 1
echo -n "...1"
sleep 1
echo -n "...2"
sleep 1
echo -n "...3"
sleep 1
echo -n "...4"
sleep 1
echo "${blue}...5!${reset}"
echo "${green}Next PAIR${reset}"
else
echo "${green}Pair $_namef RUNNING${reset}"
sleep 0.2
fi
done
-
Will it work if I have 2 folders of bot,
1 - I run mannualy and to 1 polo acc.
2 - I run with your start.sh to 2 polo acc?
Or I need to run only one of bot copy?
-
This scripts work for you, if you have two polo accounts in two folders without problem. You should change only;
screen -dmS $_namef to screen -dmS $_namef-2dary
if ! screen -list | grep -qw "$_namef"; then to if ! screen -list | grep -qw "$_namef-2dary"; then
I suggets to you, to have one script for each folder and everything will work.
-
hi
little improvement and compatibility with 3.x release :
change the grep command line to grep -qw (because pair like STR won't launch if pair STRAT is already running so the -w flag force a whole word match)
#!/bin/bash
########### EDIT PLEASE ###############
# exact folder where gunbot and config files are
botfolder="/home/user/gunbot"
########## NO MORE EDIT ###############
############## DONT EDIT ##############
_dfiles="*-config.js"
red=`tput bold setaf 1`
green=`tput bold setaf 2`
blue=`tput bold setaf 4`
reset=`tput sgr0`
for f in $_dfiles
do
_name="${f##*/}"
_namef="${f%-*}"
echo "Checking if pair $_namef is running..."
if ! screen -list | grep -qw "$_namef"; then
echo "${red}Pair not running.... ${green}Starting $_namef pair... ${reset}"
screen -dmS $_namef
screen -S $_namef -p 0 -X exec node $botfolder/index $_namef poloniex
echo "Waiting 5S"
sleep 1
echo -n "...1"
sleep 1
echo -n "...2"
sleep 1
echo -n "...3"
sleep 1
echo -n "...4"
sleep 1
echo "${blue}...5!${reset}"
echo "${green}Next PAIR${reset}"
else
echo "${green}Pair $_namef RUNNING${reset}"
sleep 0.2
fi
done
Thanks for your suggestion! Will edit the main topic to add it.
Thanks.
-
hi
little improvement and compatibility with 3.x release :
change the grep command line to grep -qw (because pair like STR won't launch if pair STRAT is already running so the -w flag force a whole word match)
screen -S $_namef -p 0 -X exec node $botfolder/index $_namef poloniex
screen -S $_namef -p 0 -X exec node $botfolder/stepgain $_namef poloniex
In my case.
-
thanks for you work, but script doesn't work for me.. while running start.sh script, some of pairs do start and some don't.
i get "no screen session found" for pairs who don't start, and when execute "screen -r BTC_XXX" i get only blank screen. no errors in logs, nothing at all.
maybe i'm doing something wrong?
-
How to run it for 3.3 version?
-
If anyone have problems to use these scripts, u need to make sure the content of ure start shell is exactly the same! Pay attention for every line.
Had problems, that if i paste the lines from here and paste it in my empty file, he mess up the content.
and if u directly upload a windows created shell file on ure *nix VPS it always nice to make all *nix conform with the program dos2unix
And thx alot for ure nice script ;)
-
Your script is cool, thanks to share it. Personally I use tmux rather than screen, by habit. So here's my launcher :
#!/bin/env bash
# start all *-config.js in a tmux new session_name
# adapt gun_command and delay to your needs
gun_command="./gunthy-linuxx64"
delay=30
session_name=$(basename $(pwd))
flag="0"
for file in *-config.js; do
pair=$(echo $file | cut -d'-' -f2)
market=$(echo $file | cut -d'-' -f1)
if [[ "$flag" = "0" ]]; then
tmux -2 new-session -d -s $session_name -n $pair "$gun_command $pair $market"
flag="1"
else
tmux -2 new-window -d -n $pair "$gun_command $pair $market"
fi
printf "Launching %s %s " "$market" "$pair"
for i in $(seq 1 $delay); do
echo -n "."
sleep 1
done
echo
done
echo Done
tmux ls
Because I use gunbot on the 3 markets (poloniex, bittrex and kraken), I created subfolders :
/home/me/gunbot/bittrex
/home/me/gunbot/kraken
/home/me/gunbot/poloniex
So in each I put files I need (gunthy-linuxx64, ALLPAIRS, config files) and my start.sh script. Launching it, in the appropriate folder (eg /home/me/gunbot/bittrex), create a tmux session well named "bittrex", "kraken" or "poloniex".
Be sure to adapt gun_command and delay to your needs. For example I set delay=30 for Poloniex and delay=10 for Bittrex.
Sessions are detached, to attach a session, do:
tmux a -t poloniex
If I want to stop ALL the pairs for a market:
tmux kill-session -t poloniex
You can give me drink at:
12aeQSpytxoehCEptQE8tUJVVSAS42LvXo
-
Your script is cool, thanks to share it. Personally I use tmux rather than screen, by habit. So here's my launcher :
#!/bin/env bash
# start all *-config.js in a tmux new session_name
# adapt gun_command and delay to your needs
gun_command="./gunthy-linuxx64"
delay=30
session_name=$(basename $(pwd))
flag="0"
for file in *-config.js; do
pair=$(echo $file | cut -d'-' -f2)
market=$(echo $file | cut -d'-' -f1)
if [[ "$flag" = "0" ]]; then
tmux -2 new-session_name -d -s $session_name -n $pair "$gun_command $pair $market"
flag="1"
else
tmux -2 new-window -d -n $pair "$gun_command $pair $market"
fi
printf "Launching %s %s " "$market" "$pair"
for i in $(seq 1 $delay); do
echo -n "."
sleep 1
done
echo
done
echo Done
tmux ls
Because I use gunbot on the 3 markets (poloniex, bittrex and kraken), I created subfolders :
/home/me/gunbot/bittrex
/home/me/gunbot/kraken
/home/me/gunbot/poloniex
So in each I put files I need (gunthy-linuxx64, ALLPAIRS, config files) and my start.sh script. Launching it, in the appropriate folder (eg /home/me/gunbot/bittrex), create a tmux session well named "bittrex", "kraken" or "poloniex".
Be sure to adapt gun_command and delay to your needs. For example I set delay=30 for Poloniex and delay=10 for Bittrex.
Sessions are detached, to attach a session, do:
tmux a -t poloniex
If I want to stop ALL the pairs for a market:
tmux kill-session -t poloniex
You can give me drink at:
12aeQSpytxoehCEptQE8tUJVVSAS42LvXo
Is a 30 second day long enough to avoid errors?
-
Is a 30 second day long enough to avoid errors?
What error are you talking about?
Be carefull, I made a mistake, replace:
tmux -2 new-session_name -d -s $session_name -n $pair "$gun_command $pair $market"
with:
tmux -2 new-session -d -s $session_name -n $pair "$gun_command $pair $market"