Bitcoin Forum

Other => Off-topic => Topic started by: johnsmithx on November 14, 2016, 06:57:52 PM



Title: -
Post by: johnsmithx on November 14, 2016, 06:57:52 PM
-


Title: Re: Autosell at Poloniex
Post by: Domanell on December 05, 2016, 02:06:52 PM
poloniex.py is ok
autosell.py
Code:
import signal, time, sys
import poloniex

APIKey = 'JH*****0U'
Secret = '9677****************************9e'
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)

error
Code:
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
========================== RESTART: C:\autosell.py ==========================

Traceback (most recent call last):
  File "C:\autosell.py", line 18, in <module>
    balance = float(p.returnBalances()['ZEC'])
KeyError: 'ZEC'
>>>

Can you help me?


Title: Re: Autosell at Poloniex
Post by: clipto on April 18, 2017, 10:58:58 AM
What Python version is used? Looks like version 2?
Guess we need other commands for Python 3.5 to get this working?


Title: Re: Autosell at Poloniex
Post by: clipto on April 18, 2017, 10:48:13 PM
Thanks for responding.
Have you succesfully used this new script?
This is what I get:

c:\Autosell>python autosell.py zec
Traceback (most recent call last):
  File "autosell.py", line 2, in <module>
    import poloniex
  File "c:\_mining\_Autosell\poloniex.py", line 2, in <module>
    import urllib2
ImportError: No module named 'urllib2'

Changed the start of the poloniex.py file:
import urllib
import urllib2
import json
import time
import hmac,hashlib

to:
import urllib
import urllib3
import json
import time
import hmac,hashlib

Not sure if that's correct? ???
But error is gone..

c:\Autosell>python autosell.py zec
Traceback (most recent call last):
  File "autosell.py", line 22, in <module>
    p = poloniexapi.poloniex(APIKey, Secret)
NameError: name 'poloniexapi' is not defined

Line 22 in autosell.py:
p = poloniexapi.poloniex(APIKey, Secret)

Old version was:
p = poloniex.poloniex(APIKey, Secret)

But that doesn't work either?  ???
Don't see a recent api connection at Poloniex either.


Title: Re: Poloniex autosell script in Python
Post by: clipto on April 19, 2017, 06:16:54 PM
It's working, thanks!  ;D