Hi, I am using Python Binance Api library.
I am now trying to convert base asset to dust.
In the docs of the libary it says:
transfer = client.transfer_dust(asset=‘BNZ’)
The Binance api website states that I need to do the following:
The asset being converted. For example: asset=BTC&asset=USDT
My code goes like this:
def C2D(symbols):
DUST = []
seperator = '&asset='
for symbol in symbols:
if any([x in symbol for x in app.blacklist]):
pass
else:
Exchange = Datamanager.Exchange(symbol)
app.time.sleep(0.01)
balance = Datamanager.wallet(Exchange['BaseAsset'])
app.time.sleep(0.01)
marketprice = Datamanager.MarketPrice(symbol)
app.time.sleep(0.01)
Dust_Valua = float(marketprice) * float(balance)
if float(Dust_Valua)>=float('0.01') and float(Dust_Valua)<=float('9.99'):
DUST.append(Exchange['BaseAsset'])
elif symbol==symbols[-1]:
CDUST = seperator.join(DUST)
print(CDUST)
if DUST!=[]:
app.BinanceClient.transfer_dust(asset=CDUST)
message = f"Converted {DUST} to bnb."
app.msg(message)
bnbprice = Datamanager.MarketPrice('BNBUSDT')
bnbbalance = Datamanager.wallet('BNB')
bnbvalua = float(bnbprice) * float(bnbbalance)
if float(bnbprice)>=float('600.0') and float(bnbvalua)>=float('10.0'):
orderId = app.BinanceClient.create_order(
symbol='BNBUSDT',
side=app.SIDE_SELL,
type=app.ORDER_TYPE_MARKET,
quoteOrderQty=round(float(bnbvalua), 2))
message = f"Sold BNB:\nMarket price: {float(orderId['fills'][0]['price'])}\nExecuted Qty: {float(orderId['executedQty'])}\nTotal: {float(orderId['cummulativeQuoteQty'])}"
app.msg(message)
return
else:
return
else:
app.time.sleep(1)
continue
the output of CDUST is QTUM&asset=NANO&asset=THETA&asset=DREP&asset=LTO&asset=STRAX&asset=TRU&asset=FLOW&asset=FOR&asset=POLY&asset=DAR
The I thought I would do app.BinanceClient.transfer_dust(asset=CDUST) like this. It might work. But then I get following error.
Traceback (most recent call last):
File “main.py”, line 41, in
main()
File “main.py”, line 7, in main
app.Datamanager.C2D(symbols)
File “/home/alpha0/tradebot/app/datamanager.py”, line 153, in C2D
app.BinanceClient.transfer_dust(asset=CDUST)
File “/home/alpha0/venv/lib/python3.6/site-packages/binance/client.py”, line 2246, in transfer_dust
return self._request_margin_api(‘post’, ‘asset/dust’, True, data=params)
File “/home/alpha0/venv/lib/python3.6/site-packages/binance/client.py”, line 364, in _request_margin_api
return self._request(method, uri, signed, **kwargs)
File “/home/alpha0/venv/lib/python3.6/site-packages/binance/client.py”, line 315, in _request
return self._handle_response(self.response)
File “/home/alpha0/venv/lib/python3.6/site-packages/binance/client.py”, line 324, in _handle_response
raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1102): illegal parameter
Any idea how I can do this correctly?