Normally when I need autosell I use Bittrex but recently I needed a similar functionality at Poloniex so I made a very simple one in Python. Maybe someone here will find it useful.
First you need to download a Python wrapper from
https://poloniex.com/support/api/, save it as poloniex.py and change
return self.api_query('sell',{"currencyPair":currencyPair,"rate":rate,"amount":amount})
to
return self.api_query('sell',{"currencyPair":currencyPair,"rate":rate,"amount":amount,"immediateOrCancel":1})
in it.
Then save the following code (checks the zec wallet balance every second and autosells it for btc at the market price) to e.g. autosell.py in the same directory and replace 'something' with your API key and secret:
import signal, time, sys
import poloniex
APIKey = 'something'
Secret = 'something'
timefmt = '%Y-%m-%d %H:%M:%S UTC'
shutdown = False
def signal_handler(signal, frame):
global shutdown
shutdown = True
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
p = poloniex.poloniex(APIKey, Secret)
while True:
balance = float(p.returnBalances()['ZEC'])
if balance >= 0.0001:
lastprice = float(p.returnTicker()['BTC_ZEC']['last'])
print '[%s] detected %s ZEC balance, selling at %s for BTC' % (time.strftime(timefmt, time.gmtime()), balance, lastprice)
print '[%s] %s' % (time.strftime(timefmt, time.gmtime()), p.sell('BTC_ZEC', lastprice, balance))
if shutdown:
print '[%s] exiting' % time.strftime(timefmt, time.gmtime())
sys.exit(1)
time.sleep(1)
Then all what you do is just run the code with
python autosell.py. For a different currency just change the symbols, or make it universal and use the command line arguments.
I noticed Poloniex server sometimes timeouts or returns an error so if you want to really rely on this then either treat exceptions or just put the whole run in an infinite loop, like
while true; do python autosell.py; done or something similar.
Enjoy.