Username: Password:

Author Topic: [LINUX] Stop after sell script  (Read 20053 times)

Offline AlfonseX

  • Contributor
  • **
  • Posts: 101
  • Trop de chefs, pas assez d'indiens !
    • View Profile
[LINUX] Stop after sell script
« on: June 27, 2017, 02:01:33 PM »
Hello all.

I made a little script to stop pairs I don't want to run anymore.

Code: [Select]
#!/bin/env bash
# usage stop_after_sell.sh pair market &

pair="$1"
market="$2"

pid_of=$(pgrep -a gunthy | grep "$pair $market" | cut -d' ' -f1)

while :; do
    if tail -n1  "${market}-${pair}-trades.txt" | grep sell; then
        kill -s SIGKILL "$pid_of"
        break
    else
        sleep 120
    fi
done

[ ! -f stop_after_sell.txt ] && touch stop_after_sell.txt
echo "$(date) $pair $market" >> stop_after_sell.txt

How to:
- save this script in GB folder, name it eg stop_after_sell.sh
- make it executable
Code: [Select]
chmod u+x stop_after_sell.sh
- launch it eg for BTC_ETH on poloniex
Code: [Select]
./stop_after_sell.sh BTC_ETC poloniex &
Note that ampersand is important.
When a sell happens this script kill GB running pair and track its work in stop_after_sell.txt. So you can watch what it will kill.

Beware of that this script isn't bullet proof it's made with "LA R.A.C.H.E : Rapid Application Conception and Heuristic Extreme-programming" ;).
Be warn and enjoy.
If you think I helped you, give me a drink:
in btc: 12aeQSpytxoehCEptQE8tUJVVSAS42LvXo
in eth: 0x02a611f0c15bccdb6fa8e5e4b0692ff6d77852bd

Offline Rakeau

  • Rookie
  • *
  • Posts: 2
    • View Profile
Re: [LINUX] Stop after sell script
« Reply #1 on: June 29, 2017, 10:41:34 AM »
Nice. I did think that Gunbot should have a built-in way to stop a bot after it completes a sale, a "graceful" stop if you will.