ericsomdahl / python-bittrex

Python bindings for bittrex
MIT License
585 stars 283 forks source link

Fix for INVALID_SIGNATURE in python3.x.x #158

Closed forgetso closed 5 years ago

forgetso commented 5 years ago

This is related to the following issue https://github.com/ericsomdahl/python-bittrex/issues/136

bitphage commented 5 years ago

Thanks, @ericsomdahl are you maintaining the project?

ericsomdahl commented 5 years ago

@bitfag still here -- just slow to get around at the holiday season. I am ok with this fix but the build is broken due to the new USD markets added recently.

I can get to the fix for the build once my holiday starts, in a few days. in the meantime I will merge this knowing that the pypy build will not propagate out.

brotolisk commented 5 years ago

I'm still getting the INVALID_SIGNATURE with API 2.0 even with @forgetso 's fix in the latest version of python-bittrex.

Am I doing something wrong?

It seems like the issue is that I'm using windows. Works fine on linux

forgetso commented 5 years ago

@brotolisk Unfortunately, I don't have windows to check this out but glad you figured it out.

Ben0n commented 5 years ago

Hi, thank you guys a lot for keeping this repo up to date!! Unfortunately I am still getting the INVALID_SIGNATURE with API 2.0. Even with the latest fix and on Python 3.6 and 2.7. I use a brand new API-key & secret with all permissions. My test code would look like this:


from bittrex.bittrex import Bittrex, API_V2_0
my_bittrex = Bittrex('<MY API KEY>', '<MY SECRET>', api_version=API_V2_0) 
result = my_bittrex.trade_sell('BTC-ADX', 'LIMIT', 50.0, 0.001, 'GOOD_TIL_CANCELLED', 'NONE', 0)
print(result)

My OS is Ubuntu 18.04 Am I doing something wrong and is the fix still working for you guys?

bitphage commented 5 years ago

@Ben0n I have no problems on API v1.1

Ben0n commented 5 years ago

@bitfag thanks for your reply! API v1.1 is working fine for me too, but since I want to place a stop-loss order via the API I would need to use the API v2.0 Is API v2.0 working for you too?

bitphage commented 5 years ago

@Ben0n can't say anything about 2.0, I'm sticking to v1.1 as officially supported.

forgetso commented 5 years ago

@Ben0n Try using

my_bittrex.buy_limit(market=self.trade_pair, quantity=volume, rate=price)

but the equivalent for sell which is .sell_limit.

forgetso commented 5 years ago

@ericsomdahl @Ben0n Sincere apologies, it seems like I had falsely attributed the disappearance of INVALID_SIGNATURE in the response to my change to python-bittrex. However, it seems that buy_limit works in python3 but trade_buy does not.

@ericsomdahl you may wish to revert this change as it effectively does nothing.

>>> hmac.new(bytearray('123','ascii'),bytearray('123','ascii'), hashlib.sha512).hexdigest() '0634fd04380bbaf5069c8c46a74c7d21df7414888d980c27a16d5e262cb8c9059139c212d0926000faf026e483904cefae2f5e9d9bd5f51fbc2ac4c4de518115' >>> hmac.new('123'.encode(),'123'.encode(), hashlib.sha512).hexdigest() '0634fd04380bbaf5069c8c46a74c7d21df7414888d980c27a16d5e262cb8c9059139c212d0926000faf026e483904cefae2f5e9d9bd5f51fbc2ac4c4de518115'

CarstenRuetz commented 5 years ago

I have the same problem here. Want to use API 2.0 but I keep getting INVALID_SIGNATURE errors.

My setup:

python --version # Python 2.7.10 pip show requests # Version: 2.21.0 pip show certifi # Version: 2018.11.29 pip show idna # Version: 2.8 pip show urllib3 # Version: 1.24.1 pip show python-bittrex # Version: 0.3.0

Testing with python3 (Python 3.7.0) shows no difference (the packages are of the same versions).

I also tried different python versions using docker images - to no avail. Also tried older versions of the above packages, no change.

Is there anyone for whom API 2.0 calls still work? Could you maybe post your output of above versions just to rule out version problems?

Or any other ideas why API 2.0 does not work?

my test code:

from bittrex.bittrex import Bittrex, API_V2_0

my_bittrex = Bittrex('apikey','secret', api_version=API_V2_0)  # or defaulting to v1.1 as Bittrex(None, None)
print(my_bittrex.get_order_history('BTC-ETH'))
print(my_bittrex.trade_sell('BTC-ETH', 'LIMIT', 0.0001, 0.00001, 'IMMEDIATE_OR_CANCEL', 'NONE', 1.0))