Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 160 fixed; 'Signature for this request is not valid' error message #192

Merged
merged 1 commit into from
Feb 13, 2018

Conversation

ykartal
Copy link
Contributor

@ykartal ykartal commented Feb 12, 2018

/myTrades endpoint support added
_sign method updated to avoid 'Signature for this request is not valid' error message

_sign method updated to avoid 'Signature for this request is not valid' error message
@yasinkuyu yasinkuyu merged commit c8f7977 into yasinkuyu:master Feb 13, 2018
@Plarkass
Copy link

Hi,
Issue still present
price:0.00069853 buyp:0.00068826 sellp:0.00069513-bid:0.00068825 ask:0.00069725 spread:1.31
m: Signature for this request is not valid.

@ykartal
Copy link
Contributor Author

ykartal commented Feb 13, 2018

Hi,
Did you try
get_myTrades(symbol, limit)

@Plarkass
Copy link

Plarkass commented Feb 13, 2018

It work fot the test that you ask get_myTrades(symbol, limit)

i update python-binance to the lastest version v0.6.5
import config

from BinanceAPI import BinanceAPI
from Messages import Messages
client = BinanceAPI(config.api_key, config.api_secret)
test = client.get_myTrades('ENJBTC', 50)
print test

result :
[{u'orderId': 1672948, u'isBuyer': True, u'price': u'0.00000632', u'isMaker': False, u'qty': u'4.00000000', u'commission': u'0.00400000', u'time': 1513809949705, u'commissionAsset': u'ENJ', u'id': 167068, u'isBestMatch': True}, {u'orderId': 1734916, u'isBuyer': False, u'price': u'0.00000604', u'isMaker': False, u'qty': u'3.00000000', u'commission': u'0.00000002', u'time': 1513928429292, u'commissionAsset': u'BTC', u'id': 177698, u'isBestMatch': True}, {u'orderId': 1765875, u'isBuyer': True, u'price': u'0.00000782', u'isMaker': False, u'qty': u'50.00000000', u'commission': u'0.05000000', u'time': 1513992621461, u'commissionAsset': u'ENJ', u'id': 182838, u'isBestMatch': True}, {u'orderId': 1837196, u'isBuyer': True, u'price': u'0.00001170', u'isMaker': False, u'qty': u'526.00000000', u'commission': u'0.52600000', u'time': 1514080173457, u'commissionAsset': u'ENJ', u'id': 205698, u'isBestMatch': True}, {u'orderId': 2027676, u'isBuyer': False, u'price': u'0.00001186', u'isMaker': True, u'qty': u'500.00000000', u'commission': u'0.00000593', u'time': 1514628359113, u'commissionAsset': u'BTC', u'id': 272271, u'isBestMatch': True}, {u'orderId': 2091359, u'isBuyer': True, u'price': u'0.00001420', u'isMaker': False, u'qty': u'106.00000000', u'commission': u'0.10600000', u'time': 1514714012470, u'commissionAsset': u'ENJ', u'id': 291257, u'isBestMatch': True}, {u'orderId': 2243594, u'isBuyer': False, u'price': u'0.00001700', u'isMaker': True, u'qty': u'91.00000000', u'commission': u'0.00000155', u'time': 1515046235957, u'commissionAsset': u'BTC', u'id': 355550, u'isBestMatch': True}, {u'orderId': 2316684, u'isBuyer': True, u'price': u'0.00002223', u'isMaker': True, u'qty': u'26.00000000', u'commission': u'0.02600000', u'time': 1515096213466, u'commissionAsset': u'ENJ', u'id': 388364, u'isBestMatch': True}, {u'orderId': 2316684, u'isBuyer': True, u'price': u'0.00002223', u'isMaker': True, u'qty': u'160.00000000', u'commission': u'0.16000000', u'time': 1515096228849, u'commissionAsset': u'ENJ', u'id': 388369, u'isBestMatch': True}]

@Plarkass
Copy link

I still have this issue:

price:0.00017451 buyp:0.00017452 sellp:0.00017678-bid:0.00017451 ask:0.00017719 spread:1.54
m: Signature for this request is not valid.
price:0.00017451 buyp:0.00017452 sellp:0.00017678-bid:0.00017451 ask:0.00017719 spread:1.54
m: Signature for this request is not valid.
price:0.00017451 buyp:0.00017452 sellp:0.00017678-bid:0.00017451 ask:0.00017719 spread:1.54
m: Signature for this request is not valid.

Do you have any suggestion ?

@ykartal
Copy link
Contributor Author

ykartal commented Feb 14, 2018

Could you send your running code? We do not know which method you are calling.

@Plarkass
Copy link

I thanks for your reply.

I get
price:0.00017451 buyp:0.00017452 sellp:0.00017678-bid:0.00017451 ask:0.00017719 spread:1.54
m: Signature for this request is not valid.

when i do:
python trader.py --symbol TNTETH

i can get the same with :
python balance.py
1 -) Print orders
2 -) Scan profits
3 -) List balances
4 -) Check balance
Enter option number: Ex: 2
1
Enter symbol: Ex: XVGBTC
XVGBTC
XVGBTC Orders
{u'msg': u'Signature for this request is not valid.', u'code': -1022}

I try to reset my API key

@Plarkass
Copy link

Hi, for info,
I ever try with an another account of a friend and I got same error.

Could you provide all requirements for that is necessary

@ykartal
Copy link
Contributor Author

ykartal commented Feb 18, 2018 via email

@melexov
Copy link

melexov commented Feb 18, 2018

i also have the same problem:

price:218.34000000 buyp:217.69000000 sellp:217.68000000-bid:217.68000000
ask:218.35000000 spread:0.31
m: Signature for this request is not valid.

price:218.35000000 buyp:217.71000000 sellp:217.70000000-bid:217.70000000
ask:218.35000000 spread:0.30
m: Signature for this request is not valid.

this error occurred when bot tried to place buy|sell order.
already tried hints from sammchardy/python-binance#5 without success.

probably something wrong here:

h = urlencode(data)
b = bytearray()
b.extend(self.secret.encode())
signature = hmac.new(b, msg=h.encode('utf-8'), digestmod=hashlib.sha256).
hexdigest()
data.update({"signature": signature})
return data

original binance api

ordered_data = self._order_params(data)
query_string = '&'.join(["{}={}".format(d[0], d[1]) for d in ordered_data])
m = hmac.new(self.API_SECRET.encode('utf-8'),
query_string.encode('utf-8'), hashlib.sha256)
return m.hexdigest()

thanks

@melexov
Copy link

melexov commented Feb 18, 2018

update

now works fine: #196 (comment) with the old version or BinanceAPI.py

h = self.secret + "|" + urlencode(data)
signature = hashlib.sha256(h.encode('utf-8')).hexdigest()
data.update({"signature": signature})
return data

@ykartal
Copy link
Contributor Author

ykartal commented Feb 19, 2018

As I said before, using base_url_v3 is also works, I think v3 api have more endpoints . So I sent a new commit. Please take it and try again.
See pull request on #204

@Plarkass
Copy link

Thanks,
Test in progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants