Signature for this request is not valid. - Binance API

86 Views Asked by At

I'm getting the following error when using the binance-connector with python:

 "price": 20348.91, "quantity": 4.914e-05, "side": "BUY", "symbol": "BTCUSDT", "timeInForce": "GTC", "timestamp": 1696014956799, "type": "LIMIT", "signature": "..."}}
{'error': {'code': -1022, 'msg': 'Signature for this request is not valid.'}

This is my python code (partially):


        qty_to_buy: float  = self.USER_TRADE_BALANCE/current_bid_price
        qty_to_buy = float("{0:.8f}".format(qty_to_buy)) # only 8 digits allowed after the comma

        self.currentlyBuying = True
        self.buying_bid_price = current_bid_price

        self.binance_client.new_order(
            symbol=self.TRADE_SYMBOL,
            side="BUY",
            type="LIMIT",
            timeInForce="GTC",
            quantity=qty_to_buy,
            price=current_bid_price,
        )

qty to buy has 8 digits after the comma, there's nothing wrong about it since I'm respecting the ticker rules. I'm trying to buy at the current bid price.

I'm using the binance testnet where I've built a new API key (and secret), so they are both correct.

What am I doing wrong? How do I fix this?.

I've tried making a new API key twice and nothing happened, I've increased recvWindow to 50000 and it still didn't work. What else am I doing wrong ?

1

There are 1 best solutions below

0
Binance On

Pass the qty as string, it should work.

e.g.

self.binance_client.new_order(
            symbol=self.TRADE_SYMBOL,
            side="BUY",
            type="LIMIT",
            timeInForce="GTC",
            quantity='0.00004914',
            price=current_bid_price,
        )